Fresh IDE . Changes On Branch FreshEdit2
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch FreshEdit2 Excluding Merge-Ins

This is equivalent to a diff from aefe3d21cc to 29632daf61

2012-11-28
21:28
Work on the text line rendering. Work on themes support. Implemented storing of the theme in uConfig file. The architecture of the themes is still not very clear... Leaf check-in: 29632daf61 user: johnfound tags: FreshEdit2
2012-11-12
15:53
Work. check-in: e2badc4838 user: lhmnai0 tags: FreshEdit2
2012-07-02
14:30
Changed macro names in executable.inc library in order to correspond to the FreshLib naming convention. check-in: 0d8d0f1a63 user: lhmnai0 tags: FreshLibDev
2012-07-01
12:50
Create new branch named "FreshEdit2" check-in: 39ec996774 user: johnfound tags: FreshEdit2
2012-06-30
19:34
Several new procedures for date and time management in timers.asm and strlib.asm library.

DaysPerYear: returns the days in the specified year; DaysPerMonth: returns the days in the specified month; TimeToDateTime: Converts Unix time to TDateTime structure;

GetLocalTimeOffset: Returns the time offset depending on the local timezone. It works for now only in Windows, the Linux version returns always 0

DateTimeToStr: Converts TDateTime structure to string. For now, the format is fixed.

Fixed some bugs. check-in: aefe3d21cc user: johnfound tags: FreshLibDev

2012-06-26
14:22
New functions in StrLib. check-in: 42d8dfa3cd user: lhmnai0 tags: FreshLibDev

Deleted freshlib/ForthScript/ForthLib.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: ForthScript standard word library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

macro ForthBlock blockname {
  forth@block equ blockname
  forth@block@size equ blockname#.size

  label blockname byte

  macro forthword name \{
    \local nnnn

    macro endfw \\{
    \\local ..footer
      endp
      label ..footer byte
      db   name
      db   16-($-..footer) dup 0
      dd   nnnn - blockname
      \\purge endfw
    \\}
    \proc nnnn
  \}
}

macro EndForthBlock {
  forth@block@size = $ - forth@block
  restore forth@block, forth@block@size
  purge forthword
}



ForthBlock ForthStandardLib

; "->" word.
forthword '->'
begin
        or      [ebx+TForthContext.Status], forthAssignMode
        clc
        retn
endfw


forthword '+'
begin
        mov     eax, [ebx+TForthContext.pAStack]
        mov     ecx, [eax+TArray.count]
        cmp     ecx, 2
        jb      .error

        dec     ecx
        imul    ecx, [eax+TArray.itemsize]
        lea     ecx, [eax+TArray.array+ecx]

        mov     edx, [ecx+TFStackCell.value]
        sub     ecx, [eax+TArray.itemsize]
        add     [ecx+TFStackCell.value], edx
        mov     [ecx+TFStackCell.type], ftypeNumber

        mov     ecx, [eax+TArray.count]
        dec     ecx
        stdcall DeleteArrayItem, [ebx+TForthContext.pAStack], ecx
        mov     [ebx+TForthContext.pAStack], edx
        clc
        return

.error:
        stc
        return
endfw


forthword '-'
begin
        mov     eax, [ebx+TForthContext.pAStack]
        mov     ecx, [eax+TArray.count]
        cmp     ecx, 2
        jb      .error

        dec     ecx
        imul    ecx, [eax+TArray.itemsize]
        lea     ecx, [eax+TArray.array+ecx]

        mov     edx, [ecx+TFStackCell.value]
        sub     ecx, [eax+TArray.itemsize]
        sub     [ecx+TFStackCell.value], edx
        mov     [ecx+TFStackCell.type], ftypeNumber

        mov     ecx, [eax+TArray.count]
        dec     ecx
        stdcall DeleteArrayItem, [ebx+TForthContext.pAStack], ecx
        mov     [ebx+TForthContext.pAStack], edx
        clc
        return

.error:
        stc
        return
endfw



forthword '*'
begin
        mov     eax, [ebx+TForthContext.pAStack]
        mov     ecx, [eax+TArray.count]
        cmp     ecx, 2
        jb      .error

        dec     ecx
        imul    ecx, [eax+TArray.itemsize]
        lea     ecx, [eax+TArray.array+ecx]

        mov     edx, [ecx+TFStackCell.value]
        sub     ecx, [eax+TArray.itemsize]
        imul    edx, [ecx+TFStackCell.value]
        mov     [ecx+TFStackCell.value], edx
        mov     [ecx+TFStackCell.type], ftypeNumber

        mov     ecx, [eax+TArray.count]
        dec     ecx
        stdcall DeleteArrayItem, [ebx+TForthContext.pAStack], ecx
        mov     [ebx+TForthContext.pAStack], edx
        clc
        return

.error:
        stc
        return
endfw



forthword '/'
begin
        mov     eax, [ebx+TForthContext.pAStack]
        mov     ecx, [eax+TArray.count]
        cmp     ecx, 2
        jb      .error

        dec     ecx
        imul    ecx, [eax+TArray.itemsize]
        lea     ecx, [eax+TArray.array+ecx]

        mov     edx, [ecx+TFStackCell.value]
        sub     ecx, [eax+TArray.itemsize]

        push    eax
        mov     eax, edx
        cdq
        idiv    [ecx+TFStackCell.value]
        mov     [ecx+TFStackCell.value], eax
        mov     [ecx+TFStackCell.type], ftypeNumber
        pop     eax

        mov     ecx, [eax+TArray.count]
        dec     ecx
        stdcall DeleteArrayItem, [ebx+TForthContext.pAStack], ecx
        mov     [ebx+TForthContext.pAStack], edx
        clc
        return

.error:
        stc
        return
endfw


forthword '%'
begin
        mov     eax, [ebx+TForthContext.pAStack]
        mov     ecx, [eax+TArray.count]
        cmp     ecx, 2
        jb      .error

        dec     ecx
        shl     ecx, 3
        lea     ecx, [eax+TArray.array+ecx]

        mov     edx, [ecx+TFStackCell.value]
        sub     ecx, [eax+TArray.itemsize]

        push    eax
        mov     eax, edx
        cdq
        idiv    [ecx+TFStackCell.value]
        mov     [ecx+TFStackCell.value], eax
        mov     [ecx+TFStackCell.type], ftypeNumber
        pop     eax

        mov     ecx, [eax+TArray.count]
        dec     ecx
        stdcall DeleteArrayItem, [ebx+TForthContext.pAStack], ecx
        mov     [ebx+TForthContext.pAStack], edx
        clc
        return

.error:
        stc
        return
endfw




forthword 'swap'
begin
        mov     eax, [ebx+TForthContext.pAStack]
        mov     ecx, [eax+TArray.count]
        cmp     ecx, 2
        jb      .finish         ; jb == jc

        shl     ecx, 3
        add     ecx, [ebx+TForthContext.pAStack]
;        lea     ecx, [ecx+TArray.array-2*sizeof.TFStackCell] TArray.array = 2*sizeof.TFStackCell

        mov     eax, [ecx+TFStackCell.value]
        mov     edx, dword [ecx+TFStackCell.type]
        xchg    eax, [ecx+sizeof.TFStackCell+TFStackCell.value]
        xchg    edx, dword [ecx+sizeof.TFStackCell+TFStackCell.type]
        mov     [ecx+TFStackCell.value], ecx
        mov     dword [ecx+TFStackCell.type], edx

        clc
.finish:
        return
endfw



forthword 'dup'
begin
        mov     eax, [ebx+TForthContext.pAStack]
        mov     ecx, [eax+TArray.count]
        cmp     ecx, 1
        jb      .finish         ; jb == jc

        shl     ecx, 3
        add     ecx, [ebx+TForthContext.pAStack]
        lea     ecx, [ecx+TArray.array-sizeof.TFStackCell]

        stdcall AddArrayItem, [ebx+TForthContext.pAStack]
        mov     [ebx+TForthContext.pAStack], edx
        jc      .finish

        pushd   [ecx+TFStackCell.value] dword [ecx+TFStackCell.type]
        popd    dword [eax+TFStackCell.type] [eax+TFStackCell.value]

        clc
.finish:
        return
endfw



forthword 'label'
begin


endfw




forthword 'jump'
begin


endfw




forthword '?branch'
begin


endfw



; : if +1 ?branch ;
forthword 'if'
begin


endfw



; : else label not +1 ?branch ;
forthword 'else'
begin


endfw


; : then label ;
forthword 'then'
begin


endfw





; : do label ;
forthword 'do'
begin


endfw


; : loop -1 ?branch ;
forthword 'loop'




forthword '.'
begin
        mov     eax, [ebx+TForthContext.pAStack]
        mov     ecx, [eax+TArray.count]
        jecxz   .exit

        dec     ecx
        mov     edx, ecx

        imul    ecx, [eax+TArray.itemsize]
        lea     ecx, [eax+TArray.array+ecx]

        cmp     [ecx+TFStackCell.type], ftypeNumber
        jne     .printstring

        stdcall NumToStr, [ecx+TFStackCell.value], ntsSigned or ntsDec
        mov     [ecx+TFStackCell.value], eax
        mov     [ecx+TFStackCell.type], ftypeStringFree

.printstring:
        stdcall StrPtr, [ecx+TFStackCell.value]
        stdcall Output, eax

        cmp     [ecx+TFStackCell.type], ftypeStringFree
        jne     .popit

        stdcall StrDel, [ecx+TFStackCell.value]

.popit:
        stdcall DeleteArrayItem, [ebx+TForthContext.pAStack], edx
        mov     [ebx+TForthContext.pAStack], edx

.exit:
        clc
        return

endfw



forthword 'crlf'
begin
        stdcall Output, sCRLF
        clc
        return
endfw



EndForthBlock



sCRLF db 13, 10, 0, 0

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/ForthScript/ForthScript.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: ForthScript engine.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________
module "Forth script compiler"

include 'ForthLib.asm'

; NOTE: E8    is the opcode for relative call
;       B8    is the opcode for mov eax, dword const
;       BA    is the opcode for mov edx, dword const
;       FF D0 is the opcode for call eax
;       C3    is the opcode for retn
;       e9    is the opcode for jmp long offset



ftypeNumber  = 0
ftypeString  = 1
ftypeStringFree = 2      ; this string should be destroyed after use.

struct TFStackCell
  .value dd ?           ; number or handle of the string.
  .type  db ?           ; number/string
  align 4
ends


struct TFLoopStackCell
ends



struct TFWordFooter
  .name    rb 16        ; max 12 bytes name paded with 0
  .entry   dd ?         ; offset to the code of the word  [.entry]-4 points to the footer of the previous word.
ends


; values for the Status flags.

forthCompileMode =  1   ; if set the script is compiled instead of interpreted
forthNextNewName =  2   ; if set the next extracted word should be interpreted as a new name.
forthAssignMode  =  4   ; if set the next variable word must pop value from the stack, instead of push.



struct TForthContext
  .pAStack     dd  ?     ; pointer to the aritmetic stack TArray.
  .pLStack     dd  ?     ; pointer to the loop stack TArray.
  .pWords      dd  ?     ; pointer to the words memory.
  .iWords      dd  ?     ; offset to the first free byte in the words memory.
  .iLastWord   dd  ?     ; offset to the end of the last word defined.
  .sizeWords   dd  ?     ; size of the words memory.

  .Status      dd ?

  .pUserWords  dd  ?     ; pointer to the user words memory.
  .iUserWords  dd  ?     ; offset of the end of the user word memory.
  .pUser       dd  ?     ; pointer to the user provided object for example TFreshEdit or other.
ends


ForthInitWordsMemory = 1024


proc ForthCreateContext
begin
        push    edi

        stdcall GetMem, sizeof.TForthContext
        mov     edi, eax

        stdcall CreateArray, sizeof.TFStackCell
        mov     [edi+TForthContext.pAStack], eax

        stdcall CreateArray, sizeof.TFLoopStackCell
        mov     [edi+TForthContext.pLStack], eax

        mov     [edi+TForthContext.sizeWords], ForthInitWordsMemory
        stdcall GetMem, [edi+TForthContext.sizeWords]
        mov     [edi+TForthContext.pWords], eax

        mov     eax, edi
        pop     edi
        return
endp


proc ForthFreeContext, .forth_context
begin


        return
endp



ferrSyntaxError = 1
ferrUnknownWord = 2
ferrOutOfMemory = 3
ferrInvalidNumber = 4
ferrInvalidString = 5
ferrMissingBracket = 6

ferrMaxError = 6

dmsgEndWithoutBegin db  'Syntax error', 0
dmsgUnknownWord     db  'Unknown word', 0
dmsgOutOfMemory     db  'Out of memory', 0
dmsgInvalidNumber   db  'Invalid number', 0
dmsgInvalidString   db  'Invalid string', 0
dmsgMissingBracket  db  'Missing ")"', 0
dmsgUnknownError    db  'Unknown error. Probably bug.', 0



ForthErrorMessages  dd  0
                    dd dmsgEndWithoutBegin
                    dd dmsgUnknownWord
                    dd dmsgOutOfMemory
                    dd dmsgInvalidNumber
                    dd dmsgInvalidString
                    dd dmsgMissingBracket
; this should be last.
                    dd dmsgUnknownError


proc GetForthErrorMsg, .errcode
begin
        mov     eax, [.errcode]
        cmp     eax, ferrMaxError
        jbe     @f
        mov     eax, ferrMaxError+1
@@:
        mov     eax, [ForthErrorMessages+4*eax]
        return
endp



proc ForthExecScript, .pcontext, .psource
.word     rb 16
.newword  rb 16
.entry    dd ?  ; the entry point of the currently compiled word.
.ofs_error dd ?
.sign      dd ?
begin
        push    ebx ecx esi edi

        mov     ebx, [.pcontext]
        mov     esi, [.psource]

.script_loop:

        xor     eax, eax
        mov     dword [.word], eax
        mov     dword [.word+4], eax
        mov     dword [.word+8], eax
        mov     dword [.word+12], eax
        xor     ecx, ecx

        dec     esi

.start_scan:

        inc     esi
        mov     al, [esi]

; offset for the error message, if any
        mov     edx, esi
        sub     edx, [.psource]
        mov     [.ofs_error], edx

        test    al, al
        jz      .end_of_script

        cmp     al, '+'
        je      .maybe_number
        cmp     al, '-'
        je      .maybe_number

        cmp     al, '0'
        jb      .nan
        cmp     al, '9'
        jbe     .extract_number

.nan:
        cmp     al, '"'
        je      .extract_string
        cmp     al, "'"
        je      .extract_string

        cmp     al, ' '
        jbe     .start_scan

        cmp     al, ':'
        jne     @f

        test    [ebx+TForthContext.Status], forthCompileMode
        jnz     .syntax_error

        or      [ebx+TForthContext.Status], forthCompileMode or forthNextNewName
        mov     eax, [ebx+TForthContext.iWords]
        mov     [.entry], eax
        jmp     .start_scan

@@:
        cmp     al, ';'
        jne     @f

        test    [ebx+TForthContext.Status], forthCompileMode
        jz      .syntax_error

; finalize the compilation of a word.

        mov     eax, sizeof.TFWordFooter+1
        call    .allocate_bytes
        jc      .err_out_of_memory

        sub     eax, sizeof.TFWordFooter
        mov     byte [eax+edx-1], $c3   ; retn

        pushd   dword [.newword] dword [.newword+4] dword [.newword+8] dword [.newword+12]
        popd    [eax+edx+12] [eax+edx+8] [eax+edx+4] [eax+edx]

        push    [.entry]
        pop     [eax+edx+TFWordFooter.entry]

        push    [ebx+TForthContext.iWords]
        pop     [ebx+TForthContext.iLastWord]

        and    [ebx+TForthContext.Status], not forthCompileMode

        jmp     .start_scan

@@:
        cmp     al, '('
        jne     @f

; comment ()
.comment_loop:
        inc     esi
        mov     al, [esi]
        test    al, al
        jz      .err_missing_bracket

        cmp     al, ')'
        jne     .comment_loop
        inc     esi
        jmp     .script_loop

@@:
        cmp     al, '\'
        jne     .extract_word

; one line comment
.comment_loop2:
        inc     esi
        mov     al, [esi]
        cmp     al, ' '
        jae     .comment_loop2
        jmp     .script_loop

.extract_word:
        mov     [.word+ecx], al
        inc     ecx
        and     ecx, $0f
        inc     esi
        mov     al, [esi]
        cmp     al, ' '
        ja      .extract_word

;.word_ok:
        test    [ebx+TForthContext.Status], forthNextNewName
        jz      .process_word

; copy the word as a new word name to be placed at the end of the word definition.
        mov     eax, dword [.word]
        mov     ecx, dword [.word+4]
        mov     dword [.newword], eax
        mov     dword [.newword+4], ecx

        mov     eax, dword [.word+8]
        mov     ecx, dword [.word+12]
        mov     dword [.newword+8], eax
        mov     dword [.newword+12], ecx

        and     [ebx+TForthContext.Status], not forthNextNewName
        jmp     .script_loop


.process_word:
        call    .search_word    ; eax offset relative to [TForthContext.pWords]
        jc      .err_unknown_word

        test    [ebx+TForthContext.Status], forthCompileMode
        jnz     .compile_the_word

        push    esi

        mov     esi, [ebx+TForthContext.pUser]
        add     eax, [ebx+TForthContext.pWords]
        call    eax

        pop     esi
        jmp     .script_loop

.compile_the_word:
        mov     ecx, eax        ; offset of the word entry

        cmp     eax, [ebx+TForthContext.iWords]
        jb      .internal_call

;.external_call:
        add     ecx, [ebx+TForthContext.pWords]         ; absolute address

        mov     eax, 7
        call    .allocate_bytes
        jc      .err_out_of_memory

        mov     byte [edx+eax-7], $b8   ; mov eax, const
        mov     [edx+eax-6], ecx
        mov     word [edx+eax-2], $d0ff

        jmp     .script_loop


.internal_call:
        mov     eax, 5
        call    .allocate_bytes ; return new offset in eax and pointer to the memory block in edx
        jc      .err_out_of_memory

; relative call to the word entry point.
        sub     ecx, eax
        mov     byte [edx+eax-5], $e8    ; call instruction opcode.
        mov     [edx+eax-4], ecx

        jmp     .script_loop


.maybe_number:
        cmp     byte [esi+1], '0'
        jb      .extract_word
        cmp     byte [esi+1], '9'
        ja      .extract_word

.extract_number:
        xor     edx, edx
        movzx   eax, al

        mov     byte [.sign], al
        cmp     al, '-'
        je      .next
        cmp     al, '+'
        je      .next

.num_loop:
        cmp     al, ' '
        jbe     .number_ok

        cmp     al, '0'
        jb      .err_invalid_number
        cmp     al, '9'
        ja      .err_invalid_number

        sub     al, '0'
        imul    edx, 10
        add     edx, eax

.next:
        inc     esi
        mov     al, [esi]
        jmp     .num_loop

.number_ok:
        cmp     byte [.sign], '-'
        jne     @f
        neg     edx
@@:
        test    [ebx+TForthContext.Status], forthCompileMode
        jnz     .compile_number

        call    forth_push_number
        jmp     .script_loop


.compile_number: ; $b8 forth_push_number $ba number $ff $d0
        mov     ecx, edx

        mov     eax, 12
        call    .allocate_bytes
        jc      .err_out_of_memory

        mov     byte  [edx+eax-12], $b8   ; mov eax, const
        mov     dword [edx+eax-11], forth_push_number
        mov     byte  [edx+eax-7], $ba    ; mov edx, const
        mov     dword [edx+eax-6], ecx
        mov     word  [edx+eax-2], $d0ff

        jmp     .script_loop


.extract_string:
        mov     ah, al          ; end character.
        xor     ecx, ecx        ; length of the string
        lea     edi, [esi+1]

.str_loop:
        inc     esi
        mov     al, [esi]
        test    al, al
        jz      .err_invalid_string

        cmp     al, ah
        je      .string_ok

        inc     ecx
        jmp     .str_loop

.string_ok:
        mov     ecx, esi
        sub     ecx, edi

        inc     esi

        test    [ebx+TForthContext.Status], forthCompileMode
        jnz     .compile_string

        stdcall StrNew
        mov     edx, eax

        stdcall StrCopyPart, edx, edi, 0, ecx

        push    edx
        stdcall AddArrayItem, [ebx+TForthContext.pAStack]
        mov     [ebx+TForthContext.pAStack], edx
        mov     [eax+TFStackCell.type], ftypeStringFree
        pop     [eax+TFStackCell.value]

        jmp     .script_loop

.compile_string:
        push    esi
        mov     esi, edi
        mov     edi, [ebx+TForthContext.iWords]

        lea     eax, [ecx+1+17]
        stdcall .allocate_bytes
        jc      .err_out_of_memory

        lea     eax, [edi+17]
        add     edi, [ebx+TForthContext.pWords]

        mov     byte [edi], $ba                ; mov edx, offset of string
        mov     dword [edi+1], eax             ; offset of string
        mov     byte [edi+5], $b8              ; mov eax, forth_push_string
        mov     dword [edi+6], forth_push_string
        mov     word [edi+10], $d0ff           ; call eax
        lea     eax, [ecx+1]
        mov     byte [edi+12], $e9             ; jmp  end
        mov     dword [edi+13], eax            ;

        add     edi, 17

        rep movsb
        mov     al, 0
        stosb

        pop     esi
        jmp     .script_loop


.end_of_script:
        mov     ecx, [ebx+TForthContext.pAStack]
        mov     eax, [ecx+TArray.count]
        test    eax, eax
        jz      @f

        lea     eax, [ecx+TArray.array+8*eax-8]
        mov     eax, [eax+TFStackCell.value]
        dec     [ecx+TArray.count]

@@:
        clc
        jmp     .finish

; error handlers
.err_missing_bracket:
        mov     eax, ferrMissingBracket
        jmp     .error

.err_invalid_string:
        mov     eax, ferrInvalidString
        jmp     .error

.err_invalid_number:
        mov     eax, ferrInvalidNumber
        jmp     .error

.err_out_of_memory:
        mov     eax, ferrOutOfMemory
        jmp     .error

.err_unknown_word:
        mov     eax, ferrUnknownWord
        jmp     .error

.syntax_error:
        mov     eax, ferrSyntaxError

.error:
        mov     edx, [.ofs_error]
        stc

.finish:
        pop     edi esi ecx ebx
        return


; internal subroutines


; returns:
; CF=0 - word found.
; eax - offset of word entry point in pWords memory.
;
; CF=1 - word not found.
.search_word:
        push    edx esi

; search in the compiled words
        mov     edx, [ebx+TForthContext.pWords]
        mov     esi, [ebx+TForthContext.iLastWord]
        call    .search_list
        jnc     .word_found

; if not found, search in the user provided words, if any.
        mov     edx, [ebx+TForthContext.pUserWords]
        test    edx, edx
        jz      .check_std

        mov     esi, [ebx+TForthContext.iUserWords]
        call    .search_list
        jnc     .word_found

.check_std:
        mov     edx, ForthStandardLib
        mov     esi, ForthStandardLib.size
        call    .search_list
        jnc     .word_found

        stc
        pop     esi edx
        retn

.word_found:
        clc
        pop     esi edx
        retn



; arguments:
;   esi - offset of the end of the word area.
;   edx - pointer to the begin of the word area.
; returns:
;   CF=0; eax=offset of the word entry in the word area.
;   CF=1 - not found
.search_list:
        add     esi, edx

.search_loop:
        sub     esi, sizeof.TFWordFooter
        cmp     esi, edx
        jb      .notfound

        mov     eax, dword [esi+TFWordFooter.name]
        cmp     eax, dword [.word]
        jne     .prev_word

        mov     eax, dword [esi+TFWordFooter.name+4]
        cmp     eax, dword [.word+4]
        jne     .prev_word

        mov     eax, dword [esi+TFWordFooter.name+8]
        cmp     eax, dword [.word+8]
        jne     .prev_word

        mov     eax, dword [esi+TFWordFooter.name+12]
        cmp     eax, dword [.word+12]
        je      .found

.prev_word:
        mov     esi, [esi+TFWordFooter.entry]
        add     esi, edx
        jmp     .search_loop

.found:
        mov     eax, [esi+TFWordFooter.entry]
        add     eax, edx
        sub     eax, [ebx+TForthContext.pWords]         ; relatively to TForthContext.pWords
        clc
        retn

.notfound:
        stc
        retn


; argument: eax - count of bytes to allocate.
; returns:
;   eax - offset in pWords of the new end ( iWords )
;   edx - pointer of pWords memory.

.allocate_bytes:
        push    ecx

        mov     edx, [ebx+TForthContext.iWords]
        add     edx, eax
        cmp     edx, [ebx+TForthContext.sizeWords]
        jb      .sizeok

        mov     ecx, [ebx+TForthContext.sizeWords]
        call    [ResizeIt]
        mov     [ebx+TForthContext.sizeWords], ecx

        stdcall ResizeMem, [ebx+TForthContext.pWords], ecx
        jc      .end_alloc
        mov     [ebx+TForthContext.pWords], eax

.sizeok:
        mov     [ebx+TForthContext.iWords], edx
        mov     eax, edx
        mov     edx, [ebx+TForthContext.pWords]
        clc

.end_alloc:
        pop     ecx
        retn

endp

; arguments:
;    ebx - TForthContext
;    edx - number to be pushed
; returns
;
forth_push_number:
        push    edx
        stdcall AddArrayItem, [ebx+TForthContext.pAStack]
        mov     [ebx+TForthContext.pAStack], edx
        mov     [eax+TFStackCell.type], ftypeNumber
        pop     [eax+TFStackCell.value]
        retn


; arguments:
;    ebx - TForthContext
; returns
;    eax - value from the top of the stack
proc forth_pop_number
begin
        mov     edx, [ebx+TForthContext.pAStack]
        mov     eax, [edx+TArray.count]
        dec     eax
        js      .empty_stack

        push    eax

        imul    eax, [edx+TArray.itemsize]
        mov     eax, [edx+TArray.array+edx+TFStackCell.value]

        stdcall DeleteArrayItem, edx ; from the stack
        clc
        return

.empty_stack:
        xor     eax, eax
        stc
        return
endp



; arguments:
;    ebx - TForthContext
;    edx - offset to the string related to pWords memory.
; returns
;
proc forth_push_string
begin
        add     edx, [ebx+TForthContext.pWords]
        push    edx
        stdcall AddArrayItem, [ebx+TForthContext.pAStack]
        mov     [ebx+TForthContext.pAStack], edx
        mov     [eax+TFStackCell.type], ftypeString
        pop     [eax+TFStackCell.value]
        return
endp






endmodule





<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Changes to freshlib/FreshEdit/FreshEdit.asm.

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
;    - Word wrap
;    - Code folding
;    - Associated debug information
;    - save with format information (bookmarks and breakpoints)
;    - Read-only lines
;    - Undo and Redo functions.
;    - Adjustable colors, keyboard and behavior.
;    - Char, Block and Line selections.
;    - Syntax highlighters interface for different languages.
;    - Interface to visual programming tools and auto source generators.
;_________________________________________________________________________________________
include "FreshEditThemes.asm"

module "TFreshEdit library"








|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
;    - Word wrap
;    - Code folding
;    - Associated debug information
;    - save with format information (bookmarks and breakpoints)
;    - Read-only lines
;    - Undo and Redo functions.
;    - Adjustable colors, keyboard and behavior.
;    - Char and Block selections.
;    - Syntax highlighters interface for different languages.
;    - Interface to visual programming tools and auto source generators.
;_________________________________________________________________________________________
include "FreshEditThemes.asm"

module "TFreshEdit library"

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

; Line flags

lfBookmark   = 1        ; the line have bookmark set.
lfFocused    = 2        ; the line is focused until the user press some key.
lfProtected  = 4        ; the line can not be edited.
lfWordWrap   = 8        ; the line must be word wrapped. After changes, the format have to be updated.

lfBreakpoint = 16       ; set breakpoint in debug mode.
lfFoldHeader = 32       ; this is the first line of foldable part of the text.


struct TEditorLine
  .Data         dd  ?   ; pointer to line data.
  .flags        dd  ?   ; line flags


  .syn_context  dd  ?   ; flags about current syntax highlighter context.
  .debugdata    dd  ?   ; pointer to debug data, associated to this line
  .fold_level   dd  ?   ; the level of folding.



  .width        dd  ?   ; width of the line text in chars. It is the length of the string for non wrapped lines and maximal subline for wrapped.
  align 32
  .shift = 5
ends








undoInsertText     = 0
undoDeleteText     = 1


struct TUndoInfo
  .operation   db ?       ; what was changed???
  .selMode     db ?
  align 4
  .caretX      dd ?
  .caretY      dd ?







>
|
<





>

|

|
>
>

<




>
>
>
>
>
>



<







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

; Line flags

lfBookmark   = 1        ; the line have bookmark set.
lfFocused    = 2        ; the line is focused until the user press some key.
lfProtected  = 4        ; the line can not be edited.
lfWordWrap   = 8        ; the line must be word wrapped. After changes, the format have to be updated.
lfHidden     = 16       ; this line is hidden
lfBreakpoint = 32       ; set breakpoint in debug mode.



struct TEditorLine
  .Data         dd  ?   ; pointer to line data.
  .flags        dd  ?   ; line flags
  .syn_context  dd  ?   ; flags about current syntax highlighter context after processing line.

  .fold_level   dd  ?
  .debugdata    dd  ?   ; pointer to debug data, associated to this line

  .subcount     dd  ?   ; count of wrapped sublines
  .pSublines    dd  ?   ; pointer to array containing offsets to the sublines inside the line.


  align 32
  .shift = 5
ends


struct TScreenLine
  .IndexLine dd ?
  .Subline   dd ?
ends


undoInsertText     = 0
undoDeleteText     = 1


struct TUndoInfo
  .operation   db ?       ; what was changed???
  .selMode     db ?
  align 4
  .caretX      dd ?
  .caretY      dd ?
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

chgfNoClearSelection = 1
chgfNeedRefresh      = 2
chgfFinished         = 4

; insert modes

modeInsert = 0
modeOverwrite = 1

; selection modes

selmChar = 0
selmBlock = 1



; flag ReadOnly values
froReadWrite          = 0
froReadOnlyWithCaret  = 1
froReadOnlyNoCaret    = 2


object TFreshEdit, TScrollWindow

  ._Font            dd  ?   ; font of the editor.

; main editor font sizes
  ._fontheight      dd  ?   ; in pixels.
  ._fontwidth       dd  ?   ; in pixels.
  ._fontdescent     dd  ?   ; in pixels.

; system font sizes (used for additional texts and line numbers)
  ._fontheight2     dd  ?   ; in pixels.
  ._fontwidth2      dd  ?   ; in pixels.
  ._fontdescent2    dd  ?   ; in pixels.

  .__LeftMargin     dd  ?   ; width of the left margin field. Auto computed.
  .__NumberMargin   dd  ?   ; width of the field for the line number. Auto computed.
  ._ExtraFont       dd  ?   ;

  ._cols            dd  ?   ; width of the window in text columns.
  ._rows            dd  ?   ; height of the window in text rows.
                            ; must to be update on resize and on font change.

  ._pLines          dd  ?   ; pointer to TArray of TEditorLine items.
  ._pIndex          dd  ?   ; pointer to TArray of dword that contains numbers of TEditorLine for the screen.
  ._pLengths        dd  ?   ; pointer to TArray with counts of the lines with given length.

  ._pUndoList       dd  ?   ; pointer to TArray of TUndoInfo
  ._pRedoList       dd  ?   ; pointer to TArray of TUndoInfo

  ._pShadow         dd  ?   ; double buffer pointer to TBackBuffer object.
  ._fShadowValid    dd  ?   ;



; view change fields

  ._TopLine         dd  ?   ; number of the line that is at the topmost line of the window.
  ._LeftColumn      dd  ?   ; the column of the text at the leftmost side of the window.

  ._xCaret          dd  ?   ; horizontal position of the caret inside the current line.
  ._yCaret          dd  ?   ; vertical position of the caret inside the text.

  ._xSelection      dd  ?
  ._ySelection      dd  ?

  ._fReadOnly       dd  ?
  ._SelMode         dd  ?
  ._InsMode         dd  ?
  ._TabStop         dd  ?

; end change fields

  ._prevTopLine     dd  ?

  ._prevLeftColumn  dd  ?

  ._prevxCaret      dd  ?
  ._prevyCaret      dd  ?

  ._prevxDelta      dd  ?
  ._prevyDelta      dd  ?

  ._prevSelMode     dd  ?
  ._prevInsMode     dd  ?

; end backup fields

  ._DragButton      dd  ?

;  ._Theme           TFETheme

  ._procSyntax      dd  ?   ; syntax highlighter procedure.


  ._iconBreakpointA dd  ?       ; active breakpoint icon.
  ._iconBreakpointI dd  ?       ; inactive breakpoint icon.
  ._iconDebugInfo   dd  ?
  ._maskBreakpointA dd  ?
  ._maskBreakpointI dd  ?
  ._maskDebugInfo   dd  ?


  ._iconUnfold      dd  ?
  ._iconFold        dd  ?

  ._maskUnfold      dd  ?

; Event handlers

  .OnControlKey     dd  ?

; Parameters
  param .Selection      ; selected text read/write

  param .CurrentLine    ; TEditorLine where caret resides.
  param .Text
  param .MaxLineLen

; Methods

  method .Clear          ; clears the text in the editor.

; navigation methods

  method .Move, .direction, .count, .force      ; moves the caret


  method .LineBegin
  method .LineEnd
  method .ScreenBegin
  method .ScreenEnd
  method .FileBegin
  method .FileEnd

; editing methods

  method .DeleteSel
  method .InsertLine, .index    ; index = -1 inserts at current position of the caret.
                                ; index = -2 appends the line at the end of the text.
  method .DeleteLine, .index    ; index = -1 deletes the line on the current position of the caret.

; block processing methods.
  method .DeleteText, .indexFrom, .charFrom, .indexTo, .charTo
  method .GetText, .indexFrom, .charFrom, .indexTo, .charTo

; Undo/Redo functions.

  method .RegisterForUndo, .operation, .data

  method .Undo
  method .Redo

  method .ClearUndo

; these two methods are flexible, but very slow. .Text parameter seting is fastest way to change whole text of the editor.
  method .InsertChar, .char
  method .InsertString, .hstring    ; inserts a string at the caret position.
                                    ; If the string contains formating chars they are processed properly.
  method .DelChar      ; deletes the char under the caret.

; appearance methods
  method .FormatLine, .index

; themes methods

  method LoadTheme, .configdb, .directory

endobj


; about .pIndex field:
;
;  This array contains the number of text lines that have to be displayed on the
;  respective screen lines.
;  Not every text line have screen line representation - it means the count of items of [pIntex]
;  can be smaller than count of items of [pLines]. This case is when some lines are folded and not visible.
;  On the other hand, another variant is also possible - several items of [pIndex] to point to
;  one line in [pLines] - when the text line is wraped and displayed on several lines of the screen.
;
;_________________________________________________________________________________________

cDefaultEditorFont text 'Fixedsys Excelsior 3.01'
;cDefaultEditorFont text 'Droid sans mono'


; left margin icons.
;iglobal
    getfile iconBreakpointA, 'images/breakpoint.gif'
    getfile iconBreakpointI, 'images/breakpoint_inactive.gif'
    getfile maskBreakpointA, 'images/breakpoint_mask.gif'
    getfile maskBreakpointI, 'images/breakpoint_mask_inactive.gif'
    getfile iconDebugInfo,   'images/debug_icon.gif'
    getfile maskDebugInfo,   'images/debug_mask.gif'
    getfile iconUnfold,      'images/unfold.gif'
    getfile iconFold,        'images/fold.gif'
    getfile maskUnfold,      'images/unfold_mask.gif'
;endg



proc TFreshEdit.Create, .pobj
begin
        push    eax edx

        mov     ebx, [.pobj]

; Main Font settings.
        stdcall FontCreate, cDefaultEditorFont, 0, 0, ffMonospaced
        mov     [ebx+TFreshEdit._Font], eax

        mov     [ebx+TFreshEdit._cursor], mcText

        stdcall FontGetCharSize, [ebx+TFreshEdit.handle], [ebx+TFreshEdit._Font], __HeightProbeString
        test    edx, edx
        jnz     @f
        inc     edx
@@:







|





|
>
>








>














<



|


<





|

>
>



<


|
|





|






>


|
|











<
<


>






<
<


<









|
|


|

|

|
|
|
>



|
<



<
<
|
|
<
<

|
<
<

<
|
<

|
|

<
|
<
<
<
<
<

|
|








<
<
<
<
<
<
<
<
<
<



>














>



|






>







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

chgfNoClearSelection = 1
chgfNeedRefresh      = 2
chgfFinished         = 4

; insert modes

modeInsert    = 0
modeOverwrite = 1

; selection modes

selmChar = 0
selmBlock = 1      ; when the editor is in block selection mode, the word wrap
                   ; feature must be switched OFF, because it is not possible
                   ; to select rectangular region, on word wrapped lines.

; flag ReadOnly values
froReadWrite          = 0
froReadOnlyWithCaret  = 1
froReadOnlyNoCaret    = 2


object TFreshEdit, TScrollWindow

  ._Font            dd  ?   ; font of the editor.

; main editor font sizes
  ._fontheight      dd  ?   ; in pixels.
  ._fontwidth       dd  ?   ; in pixels.
  ._fontdescent     dd  ?   ; in pixels.

; system font sizes (used for additional texts and line numbers)
  ._fontheight2     dd  ?   ; in pixels.
  ._fontwidth2      dd  ?   ; in pixels.
  ._fontdescent2    dd  ?   ; in pixels.

  .__LeftMargin     dd  ?   ; width of the left margin field. Auto computed.
  .__NumberMargin   dd  ?   ; width of the field for the line number. Auto computed.


  ._cols            dd  ?   ; width of the window in text columns.
  ._rows            dd  ?   ; height of the window in text rows.
                            ; must be updated on resize and on font change.

  ._pLines          dd  ?   ; pointer to TArray of TEditorLine items.

  ._pLengths        dd  ?   ; pointer to TArray with counts of the lines with given length.

  ._pUndoList       dd  ?   ; pointer to TArray of TUndoInfo
  ._pRedoList       dd  ?   ; pointer to TArray of TUndoInfo

  ._pShadow         dd  ?   ; pointer to TBackBuffer object.
  ._fShadowValid    dd  ?   ;

  .pScreenIndex     dd  ?   ; pointer to array of TScreenLine structures, containing

; view change fields


  ._LeftColumn      dd  ?   ; the column of the text at the leftmost side of the window.

  ._xCaret          dd  ?   ; the number of the char the caret resides.
  ._yCaret          dd  ?   ; the index of the line the caret resides.

  ._xSelection      dd  ?
  ._ySelection      dd  ?

  ._fReadOnly       dd  ?
  ._SelMode         dd  ?        ; NOTE: on selmBlock, the word wrap should be OFF
  ._InsMode         dd  ?
  ._TabStop         dd  ?

; end change fields

  ._prevTopLine     dd  ?
  ._prevTopOffset   dd  ?
  ._prevLeftColumn  dd  ?

  ._prevCaretChar   dd  ?
  ._prevCaretLine   dd  ?

  ._prevxDelta      dd  ?
  ._prevyDelta      dd  ?

  ._prevSelMode     dd  ?
  ._prevInsMode     dd  ?

; end backup fields

  ._DragButton      dd  ?



  ._procSyntax      dd  ?   ; syntax highlighter procedure.

; icons and masks for the left margin
  ._iconBreakpointA dd  ?       ; active breakpoint icon.
  ._iconBreakpointI dd  ?       ; inactive breakpoint icon.
  ._iconDebugInfo   dd  ?
  ._maskBreakpointA dd  ?
  ._maskBreakpointI dd  ?
  ._maskDebugInfo   dd  ?


  ._iconUnfold      dd  ?
  ._iconFold        dd  ?

  ._maskUnfold      dd  ?

; Event handlers

  .OnControlKey     dd  ?

; Parameters
  param .Selection      ; selected text read/write

  param .CurrentLine    ; TEditorLine where caret resides. read only
  param .Text           ; whole text; read/write
  param .MaxLineLen

; Commands

  method .Clear

  method .Left
  method .Right
  method .Up
  method .Down

  method .LineBegin
  method .LineEnd


  method .FileBegin
  method .FileEnd



  method .PageUp
  method .PageDown



  method .InsertString, .hString




;


  method .GetText, .LineFrom, .CharFrom, .LineTo, .CharTo
  method .DeleteSel


; Coordinates convertions






  method .PixelToCaret, .xPixel, .yPixel
  method .CaretToPixel, .iRow, .xChar

; themes methods

  method LoadTheme, .configdb, .directory

endobj













cDefaultEditorFont text 'Fixedsys Excelsior 3.01'
;cDefaultEditorFont text 'Droid sans mono'


; left margin icons.
;iglobal
    getfile iconBreakpointA, 'images/breakpoint.gif'
    getfile iconBreakpointI, 'images/breakpoint_inactive.gif'
    getfile maskBreakpointA, 'images/breakpoint_mask.gif'
    getfile maskBreakpointI, 'images/breakpoint_mask_inactive.gif'
    getfile iconDebugInfo,   'images/debug_icon.gif'
    getfile maskDebugInfo,   'images/debug_mask.gif'
    getfile iconUnfold,      'images/unfold.gif'
    getfile iconFold,        'images/fold.gif'
    getfile maskUnfold,      'images/unfold_mask.gif'
;endg



proc TFreshEdit.Create, .pobj
begin
        push    edx

        mov     ebx, [.pobj]

; Main Font settings.
        stdcall FontCreate, cDefaultEditorFont, 0, 0, ffMonospaced
        mov     [ebx+TFreshEdit._Font], eax

        mov     [ebx+TFreshEdit._cursor], mcText

        stdcall FontGetCharSize, [ebx+TFreshEdit.handle], [ebx+TFreshEdit._Font], __HeightProbeString
        test    edx, edx
        jnz     @f
        inc     edx
@@:
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
        stdcall CreateImageGIF, iconFold, iconFold.size
        mov     [ebx+TFreshEdit._iconFold], eax

        stdcall CreateImageGIF, maskUnfold, maskUnfold.size
        mov     [ebx+TFreshEdit._maskUnfold], eax

; Init some values.
        mov     [ebx+TFreshEdit._TabStop], 8

        mov     [eax+TFETheme.WrapPos], 80
        mov     [eax+TFETheme.UndoLevels], 20

        mov     [ebx+TFreshEdit._DragButton], -1

        stdcall CreateArray, sizeof.TEditorLine
        mov     [ebx+TFreshEdit._pLines], eax

        stdcall CreateArray, 4
        mov     [ebx+TFreshEdit._pIndex], eax

        stdcall CreateArray, 4
        mov     [ebx+TFreshEdit._pLengths], eax

        stdcall CreateArray, sizeof.TUndoInfo
        mov     [ebx+TFreshEdit._pUndoList], eax

        stdcall CreateArray, sizeof.TUndoInfo
        mov     [ebx+TFreshEdit._pRedoList], eax

        stdcall CreateBackBuffer, [ebx+TFreshEdit.handle], 1, 1
        mov     [ebx+TFreshEdit._pShadow], eax

        pop     edx eax
        clc
        return
endp



;_________________________________________________________________________________________


proc TFreshEdit.Destroy, .pobj
begin
        mov     ebx, [.pobj]


        execute ebx, TFreshEdit.Clear
        stdcall FreeMem, [ebx+TFreshEdit._pLines]

        stdcall FreeMem, [ebx+TFreshEdit._pIndex]
        stdcall FreeMem, [ebx+TFreshEdit._pLengths]
        stdcall FreeMem, [ebx+TFreshEdit._pUndoList]
        stdcall FreeMem, [ebx+TFreshEdit._pRedoList]


        stdcall DestroyBackBuffer, [ebx+TFreshEdit._pShadow]


        stdcall DestroyImage, [ebx+TFreshEdit._iconBreakpointA]
        stdcall DestroyImage, [ebx+TFreshEdit._iconBreakpointI]
        stdcall DestroyImage, [ebx+TFreshEdit._iconDebugInfo]
        stdcall DestroyImage, [ebx+TFreshEdit._maskBreakpointA]
        stdcall DestroyImage, [ebx+TFreshEdit._maskBreakpointI]
        stdcall DestroyImage, [ebx+TFreshEdit._maskDebugInfo]
        stdcall DestroyImage, [ebx+TFreshEdit._iconUnfold]
        stdcall DestroyImage, [ebx+TFreshEdit._iconFold]

        stdcall DestroyImage, [ebx+TFreshEdit._maskUnfold]
        clc
        return
endp


;_________________________________________________________________________________________







|
<
<
<
<





<
<
<












|












>
>

|
>
|




>


>








<







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
        stdcall CreateImageGIF, iconFold, iconFold.size
        mov     [ebx+TFreshEdit._iconFold], eax

        stdcall CreateImageGIF, maskUnfold, maskUnfold.size
        mov     [ebx+TFreshEdit._maskUnfold], eax

; Init some values.
        mov     [ebx+TFreshEdit._TabStop], 4




        mov     [ebx+TFreshEdit._DragButton], -1

        stdcall CreateArray, sizeof.TEditorLine
        mov     [ebx+TFreshEdit._pLines], eax




        stdcall CreateArray, 4
        mov     [ebx+TFreshEdit._pLengths], eax

        stdcall CreateArray, sizeof.TUndoInfo
        mov     [ebx+TFreshEdit._pUndoList], eax

        stdcall CreateArray, sizeof.TUndoInfo
        mov     [ebx+TFreshEdit._pRedoList], eax

        stdcall CreateBackBuffer, [ebx+TFreshEdit.handle], 1, 1
        mov     [ebx+TFreshEdit._pShadow], eax

        pop     edx
        clc
        return
endp



;_________________________________________________________________________________________


proc TFreshEdit.Destroy, .pobj
begin
        mov     ebx, [.pobj]

; free all text data
        execute ebx, TFreshEdit.Clear

; free the allocated buffers
        stdcall FreeMem, [ebx+TFreshEdit._pLines]
        stdcall FreeMem, [ebx+TFreshEdit._pLengths]
        stdcall FreeMem, [ebx+TFreshEdit._pUndoList]
        stdcall FreeMem, [ebx+TFreshEdit._pRedoList]

; destroy the shadow buffer.
        stdcall DestroyBackBuffer, [ebx+TFreshEdit._pShadow]

; destroy icon images.
        stdcall DestroyImage, [ebx+TFreshEdit._iconBreakpointA]
        stdcall DestroyImage, [ebx+TFreshEdit._iconBreakpointI]
        stdcall DestroyImage, [ebx+TFreshEdit._iconDebugInfo]
        stdcall DestroyImage, [ebx+TFreshEdit._maskBreakpointA]
        stdcall DestroyImage, [ebx+TFreshEdit._maskBreakpointI]
        stdcall DestroyImage, [ebx+TFreshEdit._maskDebugInfo]
        stdcall DestroyImage, [ebx+TFreshEdit._iconUnfold]
        stdcall DestroyImage, [ebx+TFreshEdit._iconFold]

        stdcall DestroyImage, [ebx+TFreshEdit._maskUnfold]
        clc
        return
endp


;_________________________________________________________________________________________
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

        stc
.exit:
        return

;................................................................
.get_selection:
        push    esi

        mov     esi, [.pobj]
        mov     eax, [esi+TFreshEdit._SelMode]
        cmp     eax, selmChar
        je      .get_sel_char
        cmp     eax, selmBlock
        je      .get_sel_block

        stc
        return

.get_sel_char:
        execute esi, TFreshEdit.GetText, [esi+TFreshEdit._yCaret], [esi+TFreshEdit._xCaret],      \
                                         [esi+TFreshEdit._ySelection], [esi+TFreshEdit._xSelection]

        clc
        pop     esi
        return


.get_sel_block:
        xor     eax, eax
        clc
        pop     esi
        return


;................................................................
.gettext:
        push    ebx ecx edx esi edi


        stdcall StrNew
        mov     ebx, eax
        mov     edi, [.pobj]

        mov     esi, [edi+TFreshEdit._pLines]
        mov     ecx, [esi+TArray.count]

        jecxz   .text_ready
        lea     esi, [esi+TArray.array]

.line_loop:
        stdcall TFreshEdit.__AddFormatLine, ebx, [esi+TEditorLine.flags]

        stdcall StrDup, [esi+TEditorLine.Data]
        push    eax
        push    eax
        push    eax
        stdcall StrLen, eax
        mov     edx, eax
        stdcall StrPtr ; from the stack







<
<
|
<
<
<
<
<
|
<
<
<
<
<
|
<

<


<
<
<
<
<
<
<
<


|
<












<
<







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

        stc
.exit:
        return

;................................................................
.get_selection:


        mov     ecx, [.pobj]





        execute ecx, TFreshEdit.GetText, [ecx+TFreshEdit._yCaret], [ecx+TFreshEdit._xCaret],      \





                                         [ecx+TFreshEdit._ySelection], [ecx+TFreshEdit._xSelection], [ecx+TFreshEdit._SelMode]

        clc

        return









;................................................................
.gettext:
        push    ebx edx esi edi


        stdcall StrNew
        mov     ebx, eax
        mov     edi, [.pobj]

        mov     esi, [edi+TFreshEdit._pLines]
        mov     ecx, [esi+TArray.count]

        jecxz   .text_ready
        lea     esi, [esi+TArray.array]

.line_loop:


        stdcall StrDup, [esi+TEditorLine.Data]
        push    eax
        push    eax
        push    eax
        stdcall StrLen, eax
        mov     edx, eax
        stdcall StrPtr ; from the stack
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
        inc     eax
        dec     edx
        jnz     .loop_char

.line_ready:
        stdcall StrCat, ebx ; from the stack.
        stdcall StrDel      ; from the stack
        stdcall StrCharCat, ebx, $0a0d

.next_line:
        add     esi, sizeof.TEditorLine
        loop    .line_loop

.text_ready:
        mov     eax, ebx
        pop     edi esi edx ecx ebx
        clc
        return

;................................................................

.currentline:
        push    ebx edx edi

        mov     edi, [.pobj]
        mov     eax, [edi+TFreshEdit._yCaret]
        mov     ebx, [edi+TFreshEdit._pIndex]
        cmp     eax, [ebx+TArray.count]
        jae     .errorcl

.lineloop:
        mov     edx, [ebx+TArray.array+4*eax]
        cmp     edx, -1
        jne     .found

        dec     eax
        jns     .lineloop

.errorcl:
        stc
        pop     edi edx ebx
        return

; edx is the number of string in the lines array.
.found:
        mov     ebx, [edi+TFreshEdit._pLines]
        cmp     edx, [ebx+TArray.count]
        jae     .errorcl

        shl     edx, TEditorLine.shift
        lea     eax, [ebx+TArray.array+edx]

        clc
        pop     edi edx ebx
        return

;................................................................

.maxlinelen:
        mov     eax, [.pobj]
        mov     eax, [eax+TFreshEdit._pLengths]







|







|






<
<
|
|
<
<
|
<
<
<
<
<
<
|
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<







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
        inc     eax
        dec     edx
        jnz     .loop_char

.line_ready:
        stdcall StrCat, ebx ; from the stack.
        stdcall StrDel      ; from the stack
        stdcall TFreshEdit.__AddFormatLine, ebx, [esi+TEditorLine.flags]

.next_line:
        add     esi, sizeof.TEditorLine
        loop    .line_loop

.text_ready:
        mov     eax, ebx
        pop     edi esi edx ebx
        clc
        return

;................................................................

.currentline:


        mov     ecx, [.pobj]
        stdcall GetArrayItem, [ecx+TFreshEdit._pLines], [ecx+TFreshEdit._yCaret]


        jnc     .endgcl






        xor     eax, eax

.endgcl:














        clc

        return

;................................................................

.maxlinelen:
        mov     eax, [.pobj]
        mov     eax, [eax+TFreshEdit._pLengths]
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588


;_________________________________________________________________________________________


proc TFreshEdit.Set, .pobj, .paramID, .value
begin
        push    eax ebx edx esi edi
        mov     edi, [.pobj]

        mov     eax, [.paramID]
        cmp     eax, TFreshEdit.Text
        je      .settext

        cmp     eax, TFreshEdit.Selection
        je      .set_selection

        stc

.finish:
        pop     edi esi edx ebx eax
        return

;.........................................................................................
.set_selection:
; delete the old selection
        push    esi eax edx
        mov     esi, [.pobj]







<
<
<
<
|


|



<
<
<







492
493
494
495
496
497
498




499
500
501
502
503
504
505



506
507
508
509
510
511
512


;_________________________________________________________________________________________


proc TFreshEdit.Set, .pobj, .paramID, .value
begin




        cmp     [.paramID], TFreshEdit.Text
        je      .settext

        cmp     [.paramID], TFreshEdit.Selection
        je      .set_selection

        stc



        return

;.........................................................................................
.set_selection:
; delete the old selection
        push    esi eax edx
        mov     esi, [.pobj]
596
597
598
599
600
601
602

603
604
605
606



607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
        pop     edx eax esi
        clc
        return

;.........................................................................................

.settext:

locals
.pLine    dd ?
.flags    dd ?
endl



        execute edi, TFreshEdit.Clear

        stdcall StrPtr, [.value]
        mov     esi, eax

.lineloop:
        mov     [.flags], 0

        stdcall TFreshEdit.__DecodeFormatLine, esi
        jc      .line_begin

        mov     [.flags], eax
        add     esi, ecx

.line_begin:
        push    esi

.char:
        lodsb
        test    al, al
        jz      .end_of_line








>


<

>
>
>






<
<
<
<
<
<
<
<
<







520
521
522
523
524
525
526
527
528
529

530
531
532
533
534
535
536
537
538
539









540
541
542
543
544
545
546
        pop     edx eax esi
        clc
        return

;.........................................................................................

.settext:

locals
.pLine    dd ?

endl
        push    eax ebx edx esi edi

        mov     edi, [.pobj]
        execute edi, TFreshEdit.Clear

        stdcall StrPtr, [.value]
        mov     esi, eax

.lineloop:









        push    esi

.char:
        lodsb
        test    al, al
        jz      .end_of_line

666
667
668
669
670
671
672


673
674
675
676
677
678
679
680
681
682


683
684
685
686

687
688
689



690
691
692
693

694
695
696
697
698
699
700
701
702
703
704
705
706
707

708
709

710
711
712
713
714
715
716
717
718
                        ; because the memory reallocation returns not zero filled memory.
        stosb

        pop     edi esi ecx

; insert text line.
        stdcall AddArrayItems, [edi+TFreshEdit._pLines], 1


        mov     [edi+TFreshEdit._pLines], edx
        mov     ecx, [edx+TArray.count]
        mov     [.pLine], eax

        mov     [eax+TEditorLine.Data], ebx
        push    [.flags]
        pop     [eax+TEditorLine.flags]
        mov     [eax+TEditorLine.syn_context], 0
        mov     [eax+TEditorLine.debugdata], 0
        mov     [eax+TEditorLine.width], -1



; insert index line.
        stdcall AddArrayItems, [edi+TFreshEdit._pIndex], 1
        mov     [edi+TFreshEdit._pIndex], edx


        dec     ecx
        mov     [eax], ecx




; format the line
        mov     ecx, [edx+TArray.count]
        dec     ecx

        execute edi, TFreshEdit.FormatLine, ecx

; goto next line.
        cmp     byte [esi], 0
        jne     .lineloop

        mov     [edi+TFreshEdit._TopLine], 0
        mov     [edi+TFreshEdit._yCaret], 0

        mov     eax, [edi+TFreshEdit._pLengths]

        stdcall TFreshEdit.__UpdateScrollBars, edi
        mov     [edi+TFreshEdit._fShadowValid], 0


        clc
        jmp     .finish

endp



;_________________________________________________________________________________________

; move commands
mvcMoveX   = 1
mvcMoveY   = 2







>
>

<



|
|
|
|
|
>
>

<
|
|
>

|
|
>
>
>




>
|













>

|
>

<







584
585
586
587
588
589
590
591
592
593

594
595
596
597
598
599
600
601
602
603
604

605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637

638
639
640
641
642
643
644
                        ; because the memory reallocation returns not zero filled memory.
        stosb

        pop     edi esi ecx

; insert text line.
        stdcall AddArrayItems, [edi+TFreshEdit._pLines], 1
        jc      .end_set_text

        mov     [edi+TFreshEdit._pLines], edx

        mov     [.pLine], eax

        mov     [eax+TEditorLine.Data], ebx
        xor     ecx, ecx
        mov     [eax+TEditorLine.flags], ecx
        mov     [eax+TEditorLine.syn_context], ecx
        mov     [eax+TEditorLine.debugdata], ecx
        mov     [eax+TEditorLine.fold_level], ecx
        dec     ecx
;        mov     [eax+TEditorLine.width], ecx


        stdcall StrPtr, ebx
        stdcall TFreshEdit.__DecodeFormatLine, eax
        jc      .format_ok

        mov     edx, [.pLine]
        mov     [edx+TEditorLine.flags], eax
        stdcall StrCopyPart, ebx, ebx, 0, ecx

.format_ok:

; format the line
        mov     ecx, [edx+TArray.count]
        dec     ecx

;        execute edi, TFreshEdit.FormatLine, ecx

; goto next line.
        cmp     byte [esi], 0
        jne     .lineloop

        mov     [edi+TFreshEdit._TopLine], 0
        mov     [edi+TFreshEdit._yCaret], 0

        mov     eax, [edi+TFreshEdit._pLengths]

        stdcall TFreshEdit.__UpdateScrollBars, edi
        mov     [edi+TFreshEdit._fShadowValid], 0

.end_set_text:
        clc
        pop     edi esi edx ebx eax
        return
endp



;_________________________________________________________________________________________

; move commands
mvcMoveX   = 1
mvcMoveY   = 2
732
733
734
735
736
737
738












739
740
741
742
743
744
745
746
747



748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765



766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
















1024

1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040

1041
1042


1043
1044
1045

1046
1047
1048
1049


1050
1051


1052
1053
1054
1055
1056

1057
1058
1059
1060
1061
1062
1063
        je      .movecaret

        cmp     [.method], TFreshEdit.LineBegin
        je      .linebegin

        cmp     [.method], TFreshEdit.LineEnd
        je      .lineend













        cmp     [.method], TFreshEdit.DeleteSel
        je      .delete_selection

        cmp     [.method], TFreshEdit.DeleteText
        je      .delete_text

        cmp     [.method], TFreshEdit.GetText
        je      .get_text




        cmp     [.method], TFreshEdit.DeleteLine
        je      .delete_line

        cmp     [.method], TFreshEdit.InsertChar
        je      .insert_char

        cmp     [.method], TFreshEdit.InsertString
        je      .insert_string

        cmp     [.method], TFreshEdit.InsertLine
        je      .insert_line

        cmp     [.method], TFreshEdit.FormatLine
        je      .format_line

        cmp     [.method], TFreshEdit.DelChar
        je      .del_char




        stc
        return

;.........................................................................................
.refresh:
        mov     eax, [.self]
        mov     [eax+TFreshEdit._fShadowValid], 0
        stc
        return

;.........................................................................................
; formats some line of the text, depending on the flags. Also, fix the index items for
; this line.
.format_line:
virtual at ebx
  .index dd ?
end virtual

; first get the line pointer
locals
  .imin  dd  ?
  .imax  dd  ?
  .start_count dd ?
  .rows        dd ?

  .caret_ofs dd ?
  .wrap_here dd ?

  .retval dd ?   ; correction count on tab-expansion
endl
        push    ecx esi edi

        mov     esi, [.self]
        mov     edi, [esi+TFreshEdit._pIndex]

        mov     ecx, [.index]
        cmp     ecx, [edi+TArray.count]
        jae     .error_format

.loop_end:
        inc     ecx
        cmp     ecx, [edi+TArray.count]
        jae     .end_found
        cmp     [edi+TArray.array+4*ecx], -1
        je      .loop_end

.end_found:
        dec     ecx
        mov     [.imax], ecx

        mov     ecx, [.index]
        inc     ecx

.loop_start:
        dec     ecx
        js      .error_format

        cmp     [edi+TArray.array+4*ecx], -1
        je      .loop_start

        mov     [.imin], ecx
        mov     [.rows], 1    ; how many lines are withit the line

        mov     ecx, [edi+TArray.array+4*ecx]   ; index in _pLines array.
        shl     ecx, TEditorLine.shift
        add     ecx, [esi+TFreshEdit._pLines]
        lea     edi, [ecx+TArray.array]         ; edi points to TEditorLine structure.

; begin of formating
        stdcall StrClipSpacesR, [edi+TEditorLine.Data]
        stdcall ExpandTabs, [edi+TEditorLine.Data], [esi+TFreshEdit._TabStop]
        mov     [.retval], eax
        stdcall StrLen, [edi+TEditorLine.Data]
        mov     ecx, eax
        mov     [.start_count], eax
        jecxz   .wrap_ok

        stdcall StrPtr, [edi+TEditorLine.Data]
        mov     edx, eax

; first replace $01 with $20 (wrap char to space)
        push    edx ecx
.spc_loop:
        cmp     byte [edx], $01
        jne     @f
        mov     byte [edx], $20
@@:
        inc     edx
        loop    .spc_loop
        pop     ecx edx

; word wrap?
        test    [edi+TEditorLine.flags], lfWordWrap
        jz      .wrap_ok

        push    edi

        mov     edi, edx
.wrap_outer:
        mov     ecx, [FreshEditTheme.WrapPos]
        inc     ecx
        mov     [.wrap_here], -1
        xor     edx, edx

.wrap_loop:
        add     edi, edx
        stdcall DecodeUtf8, [edi]
        test    eax, eax
        jz      .wrap_ready

        cmp     eax, ' '
        jne     @f
        mov     [.wrap_here], edi
@@:
        loop    .wrap_loop

        cmp     [.wrap_here], -1
        jne     .do_wrap

.forward:
        add     edi, edx
        stdcall DecodeUtf8, [edi]
        test    eax, eax
        jz      .wrap_ready

        cmp     eax, ' '
        jne     .forward

        mov     [.wrap_here], edi

.do_wrap:
        mov     edi, [.wrap_here]
        mov     byte [edi], $01         ; wrap the line.
        inc     edi
        inc     [.rows]
        jmp     .wrap_outer


.wrap_ready:
; ready, so fix the index.
        pop     edi

.wrap_ok:
        mov     eax, [.imin]
        inc     eax

        mov     ecx, [.imax]
        sub     ecx, [.imin]
        inc     ecx
        sub     ecx, [.rows]    ; ecx>0 means some rows from the index must be deleted
                                ; ecx<0 means some rows must be added.
                                ; ecx=0 means the index is ok
        jz      .index_ok
        js      .add_more_index

        stdcall DeleteArrayItems, [esi+TFreshEdit._pIndex], eax, ecx
        mov     [esi+TFreshEdit._pIndex], edx
        jmp     .index_ok

.add_more_index:
        neg     ecx
        stdcall InsertArrayItems, [esi+TFreshEdit._pIndex], eax, ecx
        mov     [esi+TFreshEdit._pIndex], edx

.fill_new_items:
        mov     dword [eax], -1
        lea     eax, [eax+4]
        loop    .fill_new_items

.index_ok:
        stdcall TFreshEdit.__LineWidth, [edi+TEditorLine.Data]
        xchg    eax, [edi+TEditorLine.width]
        stdcall TFreshEdit.__FixLength, esi, [edi+TEditorLine.width], eax

        clc
        mov     eax, [.retval]
        mov     edx, [.imin]
        pop     edi esi ecx
        return

.error_format:
        int3
        mov     eax, -1
        clc
        pop     edi esi ecx
        return

;.........................................................................................
.delete_line:
virtual at ebx
  .del_index dd ?
end virtual

        push    edx esi edi
        mov     esi, [.self]

        mov     eax, [.del_index]
        cmp     eax, -1
        jne     @f
        mov     eax, [esi+TFreshEdit._yCaret]
@@:
        mov     edi, [esi+TFreshEdit._pIndex]
        cmp     eax, [edi+TArray.count]
        jae     .end_del_line

.beg_search:
        cmp     [edi+TArray.array+4*eax], -1    ; word wrap
        jne     .do_del
        dec     eax
        jnz     .beg_search

.do_del:
        mov     ecx, [edi+TArray.array+4*eax]
        shl     ecx, TEditorLine.shift
        add     ecx, TArray.array
        add     ecx, [esi+TFreshEdit._pLines]
        stdcall StrDel, [ecx+TEditorLine.Data]
        stdcall TFreshEdit.__FixLength, esi, -1, [ecx+TEditorLine.width]

        stdcall DeleteArrayItems, [esi+TFreshEdit._pLines], [edi+TArray.array+4*eax], 1
        mov     [esi+TFreshEdit._pLines], edx

.del_index2:
        stdcall DeleteArrayItems, edi, eax, 1
        mov     edi, edx
        cmp     eax, [edi+TArray.count]
        jae     .end_del_index2

        cmp     [edi+TArray.array+4*eax], -1
        je      .del_index2

.end_del_index2:
        mov     [esi+TFreshEdit._pIndex], edi
        push    eax

; fix the index to the end:
.fix_index_del:
        cmp     eax, [edi+TArray.count]
        jae     .end_fix_index

        cmp     [edi+TArray.array+4*eax], -1
        je      @f
        dec     [edi+TArray.array+4*eax]
@@:
        inc     eax
        jmp     .fix_index_del

.end_fix_index:
        pop     eax
.end_del_line:
        clc
        pop     edi esi edx
        return

;.........................................................................................
.get_text:
; have the same arguments and local variables as .delete_text
















        pushad

        mov     [.ret_str], 0

; sort the "from" and "To" in order to have "From" < "To"
        mov     eax, [.indexFrom]
        mov     ecx, [.charFrom]
        cmp     eax, [.indexTo]
        jne     @f
        cmp     ecx, [.charTo]
@@:
        je      .finish_get    ; from == to so nothing to return
        jb      @f
        xchg    eax, [.indexTo]
        xchg    ecx, [.charTo]
        mov     [.indexFrom], eax
        mov     [.charFrom], ecx
@@:


; last line processing


        stdcall TFreshEdit.__PosToPointer, [.self], [.charTo], [.indexTo]
        mov     [.toline], edx


        stdcall StrExtract, [edx+TEditorLine.Data], 0, eax
        mov     [.final_str], eax

; first line processing


        stdcall TFreshEdit.__PosToPointer, [.self], [.charFrom], [.indexFrom]
        mov     [.fromline], edx



        mov     edi, [edx+TEditorLine.Data]
        cmp     edx, [.toline]
        jne     .dup_first
        mov     edi, [.final_str]

.dup_first:
        push    eax
        stdcall StrDup, edi
        mov     edi, eax
        pop     eax

        jecxz   .get_splitit







>
>
>
>
>
>
>
>
>
>
>
>









>
>
>




<
<
<






|
|

|
|
>
>
>






|
|



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




|


|







|
|


|
|
<
|
<

<
<
<
<
<


<
<
<
<
<
|
<
<
<
<
<
<
<
<
|
<

<
<
<
<
|
<
<
<
<
<
<
<
<
<


|





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
















>


>
>
|
|
|
>
|



>
>
|
|
>
>





>







658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692



693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
















































































































































































718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738

739

740





741
742





743








744

745




746









747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
        je      .movecaret

        cmp     [.method], TFreshEdit.LineBegin
        je      .linebegin

        cmp     [.method], TFreshEdit.LineEnd
        je      .lineend

        cmp     [.method], TFreshEdit.FileBegin
        je      .filebegin

        cmp     [.method], TFreshEdit.FileEnd
        je      .fileend

        cmp     [.method], TFreshEdit.ScreenBegin
        je      .pagebegin

        cmp     [.method], TFreshEdit.ScreenEnd
        je      .pageend

        cmp     [.method], TFreshEdit.DeleteSel
        je      .delete_selection

        cmp     [.method], TFreshEdit.DeleteText
        je      .delete_text

        cmp     [.method], TFreshEdit.GetText
        je      .get_text

        cmp     [.method], TFreshEdit.InsertText
        je      .insert_text

        cmp     [.method], TFreshEdit.DeleteLine
        je      .delete_line




        cmp     [.method], TFreshEdit.InsertString
        je      .insert_string

        cmp     [.method], TFreshEdit.InsertLine
        je      .insert_line

        cmp     [.method], TFreshEdit.DelChar
        je      .del_char

        cmp     [.method], TFreshEdit.PixelToCaret
        je      .pixel_to_caret

        cmp     [.method], TFreshEdit.CaretToPixel
        je      .caret_to_pixel

        stc
        return

;.........................................................................................
.refresh:
        mov     ecx, [.self]
        mov     [ecx+TFreshEdit._fShadowValid], 0
        stc
        return


















































































































































































;.........................................................................................
.delete_line:
virtual at ebx
  .del_index  dd  ?
end virtual

        push    edx esi
        mov     esi, [.self]

        mov     eax, [.del_index]
        cmp     eax, -1
        jne     @f
        mov     eax, [esi+TFreshEdit._yCaret]
@@:
        mov     edx, [esi+TFreshEdit._pLines]
        cmp     eax, [edx+TArray.count]
        jae     .end_del_line

        shl     eax, TEditorLine.shift
        lea     ecx, [edx+TArray.array+eax]

        shr     eax, TEditorLine.shift







        stdcall StrDel, [ecx+TEditorLine.Data]
        stdcall TFreshEdit.__FixLength, esi, -1, [ecx+TEditorLine.width]





        stdcall DeleteArrayItems, edx, eax, 1








        mov     [esi+TFreshEdit._pLines], edx






; delete the wrapped line (if any)









.end_del_line:
        clc
        pop     esi edx
        return

;.........................................................................................
.get_text:
; have the same arguments and local variables as .delete_text
virtual at ebx  ; arguments
  .indexFrom dd ?
  .charFrom  dd ?
  .indexTo   dd ?
  .charTo    dd ?
  .BlockKind dd ?
end virtual
locals
  .final_str   dd ?
  .final_flags dd ?
  .final_level dd ?
  .fromline    dd ?
  .toline      dd ?
  .ret_str     dd ?
endl

        pushad

        mov     [.ret_str], 0

; sort the "from" and "To" in order to have "From" < "To"
        mov     eax, [.indexFrom]
        mov     ecx, [.charFrom]
        cmp     eax, [.indexTo]
        jne     @f
        cmp     ecx, [.charTo]
@@:
        je      .finish_get    ; from == to so nothing to return
        jb      @f
        xchg    eax, [.indexTo]
        xchg    ecx, [.charTo]
        mov     [.indexFrom], eax
        mov     [.charFrom], ecx
@@:
        mov     esi, [.self]

; last line processing
        stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.indexTo]
        jc      .error_get

        mov     [.toline], eax
        mov     edx, eax
        stdcall StrOffsUtf8, [edx+TEditorLine.Data], [.charTo]
        stdcall StrExtract,  [edx+TEditorLine.Data], 0, eax
        mov     [.final_str], eax

; first line processing
        stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.indexFrom]
        jc      .error_get

        mov     [.fromline], eax
        mov     edx, eax
        stdcall StrOffsUtf8, [edx+TEditorLine.Data], [.charFrom]

        mov     edi, [edx+TEditorLine.Data]
        cmp     edx, [.toline]
        jne     .dup_first
        mov     edi, [.final_str]

.dup_first:
        push    eax
        stdcall StrDup, edi
        mov     edi, eax
        pop     eax

        jecxz   .get_splitit
1111
1112
1113
1114
1115
1116
1117


































































































































































1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152

1153


1154
1155
1156
1157
1158
1159
1160
1161
1162
1163


1164
1165


1166
1167
1168
1169
1170


1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238

1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314

1315
1316
1317
1318
1319
1320
1321
1322
1323

1324
1325
1326
1327
1328



1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348



1349
1350
1351

1352
1353

1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637









1638











































































1639
1640
1641

1642
1643
1644
1645
1646
1647
1648

.finish_get:
        clc
        popad
        mov     eax, [.ret_str]
        return



































































































































































;.........................................................................................
.delete_text:
virtual at ebx  ; arguments
  .indexFrom dd ?
  .charFrom  dd ?
  .indexTo   dd ?
  .charTo    dd ?
end virtual
locals
  .final_str   dd ?
  .final_flags dd ?
  .final_level dd ?
  .fromline    dd ?
  .toline      dd ?
  .ret_str     dd ?
endl
        pushad

; sort the "from" and "To" in order to have "From" < "To"
        mov     eax, [.indexFrom]
        mov     ecx, [.charFrom]
        cmp     eax, [.indexTo]
        jne     @f
        cmp     ecx, [.charTo]
@@:
        je      .nothing_to_delete    ; from == to so nothing to delete.
        jb      @f
        xchg    eax, [.indexTo]
        xchg    ecx, [.charTo]
        mov     [.indexFrom], eax
        mov     [.charFrom], ecx
@@:

; last line processing
        stdcall TFreshEdit.__PosToPointer, [.self], [.charTo], [.indexTo]




        stdcall StrSplit, [edx+TEditorLine.Data], eax
        mov     [.final_str], eax

        mov     eax, [edx+TEditorLine.flags]
        mov     ecx, [edx+TEditorLine.fold_level]
        mov     [.final_flags], eax
        mov     [.final_level], ecx

; first line processing
        stdcall TFreshEdit.__PosToPointer, [.self], [.charFrom], [.indexFrom]


        mov     [.fromline], edx



        jecxz   .splitit
        add     eax, ecx
.addspc:
        stdcall StrCharCat, [edx+TEditorLine.Data], ' '
        dec     ecx


        jnz     .addspc

.splitit:
        stdcall StrSplit, [edx+TEditorLine.Data], eax
        stdcall StrDel, eax
        stdcall StrCat, [edx+TEditorLine.Data], [.final_str]
        stdcall StrDel, [.final_str]
        mov     eax, [.final_level]
        mov     ecx, [.final_flags]
        mov     [edx+TEditorLine.fold_level], eax
        or      [edx+TEditorLine.flags], ecx

; now delete all lines except the first.

        mov     edi, [.indexTo]

.del_loop:
        stdcall TFreshEdit.__PosToPointer, [.self], -1, edi
        cmp     edx, [.fromline]
        je      .delete_ok

        execute [.self], TFreshEdit.DeleteLine, edi
        mov     edi, eax
        dec     edi
        jmp     .del_loop


.delete_ok:
        execute [.self], TFreshEdit.FormatLine, [.indexFrom]

        clc
        popad
        mov     eax, [.indexFrom]
        mov     edx, [.charFrom]
        return

.nothing_to_delete:
        clc
        popad
        xor     eax, eax
        dec     eax
        return

;.........................................................................................
; delete the selection
.delete_selection:
        mov     esi, [.self]
        mov     eax, [esi+TFreshEdit._SelMode]
        cmp     eax, selmChar
        je      .del_sel_char
        cmp     eax, selmBlock
        je      .del_sel_block

        stc
        return

.del_sel_char:
        execute esi, TFreshEdit.DeleteText, [esi+TFreshEdit._yCaret], [esi+TFreshEdit._xCaret],      \
                                            [esi+TFreshEdit._ySelection], [esi+TFreshEdit._xSelection]
        clc
        return


.del_sel_block:
        clc
        return

;.........................................................................................

.insert_line:
virtual at ebx
  .ins_index dd ?
end virtual
        push    esi edi
        mov     esi, [.self]

; first where to search. The next line is OK, but if the line is wrapped...
        cmp     [.ins_index], -1
        jne     @f
        mov     eax, [esi+TFreshEdit._yCaret]
        mov     [.ins_index], eax
@@:

        mov     edi, [esi+TFreshEdit._pIndex]
        mov     edx, [.ins_index]

        cmp     edx, [edi+TArray.count]
        jb      .search_begin

; insert as a last line
        mov     edx, [edi+TArray.count]
        mov     ecx, -1
        jmp     .ins_here

; if the line is wrapped, search for the begin.
.search_begin:
        mov     ecx, [edi+TArray.array+4*edx]
        cmp     ecx, -1                         ; wrapped line?
        jne     .ins_here
        dec     edx
        jns     .search_begin
        jmp     .err_ins_line

; ...insert index item.
; edx contains the index in _pIndex where the new line have to be inserted.
; ecx contains the index in _pLines where the new line have to be inserted.
.ins_here:
        push    edx
        stdcall InsertArrayItems, [esi+TFreshEdit._pIndex], edx, 1
        mov     [esi+TFreshEdit._pIndex], edx
        mov     edi, edx
        pop     edx
        jc      .err_ins_line

        cmp     ecx, -1
        jne     .storeline

        mov     ecx, [esi+TFreshEdit._pLines]
        mov     ecx, [ecx+TArray.count]

.storeline:
        mov     [eax], ecx

; ...then fix the index to the end.

        sub     edx, [edi+TArray.count]
        neg     edx
        dec     edx
        jle     .index_fixed

.inc_index:
        lea     eax, [eax+4]
        cmp     dword [eax], -1
        je      @f
        inc     dword [eax]
@@:
        dec     edx
        jnz     .inc_index


.index_fixed:
; then insert new line
        stdcall InsertArrayItems, [esi+TFreshEdit._pLines], ecx, 1
        mov     [esi+TFreshEdit._pLines], edx
        jc      .err_ins_line


        mov     edx, eax
        stdcall StrNew

        mov     [edx+TEditorLine.Data], eax
        xor     eax, eax
        mov     [edx+TEditorLine.flags], eax
        mov     [edx+TEditorLine.syn_context], eax
        mov     [edx+TEditorLine.debugdata], eax

        mov     [edx+TEditorLine.width], eax
        mov     eax, edx

        stdcall TFreshEdit.__FixLength, esi, 0, -1




        pop     edi esi
        clc
        return

.err_ins_line:
        pop     edi esi
        stc
        return

;.........................................................................................
.del_char:
locals
  .del_char_line dd ?
  .del_line_index dd ?
  .byte_offs dd ?
endl
        push    ecx edx esi edi

        mov     esi, [.self]
        stdcall TFreshEdit.__PosToPointer, esi, [esi+TFreshEdit._xCaret], [esi+TFreshEdit._yCaret]



        jc      .end_del_char

        test    [edx+TEditorLine.flags], lfProtected

        jnz     .end_del_char


        jecxz   .do_del_char

.del_pad_spc:
        stdcall StrCharInsert, [edx+TEditorLine.Data], ' ', eax
        inc     eax
        loop    .del_pad_spc

.do_del_char:
        mov     [.byte_offs], eax
        mov     [.del_char_line], edx
        mov     ebx, eax
        stdcall StrLen, [edx+TEditorLine.Data]
        cmp     ebx, eax
        je      .join_next_line

        mov     ecx, eax
        sub     ecx, ebx

        stdcall StrPtr, [edx+TEditorLine.Data]
        mov     edi, eax
        stdcall DecodeUtf8, [edi+ebx]
        lea     esi, [edi+edx]
        sub     [edi+string.len], edx
        add     esi, ebx
        add     edi, ebx
        cld
        rep movsb

.end_del_char:
        mov     eax, [.byte_offs]
        pop     edi esi edx ecx
        clc
        return

.join_next_line:
        mov     eax, [.del_char_line]
        mov     edx, [esi+TFreshEdit._pLines]
        sub     eax, edx
        sub     eax, TArray.array
        shr     eax, TEditorLine.shift
        inc     eax
        cmp     eax, [edx+TArray.count]
        jae     .end_del_char

        mov     [.del_line_index], eax

        mov     edx, [.del_char_line]
        mov     ebx, edx
        add     edx, sizeof.TEditorLine
        test    [edx+TEditorLine.flags], lfProtected
        jz      .do_join

        stdcall StrLen, [ebx+TEditorLine.Data]
        test    eax, eax
        jnz     .end_del_char

.do_join:
        stdcall StrCat, [ebx+TEditorLine.Data], [edx+TEditorLine.Data]
        mov     eax, [edx+TEditorLine.flags]
        or      [ebx+TEditorLine.flags], eax

; now delete the line
        stdcall TFreshEdit.__FixLength, esi, -1, [edx+TEditorLine.width]
        stdcall StrDel, [edx+TEditorLine.Data]
        stdcall DeleteArrayItems, [esi+TFreshEdit._pLines], [.del_line_index], 1
        mov     [esi+TFreshEdit._pLines], edx

; then fix the index.
        mov     edi, [esi+TFreshEdit._pIndex]
        mov     eax, [esi+TFreshEdit._yCaret]
        mov     edx, [.del_line_index]
        inc     eax

.char_fix_index:
        cmp     eax, [edi+TArray.count]
        jae     .end_del_char

        cmp     [edi+TArray.array+4*eax], -1
        je      .next_line_fix
        cmp     [edi+TArray.array+4*eax], edx
        je      .del_index_elements

        dec     [edi+TArray.array+4*eax]

.next_line_fix:
        inc     eax
        jmp     .char_fix_index

.del_index_elements:
        mov     ecx, eax

.char_scan_loop:
        inc     ecx
        cmp     ecx, [edi+TArray.count]
        jae     .end_char_scan
        cmp     [edi+TArray.array+4*ecx], -1
        je      .char_scan_loop

.end_char_scan:
        sub     ecx, eax
        stdcall DeleteArrayItems, edi, eax, ecx
        mov     [esi+TFreshEdit._pIndex], edx
        mov     edi, edx
        mov     edx, [.del_line_index]
        jmp     .char_fix_index

;.........................................................................................
.insert_char:
; arguments
virtual at ebx
  .ins_char dd ?
end virtual

        push    ecx edx esi edi

        mov     esi, [.self]
.ins_loop:
        stdcall TFreshEdit.__PosToPointer, esi, [esi+TFreshEdit._xCaret], [esi+TFreshEdit._yCaret]
        jnc     .line_found

        execute [.self], TFreshEdit.InsertLine, -2
        jnc     .ins_loop                               ; possible hang!

        xor     edx, edx
        jmp     .end_ins_char

.line_found:
        test    [edx+TEditorLine.flags], lfProtected
        jz      .not_protected

        lea     edx, [eax+ecx]
        jmp     .end_ins_char

.not_protected:
        cmp     [.ins_char], $0d
        je      .split_here
        cmp     [.ins_char], $0a
        je      .split_here

        jecxz   .spaces_ok

.addspc2:
        stdcall StrCharInsert, [edx+TEditorLine.Data], ' ', eax
        inc     eax
        loop    .addspc2

.spaces_ok:
.do_ins_char:
        stdcall StrCharInsert, [edx+TEditorLine.Data], [.ins_char], eax
        mov     esi, eax
        stdcall DecodeUtf8, [.ins_char]
        add     edx, esi
        jmp     .end_ins_char

.split_here:
        push    eax edx

        mov     eax, [esi+TFreshEdit._yCaret]
        inc     eax
        execute [.self], TFreshEdit.InsertLine, eax
        mov     edi, eax

        pop     edx eax
        stdcall StrSplit, [edx+TEditorLine.Data], eax

        stdcall StrDel, [edi+TEditorLine.Data]
        mov     [edi+TEditorLine.Data], eax

        mov     eax, [esi+TFreshEdit._yCaret]
        inc     eax
        execute esi, TFreshEdit.FormatLine, eax
        execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]

.split_ok:
        execute esi, TFreshEdit.LineBegin
        execute esi, TFreshEdit.Move, mvcMoveY, 1, TRUE
        xor     edx, edx

.end_ins_char:
        push    edx
        mov     esi, [.self]
        stdcall TFreshEdit.__PointerToPos, [.self], [esi+TFreshEdit._yCaret], edx
        mov     [esi+TFreshEdit._xCaret], edx
        mov     [esi+TFreshEdit._yCaret], eax
        pop     eax
        clc
        pop     edi esi edx ecx
        return
;.........................................................................................

.insert_string:
; arguments
virtual at ebx
  .hstring dd ?
end virtual

        push    ecx edx esi

        stdcall StrPtr, [.hstring]
        mov     esi, eax

.char_loop:
        stdcall DecodeUtf8, [esi]
        jc      .end_ins_str

        mov     eax, [esi]
        add     esi, edx

        lea     ecx, [8*edx]
        mov     edx, 1
        shl     edx, cl
        dec     edx
        and     eax, edx

        cmp     eax, 0
        je      .end_ins_str

        cmp     eax, $0d
        je      .ins_cr
        cmp     eax, $0a
        jne     .ins_it

.ins_cr:
        xor     al, $0d xor $0a
        cmp     al, [esi]
        je      .char_loop

.ins_it:
        execute [.self], TFreshEdit.InsertChar, eax
        jmp     .char_loop

.end_ins_str:
        clc
        pop     esi edx ecx
        return

;.........................................................................................
.linebegin:
        stdcall TFreshEdit.__FitCaretInWindow, [.self]
        jnz     .endlb

        mov     eax, [.self]
        mov     [eax+TFreshEdit._xCaret], 0
        mov     [eax+TFreshEdit._LeftColumn], 0

.endlb:
        clc
        return

;.........................................................................................
.lineend:
        push    ecx edx esi edi
        mov     esi, [.self]

        stdcall TFreshEdit.__FitCaretInWindow, esi
        jnz     .endle

        mov     esi, [.self]
        mov     ecx, [esi+TFreshEdit._yCaret]
        mov     ebx, [esi+TFreshEdit._pIndex]

        stdcall TFreshEdit.__PosToPointer, esi, [esi+TFreshEdit._xCaret], [esi+TFreshEdit._yCaret]
        mov     ebx, eax

        stdcall StrPtr, [edx+TEditorLine.Data]
        mov     edi, eax

; search the end of the current line
.el_loop:
        stdcall DecodeUtf8, [edi+ebx]
        test    eax, eax
        jz      .el_found
        cmp     eax, $01
        je      .el_found

        add     ebx, edx
        jmp     .el_loop

.el_found:
        stdcall TFreshEdit.__PointerToPos, esi, [esi+TFreshEdit._yCaret], ebx
        mov     [esi+TFreshEdit._yCaret], eax
        mov     [esi+TFreshEdit._xCaret], edx

.endle:









        stdcall TFreshEdit.__FitCaretInWindow, esi











































































        pop     edi esi edx ecx
        clc
        return


;.........................................................................................
; The method TFreshEdit.Move moves the caret towards given direction and on
; the given count of steps.
;
.movecaret:
virtual at ebx







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|
<
<
<
<
<
<
<
<
<
<
<
<
<









|






|

|
>

>
>









|
>
>
|

>
>
|
<

<

>
>
|

|
<
<








|
|
|
<
<
|
<
|
<
<
<
<
|

|
<
<






<
<
<
<
<
<




|
<
<
<
<
<
|
<
<
<
<
<
|
<
<

<
<




>




|
<

<
<
<
<
|
<
<
<
|
<
<
<
<
<
<
|
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

|
<
|
<
<
<
<
<
<
<
<
<
|
<
|
<
<
|
|
|

<
<

<
<
<
|


>

<

<
|

|
|
|
>
|
<



>
>
>
|




|
|
<




|
<
|

|


|
>
>
>
|

<
>
|

>


|
<
|
<


<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


<
<
<
<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<




|
<
<
|

<
<
<
|
<
<
|
<
|
<
<
<

|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<

















|





<
<
<

|
|

<
<
|
<
<
<
<
<
<
<
<
<
|

|
<
|
|


>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|


>







868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039













1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079

1080

1081
1082
1083
1084
1085
1086


1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097


1098

1099




1100
1101
1102


1103
1104
1105
1106
1107
1108






1109
1110
1111
1112
1113





1114





1115


1116


1117
1118
1119
1120
1121
1122
1123
1124
1125
1126

1127




1128



1129






1130

1131




















1132
1133

1134









1135

1136


1137
1138
1139
1140


1141



1142
1143
1144
1145
1146

1147

1148
1149
1150
1151
1152
1153
1154

1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167

1168
1169
1170
1171
1172

1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183

1184
1185
1186
1187
1188
1189
1190

1191

1192
1193






1194















1195
1196
1197








































































1198
1199





1200













































































1201

1202
1203
1204
1205
1206


1207
1208



1209


1210

1211



1212
1213

















1214

1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237



1238
1239
1240
1241


1242









1243
1244
1245

1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345

.finish_get:
        clc
        popad
        mov     eax, [.ret_str]
        return

.error_get:
        clc
        popad
        xor     eax, eax
        return

;.........................................................................................
;  method .InsertText, .lineFrom, .charFrom, .hString, .fInsert
.insert_text:
virtual at ebx
  .lineFrom2 dd ?
  .charFrom2 dd ?
  .hString2  dd ?
  .fInsert   dd ?
end virtual

locals
  .suffix       dd ?
  .end_ptr      dd ?
  .current_line dd ?
  .current_char dd ?
  .ptr_line     dd ?
  .char_count   dd ?
endl
        pushad

        mov     esi, [.self]

.search_line:
        stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.lineFrom2]
        jnc     .linefound

        execute esi, TFreshEdit.InsertLine, -2
        jmp     .search_line

.linefound:
        mov     edi, eax
        mov     eax, [.lineFrom2]
        mov     [.current_line], eax

        mov     [.suffix], 0

        stdcall StrOffsUtf8, [edi+TEditorLine.Data], [.charFrom2]
        test    ecx, ecx
        jnz     .add_spaces

        stdcall StrSplit, [edi+TEditorLine.Data], eax
        mov     [.suffix], eax
        jmp     .do_insertion

.add_spaces:
        stdcall StrCharCat, [edi+TEditorLine.Data], ' '
        dec     ecx
        jnz     .add_spaces

.do_insertion:
        stdcall StrPtr, [.hString2]
        mov     esi, eax
        stdcall StrLen, [.hString2]
        lea     eax, [esi+eax]
        mov     [.end_ptr], eax

        stdcall StrLen, [edi+TEditorLine.Data]
        mov     ecx, eax
        stdcall StrLen, [.hString2]
        add     ecx, eax

.loop_lines:
        mov     [.ptr_line], edi

        stdcall StrSetCapacity, [edi+TEditorLine.Data], ecx
        mov     edi, eax
        lea     ecx, [edi+string.len]
        add     edi, [ecx]   ; append the string to the end...
        mov     [.char_count], 0

.append_loop:
        stdcall DecodeUtf8, [esi]
        test    eax, eax
        jz      .end_of_string

        cmp     eax, $0d
        je      .new_line
        cmp     eax, $0a
        je      .new_line

        mov     eax, [esi]
        mov     [edi], eax
        add     esi, edx
        add     edi, edx

        add     [ecx], edx
        inc     [.char_count]
        jmp    .append_loop

.new_line:
        xor     al, $0d xor $0a
        inc     esi
        cmp     [esi], al
        jne     @f
        inc     esi
@@:
        call    .finish_current_line

        inc     [.current_line]
        execute [.self], TFreshEdit.InsertLine, [.current_line]
        mov     edi, eax

        mov     ecx, [.end_ptr]
        sub     ecx, esi
        jmp     .loop_lines


.finish_current_line:
        xor     eax, eax
        stosd

        cmp     [.fInsert], modeInsert
        je      .overwrite_ok

        cmp     [.suffix], 0
        je      .overwrite_ok

        stdcall StrOffsUtf8, [.suffix], [.char_count]
        jecxz   .split_suffix

        stdcall StrDel, [.suffix]
        mov     [.suffix], 0
        retn

.split_suffix:
        stdcall StrSplit, [.suffix], eax
        xchg    [.suffix], eax
        stdcall StrDel, eax

.overwrite_ok:
        retn


.end_of_string:
        call    .finish_current_line

        mov     edi, [.ptr_line]

        stdcall StrLenUtf8, [edi+TEditorLine.Data], -1
        mov     [.current_char], eax

        cmp     [.suffix], 0
        je      .last_ok

        stdcall StrCat, [edi+TEditorLine.Data], [.suffix]
        stdcall StrDel, [.suffix]

.last_ok:

.finish_ins_text:
        popad
        mov     eax, [.current_line]
        mov     edx, [.current_char]
        clc
        return

;.........................................................................................
.delete_text:
; have the same arguments and local variables as .get_text













        pushad

; sort the "from" and "To" in order to have "From" < "To"
        mov     eax, [.indexFrom]
        mov     ecx, [.charFrom]
        cmp     eax, [.indexTo]
        jne     @f
        cmp     ecx, [.charTo]
@@:
        je      .finish_delete    ; from == to so nothing to delete.
        jb      @f
        xchg    eax, [.indexTo]
        xchg    ecx, [.charTo]
        mov     [.indexFrom], eax
        mov     [.charFrom], ecx
@@:
        mov     esi, [.self]
; last line processing
        stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.indexTo]
        jc      .finish_delete

        mov     edx, eax
        stdcall StrOffsUtf8, [edx+TEditorLine.Data], [.charTo]
        stdcall StrSplit, [edx+TEditorLine.Data], eax
        mov     [.final_str], eax

        mov     eax, [edx+TEditorLine.flags]
        mov     ecx, [edx+TEditorLine.fold_level]
        mov     [.final_flags], eax
        mov     [.final_level], ecx

; first line processing
        stdcall GetArrayItem, [esi+TFreshEdit._pLines], [.indexFrom]
        jc      .finish_delete
        mov     edx, eax
        mov     [.fromline], eax

        stdcall StrOffsUtf8, [edx+TEditorLine.Data], [.charFrom]
        stdcall StrTrim, [edx+TEditorLine.Data], eax


.addspc:

        dec     ecx
        js      .catit
        stdcall StrCharCat, [edx+TEditorLine.Data], ' ', eax
        jmp     .addspc

.catit:


        stdcall StrCat, [edx+TEditorLine.Data], [.final_str]
        stdcall StrDel, [.final_str]
        mov     eax, [.final_level]
        mov     ecx, [.final_flags]
        mov     [edx+TEditorLine.fold_level], eax
        or      [edx+TEditorLine.flags], ecx

; now delete all lines except the first.
        mov     eax, [.indexFrom]
        mov     ecx, [.indexTo]
        sub     ecx, eax


        inc     eax

        stdcall DeleteArrayItems, [esi+TFreshEdit._pLines], eax, ecx




        mov     [esi+TFreshEdit._pLines], edx

.finish_delete:


        clc
        popad
        mov     eax, [.indexFrom]
        mov     edx, [.charFrom]
        return








;.........................................................................................
; delete the selection
.delete_selection:
        mov     ecx, [.self]





        execute ecx, TFreshEdit.DeleteText, [ecx+TFreshEdit._yCaret], [ecx+TFreshEdit._xCaret],      \





                                            [ecx+TFreshEdit._ySelection], [ecx+TFreshEdit._xSelection], [ecx+TFreshEdit._SelMode]





        clc
        return

;.........................................................................................

.insert_line:
virtual at ebx
  .ins_index dd ?
end virtual
        push    edx esi






        mov     esi, [.self]



        mov     edx, [esi+TFreshEdit._pLines]






        mov     ecx, [.ins_index]






















        cmp     ecx, -1
        jne     @f

        mov     ecx, [esi+TFreshEdit._yCaret]









        inc     ecx

@@:


        cmp     ecx, [edx+TArray.count]
        jb      @f
        mov     ecx, [edx+TArray.count]
@@:






        stdcall InsertArrayItems, edx, ecx, 1
        mov     [esi+TFreshEdit._pLines], edx
        jc      .err_ins_line
        mov     ebx, eax


        stdcall StrNew

        mov     [ebx+TEditorLine.Data], eax
        xor     eax, eax
        mov     [ebx+TEditorLine.flags], eax
        mov     [ebx+TEditorLine.syn_context], eax
        mov     [ebx+TEditorLine.debugdata], eax
        mov     [ebx+TEditorLine.fold_level], eax
        mov     [ebx+TEditorLine.width], eax


        stdcall TFreshEdit.__FixLength, esi, 0, -1

        mov     eax, ebx

.finish_ins_line:
        pop     esi edx
        clc
        return

.err_ins_line:
        xor     eax, eax
        jmp     .finish_ins_line


;.........................................................................................
.del_char:
locals
  .del_char_to_line dd ?

  .del_char_to_char dd ?
endl
        push    eax ecx edx esi

        mov     esi, [.self]
        mov     eax, [esi+TFreshEdit._xCaret]
        mov     ecx, [esi+TFreshEdit._yCaret]
        mov     [.del_char_to_char], eax
        mov     [.del_char_to_line], ecx
        inc     [.del_char_to_char]


        stdcall GetArrayItem, [esi+TFreshEdit._pLines], ecx
        jc      .do_del_char

        stdcall StrOffsUtf8, [eax+TEditorLine.Data], [.del_char_to_char]
        jecxz   .do_del_char

        mov     [.del_char_to_char], 0

        inc     [.del_char_to_line]


.do_del_char:






        execute esi, TFreshEdit.DeleteText, [esi+TFreshEdit._yCaret], [esi+TFreshEdit._xCaret], [.del_char_to_line], [.del_char_to_char], selmChar















        pop     esi edx ecx eax
        clc
        return









































































;.........................................................................................



















































































.insert_string:

virtual at ebx
  .hstring dd ?
end virtual

        push    eax edx


        mov     ecx, [.self]




        execute ecx, TFreshEdit.InsertText, [ecx+TFreshEdit._yCaret], [ecx+TFreshEdit._xCaret], [.hstring], [ecx+TFreshEdit._InsMode]


        mov     [ecx+TFreshEdit._yCaret], eax

        mov     [ecx+TFreshEdit._xCaret], edx




        pop     edx eax

















        clc

        return

;.........................................................................................
.linebegin:
        stdcall TFreshEdit.__FitCaretInWindow, [.self]
        jnz     .endlb

        mov     eax, [.self]
        mov     [eax+TFreshEdit._xCaret], 0
        mov     [eax+TFreshEdit._LeftColumn], 0

.endlb:
        clc
        return

;.........................................................................................
.lineend:
        push    edx esi edi
        mov     esi, [.self]

        stdcall TFreshEdit.__FitCaretInWindow, esi
        jnz     .endle





        stdcall GetArrayItem, [esi+TFreshEdit._pLines], [esi+TFreshEdit._yCaret]
        jnc     .inline



        mov     [esi+TFreshEdit._xCaret], 0









        jmp     .endle

.inline:

        mov     eax, [eax+TEditorLine.width]
        mov     [esi+TFreshEdit._xCaret], eax

.endle:
        pop     edi esi edx
        clc
        return


;.........................................................................................
.filebegin:
        mov     ecx, [.self]

        stdcall TFreshEdit.__FitCaretInWindow, ecx
        jnz     .endfb

        mov     [ecx+TFreshEdit._TopLine], 0
        mov     [ecx+TFreshEdit._yCaret], 0
        mov     [ecx+TFreshEdit._ySelection], 0

.endfb:
        clc
        return

;.........................................................................................
.fileend:
        mov     ecx, [.self]

        stdcall TFreshEdit.__FitCaretInWindow, ecx
        jnz     .endfe

        mov     eax, [ecx+TFreshEdit._pLines]
        mov     eax, [eax+TArray.count]
        dec     eax
        jns     @f
        inc     eax
@@:
        mov     [ecx+TFreshEdit._yCaret], eax
        mov     [ecx+TFreshEdit._ySelection], eax

        inc     eax
        sub     eax, [ecx+TFreshEdit._rows]
        jns     @f
        xor     eax, eax
@@:
        mov     [ecx+TFreshEdit._TopLine], eax

.endfe:
        clc
        return

;.........................................................................................
.pagebegin:
        mov     ecx, [.self]
        stdcall TFreshEdit.__FitCaretInWindow, ecx
        jnz     .endpb

        mov     eax, [ecx+TFreshEdit._TopLine]
        mov     [ecx+TFreshEdit._yCaret], eax
        mov     [ecx+TFreshEdit._ySelection], eax

.endpb:
        clc
        return

;.........................................................................................
.pageend:
        push    edx

        mov     ecx, [.self]
        stdcall TFreshEdit.__FitCaretInWindow, ecx
        jnz     .endpe

        mov     eax, [ecx+TFreshEdit._TopLine]
        add     eax, [ecx+TFreshEdit._rows]
        dec     eax
        jns     @f
        xor     eax, eax
@@:
        mov     edx, [ecx+TFreshEdit._pLines]
        cmp     eax, [edx+TArray.count]
        jb      @f
        mov     eax, [edx+TArray.count]
        dec     eax
@@:
        mov     [ecx+TFreshEdit._yCaret], eax
        mov     [ecx+TFreshEdit._ySelection], eax

.endpe:
        pop     edx
        clc
        return


;.........................................................................................
; The method TFreshEdit.Move moves the caret towards given direction and on
; the given count of steps.
;
.movecaret:
virtual at ebx
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670



1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710

1711
1712
1713
1714
1715
1716
1717
        test    [.direction], mvcMoveX or mvcMoveY
        jz      .fitok

        cmp     [.force], 0
        jne     .fitok

        stdcall TFreshEdit.__FitCaretInWindow, esi

        test    eax, eax
        jnz     .endmove

.fitok:



        test    [.direction], mvcMoveX or mvcScrollX
        jnz     .move_horizontal

        test    [.direction], mvcMoveY or mvcScrollY
        jnz     .move_vertical

.endmove:
        clc
        pop     edi esi edx
        return


.move_horizontal:
        test    [.direction], mvcMoveX
        jz      .xcaretok

        mov     ecx, [esi+TFreshEdit._xCaret]
        add     ecx, [.count]
        jns     @f
        xor     ecx, ecx
@@:
        mov     [esi+TFreshEdit._xCaret], ecx

.xcaretok:
        test    [.direction], mvcScrollX
        jz      .leftcolok

        mov     ecx, [esi+TFreshEdit._LeftColumn]
        add     ecx, [.count]
        jns     @f
        xor     ecx, ecx
@@:
        mov     [esi+TFreshEdit._LeftColumn], ecx

.leftcolok:

        mov     ecx, [esi+TFreshEdit._xCaret]
        mov     edx, [esi+TFreshEdit._LeftColumn]
        cmp     ecx, edx
        jb      .hscroll

        add     edx, [esi+TFreshEdit._cols]
        cmp     ecx, edx
        jb      .endmove

.hscroll:
        mov     ecx, [esi+TFreshEdit._cols]
        mov     eax, [.count]







<
<



>
>
>
















|
|
|
<
<
|





|
|
|
<
<
|


<




>







1356
1357
1358
1359
1360
1361
1362


1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387


1388
1389
1390
1391
1392
1393
1394
1395
1396


1397
1398
1399

1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
        test    [.direction], mvcMoveX or mvcMoveY
        jz      .fitok

        cmp     [.force], 0
        jne     .fitok

        stdcall TFreshEdit.__FitCaretInWindow, esi


        jnz     .endmove

.fitok:
        test    [.direction], mvcMoveX or mvcMoveY or mvcScrollX or mvcScrollY
        jz      .endmove

        test    [.direction], mvcMoveX or mvcScrollX
        jnz     .move_horizontal

        test    [.direction], mvcMoveY or mvcScrollY
        jnz     .move_vertical

.endmove:
        clc
        pop     edi esi edx
        return


.move_horizontal:
        test    [.direction], mvcMoveX
        jz      .xcaretok

        mov     ecx, [.count]
        add     [esi+TFreshEdit._xCaret], ecx
        jns     .xcaretok


        mov     [esi+TFreshEdit._xCaret], 0

.xcaretok:
        test    [.direction], mvcScrollX
        jz      .leftcolok

        mov     ecx, [.count]
        add     [esi+TFreshEdit._LeftColumn], ecx
        jns     .leftcolok


        mov     [esi+TFreshEdit._LeftColumn], 0

.leftcolok:

        mov     ecx, [esi+TFreshEdit._xCaret]
        mov     edx, [esi+TFreshEdit._LeftColumn]
        cmp     ecx, edx
        jb      .hscroll

        add     edx, [esi+TFreshEdit._cols]
        cmp     ecx, edx
        jb      .endmove

.hscroll:
        mov     ecx, [esi+TFreshEdit._cols]
        mov     eax, [.count]
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782



1783
1784
1785
1786
1787
1788
1789

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.move_vertical:
        test    [.direction], mvcMoveY
        jz      .ycaretok

        mov     ecx, [esi+TFreshEdit._yCaret]
        add     ecx, [.count]
        jns     @f
        xor     ecx, ecx
@@:
        mov     [esi+TFreshEdit._yCaret], ecx

.ycaretok:
        test    [.direction], mvcScrollY
        jz      .toplineok

        mov     ecx, [esi+TFreshEdit._TopLine]
        add     ecx, [.count]
        jns     @f
        xor     ecx, ecx
@@:
        mov     edx, [esi+TFreshEdit._pIndex]
        mov     edx, [edx+TArray.count]
        sub     edx, [esi+TFreshEdit._rows]
        jns     @f
        xor     edx, edx
@@:
        cmp     ecx, edx
        jl      @f
        mov     ecx, edx
@@:
        mov     [esi+TFreshEdit._TopLine], ecx

.toplineok:

        mov     ecx, [esi+TFreshEdit._yCaret]
        mov     eax, [esi+TFreshEdit._pIndex]
        mov     eax, [eax+TArray.count]
        cmp     ecx, eax
        jb      @f
        lea     ecx, [eax-1]
@@:
        mov     [esi+TFreshEdit._yCaret], ecx

        mov     edx, [esi+TFreshEdit._TopLine]
        cmp     ecx, edx
        jb      .vscroll
        add     edx, [esi+TFreshEdit._rows]



        cmp     ecx, edx
        jb      .endmove

.vscroll:
        test    [.direction], mvcMoveX or mvcMoveY
        jz      .endmove                             ; it is only scroll, so don't care about caret.








|
|
|
<
<
|





<
|
<
<
<
<
<
|
|
<
<
<
<
<
<
|


<

|











>
>
>







1427
1428
1429
1430
1431
1432
1433
1434
1435
1436


1437
1438
1439
1440
1441
1442

1443





1444
1445






1446
1447
1448

1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.move_vertical:
        test    [.direction], mvcMoveY
        jz      .ycaretok

        mov     ecx, [.count]
        add     [esi+TFreshEdit._yCaret], ecx
        jns     .ycaretok


        mov     [esi+TFreshEdit._yCaret], 0

.ycaretok:
        test    [.direction], mvcScrollY
        jz      .toplineok


        mov     ecx, [.count]





        add     [esi+TFreshEdit._TopLine], ecx
        jns     .toplineok






        mov     [esi+TFreshEdit._TopLine], 0

.toplineok:

        mov     ecx, [esi+TFreshEdit._yCaret]
        mov     eax, [esi+TFreshEdit._pLines]
        mov     eax, [eax+TArray.count]
        cmp     ecx, eax
        jb      @f
        lea     ecx, [eax-1]
@@:
        mov     [esi+TFreshEdit._yCaret], ecx

        mov     edx, [esi+TFreshEdit._TopLine]
        cmp     ecx, edx
        jb      .vscroll
        add     edx, [esi+TFreshEdit._rows]
        cmp     edx, eax
        jae     .vscroll

        cmp     ecx, edx
        jb      .endmove

.vscroll:
        test    [.direction], mvcMoveX or mvcMoveY
        jz      .endmove                             ; it is only scroll, so don't care about caret.

1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851

















































































1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
        mov     [ebx+TEditorLine.Data], 0
        add     ebx, sizeof.TEditorLine
        dec     ecx
        jmp     .clrloop

.endclr:
        mov     ebx, [.self]
        stdcall FreeMem, [ebx+TFreshEdit._pIndex]
        stdcall FreeMem, [ebx+TFreshEdit._pLines]
        stdcall FreeMem, [ebx+TFreshEdit._pLengths]

        stdcall CreateArray, 4
        mov     [ebx+TFreshEdit._pIndex], eax

        stdcall CreateArray, sizeof.TEditorLine
        mov     [ebx+TFreshEdit._pLines], eax

        stdcall CreateArray, 4
        mov     [ebx+TFreshEdit._pLengths], eax

        xor     eax, eax

        mov     [ebx+TFreshEdit._fShadowValid], eax
        mov     [ebx+TFreshEdit._xCaret], eax
        mov     [ebx+TFreshEdit._yCaret], eax
        mov     [ebx+TFreshEdit._xSelection], eax
        mov     [ebx+TFreshEdit._ySelection], eax

        execute ebx, TFreshEdit.Refresh
        stdcall TFreshEdit.__UpdateScrollBars, ebx

        clc
        return

















































































endp



;_________________________________________________________________________________________



proc TFreshEdit.SysEventHandler, .pobj, .pEvent
.changes dd ?
begin
        push    eax ebx ecx edx esi edi

        mov     [.changes], 0
        mov     ebx, [.pEvent]
        mov     esi, [.pobj]

        mov     eax, [ebx+TSysEvent.event]








<



<
<
<



















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











|







1501
1502
1503
1504
1505
1506
1507

1508
1509
1510



1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
        mov     [ebx+TEditorLine.Data], 0
        add     ebx, sizeof.TEditorLine
        dec     ecx
        jmp     .clrloop

.endclr:
        mov     ebx, [.self]

        stdcall FreeMem, [ebx+TFreshEdit._pLines]
        stdcall FreeMem, [ebx+TFreshEdit._pLengths]




        stdcall CreateArray, sizeof.TEditorLine
        mov     [ebx+TFreshEdit._pLines], eax

        stdcall CreateArray, 4
        mov     [ebx+TFreshEdit._pLengths], eax

        xor     eax, eax

        mov     [ebx+TFreshEdit._fShadowValid], eax
        mov     [ebx+TFreshEdit._xCaret], eax
        mov     [ebx+TFreshEdit._yCaret], eax
        mov     [ebx+TFreshEdit._xSelection], eax
        mov     [ebx+TFreshEdit._ySelection], eax

        execute ebx, TFreshEdit.Refresh
        stdcall TFreshEdit.__UpdateScrollBars, ebx

        clc
        return


;.........................................................................................
;  method .PixelToCaret, .xPixel, .yPixel
;    .xPixel, .yPixel - coordinates of pixel related to the editor window.
;  Returns:
;    eax - index of the text line in TFreshEdit._pLines array.
;    edx - character in the line.
.pixel_to_caret:
virtual at ebx
  .xPixel dd ?
  .yPixel dd ?
end virtual

        mov     esi, [.self]

        mov     ecx, [.xPixel]
        mov     eax, [.yPixel]

        mov     edi, [esi+TFreshEdit._FreeArea.x]
        mov     edx, [esi+TFreshEdit._FreeArea.y]

        cmp     ecx, edi
        jl      .pixel_outside
        cmp     eax, edx
        jl      .pixel_outside

        add     edi, [esi+TFreshEdit._FreeArea.width]
        add     edx, [esi+TFreshEdit._FreeArea.height]

        cmp     ecx, edi
        jge     .pixel_outside
        cmp     eax, edx
        jge     .pixel_outside

        sub     ecx, [esi+TFreshEdit.__LeftMargin]
        jge     @f
        xor     ecx, ecx
@@:
        cdq
        idiv    [esi+TFreshEdit._fontheight]
        add     eax, [esi+TFreshEdit._TopOffset]
        mov     [.yPixel], eax

        mov     eax, ecx
        cdq
        idiv    [esi+TFreshEdit._fontwidth]
        add     eax, [esi+TFreshEdit._LeftColumn]
        mov     [.xPixel], eax

; search the line and char

; first the line:
        mov     edi, [esi+TFreshEdit._TopLine]
        stdcall GetArrayItem, [esi+TFreshEdit._pLines], edi

        test    [eax+TEditorLine.flags], lfWordWrap





        mov     edx, [.xPixel]
        mov     eax, [.yPixel]
        clc
        return

.pixel_outside:
        xor     eax, eax
        dec     eax
        clc
        return

;.........................................................................................
;  method .CaretToPixel, .iRow, .xChar
.caret_to_pixel:





endp



;_________________________________________________________________________________________



proc TFreshEdit.SysEventHandler, .pobj, .pEvent
.changes dd ?
begin
        push    eax ebx edx esi edi

        mov     [.changes], 0
        mov     ebx, [.pEvent]
        mov     esi, [.pobj]

        mov     eax, [ebx+TSysEvent.event]

1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919




1920
1921
1922
1923
1924
1925
1926

        cmp     [ebx+TSysEvent.event], seMouseBtnRelease
        je      .mousebtnrelease

        cmp     [ebx+TSysEvent.event], seMouseMove
        je      .mousemove


.continue:
        stc
.finish:
        pop     edi esi edx ecx ebx eax
        return

;.........................................................................................
.mousemove:
        mov     ecx, mcText
        mov     eax, [ebx+TMouseMoveEvent.x]
        cmp     eax, [esi+TFreshEdit.__LeftMargin]
        ja      @f
        mov     ecx, mcArrow
@@:
        mov     [esi+TFreshEdit._cursor], ecx

        cmp     [esi+TFreshEdit._DragButton], mbLeft
        jne     .continue

        stdcall TFreshEdit.__MoveCaretToPixel, esi, [ebx+TMouseMoveEvent.x], [ebx+TMouseMoveEvent.y]
        jc      .continue




        jmp     .refresh

;.........................................................................................
.mousebtnrelease:
        mov     eax, [ebx+TMouseButtonEvent.Button]
        cmp     eax, [esi+TFreshEdit._DragButton]
        jne     .continue







<



|















|

>
>
>
>







1650
1651
1652
1653
1654
1655
1656

1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688

        cmp     [ebx+TSysEvent.event], seMouseBtnRelease
        je      .mousebtnrelease

        cmp     [ebx+TSysEvent.event], seMouseMove
        je      .mousemove


.continue:
        stc
.finish:
        pop     edi esi edx ebx eax
        return

;.........................................................................................
.mousemove:
        mov     ecx, mcText
        mov     eax, [ebx+TMouseMoveEvent.x]
        cmp     eax, [esi+TFreshEdit.__LeftMargin]
        ja      @f
        mov     ecx, mcArrow
@@:
        mov     [esi+TFreshEdit._cursor], ecx

        cmp     [esi+TFreshEdit._DragButton], mbLeft
        jne     .continue

        stdcall TFreshEdit.__PixelToCaretPos, esi, [ebx+TMouseMoveEvent.x], [ebx+TMouseMoveEvent.y]
        jc      .continue

        mov     [esi+TFreshEdit._yCaret], eax
        mov     [esi+TFreshEdit._xCaret], edx

        jmp     .refresh

;.........................................................................................
.mousebtnrelease:
        mov     eax, [ebx+TMouseButtonEvent.Button]
        cmp     eax, [esi+TFreshEdit._DragButton]
        jne     .continue
1956
1957
1958
1959
1960
1961
1962
1963
1964



1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
        stdcall MouseCapture, [esi+TWindow.handle]
        mov     eax, [ebx+TMouseButtonEvent.Button]
        mov     [esi+TFreshEdit._DragButton], eax

        cmp     [ebx+TMouseButtonEvent.Button], mbLeft
        jne     .continue

        stdcall TFreshEdit.__MoveCaretToPixel, esi, [ebx+TMouseButtonEvent.x], [ebx+TMouseButtonEvent.y]
        jc      .continue



        jmp     .refresh

.left_margin_process:
        sub     edx, 16
        cmp     ecx, edx
        jl      .continue       ; number or breakpoint click

; Fold/unfold click
; check for the fold/unfold icon under the cursor
        xor     edx, edx
        div     [esi+TFreshEdit._fontheight]
        add     eax, [esi+TFreshEdit._TopLine]

        mov     edx, [esi+TFreshEdit._pIndex]
        cmp     eax, [edx+TArray.count]
        jae     .continue

        mov     ecx, [edx+TArray.array+4*eax]
        cmp     ecx, -1
        je      .continue       ; it is not fold icon row.

        shl     ecx, TEditorLine.shift
        add     ecx, [esi+TFreshEdit._pLines]
        add     ecx, TArray.array                       ; pointer to TEditorLine

        test    [ecx+TEditorLine.flags], lfFoldHeader
        jz      .continue

; determine what is the current state folded or expanded
locals
  .current dd ?
  .next    dd ?
endl
        mov     [.current], eax        ; current line index
        mov     ecx, [edx+TArray.array+4*eax]
        inc     ecx

.next_loop:
        inc     eax
        cmp     eax, [edx+TArray.count]
        jae     .folded

        cmp     [edx+TArray.array+4*eax], -1
        je      .next_loop

        mov     [.next], eax
        cmp     ecx, [edx+TArray.array+4*eax]         ; the next index == current+1 -> expanded
        jne     .folded

; so, fold it...
        stdcall TFreshEdit.__FoldZoneLen, esi, [.current]

        mov     ecx, [.next]
        sub     ecx, [.current]
        inc     ecx

        cmp     eax, ecx
        jbe     .continue       ; nothing to fold

        sub     eax, ecx
        stdcall DeleteArrayItems, [esi+TFreshEdit._pIndex], [.next], eax
        mov     [esi+TFreshEdit._pIndex], edx

        stdcall TFreshEdit.__UpdateScrollBars, esi
        or      [.changes], chgfNeedRefresh
        jmp     .refresh

.folded:
; the zone is folded, so restore the index items.
        stdcall TFreshEdit.__RestoreIndex, esi, [.current], [.next]
        stdcall TFreshEdit.__UpdateScrollBars, esi
        or      [.changes], chgfNeedRefresh
        jmp     .refresh

;.........................................................................................
.scroll:
        cmp     [ebx+TScrollEvent.ScrollBar], scrollX
        je      .xscroll








|

>
>
>



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
        stdcall MouseCapture, [esi+TWindow.handle]
        mov     eax, [ebx+TMouseButtonEvent.Button]
        mov     [esi+TFreshEdit._DragButton], eax

        cmp     [ebx+TMouseButtonEvent.Button], mbLeft
        jne     .continue

        stdcall TFreshEdit.__PixelToCaretPos, esi, [ebx+TMouseButtonEvent.x], [ebx+TMouseButtonEvent.y]
        jc      .continue

        mov     [esi+TFreshEdit._yCaret], eax
        mov     [esi+TFreshEdit._xCaret], edx
        jmp     .refresh

.left_margin_process:
;        sub     edx, 16
;        cmp     ecx, edx
;        jl      .continue       ; number or breakpoint click
;
;; Fold/unfold click
;; check for the fold/unfold icon under the cursor
;        xor     edx, edx
;        div     [esi+TFreshEdit._fontheight]
;        add     eax, [esi+TFreshEdit._TopLine]
;
;        mov     edx, [esi+TFreshEdit._pIndex]
;        cmp     eax, [edx+TArray.count]
;        jae     .continue
;
;        mov     ecx, [edx+TArray.array+4*eax]
;        cmp     ecx, -1
;        je      .continue       ; it is not fold icon row.
;
;        shl     ecx, TEditorLine.shift
;        add     ecx, [esi+TFreshEdit._pLines]
;        add     ecx, TArray.array                       ; pointer to TEditorLine
;
;        test    [ecx+TEditorLine.flags], lfFoldHeader
;        jz      .continue
;
;; determine what is the current state folded or expanded
;locals
;  .current dd ?
;  .next    dd ?
;endl
;        mov     [.current], eax        ; current line index
;        mov     ecx, [edx+TArray.array+4*eax]
;        inc     ecx
;
;.next_loop:
;        inc     eax
;        cmp     eax, [edx+TArray.count]
;        jae     .folded
;
;        cmp     [edx+TArray.array+4*eax], -1
;        je      .next_loop
;
;        mov     [.next], eax
;        cmp     ecx, [edx+TArray.array+4*eax]         ; the next index == current+1 -> expanded
;        jne     .folded
;
;; so, fold it...
;        stdcall TFreshEdit.__FoldZoneLen, esi, [.current]
;
;        mov     ecx, [.next]
;        sub     ecx, [.current]
;        inc     ecx
;
;        cmp     eax, ecx
;        jbe     .continue       ; nothing to fold
;
;        sub     eax, ecx
;        stdcall DeleteArrayItems, [esi+TFreshEdit._pIndex], [.next], eax
;        mov     [esi+TFreshEdit._pIndex], edx
;
;        stdcall TFreshEdit.__UpdateScrollBars, esi
;        or      [.changes], chgfNeedRefresh
;        jmp     .refresh
;
;.folded:
;; the zone is folded, so restore the index items.
;        stdcall TFreshEdit.__RestoreIndex, esi, [.current], [.next]
;        stdcall TFreshEdit.__UpdateScrollBars, esi
;        or      [.changes], chgfNeedRefresh
        jmp     .refresh

;.........................................................................................
.scroll:
        cmp     [ebx+TScrollEvent.ScrollBar], scrollX
        je      .xscroll

2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132





2133



2134
2135

2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
locals
  .byte_offs dd ?
endl
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        execute esi, TFreshEdit.DeleteSel
        test    eax, eax
        js      @f
        mov     [esi+TFreshEdit._yCaret], eax
        mov     [esi+TFreshEdit._xCaret], edx
@@:





        execute esi, TFreshEdit.InsertChar, [ebx+TKeyboardEvent.key]



        mov     [.byte_offs], eax


        execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]
        add     [.byte_offs], eax

        stdcall TFreshEdit.__PointerToPos, esi, [esi+TFreshEdit._yCaret], [.byte_offs]

        mov     [esi+TFreshEdit._yCaret], eax
        mov     [esi+TFreshEdit._xCaret], edx

        stdcall TFreshEdit.__UpdateScrollBars, esi
        stdcall TFreshEdit.__FitCaretInWindow, esi

        or     [.changes], chgfNeedRefresh
        jmp    .refresh








<
<


|
>
>
>
>
>
|
>
>
>
|

>
|
|
|
|
|
|
|







1886
1887
1888
1889
1890
1891
1892


1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
locals
  .byte_offs dd ?
endl
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        execute esi, TFreshEdit.DeleteSel


        mov     [esi+TFreshEdit._yCaret], eax
        mov     [esi+TFreshEdit._xCaret], edx

        stdcall StrNew
        push    eax

        stdcall StrCharCat, eax, [ebx+TKeyboardEvent.key]

        execute esi, TFreshEdit.InsertString, eax

        stdcall StrDel ; from the stack

        mov     [.byte_offs], 0

; is it necessary???
;        execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]
;        add     [.byte_offs], eax
;
;        stdcall GetArrayItem, [esi+TFreshEdit._pLines], [esi+TFreshEdit._yCaret]
;
;        stdcall StrCharUtf8, [eax+TEditorLine.Data], [.byte_offs]
;        mov     [esi+TFreshEdit._xCaret], eax

        stdcall TFreshEdit.__UpdateScrollBars, esi
        stdcall TFreshEdit.__FitCaretInWindow, esi

        or     [.changes], chgfNeedRefresh
        jmp    .refresh

2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269

.handler_pgdn:
        mov     eax, [esi+TFreshEdit._rows]
        dec     eax
        mov     ecx, mvcMoveY or mvcScrollY
        jmp     .moveit


.moveit:
        test    [ebx+TKeyboardEvent.kbdStatus], maskScrLk
        jnz     .scroll_override

        cmp     [esi+TFreshEdit._fReadOnly], froReadOnlyNoCaret
        jne     .scroll_override_ok








<







2027
2028
2029
2030
2031
2032
2033

2034
2035
2036
2037
2038
2039
2040

.handler_pgdn:
        mov     eax, [esi+TFreshEdit._rows]
        dec     eax
        mov     ecx, mvcMoveY or mvcScrollY
        jmp     .moveit


.moveit:
        test    [ebx+TKeyboardEvent.kbdStatus], maskScrLk
        jnz     .scroll_override

        cmp     [esi+TFreshEdit._fReadOnly], froReadOnlyNoCaret
        jne     .scroll_override_ok

2292
2293
2294
2295
2296
2297
2298

2299
2300
2301
2302
2303

2304
2305
2306
2307
2308

2309
2310
2311
2312
2313

2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334

2335
2336


2337
2338
2339
2340
2341
2342

2343
2344
2345
2346

2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375




2376

2377
2378
2379
2380
2381
2382
2383
.handler_end:
        execute esi, TFreshEdit.LineEnd
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_pgbeg:

        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_pgend:

        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_txtbeg:

        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_txtend:

        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_wordleft:
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_wordright:
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_delete:
locals
  .byte_offs2 dd ?
endl
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        execute esi, TFreshEdit.DeleteSel

        test    eax, eax
        jns     .deleted



        execute esi, TFreshEdit.DelChar
        mov     [.byte_offs2], eax
        execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]
        stdcall TFreshEdit.__PointerToPos, esi, edx, [.byte_offs2]


.deleted:
        mov     [esi+TFreshEdit._yCaret], eax
        mov     [esi+TFreshEdit._xCaret], edx


        stdcall TFreshEdit.__FitCaretInWindow, esi
        stdcall TFreshEdit.__UpdateScrollBars, esi
        or      [.changes], chgfNeedRefresh
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
; BUG:  it does not works as expected, but I don't have anough patience to fix it just now.....
.handler_backspc:
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        push    [esi+TFreshEdit._xCaret] [esi+TFreshEdit._yCaret]
        execute esi, TFreshEdit.Move, mvcMoveX, -1, FALSE
        pop     edx eax

        cmp     eax, [esi+TFreshEdit._xCaret]
        jne     .do_del
        cmp     edx, [esi+TFreshEdit._yCaret]
        je      .refresh

.do_del:
        stdcall TFreshEdit.__PosToPointer, esi, [esi+TFreshEdit._xCaret], [esi+TFreshEdit._yCaret]
        test    ecx, ecx
        jnz     .refresh

        stdcall StrLen, [edx+TEditorLine.Data]
        cmp     ecx, eax
        jae     .refresh





        jmp     .handler_delete


;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_linedel:
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        execute esi, TFreshEdit.DeleteLine, [esi+TFreshEdit._yCaret]







>





>





>





>




















|
>
|
|
>
>


|
<
<

>
|



>






|




|
|
<

<
|
<
|

|
|
<
|

|
|
<

>
>
>
>
|
>







2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117


2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137

2138

2139

2140
2141
2142
2143

2144
2145
2146
2147

2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
.handler_end:
        execute esi, TFreshEdit.LineEnd
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_pgbeg:
        execute esi, TFreshEdit.ScreenBegin
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_pgend:
        execute esi, TFreshEdit.ScreenEnd
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_txtbeg:
        execute esi, TFreshEdit.FileBegin
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_txtend:
        execute esi, TFreshEdit.FileEnd
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_wordleft:
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_wordright:
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_delete:
locals
  .byte_offs2 dd ?
endl
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        mov     eax, [esi+TFreshEdit._yCaret]
        mov     ecx, [esi+TFreshEdit._xCaret]
        cmp     eax, [esi+TFreshEdit._ySelection]
        jne     .havesel
        cmp     ecx, [esi+TFreshEdit._xSelection]
        jne     .havesel

        execute esi, TFreshEdit.DelChar
        jmp     .end_del



.havesel:
        execute esi, TFreshEdit.DeleteSel
        mov     [esi+TFreshEdit._yCaret], eax
        mov     [esi+TFreshEdit._xCaret], edx

.end_del:
        stdcall TFreshEdit.__FitCaretInWindow, esi
        stdcall TFreshEdit.__UpdateScrollBars, esi
        or      [.changes], chgfNeedRefresh
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
; BUG:  it does not works as expected, but I don't have enough patience to fix it just now.....
.handler_backspc:
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        mov     edx, [esi+TFreshEdit._yCaret]
        mov     ecx, [esi+TFreshEdit._xCaret]



        dec     ecx

        jns     .posok

        dec     edx
        stdcall GetArrayItem, [esi+TFreshEdit._pLines], edx

        jc      .refresh

        stdcall StrLenUtf8, [eax+TEditorLine.Data], -1
        mov     ecx, eax


.posok:
        execute esi, TFreshEdit.DeleteText, edx, ecx, [esi+TFreshEdit._yCaret], [esi+TFreshEdit._xCaret]
        mov     [esi+TFreshEdit._yCaret], eax
        mov     [esi+TFreshEdit._xCaret], edx
        jmp     .end_del


;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.handler_linedel:
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        execute esi, TFreshEdit.DeleteLine, [esi+TFreshEdit._yCaret]
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        stdcall Get, esi, TFreshEdit.CurrentLine
        jc      .refresh

        xor     [eax+TEditorLine.flags], lfWordWrap
        execute esi, TFreshEdit.FormatLine, [esi+TFreshEdit._yCaret]
        stdcall TFreshEdit.__UpdateScrollBars, esi
        or      [.changes], chgfNeedRefresh
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_bookmark:







<







2172
2173
2174
2175
2176
2177
2178

2179
2180
2181
2182
2183
2184
2185
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .refresh

        stdcall Get, esi, TFreshEdit.CurrentLine
        jc      .refresh

        xor     [eax+TEditorLine.flags], lfWordWrap

        stdcall TFreshEdit.__UpdateScrollBars, esi
        or      [.changes], chgfNeedRefresh
        jmp     .refresh

;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.handler_bookmark:
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
        or      [.changes], chgfNeedRefresh
        jmp     .caretmoved

.scrollerok:
        mov     eax, [esi+TFreshEdit._xCaret]
        mov     ecx, [esi+TFreshEdit._yCaret]
        mov     edx, [esi+TFreshEdit._InsMode]
        cmp     eax, [esi+TFreshEdit._prevxCaret]
        jne     .caretmoved
        cmp     ecx, [esi+TFreshEdit._prevyCaret]
        jne     .caretmoved
        cmp     edx, [esi+TFreshEdit._prevInsMode]
        je      .caretposok

.caretmoved:
        stdcall TFreshEdit.__UpdateCaretPosition, esi








|

|







2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
        or      [.changes], chgfNeedRefresh
        jmp     .caretmoved

.scrollerok:
        mov     eax, [esi+TFreshEdit._xCaret]
        mov     ecx, [esi+TFreshEdit._yCaret]
        mov     edx, [esi+TFreshEdit._InsMode]
        cmp     eax, [esi+TFreshEdit._prevCaretChar]
        jne     .caretmoved
        cmp     ecx, [esi+TFreshEdit._prevCaretLine]
        jne     .caretmoved
        cmp     edx, [esi+TFreshEdit._prevInsMode]
        je      .caretposok

.caretmoved:
        stdcall TFreshEdit.__UpdateCaretPosition, esi

2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
        mov     ecx, [esi+TFreshEdit._LeftColumn]
        mov     [esi+TFreshEdit._prevTopLine], eax
        mov     [esi+TFreshEdit._prevLeftColumn], ecx

        mov     eax, [esi+TFreshEdit._xCaret]
        mov     ecx, [esi+TFreshEdit._yCaret]
        mov     edx, [esi+TFreshEdit._InsMode]
        mov     [esi+TFreshEdit._prevxCaret], eax
        mov     [esi+TFreshEdit._prevyCaret], ecx
        mov     [esi+TFreshEdit._prevInsMode], edx

        mov     eax, [esi+TFreshEdit._xSelection]
        mov     ecx, [esi+TFreshEdit._ySelection]
        sub     eax, [esi+TFreshEdit._xCaret]
        sub     ecx, [esi+TFreshEdit._yCaret]
        mov     edx, [esi+TFreshEdit._SelMode]







|
|







2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
        mov     ecx, [esi+TFreshEdit._LeftColumn]
        mov     [esi+TFreshEdit._prevTopLine], eax
        mov     [esi+TFreshEdit._prevLeftColumn], ecx

        mov     eax, [esi+TFreshEdit._xCaret]
        mov     ecx, [esi+TFreshEdit._yCaret]
        mov     edx, [esi+TFreshEdit._InsMode]
        mov     [esi+TFreshEdit._prevCaretChar], eax
        mov     [esi+TFreshEdit._prevCaretLine], ecx
        mov     [esi+TFreshEdit._prevInsMode], edx

        mov     eax, [esi+TFreshEdit._xSelection]
        mov     ecx, [esi+TFreshEdit._ySelection]
        sub     eax, [esi+TFreshEdit._xCaret]
        sub     ecx, [esi+TFreshEdit._yCaret]
        mov     edx, [esi+TFreshEdit._SelMode]
2547
2548
2549
2550
2551
2552
2553



2554
2555









2556
2557
2558
2559
2560
2561
2562
2563





2564
2565
2566
2567
2568
2569
2570
.finish_event:
        test    [.changes], chgfFinished
        jz      .continue
        clc
        jmp     .finish

;.........................................................................................




.paint:









        cmp     [esi+TFreshEdit._fShadowValid], 0
        jne     @f
        stdcall TFreshEdit.__DrawShadow, esi
@@:
        stdcall SetClipRectangle, [ebx+TPaintEvent.context], 0
        stdcall TScrollWindow.SysEventHandler, [.pobj], [.pEvent]
        stdcall DrawBackBuffer, [ebx+TPaintEvent.context], [esi+TFreshEdit._pShadow], 0, 0






        clc
        jmp     .finish

;.........................................................................................

.moveresize:
        stdcall Get, esi, TFreshEdit.FreeArea







>
>
>


>
>
>
>
>
>
>
>
>








>
>
>
>
>







2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
.finish_event:
        test    [.changes], chgfFinished
        jz      .continue
        clc
        jmp     .finish

;.........................................................................................
uglobal
  Prevtime dd ?
endg

.paint:

      if defined options.DebugMode and options.DebugMode
        stdcall GetTimestamp
        xchg    eax, [Prevtime]
        sub     eax, [Prevtime]
        neg     eax
        OutputRegister regEAX, 10
      end if

        cmp     [esi+TFreshEdit._fShadowValid], 0
        jne     @f
        stdcall TFreshEdit.__DrawShadow, esi
@@:
        stdcall SetClipRectangle, [ebx+TPaintEvent.context], 0
        stdcall TScrollWindow.SysEventHandler, [.pobj], [.pEvent]
        stdcall DrawBackBuffer, [ebx+TPaintEvent.context], [esi+TFreshEdit._pShadow], 0, 0

; debug mode of autoscroll with maximal speed.
;        execute esi, TFreshEdit.Move, mvcMoveY or mvcScrollY, 2, TRUE
;        execute esi, TFreshEdit.Refresh
;        stdcall TFreshEdit.__UpdateScrollBars, esi

        clc
        jmp     .finish

;.........................................................................................

.moveresize:
        stdcall Get, esi, TFreshEdit.FreeArea
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
        mov     [esi+TFreshEdit._fShadowValid], 0
        jmp     .continue
endp



;_________________________________________________________________________________________



proc TFreshEdit.__MoveCaretToPixel, .editor, .x, .y
begin
        push    ecx edx esi

        xor     ecx, ecx
        mov     esi, [.editor]

; x
        mov     eax, [.y]
        mov     edx, [esi+TFreshEdit._FreeArea.y]
        cmp     eax, edx
        jl      .nomove

        add     edx, [esi+TFreshEdit._FreeArea.height]
        cmp     eax, edx
        jge     .nomove

        mov     eax, [.x]
        mov     edx, [esi+TFreshEdit._FreeArea.x]
        cmp     eax, edx
        jl      .nomove

        add     edx, [esi+TFreshEdit._FreeArea.width]
        cmp     eax, edx
        jge     .nomove

        sub     eax, [esi+TFreshEdit.__LeftMargin]
        jge     @f
        xor     eax, eax
@@:
        cdq
        idiv    [esi+TFreshEdit._fontwidth]
        add     eax, [esi+TFreshEdit._LeftColumn]

        cmp     [esi+TFreshEdit._xCaret], eax
        je      @f

        test    eax, eax
        js      @f

        mov     [esi+TFreshEdit._xCaret], eax
@@:
; y
        mov     eax, [.y]
        cdq
        idiv    [esi+TFreshEdit._fontheight]
        add     eax, [esi+TFreshEdit._TopLine]

        cmp     [esi+TFreshEdit._yCaret], eax
        je      @f

        test    eax, eax
        js      @f
        mov     [esi+TFreshEdit._yCaret], eax
@@:
        mov     eax, ecx
        clc

.finish:
        pop     esi edx ecx
        return

.nomove:
        stc
        jmp     .finish
endp




proc TFreshEdit.__DrawShadow, .editor
  .context  dd  ?
  .latest   dd  ?
  .color     dd ?







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







2390
2391
2392
2393
2394
2395
2396






































































2397
2398
2399
2400
2401
2402
2403
        mov     [esi+TFreshEdit._fShadowValid], 0
        jmp     .continue
endp



;_________________________________________________________________________________________









































































proc TFreshEdit.__DrawShadow, .editor
  .context  dd  ?
  .latest   dd  ?
  .color     dd ?
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811



2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048

3049
3050






































































3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078


3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147

3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170

3171
3172
3173
3174
3175
3176
3177
        cmp     eax, [edi+TBackBuffer.width]
        jge     .wrapok

        stdcall SetSimpleLine, [.context], [FreshEditTheme.clWrapColumn]
        stdcall DrawLine, [.context], eax, 0, eax, [edi+TBackBuffer.height]

.wrapok:
; ebx is pointer to the index array.
        mov     ebx, [esi+TFreshEdit._pIndex]

; edx is the number of the line in [pIndex]
        mov     edx, [esi+TFreshEdit._TopLine]

; ecx is the y coordinate of the line.
        mov     ecx, [esi+TFreshEdit._fontheight]
        sub     ecx, [esi+TFreshEdit._fontdescent]
;        sub     ecx, 3                                  ; this is not good.

; check the first line
.searchbegin:
        cmp     [ebx+TArray.array+4*edx], -1
        jne     .lineloop

        sub     ecx, [esi+TFreshEdit._fontheight]
        dec     edx
        jnz     .searchbegin

; so draw the lines.
.lineloop:
        mov     eax, ecx
        sub     eax, [esi+TFreshEdit._fontheight]
        add     eax, [esi+TFreshEdit._fontdescent]
        cmp     eax, [edi+TBackBuffer.height]
        jge     .endlines

        cmp     edx, [ebx+TArray.count]
        jae     .endlines

; call the TFreshEditLineType.procDraw for the current line type.
        stdcall TFreshEdit.__DrawLine, esi, [.context], edx, ecx
        add     ecx, [esi+TFreshEdit._fontheight]

        inc     edx
        jmp     .lineloop

.endlines:
; fix the left line border to the end of the windows.
        add     ecx, [esi+TFreshEdit._fontdescent]
        mov     eax, [esi+TFreshEdit.__LeftMargin]
        sub     ecx, [esi+TFreshEdit._fontheight]
        sub     eax, 2
        stdcall SetSimpleLine, [.context], [FreshEditTheme.clLeftMarginBorder]
        stdcall DrawLine, [.context], eax, ecx, eax, [edi+TBackBuffer.height]
        stdcall SetSimpleLine, [.context], [FreshEditTheme.clLeftMargin]
        dec     eax
        stdcall DrawLine, [.context], eax, ecx, eax, [edi+TBackBuffer.height]
        dec     eax
        stdcall DrawLine, [.context], eax, ecx, eax, [edi+TBackBuffer.height]

        stdcall ReleaseContext, [.context]

.finish:
        mov     [esi+TFreshEdit._fShadowValid], 1

        popad
        return
endp






proc TFreshEdit.__DrawLine, .editor, .context, .indexLine, .y
  .line   dd  ?
  .last_line dd ?

  .attr   dd  ?
  .ysel0  dd  ?
  .xsel0  dd  ?
  .ysel1  dd  ?
  .xsel1  dd  ?

  .unfold dd  ?

  .next   dd  ?
  .markh  dd  ?

  .linenumber dd ?

  .fold_icon dd ?
  .fold_line dd ?

begin
        pushad

        mov     edi, [.editor]

        mov     [.line], -1
        mov     [.unfold], 0

        mov     eax, [.indexLine]
        lea     ecx, [eax+1]
        mov     edx, [edi+TFreshEdit._pIndex]

.nextloop:
        cmp     ecx, [edx+TArray.count]
        jae     .unfoldok
        cmp     [edx+TArray.array+4*ecx], -1
        jne     @f
        inc     ecx
        jmp     .nextloop
@@:
        push    ecx
        mov     ecx, [edx+TArray.array+4*ecx]
        dec     ecx
        cmp     ecx, [edx+TArray.array+4*eax]
        pop     ecx
        je      .unfoldok

        mov     [.unfold], 1

.unfoldok:
        mov     [.next], ecx

; if the line is part of the word-wrapped line, don't draw the text, because it is already OK.
        mov     edx, [edx+TArray.array+4*eax]     ; index in pLines
        mov     [.linenumber], edx
        inc     [.linenumber]           ; count it from 1
        cmp     edx, -1
        je      .end_draw_text       ; wrapped line.

        mov     eax, [edi+TFreshEdit._pLines]
        mov     [.last_line], 0
        mov     eax, [eax+TArray.count]
        dec     eax
        cmp     eax, edx
        jne     @f
        inc     [.last_line]    ; flag that this line is the last line.
@@:
        shl     edx, TEditorLine.shift
        add     edx, [edi+TFreshEdit._pLines]
        add     edx, TArray.array
        mov     [.line], edx                      ; pointer to TEditorLines

; draw the text of the line
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
        stdcall StrLen, [edx+TEditorLine.Data]
        test    eax, eax
        jz      .empty_string

        mov     ecx, eax
        shl     eax, 4          ; sizeof.TCharAttr =  16

        stdcall GetMem, eax     ; attr array.
        mov     [.attr], eax
        mov     esi, eax

        mov     ebx, [FreshEditTheme.clSimpleText]
        test    [edx+TEditorLine.flags], lfProtected
        jz      @f
        mov     ebx, [FreshEditTheme.clProtectedText]
@@:
        mov     edx, [edi+TFreshEdit._Font]

; fill the attribute array with the default values.
.attrloop:
        mov     [esi+TCharAttr.color], ebx
        mov     [esi+TCharAttr.font], edx
        lea     esi, [esi+sizeof.TCharAttr]
        loop    .attrloop

        mov     edx, [.line]
        test    [edx+TEditorLine.flags], lfProtected
        jnz     .syntaxok

; Call the syntax highlighter if any:
        xor     ecx, ecx
        cmp     [.indexLine], ecx
        je      @f
        mov     ecx, [edx-sizeof.TEditorLine+TEditorLine.syn_context]
@@:
        cmp     [edi+TFreshEdit._procSyntax], 0
        je      .syntaxok

        push    edi edx
        stdcall [edi+TFreshEdit._procSyntax], [edx+TEditorLine.Data], [.attr], ecx
        pop     edx edi
        mov     [edx+TEditorLine.syn_context], eax

.syntaxok:
        stdcall StrPtr, [edx+TEditorLine.Data]
        cmp     byte [eax], 0
        je      .end_draw_text

        stdcall DrawColoredString, [.context], eax, [.attr], [eax+string.len], [edi+TFreshEdit.__LeftMargin],     \
                                   [.y], [edi+TFreshEdit._LeftColumn], [edi+TFreshEdit._fontwidth], [edi+TFreshEdit._fontheight]

        stdcall FreeMem, [.attr]

.end_draw_text:

; draw left margin graphics:
        stdcall TFreshEdit.__DrawLeftMargin, edi, [.context], [.indexLine]

; now draw transparent selection

; selection bounds.
        mov     eax, [edi+TFreshEdit._xSelection]
        mov     ecx, [edi+TFreshEdit._ySelection]
        mov     ebx, [edi+TFreshEdit._xCaret]
        mov     edx, [edi+TFreshEdit._yCaret]

        cmp     ecx, edx
        jl      @f
        je      .sortx
        xchg    ecx, edx
        cmp     [edi+TFreshEdit._SelMode], selmChar
        jne     @f
        xchg    eax, ebx
@@:
        cmp     [edi+TFreshEdit._SelMode], selmChar
        je      .endsort

.sortx:
        cmp     eax, ebx
        jle     @f
        xchg    eax, ebx
@@:

.endsort:
        mov     [.xsel0], eax
        mov     [.ysel0], ecx
        mov     [.xsel1], ebx
        mov     [.ysel1], edx

        mov     eax, [.indexLine]
        cmp     eax, [.ysel0]
        jl      .end_sel
        cmp     eax, [.ysel1]
        jg      .end_sel

        mov     eax, [edi+TFreshEdit._SelMode]

        cmp     eax, selmChar
        je      .selchar

; sel block
        mov     eax, [.xsel0]
        cmp     eax, [.xsel1]
        je      .end_sel

        sub     eax, [edi+TFreshEdit._LeftColumn]
        jge     @f
        xor     eax, eax
@@:
        imul    eax, [edi+TFreshEdit._fontwidth]
        add     eax, [edi+TFreshEdit.__LeftMargin]

        mov     ecx, [.xsel1]
        sub     ecx, [edi+TFreshEdit._LeftColumn]
        jge     @f
        xor     ecx, ecx
@@:
        imul    ecx, [edi+TFreshEdit._fontwidth]
        add     ecx, [edi+TFreshEdit.__LeftMargin]
        sub     ecx, eax
        jmp     .drawsel

.selchar:
        xor     eax, eax
        mov     edx, [.indexLine]
        cmp     edx, [.ysel0]
        jne     .firstok

        mov     eax, [.xsel0]
        sub     eax, [edi+TFreshEdit._LeftColumn]
        jge     .firstok
        xor     eax, eax

.firstok:
        imul    eax, [edi+TFreshEdit._fontwidth]
        add     eax, [edi+TFreshEdit.__LeftMargin]

        mov     ecx, [edi+TFreshEdit._cols]    ; selection is to the end of the line, for the intermediate lines.
        inc     ecx

        cmp     edx, [.ysel1]
        jne     .lastok

        mov     ecx, [.xsel1]
        sub     ecx, [edi+TFreshEdit._LeftColumn]
        test    ecx, ecx
        jns     .lastok
        xor     ecx, ecx

.lastok:
        imul    ecx, [edi+TFreshEdit._fontwidth]
        add     ecx, [edi+TFreshEdit.__LeftMargin]
        sub     ecx, eax

.drawsel:
        mov     edx, [.y]
        sub     edx, [edi+TFreshEdit._fontheight]
        add     edx, 3

        stdcall SetDrawMode, [.context], [FreshEditTheme.clSelMode]
        stdcall DrawFillRect, [.context], eax, edx, ecx, [edi+TFreshEdit._fontheight], [FreshEditTheme.clSelBack]
        stdcall SetDrawMode, [.context], cmCopy


.end_sel:






































































        popad
        return

.empty_string:
        mov     eax, [.indexLine]
        mov     ecx, [FreshEditTheme.clBackground]
        cmp     eax, [.ysel0]
        jb      .setback
        cmp     eax, [.ysel1]
        jae     .setback

        mov     ecx, [FreshEditTheme.clSelBack]

.setback:
        jmp     .end_draw_text

endp





proc TFreshEdit.__DrawLeftMargin, .editor, .context, .indexLine

.x         dd ?
.y         dd ?
.width     dd ?
.height    dd ?



.ytext     dd ?
.yicons    dd ?

.unfold    dd ?  ; is the line folded?
.indexNext dd ?  ; the index of the next line in TFreshEdit._pIndex

.ipLines   dd ?  ; the index of the current line in pLines array.
.ptrLine   dd ?  ; pointer of the current TEditorLine.

.fold_icon dd ?
.fold_line dd ?

begin
        pushad

        mov     esi, [.editor]

        test    [FreshEditTheme.Options], eoLeftMargin
        jz      .finish

        stdcall SetDrawMode, [.context], cmCopy

; search for the next line index;
        mov     ecx, [.indexLine]
        mov     edx, [esi+TFreshEdit._pIndex]
        cmp     [edx+TArray.array+4*ecx], -1
        je      .finish

        mov     [.unfold], 0

        xor     eax, eax
        dec     eax

.nextloop:
        inc     ecx
        cmp     ecx, [edx+TArray.count]
        jae     .found_next

        cmp     [edx+TArray.array+4*ecx], eax
        je      .nextloop

.found_next:
        mov     [.indexNext], ecx

        mov     eax, [.indexLine]
        mov     eax, [edx+TArray.array+4*eax]   ; current line - index in pLines
        mov     [.ipLines], eax

        cmp     ecx, [edx+TArray.count]
        jae     .unfoldok

        mov     ecx, [edx+TArray.array+4*ecx]   ; next line index in pLines
        dec     ecx
        cmp     ecx, eax
        setne   byte [.unfold]

.unfoldok:
        mov     edx, eax
        shl     edx, TEditorLine.shift
        add     edx, TArray.array
        add     edx, [esi+TFreshEdit._pLines]
        mov     [.ptrLine], edx

; determine the bounds of the drawing
        mov     ecx, [.indexNext]
        sub     ecx, [.indexLine]
        mov     eax, [esi+TFreshEdit.__LeftMargin]
        imul    ecx, [esi+TFreshEdit._fontheight]

        mov     [.width], eax
        mov     [.height], ecx

        xor     eax, eax
        mov     [.x], eax

        mov     eax, [.indexLine]
        sub     eax, [esi+TFreshEdit._TopLine]
        imul    eax, [esi+TFreshEdit._fontheight]
        mov     [.y], eax                               ; it can be negative for the word wrapped lines, partially displayed.

        add     eax, [esi+TFreshEdit._fontheight]
        sub     eax, [esi+TFreshEdit._fontdescent]
        mov     [.ytext], eax

        mov     ecx, [esi+TFreshEdit._iconBreakpointA]
        mov     eax, [esi+TFreshEdit._fontheight]
        sub     eax, [ecx+TImage.height]
        sar     eax, 1
        adc     eax, [.y]
        mov     [.yicons], eax

; draw the bookmark background.

        test    [edx+TEditorLine.flags], lfBookmark
        jz      .bookmarkok
        mov     eax, [.width]
        sub     eax, 4
        stdcall DrawFillRect, [.context], [.x], [.y], eax, [.height], [FreshEditTheme.clBookmarkBack]
.bookmarkok:








<
|
<
<

<
<
<
<
<
<
<
<
<
<
<
<
|
<



<
<
<
|








<





<

<








<










>
>
>

|
<
<






<
<
<
<
<
<
<
<
<
<
<



|

<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
|
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




|
|
|
|





|



|














|





|









|



|
|


|



|
|





|




|




|
|

|






|





|
|




|
|

|
<

>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


<
<
<
<
<
<
<
<
<
<
<
<
<
<






|


<


>
>





<
|
<
|














<
<
|
|
|
|
|

<
|
<
<
|
|
<
<
<
|
|
<
<
|
<
<
|

<
<
<
|
|
|
<

|
|
<
<
<
<


|
<

|
>





<
|
<
<
<













>







2467
2468
2469
2470
2471
2472
2473

2474


2475












2476

2477
2478
2479



2480
2481
2482
2483
2484
2485
2486
2487
2488

2489
2490
2491
2492
2493

2494

2495
2496
2497
2498
2499
2500
2501
2502

2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517


2518
2519
2520
2521
2522
2523











2524
2525
2526
2527
2528



2529






























2530







2531

2532





























































2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635

2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711














2712
2713
2714
2715
2716
2717
2718
2719
2720

2721
2722
2723
2724
2725
2726
2727
2728
2729

2730

2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745


2746
2747
2748
2749
2750
2751

2752


2753
2754



2755
2756


2757


2758
2759



2760
2761
2762

2763
2764
2765




2766
2767
2768

2769
2770
2771
2772
2773
2774
2775
2776

2777



2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
        cmp     eax, [edi+TBackBuffer.width]
        jge     .wrapok

        stdcall SetSimpleLine, [.context], [FreshEditTheme.clWrapColumn]
        stdcall DrawLine, [.context], eax, 0, eax, [edi+TBackBuffer.height]

.wrapok:

        mov     ebx, [esi+TFreshEdit._pLines]


        mov     edx, [esi+TFreshEdit._TopLine]












        xor     ecx, ecx


; so draw the lines.
.lineloop:



        cmp     ecx, [edi+TBackBuffer.height]
        jge     .endlines

        cmp     edx, [ebx+TArray.count]
        jae     .endlines

; call the TFreshEditLineType.procDraw for the current line type.
        stdcall TFreshEdit.__DrawLine, esi, [.context], edx, ecx
        add     ecx, [esi+TFreshEdit._fontheight]

        inc     edx
        jmp     .lineloop

.endlines:
; fix the left line border to the end of the windows.

        mov     eax, [esi+TFreshEdit.__LeftMargin]

        sub     eax, 2
        stdcall SetSimpleLine, [.context], [FreshEditTheme.clLeftMarginBorder]
        stdcall DrawLine, [.context], eax, ecx, eax, [edi+TBackBuffer.height]
        stdcall SetSimpleLine, [.context], [FreshEditTheme.clLeftMargin]
        dec     eax
        stdcall DrawLine, [.context], eax, ecx, eax, [edi+TBackBuffer.height]
        dec     eax
        stdcall DrawLine, [.context], eax, ecx, eax, [edi+TBackBuffer.height]

        stdcall ReleaseContext, [.context]

.finish:
        mov     [esi+TFreshEdit._fShadowValid], 1

        popad
        return
endp


; y is the coordinate of the top of the line!
; returns the height of the line in characters.
; if the line is not drawn (because is hidden) returns 0

proc TFreshEdit.__DrawLine, .editor, .context, .iLine, .y



  .attr   dd  ?
  .ysel0  dd  ?
  .xsel0  dd  ?
  .ysel1  dd  ?
  .xsel1  dd  ?











begin
        pushad

        mov     esi, [.editor]




        mov     eax, [.iLine]






























        mov     edi, [esi+TFreshEdit._pLines]







        shl     eax, TEditorLine.shift

        lea     edi, [edi+TArray.array+eax]






























































; now draw transparent selection

; selection bounds.
        mov     eax, [esi+TFreshEdit._xSelection]
        mov     ecx, [esi+TFreshEdit._ySelection]
        mov     ebx, [esi+TFreshEdit._xCaret]
        mov     edx, [esi+TFreshEdit._yCaret]

        cmp     ecx, edx
        jl      @f
        je      .sortx
        xchg    ecx, edx
        cmp     [esi+TFreshEdit._SelMode], selmChar
        jne     @f
        xchg    eax, ebx
@@:
        cmp     [esi+TFreshEdit._SelMode], selmChar
        je      .endsort

.sortx:
        cmp     eax, ebx
        jle     @f
        xchg    eax, ebx
@@:

.endsort:
        mov     [.xsel0], eax
        mov     [.ysel0], ecx
        mov     [.xsel1], ebx
        mov     [.ysel1], edx

        mov     eax, [.iLine]
        cmp     eax, [.ysel0]
        jl      .end_sel
        cmp     eax, [.ysel1]
        jg      .end_sel

        mov     eax, [esi+TFreshEdit._SelMode]

        cmp     eax, selmChar
        je      .selchar

; sel block
        mov     eax, [.xsel0]
        cmp     eax, [.xsel1]
        je      .end_sel

        sub     eax, [esi+TFreshEdit._LeftColumn]
        jge     @f
        xor     eax, eax
@@:
        imul    eax, [esi+TFreshEdit._fontwidth]
        add     eax, [esi+TFreshEdit.__LeftMargin]

        mov     ecx, [.xsel1]
        sub     ecx, [esi+TFreshEdit._LeftColumn]
        jge     @f
        xor     ecx, ecx
@@:
        imul    ecx, [esi+TFreshEdit._fontwidth]
        add     ecx, [esi+TFreshEdit.__LeftMargin]
        sub     ecx, eax
        jmp     .drawsel

.selchar:
        xor     eax, eax
        mov     edx, [.iLine]
        cmp     edx, [.ysel0]
        jne     .firstok

        mov     eax, [.xsel0]
        sub     eax, [esi+TFreshEdit._LeftColumn]
        jge     .firstok
        xor     eax, eax

.firstok:
        imul    eax, [esi+TFreshEdit._fontwidth]
        add     eax, [esi+TFreshEdit.__LeftMargin]

        mov     ecx, [esi+TFreshEdit._cols]    ; selection is to the end of the line, for the intermediate lines.
        inc     ecx

        cmp     edx, [.ysel1]
        jne     .lastok

        mov     ecx, [.xsel1]
        sub     ecx, [esi+TFreshEdit._LeftColumn]
        test    ecx, ecx
        jns     .lastok
        xor     ecx, ecx

.lastok:
        imul    ecx, [esi+TFreshEdit._fontwidth]
        add     ecx, [esi+TFreshEdit.__LeftMargin]
        sub     ecx, eax

.drawsel:
        mov     edx, [.y]
;        sub     edx, [esi+TFreshEdit._fontheight]
;        add     edx, 3

;        stdcall SetDrawMode, [.context], [FreshEditTheme.clSelMode]

        stdcall SetDrawMode, [.context], cmCopy
        stdcall DrawFillRect, [.context], eax, edx, ecx, [esi+TFreshEdit._fontheight], [FreshEditTheme.clSelBack]

.end_sel:
        mov     eax, [.iLine]
        mov     edi, [esi+TFreshEdit._pLines]
        shl     eax, TEditorLine.shift
        lea     edi, [edi+TArray.array+eax]

; draw the text of the line

; allocate memory for the color data.
        stdcall StrLen, [edi+TEditorLine.Data]
        test    eax, eax
        jz      .end_draw_text

        mov     ecx, eax
        shl     eax, 4          ; sizeof.TCharAttr =  16

        stdcall GetMem, eax     ; attr array.
        mov     [.attr], eax
        mov     edx, eax

        mov     ebx, [FreshEditTheme.clSimpleText]
        test    [edi+TEditorLine.flags], lfProtected
        jz      @f
        mov     ebx, [FreshEditTheme.clProtectedText]
@@:
        mov     eax, [esi+TFreshEdit._Font]

; fill the attribute array with the default values.
.attrloop:
        mov     [edx+TCharAttr.color], ebx
        mov     [edx+TCharAttr.font], eax
        lea     edx, [edx+sizeof.TCharAttr]
        loop    .attrloop

.attrok:
; Call the syntax highlighter if any:
        cmp     [esi+TFreshEdit._procSyntax], 0
        je      .syntaxok

; get the syntax context of the previous line:
        xor     ecx, ecx
        cmp     [.iLine], ecx
        je      .prev_ok                ; there is no previous line

        lea     edx, [edi-sizeof.TEditorLine]

        mov     ecx, [edx+TEditorLine.syn_context]
        or      ecx, ttNewLine

; ecx contains the syntax context:
.prev_ok:
        stdcall [esi+TFreshEdit._procSyntax], [edi+TEditorLine.Data], [.attr], ecx
        mov     [edi+TEditorLine.syn_context], eax

.syntaxok:
        stdcall StrPtr, [edi+TEditorLine.Data]
        mov     ecx, [.y]
        add     ecx, [esi+TFreshEdit._fontheight]
        sub     ecx, [esi+TFreshEdit._fontdescent]
        stdcall DrawColoredString, [.context], eax, [.attr], [eax+string.len], [esi+TFreshEdit.__LeftMargin],     \
                                   ecx, [esi+TFreshEdit._LeftColumn], [esi+TFreshEdit._fontwidth], [esi+TFreshEdit._fontheight]

        stdcall FreeMem, [.attr]

.end_draw_text:

        stdcall TFreshEdit.__DrawLeftMargin, esi, [.context], edi, [.y]



.finish_draw_line:
        popad
        return














endp





proc TFreshEdit.__DrawLeftMargin, .editor, .context, .pLine, .y

.x         dd ?

.width     dd ?
.height    dd ?

.maxptr    dd ?

.ytext     dd ?
.yicons    dd ?

.unfold    dd ?  ; is the line folded?

.pNext     dd ?  ; pointer to the next line.

.pPrev     dd ?  ; pointer to the previous line.

.fold_icon dd ?
.fold_line dd ?

begin
        pushad

        mov     esi, [.editor]

        test    [FreshEditTheme.Options], eoLeftMargin
        jz      .finish

        stdcall SetDrawMode, [.context], cmCopy



        mov     edx, [esi+TFreshEdit._pLines]
        mov     ecx, [edx+TArray.count]
        shl     ecx, TEditorLine.shift
        lea     ecx, [edx+TArray.array+ecx]
        mov     [.maxptr], ecx


        mov     ecx, [.pLine]


        sub     ecx, sizeof.TEditorLine
        cmp     ecx, [esi+TFreshEdit._pLines]



        ja      @f
        xor     ecx, ecx


@@:


        mov     [.pPrev], ecx




        mov     ecx, [.pLine]
        add     ecx, sizeof.TEditorLine
        mov     [.pNext], ecx


        mov     [.unfold], 0
        mov     edx, [.pLine]





; determine the bounds of the drawing


        mov     eax, [esi+TFreshEdit.__LeftMargin]
        mov     ecx, [esi+TFreshEdit._fontheight]

        mov     [.width], eax
        mov     [.height], ecx

        xor     eax, eax
        mov     [.x], eax

        mov     eax, [.y]




        add     eax, [esi+TFreshEdit._fontheight]
        sub     eax, [esi+TFreshEdit._fontdescent]
        mov     [.ytext], eax

        mov     ecx, [esi+TFreshEdit._iconBreakpointA]
        mov     eax, [esi+TFreshEdit._fontheight]
        sub     eax, [ecx+TImage.height]
        sar     eax, 1
        adc     eax, [.y]
        mov     [.yicons], eax

; draw the bookmark background.

        test    [edx+TEditorLine.flags], lfBookmark
        jz      .bookmarkok
        mov     eax, [.width]
        sub     eax, 4
        stdcall DrawFillRect, [.context], [.x], [.y], eax, [.height], [FreshEditTheme.clBookmarkBack]
.bookmarkok:

3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209



3210
3211
3212
3213
3214
3215

3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242



3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253

3254
3255
3256
3257
3258
3259
3260
3261

3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
        dec     eax
        stdcall DrawLine, [.context], eax, [.y], eax, ecx
        jmp     .borderok

.wrap_border:
        dec     ecx

        push    ecx  eax [.y] eax [.context]       ; vertical
        push    [.y] eax [.y] eax [.context]       ; upper edge
        push    ecx  eax ecx  eax [.context]       ; down edge




        sub     dword [esp+12], 2
        sub     dword [esp+16], 2
        stdcall DrawLine

        sub     dword [esp+12], 2
        add     dword [esp+16], 2

        stdcall DrawLine

        sub     dword [esp+4], 2
        add     dword [esp+8], 2
        sub     dword [esp+12], 2
        sub     dword [esp+16], 1
        stdcall DrawLine

        mov     ebx, [FreshEditTheme.clLeftMargin]
        test    [edx+TEditorLine.flags], lfBookmark
        jz      @f
        mov     ebx, [FreshEditTheme.clBookmarkBack]
@@:
        stdcall SetSimpleLine, [.context], ebx

        push    [.y] eax [.y] eax [.context]       ; upper edge
        push    [.y] eax [.y] eax [.context]       ; upper edge
        push    ecx  eax ecx  eax [.context]       ; down corner pixels
        push    ecx  eax ecx  eax [.context]       ; down corner pixels

        sub     dword [esp+4], 2
        stdcall DrawLine

        sub     dword [esp+4], 2
        sub     dword [esp+8], 1
        sub     dword [esp+12], 2
        stdcall DrawLine




        sub     dword [esp+4], 2
        stdcall DrawLine

        sub     dword [esp+4], 2
        add     dword [esp+8], 1
        sub     dword [esp+12], 2
        stdcall DrawLine

.borderok:
; Line number draw

        test    [FreshEditTheme.Options], eoLineNumbers
        jz      .line_numbers_ok

        mov     ecx, [.ipLines]
        test    ecx, ecx
        jl      .line_numbers_ok

        inc     ecx

        stdcall NumToStr, ecx, ntsDec or ntsUnsigned
        push    eax eax
        stdcall StrLen, eax
        mov     ecx, eax
        stdcall StrPtr ; from the stack
        mov     ebx, eax

        stdcall GetTextBounds, [.context], eax, ecx, 0 ; [edi+TFreshEdit._Font]
        sub     eax, [esi+TFreshEdit.__NumberMargin]
        neg     eax
        stdcall DrawString, [.context], ebx, ecx, eax, [.ytext], 0, [FreshEditTheme.clLeftMarginText]
        stdcall StrDel ; from the stack

.line_numbers_ok:
; draw icons in the middle

; icon breakpoint
        mov     edx, [.ptrLine]
        test    [edx+TEditorLine.flags], lfBreakpoint
        jnz     .draw_breakpoint

        cmp     [edx+TEditorLine.debugdata], 0
        je      .breakpoint_ok

.draw_breakpoint:







|
|


>
>
>




|

>















|
|
|
|








>
>
>









<

>



|
|
|
|

>







|









|







2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879

2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
        dec     eax
        stdcall DrawLine, [.context], eax, [.y], eax, ecx
        jmp     .borderok

.wrap_border:
        dec     ecx

        push    ecx  eax [.y] eax [.context]       ; vertical   ye x ys x
        push    [.y] eax [.y] eax [.context]       ; upper edge ys
        push    ecx  eax ecx  eax [.context]       ; down edge

; down edge
        mov     ebx, [.pNext]
        sub     dword [esp+4], 2
        sub     dword [esp+12], 2
        sub     dword [esp+16], 2
        stdcall DrawLine

        sub     dword [esp+4], 2
        add     dword [esp+16], 2
        sub     dword [esp+12], 2
        stdcall DrawLine

        sub     dword [esp+4], 2
        add     dword [esp+8], 2
        sub     dword [esp+12], 2
        sub     dword [esp+16], 1
        stdcall DrawLine

        mov     ebx, [FreshEditTheme.clLeftMargin]
        test    [edx+TEditorLine.flags], lfBookmark
        jz      @f
        mov     ebx, [FreshEditTheme.clBookmarkBack]
@@:
        stdcall SetSimpleLine, [.context], ebx

        mov     ebx, [.pNext]

        push    ecx  eax ecx  eax [.context]       ; down edge
        push    ecx  eax ecx  eax [.context]       ; down edge

        sub     dword [esp+4], 2
        stdcall DrawLine

        sub     dword [esp+4], 2
        sub     dword [esp+8], 1
        sub     dword [esp+12], 2
        stdcall DrawLine

        push    [.y] eax [.y] eax [.context]       ; upper edge
        push    [.y] eax [.y] eax [.context]       ; upper edge

        sub     dword [esp+4], 2
        stdcall DrawLine

        sub     dword [esp+4], 2
        add     dword [esp+8], 1
        sub     dword [esp+12], 2
        stdcall DrawLine


; Line number draw
.borderok:
        test    [FreshEditTheme.Options], eoLineNumbers
        jz      .line_numbers_ok

        mov     ecx, [.pLine]
        sub     ecx, [esi+TFreshEdit._pLines]
        sub     ecx, TArray.array
        shr     ecx, TEditorLine.shift
        inc     ecx

        stdcall NumToStr, ecx, ntsDec or ntsUnsigned
        push    eax eax
        stdcall StrLen, eax
        mov     ecx, eax
        stdcall StrPtr ; from the stack
        mov     ebx, eax

        stdcall GetTextBounds, [.context], eax, ecx, 0
        sub     eax, [esi+TFreshEdit.__NumberMargin]
        neg     eax
        stdcall DrawString, [.context], ebx, ecx, eax, [.ytext], 0, [FreshEditTheme.clLeftMarginText]
        stdcall StrDel ; from the stack

.line_numbers_ok:
; draw icons in the middle

; icon breakpoint
        mov     edx, [.pLine]
        test    [edx+TEditorLine.flags], lfBreakpoint
        jnz     .draw_breakpoint

        cmp     [edx+TEditorLine.debugdata], 0
        je      .breakpoint_ok

.draw_breakpoint:
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320





3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
        mov     ecx, [esi+TFreshEdit._iconBreakpointI]
@@:
        stdcall DrawMaskedImage, [.context], eax, ecx

.breakpoint_ok:

; draw fold tree.

        mov     edx, [.ptrLine]

; first, determine, what icon should be set for fold/unfold icon:
        xor     ecx, ecx
        mov     ebx, [esi+TFreshEdit._pIndex]
        mov     eax, [.indexNext]
        cmp     eax, [ebx+TArray.count]
        jae     @f
        mov     eax, [ebx+TArray.array+4*eax]   ; index in pLines of the next visible line.
        shl     eax, TEditorLine.shift
        mov     ecx, [esi+TFreshEdit._pLines]
        lea     ecx, [ecx+TArray.array+eax]
@@:





        test    [edx+TEditorLine.flags], lfFoldHeader
        jnz     .fold_fold

        jecxz   .fold_end

        mov     eax, [ecx+TEditorLine.fold_level]
        cmp     eax, [edx+TEditorLine.fold_level]
        ja      .fold_continue
        jb      .fold_end

        test    [ecx+TEditorLine.flags], lfFoldHeader
        jz      .fold_continue

.fold_end:
        xor     eax, eax
        mov     ecx, 2          ; 2 means corner up/right
        jmp     .fold_ok

.fold_fold:
        mov     ecx, 1          ; 1 means half vertical down
        mov     eax, [esi+TFreshEdit._iconUnfold]
        cmp     [.unfold], 0
        jne     .fold_ok
        mov     eax, [esi+TFreshEdit._iconFold]
        jmp     .fold_ok

.fold_continue:
        xor     eax, eax
        xor     ecx, ecx        ; 0 means full vertical line








<
|



<
|
|

<
<
|
<

>
>
>
>
>
|
|








<
<
<








|
<







2929
2930
2931
2932
2933
2934
2935

2936
2937
2938
2939

2940
2941
2942


2943

2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959



2960
2961
2962
2963
2964
2965
2966
2967
2968

2969
2970
2971
2972
2973
2974
2975
        mov     ecx, [esi+TFreshEdit._iconBreakpointI]
@@:
        stdcall DrawMaskedImage, [.context], eax, ecx

.breakpoint_ok:

; draw fold tree.

        mov     edx, [.pLine]

; first, determine, what icon should be set for fold/unfold icon:
        xor     ecx, ecx

        mov     eax, [.pNext]
        cmp     eax, [.maxptr]
        jae     @f


        mov     ecx, eax

@@:
        cmp     [.pPrev], 0
        je      .fold_fold

        mov     eax, [.pPrev]
        mov     eax, [edx-sizeof.TEditorLine+TEditorLine.fold_level]
        cmp     eax, [edx+TEditorLine.fold_level]
        jb      .fold_fold

        jecxz   .fold_end

        mov     eax, [ecx+TEditorLine.fold_level]
        cmp     eax, [edx+TEditorLine.fold_level]
        ja      .fold_continue
        jb      .fold_end




.fold_end:
        xor     eax, eax
        mov     ecx, 2          ; 2 means corner up/right
        jmp     .fold_ok

.fold_fold:
        mov     ecx, 1          ; 1 means half vertical down
        mov     eax, [esi+TFreshEdit._iconUnfold]


        mov     eax, [esi+TFreshEdit._iconFold]
        jmp     .fold_ok

.fold_continue:
        xor     eax, eax
        xor     ecx, ecx        ; 0 means full vertical line

3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
.height dd ?
.offset dd ?
begin
        push    eax ebx edx

        mov     ebx, [.editor]


        mov     eax, [ebx+TFreshEdit._fontheight]
        mov     edx, [ebx+TFreshEdit._fontwidth]

        mov     [.offset], 0

        cmp     [ebx+TFreshEdit._InsMode], modeInsert
        jne     .sizeok







<







3039
3040
3041
3042
3043
3044
3045

3046
3047
3048
3049
3050
3051
3052
.height dd ?
.offset dd ?
begin
        push    eax ebx edx

        mov     ebx, [.editor]


        mov     eax, [ebx+TFreshEdit._fontheight]
        mov     edx, [ebx+TFreshEdit._fontwidth]

        mov     [.offset], 0

        cmp     [ebx+TFreshEdit._InsMode], modeInsert
        jne     .sizeok
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
proc TFreshEdit.__UpdateScrollBars, .editor
begin
        push    eax ebx ecx edx

        mov     ebx, [.editor]

; V scroller
        mov     eax, [ebx+TFreshEdit._pIndex]
        mov     eax, [eax+TArray.count]
        sub     eax, [ebx+TFreshEdit._rows]
        mov     [ebx+TFreshEdit._VScroller.Max], eax

        mov     eax, [ebx+TFreshEdit._TopLine]
        mov     [ebx+TFreshEdit._VScroller.Pos], eax








|







3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
proc TFreshEdit.__UpdateScrollBars, .editor
begin
        push    eax ebx ecx edx

        mov     ebx, [.editor]

; V scroller
        mov     eax, [ebx+TFreshEdit._pLines]
        mov     eax, [eax+TArray.count]
        sub     eax, [ebx+TFreshEdit._rows]
        mov     [ebx+TFreshEdit._VScroller.Max], eax

        mov     eax, [ebx+TFreshEdit._TopLine]
        mov     [ebx+TFreshEdit._VScroller.Pos], eax

3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595

3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688

3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798

.endset:
        test    eax, eax
        pop     esi edx ecx ebx
        return
endp

; Converts x,y position in the text to memory parameters
; arguments:
;   .x, .y - x and y coordinates of the position.
; returns:
; edx - pointer to the TEditorLine
; eax - byte offset inside the string that corresponds with the given position.
; ecx - count of the spaces that have to be inserted on offset eax in the string
;       in order to reach the .x coordinate (when the position is beyond the end of the line)
proc TFreshEdit.__PosToPointer, .editor, .x, .y
.pline dd ?
.start dd ?
begin
        push    ebx esi edi

        mov     edi, [.editor]
        mov     eax, [.y]
        mov     ebx, [edi+TFreshEdit._pIndex]
        cmp     eax, [ebx+TArray.count]
        jae     .error

        xor     ecx, ecx

.lineloop:
        mov     edx, [ebx+TArray.array+4*eax]
        cmp     edx, -1
        jne     .found


        inc     ecx
        dec     eax
        jns     .lineloop

.error:
        stc
        jmp     .finish

.crash_error:
        int3
        jmp     .error

; ecx is the wrapped line count.
; edx is the number of string in the lines array.
.found:
        mov     ebx, [edi+TFreshEdit._pLines]
        cmp     edx, [ebx+TArray.count]
        jae     .crash_error

        shl     edx, TEditorLine.shift
        lea     eax, [ebx+TArray.array+edx]

        mov     [.pline], eax        ; handle of the string.

        cmp     [.x], -1
        je      .only_line

        stdcall StrPtr, [eax+TEditorLine.Data]
        mov     esi, eax
        mov     [.start], eax
        jecxz   .wrapok

.wraploop:
        stdcall DecodeUtf8, dword [esi]
        add     esi, edx

        test    eax, eax
        jz      .crash_error

        cmp     eax, $01        ; line wrap char
        jne     .wraploop

        dec     ecx
        jnz     .wraploop

.wrapok:
        mov     ecx, [.x]
        jecxz   .endofstring

.charloop:
        stdcall DecodeUtf8, dword [esi]
        test    eax, eax
        jz      .endofstring
        cmp     eax, $01
        je      .endofstring

        add     esi, edx
        dec     ecx
        jnz     .charloop

.endofstring:
        sub     esi, [.start]
        mov     eax, esi

.only_line:
        mov     edx, [.pline]

        clc

.finish:
        pop     edi esi ebx
        return
endp


; Converts the pointer parameters to caret coordinate.
; arguments:
;   .index - index of the line
;   .offset - byte offset inside the string.
; returns:
;   eax - y coordinate of the caret
;   edx - x coordinate of the caret
;   ecx - pointer to the current TEditorLine

proc TFreshEdit.__PointerToPos, .editor, .index, .offset
.base dd ?
.x    dd ?
begin
        push    esi edi

        mov     esi, [.editor]
        mov     edi, [esi+TFreshEdit._pIndex]
        mov     ecx, [.index]


.line_loop:
        cmp     [edi+TArray.array+4*ecx], -1
        jne     .found
        dec     ecx
        jns     .line_loop

.error:
        stc
        jmp     .finish

.found:
        mov     [.base], ecx                ; base index
        mov     [.x], 0

        mov     ecx, [edi+TArray.array+4*ecx] ; index in pLines
        shl     ecx, TEditorLine.shift
        add     ecx, [esi+TFreshEdit._pLines]
        add     ecx, TArray.array

        cmp     [.offset], 0
        je      .ready

        stdcall StrPtr, [ecx+TEditorLine.Data]
        mov     esi, eax

.char_loop:
        stdcall DecodeUtf8, [esi]
        jc      .error
        add     esi, edx

        cmp     eax, 1  ; wrap char
        jne     .no_wrap

        inc     [.base]
        mov     [.x], -1

.no_wrap:
        inc     [.x]
        sub     [.offset], edx
        ja      .char_loop

.ready:
        mov     eax, [.base]
        mov     edx, [.x]
        clc

.finish:
        pop     edi esi
        return
endp



; .hString - the string containing the line.
;
; returns:
;   eax - the width of the line in chars.
;         if the line contains wrapped sublines,
;         the maximal length will be returned.

proc TFreshEdit.__LineWidth, .hString
.maxlen dd ?
begin
        push    esi ecx edx

        mov     [.maxlen], 0
        stdcall StrPtr, [.hString]
        mov     esi, eax

.outer:
        xor     ecx, ecx

.loop:
        stdcall DecodeUtf8, [esi]
        jc      .error

        add     esi, edx

        test    eax, eax
        jz      .endofline

        cmp     eax, $01        ; wrap char
        je      .endofline

        inc     ecx
        jmp     .loop

.endofline:
        cmp     ecx, [.maxlen]
        jbe     .maxok
        mov     [.maxlen], ecx
.maxok:
        test    eax, eax
        jnz     .outer

        mov     eax, [.maxlen]
        clc

.error:
        pop     edx ecx esi
        return
endp




proc TFreshEdit.__FixLength, .editor, .newlen, .oldlen
begin
        push    eax ecx edx esi edi







<
<
<
<
<
<
<
<
<
<
<
<
<

<
<
<
<
<

<
|
<
<
<
<
|
>
|
|
|
|
<
<
<
|
<
<
<
|
<
<
<
|
<
<
|
<
<
|
<

<
<
|
<
|
<
<

<
<
<
|
<
<
<
<
<
<
<
<
<
<
|
<
|
<
<
<
<
|
|

|
|
|

<
<
|
<
<
|
<
<
<
<
|
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<
|
|
>

<
|
|
|
<
|
<
|
<
|
<
<
<
<
<
<
|
<

<
|
|
<
|
|
<
<
<
<
|
<
<

<
<
<
<
<
<
<
<
<
|
|



|

<

|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
|
<
<
<
<
<
<

<
<

<
<
<
<







3186
3187
3188
3189
3190
3191
3192













3193





3194

3195




3196
3197
3198
3199
3200
3201



3202



3203



3204


3205


3206

3207


3208

3209


3210



3211










3212

3213




3214
3215
3216
3217
3218
3219
3220


3221


3222




3223


3224















3225

3226
3227
3228
3229

3230
3231
3232

3233

3234

3235






3236

3237

3238
3239

3240
3241




3242


3243









3244
3245
3246
3247
3248
3249
3250

3251
3252
3253
































3254

3255






3256


3257




3258
3259
3260
3261
3262
3263
3264

.endset:
        test    eax, eax
        pop     esi edx ecx ebx
        return
endp






















; Arguments:




;
; Returns:
; CF=0
;    eax - number of the line
;    edx - offset inside the line
; CF=1



;    the pixel is outside the client area.



;



proc TFreshEdit.__PixelToCaretPos, .editor, .x, .y


begin


        push    ebx ecx esi edi




        xor     ecx, ecx

        mov     esi, [.editor]






; x










        mov     eax, [.y]

        mov     edx, [esi+TFreshEdit._FreeArea.y]




        cmp     eax, edx
        jl      .nomove

        add     edx, [esi+TFreshEdit._FreeArea.height]
        cmp     eax, edx
        jge     .nomove



        mov     eax, [.x]


        mov     edx, [esi+TFreshEdit._FreeArea.x]




        cmp     eax, edx


        jl      .nomove

















        add     edx, [esi+TFreshEdit._FreeArea.width]
        cmp     eax, edx
        jge     .nomove


        sub     eax, [esi+TFreshEdit.__LeftMargin]
        jge     @f
        xor     eax, eax

@@:

        cdq

        idiv    [esi+TFreshEdit._fontwidth]






        add     eax, [esi+TFreshEdit._LeftColumn]



        push    eax
; y

        mov     eax, [.y]
        cdq




        idiv    [esi+TFreshEdit._fontheight]












        add     eax, [esi+TFreshEdit._TopLine]
        pop     edx
        clc

.finish:
        pop     edi esi ecx ebx
        return


.nomove:
        stc
































        jmp     .finish

endp


















proc TFreshEdit.__FixLength, .editor, .newlen, .oldlen
begin
        push    eax ecx edx esi edi
3854
3855
3856
3857
3858
3859
3860

3861
3862
3863
3864
3865
3866
3867
        mov     [esi+TFreshEdit._pLengths], edx

        pop     edi esi edx ecx eax
        return
endp




proc TFreshEdit.__ComputeLeftMargin, .editor
begin
        pushad
        mov     esi, [.editor]
        xor     ebx, ebx
        mov     [esi+TFreshEdit.__NumberMargin], ebx







>







3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
        mov     [esi+TFreshEdit._pLengths], edx

        pop     edi esi edx ecx eax
        return
endp




proc TFreshEdit.__ComputeLeftMargin, .editor
begin
        pushad
        mov     esi, [.editor]
        xor     ebx, ebx
        mov     [esi+TFreshEdit.__NumberMargin], ebx
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012

4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025







4026
4027
4028
4029
4030


4031




4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
proc TFreshEdit.__FoldZoneLen, .editor, .index
.result dd ?
begin
        pushad

        mov     [.result], 0

        mov     esi, [.editor]
        mov     edi, [esi+TFreshEdit._pLines]
        mov     edx, [esi+TFreshEdit._pIndex]

        mov     eax, [.index]
        cmp     eax, [edx+TArray.count]
        jae     .finish

        mov     ecx, [edx+TArray.array+4*eax]   ; index of the first element.
        shl     ecx, TEditorLine.shift
        mov     ebx, [edi+TArray.array+ecx+TEditorLine.fold_level]

.loop:
        inc     [.result]
        inc     eax
        cmp     eax, [edx+TArray.count]
        je      .finish

        mov     ecx, [edx+TArray.array+4*eax]
        cmp     ecx, -1
        je      .loop

        shl     ecx, TEditorLine.shift

        cmp     [edi+TArray.array+ecx+TEditorLine.fold_level], ebx
        jb      .finish
        ja      .loop

        test    [edi+TArray.array+ecx+TEditorLine.flags], lfFoldHeader
        jz      .loop

.finish:
        popad
        mov     eax, [.result]
        return
endp


proc TFreshEdit.__RestoreIndex, .editor, .start_index, .end_index
begin
        pushad

        mov     esi, [.editor]
        mov     edi, [esi+TFreshEdit._pIndex]

        mov     eax, [.start_index]
        mov     edx, [.end_index]

        mov     ebx, [edi+TArray.array+4*edx]
        mov     ecx, [edi+TArray.array+4*eax]   ; index of the first element
        sub     ebx, ecx
        dec     ebx
        jz      .finish

        stdcall InsertArrayItems, [esi+TFreshEdit._pIndex], edx, ebx
        mov     [esi+TFreshEdit._pIndex], edx

        add     [.end_index], ebx

.fill_loop:
        inc     ecx
        mov     [eax], ecx
        add     eax, 4
        dec     ebx
        jnz     .fill_loop

        mov     ecx, [.end_index]

.format_loop:
        execute esi, TFreshEdit.FormatLine, ecx
        dec     ecx
        cmp     ecx, [.start_index]
        jne     .format_loop

.finish:
        popad
        return
endp


proc TFreshEdit.__AddFormatLine, .hstring, .format
begin
        test    [.format], lfBookmark or lfWordWrap or lfProtected
        jz      .format_ok

        stdcall StrCharCat, [.hstring], ';#F:'

        test    [.format], lfBookmark
        jz      @f
        stdcall StrCharCat, [.hstring], 'b'    ; ctrl-B == Bookmark
@@:
        test    [.format], lfWordWrap
        jz      @f
        stdcall StrCharCat, [.hstring], 'w'   ; ctrl-A == Word wrap
@@:
        test    [.format], lfProtected
        jz      @f
        stdcall StrCharCat, [.hstring], 'p'   ; ctrl-D == Protected
@@:

        stdcall StrCharCat, [.hstring], $0a0d

.format_ok:
        return
endp


; decodes format line (begining with ';#F:')
; returns:
;       CF=0 if the line contains format information.
;            eax - format flags
;            ecx - format line length;
;








proc TFreshEdit.__DecodeFormatLine, .pString
begin
        push    ebx esi



        mov     esi, [.pString]





        lodsb
        cmp     al, ';'
        jne     .not_format
        lodsb
        cmp     al, '#'
        jne     .not_format
        lodsb
        cmp     al, 'F'
        jne     .not_format
        lodsb
        cmp     al, ':'
        jne     .not_format

        xor     ebx, ebx

.format_loop:
        lodsb
        test    al, al
        jz      .not_format

        cmp     al, $0d
        je      .eol
        cmp     al, $0a
        je      .eol

        cmp     al, 'b'
        jne     @f
        or      ebx, lfBookmark
        jmp     .format_loop
@@:







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|








<
<
<

<
<

<
<

<
<
<
<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







|













>













>
>
>
>
>
>
>





>
>

>
>
>
>


















<
|

|
<
<







3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418



3419


3420


3421





3422
























3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494

3495
3496
3497


3498
3499
3500
3501
3502
3503
3504
proc TFreshEdit.__FoldZoneLen, .editor, .index
.result dd ?
begin
        pushad

        mov     [.result], 0

;        mov     esi, [.editor]
;        mov     edi, [esi+TFreshEdit._pLines]
;        mov     edx, [esi+TFreshEdit._pIndex]
;
;        mov     eax, [.index]
;        cmp     eax, [edx+TArray.count]
;        jae     .finish
;
;        mov     ecx, [edx+TArray.array+4*eax]   ; index of the first element.
;        shl     ecx, TEditorLine.shift
;        mov     ebx, [edi+TArray.array+ecx+TEditorLine.fold_level]
;
;.loop:
;        inc     [.result]
;        inc     eax
;        cmp     eax, [edx+TArray.count]
;        je      .finish
;
;        mov     ecx, [edx+TArray.array+4*eax]
;        cmp     ecx, -1
;        je      .loop
;
;        shl     ecx, TEditorLine.shift
;
;        cmp     [edi+TArray.array+ecx+TEditorLine.fold_level], ebx
;        jb      .finish
;        ja      .loop
;
;        test    [edi+TArray.array+ecx+TEditorLine.flags], lfFoldHeader
;        jz      .loop

.finish:
        popad
        mov     eax, [.result]
        return
endp












































proc TFreshEdit.__AddFormatLine, .hstring, .format
begin
        test    [.format], lfBookmark or lfWordWrap or lfProtected
        jz      .format_ok

        stdcall StrCharCat, [.hstring], ';'

        test    [.format], lfBookmark
        jz      @f
        stdcall StrCharCat, [.hstring], 'b'    ; ctrl-B == Bookmark
@@:
        test    [.format], lfWordWrap
        jz      @f
        stdcall StrCharCat, [.hstring], 'w'   ; ctrl-A == Word wrap
@@:
        test    [.format], lfProtected
        jz      @f
        stdcall StrCharCat, [.hstring], 'p'   ; ctrl-D == Protected
@@:
        stdcall StrCharCat, [.hstring], ':F#;'
        stdcall StrCharCat, [.hstring], $0a0d

.format_ok:
        return
endp


; decodes format line (begining with ';#F:')
; returns:
;       CF=0 if the line contains format information.
;            eax - format flags
;            ecx - format line length;
;

; decodes format line (ending with ':F#;')
; returns:
;       CF=0 if the line contains format information.
;            eax - format flags
;            ecx - format line length;
;

proc TFreshEdit.__DecodeFormatLine, .pString
begin
        push    ebx esi

        std

        mov     esi, [.pString]
        mov     ecx, [esi+string.len]
        jecxz   .not_format

        lea     esi, [esi+ecx-1]

        lodsb
        cmp     al, ';'
        jne     .not_format
        lodsb
        cmp     al, '#'
        jne     .not_format
        lodsb
        cmp     al, 'F'
        jne     .not_format
        lodsb
        cmp     al, ':'
        jne     .not_format

        xor     ebx, ebx

.format_loop:
        lodsb

        jecxz   .eol

        cmp     al, ';'


        je      .eol

        cmp     al, 'b'
        jne     @f
        or      ebx, lfBookmark
        jmp     .format_loop
@@:
4071
4072
4073
4074
4075
4076
4077

4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093

4094
4095
4096
4097






4098
4099

        jmp     .format_loop
@@:

.not_format:
        xor     eax, eax
        pop     esi ebx
        stc

        return

.eol:
        mov     ah, al
        xor     ah, $0a xor $0d
        lodsb
        cmp     al, ah
        je      .format_ok
        dec     esi

.format_ok:
        sub     esi, [.pString]
        mov     ecx, esi
        mov     eax, ebx
        pop     esi ebx
        clc

        return
endp








endmodule









>



<
<
<
<
<
<
<
<





>




>
>
>
>
>
>


>
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523








3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
        jmp     .format_loop
@@:

.not_format:
        xor     eax, eax
        pop     esi ebx
        stc
        cld
        return

.eol:








        sub     esi, [.pString]
        mov     ecx, esi
        mov     eax, ebx
        pop     esi ebx
        clc
        cld
        return
endp








endmodule


Added freshlib/FreshEdit/FreshEdit2.asm.





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882

include "FreshEditThemes.asm"
include "LineProcessors.asm"


ObjectClass FreshEdit,                   \
            ScrollWindow,                \
            TFreshEdit.Create,           \
            TFreshEdit.Destroy,          \
            TFreshEdit.Get,              \
            TFreshEdit.Set,              \
            TFreshEdit.ExecCmd,          \
            TFreshEdit.SysEventHandler


; values for ._EditorMode field
femSelBlock   = 1
femOverwrite  = 2



object TFreshEdit, TScrollWindow

; system font sizes (used for additional texts and line numbers)
  ._Font2           dd  ?   ; Supplementary font.

  ._fontwidth2      dd  ?   ; in pixels.
  ._fontheight2     dd  ?   ; in pixels.
  ._fontdescent2    dd  ?   ; in pixels.


; Shadow object for double buffered paint and other paint related fields.

  ._pShadow         dd  ?   ; pointer to TBackBuffer object.
  ._fShadowValid    dd  ?   ; the shadow buffer is valid and should not be repainted.

; Text related data structures.

  ._pLines          dd  ?   ; TArray of dword pointers to TEditorLine structures.
  ._pLengths        dd  ?   ; TArray with count of the lines of given width (in pixels).
                            ; It is needed for horizontal scrollbar adjustment.

; when non textual lines are selected, the entire lines should be selected actually.
  ._CaretLine       dd  ?   ; index of the line where caret resides.
  ._CaretChar       dd  ?   ; char of the line where caret resides. It can be bigger than the line length.

  ._SelLine         dd  ?   ; index of the line where selection starts.
  ._SelChar         dd  ?   ; char of the line where selection starts.

  ._WrapX           dd  ?   ; X coordinate (in pixels) where the lines should be word wraped.


  .__LeftMargin     dd  ?   ; width of the left margin field.
  .__NumberMargin   dd  ?

; Syntax highlighter

  ._procSyntax      dd  ?   ; procedure for syntax highlighting.


; params of TFreshEdit

; methods of TFreshEdit

; internal methods

  method .__DrawShadow
  method .__ComputeLeftMargin

; public methods
  method .Clear    ; clears the text of the editor.

  method .AppendLine, .hText    ; appends the line at the end of the text.
  method .LoadFromFile, .hFilename

endobj




; TEditorLine.flags

lfBookmark    = 1        ; the line have bookmark set.
lfProtected   = 2        ; the line can not be edited.
lfWordWrap    = 4        ; the line must be word wrapped.
lfBreakpoint  = 8        ; set breakpoint in debug mode.

lfFormatted   = $10

struct TEditorLine
  .pProcessor   dd  ?   ; pointer to TLineProcessor structure, that will process this line.

  .pData        dd  ?   ; internal representation of the line data.
                        ; Can differs for different types of lines.
                        ; the canonical content of this field is a handle of string with the text
                        ; of the line in UTF-8 encoding. All editors must understand this type
                        ; and to convert back to it.

  .LineY        dd  ?   ; Y coordinate of the line in pixels inside the document.
  .LineH        dd  ?   ; Height of the line in pixels.

  .flags        dd  ?

  .syn_context  dd  ?
  .debug_data   dd  ?

  .pRenderInfo  dd  ?   ; pointer to some internal rendering info for this line.
                        ; this array must exists only when the line is inside the
                        ; visible window.
ends




;_______________________________________________________________________________________________

proc TFreshEdit.Create, .pobj
begin
        mov     ebx, [.pobj]

        mov     [ebx+TFreshEdit._cursor], mcText
        mov     [ebx+TFreshEdit._WrapX], 640

        stdcall CreateBackBuffer, [ebx+TFreshEdit.handle], 1, 1
        mov     [ebx+TFreshEdit._pShadow], eax

        execute ebx, TFreshEdit.Clear


        clc
        return
endp



;_______________________________________________________________________________________________



proc TFreshEdit.Destroy, .pobj
begin
        mov     ebx, [.pobj]

        execute ebx, TFreshEdit.Clear

; destroy arrays.
        stdcall FreeMem, [ebx+TFreshEdit._pLines]
        stdcall FreeMem, [ebx+TFreshEdit._pLengths]

; destroy the shadow buffer.
        stdcall DestroyBackBuffer, [ebx+TFreshEdit._pShadow]

        clc
        return
endp



;_______________________________________________________________________________________________



dproc TFreshEdit.Get, .pobj, .paramID
begin
        mov     ecx, [.pobj]

        dispatch [.paramID]
        stc
        return
enddp



;_______________________________________________________________________________________________




dproc TFreshEdit.Set, .pobj, .paramID, .value
begin
        pushad

        mov     esi, [.pobj]
        mov     ebx, [.value]

        dispatch [.paramID]

.continue:
        stc
        popad
        return

enddp



;_______________________________________________________________________________________________



dproc TFreshEdit.ExecCmd, .self, .method
begin
        pushad
        mov     esi, [.self]

        dispatch [.method]
        stc
        popad
        return

oncase TFreshEdit.LoadFromFile
virtual at ebx
  .hFilename dd ?
end virtual
        execute esi, TFreshEdit.Clear

        stdcall FileOpen, [.hFilename]
        jc      .error

        mov     edx, eax

.load_loop:
        stdcall FileReadLine, edx
        jc      .error_close

        test    eax, eax
        jz      .end_of_file

        push    eax
        execute esi, TFreshEdit.AppendLine, eax
        stdcall StrDel ; from the stack.
        jmp     .load_loop

.end_of_file:
        stdcall FileClose, edx
        mov     [esi+TFreshEdit._fShadowValid], 0

        popad
        xor     eax, eax
        clc
        return

.error_close:
        stdcall FileClose, edx
        mov     [esi+TFreshEdit._fShadowValid], 0

.error:
        mov     [esp+4*regEAX], eax
        popad
        clc
        return

;..............................................................................................

oncase TFreshEdit.AppendLine
virtual at ebx
  .hText dd ?
end virtual

        stdcall GetMem, sizeof.TEditorLine
        mov     edi, eax

; append the line to the text...
        stdcall AddArrayItems, [esi+TFreshEdit._pLines], 1
        mov     [esi+TFreshEdit._pLines], edx
        mov     [eax], edi

        mov     [edi+TEditorLine.pProcessor], lprTextLine

        stdcall textLineCreate, edi, [.hText]

        xor     edx, edx

        mov     ebx, [esi+TFreshEdit._pLines]
        mov     eax, [ebx+TArray.count]
        cmp     eax, 1
        je      .coor_ok

        mov     eax, [ebx+TArray.array+4*eax-8]
        mov     edx, [eax+TEditorLine.LineY]
        add     edx, [eax+TEditorLine.LineH]

.coor_ok:
        mov     [edi+TEditorLine.LineY], edx
        mov     [edi+TEditorLine.LineH], 16

        stdcall TFreshEdit.__UpdateScrollbars

        clc
        popad
        return

;..............................................................................................


oncase TFreshEdit.Clear

        mov     ebx, [esi+TFreshEdit._pLines]
        test    ebx, ebx
        jz      .endclr1

        mov     ecx, [ebx+TArray.count]

.clrloop:
        dec     ecx
        js      .endclr

        mov     edi, [ebx+TArray.array+4*ecx]

        mov     edx, [edi+TEditorLine.pProcessor]
        test    edx, edx
        jz      .line_ok
        stdcall [edx+TLineProcessor.__Free], edi
.line_ok:
        stdcall FreeMem, edi
        mov     [ebx+TArray.array+4*ecx], 0
        jmp     .clrloop

.endclr:
        stdcall FreeMem, ebx

.endclr1:
        mov     eax, [esi+TFreshEdit._pLengths]
        test    eax, eax
        jz      .all_cleared
        stdcall FreeMem, eax

.all_cleared:
        stdcall CreateArray, 4
        mov     [esi+TFreshEdit._pLines], eax

        stdcall CreateArray, 4
        mov     [esi+TFreshEdit._pLengths], eax

        xor     eax, eax
        mov     [esi+TFreshEdit._fShadowValid], eax
        mov     [esi+TFreshEdit._CaretLine], eax
        mov     [esi+TFreshEdit._CaretChar], eax
        mov     [esi+TFreshEdit._SelLine], eax
        mov     [esi+TFreshEdit._SelChar], eax

        clc
        popad
        return


;..............................................................................................


oncase TFreshEdit.__ComputeLeftMargin

        xor     ebx, ebx
        mov     [esi+TFreshEdit.__NumberMargin], ebx

        test    [FreshEditTheme.Options], eoLeftMargin
        jz      .marginok

        test    [FreshEditTheme.Options], eoLineNumbers
        jz      .marginok1

        mov     eax, [esi+TFreshEdit._pLines]
        mov     eax, [eax+TArray.count]
        test    eax, eax
        jz      .marginok1
        mov     ecx, 10

.digits:
        add     ebx, [esi+TFreshEdit._fontwidth2]
        cdq
        div     ecx
        test    eax, eax
        jnz     .digits

        mov     [esi+TFreshEdit.__NumberMargin], ebx

.marginok1:
        add     ebx, 17+11+3+1 ; 17px breakpoints and other icons; 11px fold tree; 3px word-wrap cut; 1px whitespace at the begining of the line.

.marginok:
        xchg    [esi+TFreshEdit.__LeftMargin], ebx
        cmp     ebx, [esi+TFreshEdit.__LeftMargin]
        je      .end_clm


.end_clm:
        clc
        popad
        return

;..............................................................................................



oncase TFreshEdit.__DrawShadow
locals
  .context dd ?
  .clip    TBounds
  .line    dd ?
endl
        execute esi, TFreshEdit.__ComputeLeftMargin

        mov     edi, [esi+TFreshEdit._pShadow]
        stdcall AllocateContext, [edi+TBackBuffer.raster]
        mov     [.context], eax

        mov     eax, [edi+TBackBuffer.width]
        sub     eax, [esi+TFreshEdit.__LeftMargin]
        mov     [.clip.width], eax
;        stdcall DrawFillRect, [.context], [esi+TFreshEdit.__LeftMargin], 0, eax, [edi+TBackBuffer.height], [FreshEditTheme.clBackground]

        mov     ecx, [esi+TFreshEdit.__LeftMargin]
        mov     edx, [edi+TBackBuffer.height]
        mov     [.clip.x], ecx
        mov     [.clip.height], edx
        mov     [.clip.y], 0

        lea     eax, [.clip]
        stdcall SetClipRectangle, [.context], eax

        mov     ebx, [esi+TFreshEdit._pLines]
        mov     edx, [esi+TFreshEdit._VScroller.Pos]

; search the first line

        stdcall __SearchLine, ebx, edx
        jc      .end_draw_lines

; ecx - index of the line.
; edx - offset inside the line.
        neg    edx

.line_loop:

        mov     eax, [FreshEditTheme.clBackground]
        test    [FreshEditTheme.Options], eoStripedBackground
        jz      .color_ok
        test    ecx, 1
        jz      .color_ok
        mov     eax, [FreshEditTheme.clAltBack]
.color_ok:
        push    eax

        mov     eax, [ebx+TArray.array+4*ecx]
        stdcall DrawFillRect, [.context], 0, edx, [edi+TBackBuffer.width], [eax+TEditorLine.LineH] ; color from the stack

        add     [.clip.x], 2
        sub     [.clip.width], 2
        lea     eax, [.clip]
        stdcall SetClipRectangle, [.context], eax

        push    edx             ; Y

        mov     eax, [esi+TFreshEdit._HScroller.Pos]
        neg     eax
        add     eax, [esi+TFreshEdit.__LeftMargin]
        add     eax, 2
        push    eax             ; X

        mov     eax, [ebx+TArray.array+4*ecx]
        push    eax

        mov     [.line], eax

        mov     eax, [eax+TEditorLine.pProcessor]
        stdcall [eax+TLineProcessor.Draw], [.context] ; remaining parameters from the stack...

        mov     eax, [.line]
        add     edx, [eax+TEditorLine.LineH]    ; the Draw procedure can changes the line height
                                                ; that is why the change of the Y coordinate
                                                ; should be after draw call.

        sub     [.clip.x], 2
        add     [.clip.width], 2
        lea     eax, [.clip]
        stdcall SetClipRectangle, [.context], eax

        cmp     edx, [edi+TBackBuffer.height]
        jae     .end_draw_lines

        inc     ecx
        cmp     ecx, [ebx+TArray.count]
        jb      .line_loop

; clear to the end of the screen...

        mov     eax, [edi+TBackBuffer.height]
        sub     eax, edx

        stdcall DrawFillRect, [.context], 0,edx, [edi+TBackBuffer.width], eax, [FreshEditTheme.clAfterBackground]

.end_draw_lines:
        mov     eax, [esi+TFreshEdit._WrapX]
        sub     eax, [esi+TFreshEdit._HScroller.Pos]
        add     eax, [esi+TFreshEdit.__LeftMargin]
        add     eax, 2

        stdcall SetSimpleLine, [.context], [FreshEditTheme.clWrapColumn]
        stdcall DrawLine, [.context], eax, 0, eax, [edi+TBackBuffer.height]

        xor     eax, eax
        xchg    eax, [.clip.x]
        test    eax, eax
        jz      .left_ok

        mov     [.clip.width], eax

        lea     eax, [.clip]
        stdcall SetClipRectangle, [.context], eax

        stdcall DrawFillRect, [.context], 0, 0, [esi+TFreshEdit.__LeftMargin], [edi+TBackBuffer.height], [FreshEditTheme.clLeftMargin]

        stdcall SetSimpleLine, [.context], [FreshEditTheme.clLeftMarginBorder]
        mov     eax, [esi+TFreshEdit.__LeftMargin]
        dec     eax
        stdcall DrawLine, [.context], eax, 0, eax, [edi+TBackBuffer.height]

.left_ok:
        stdcall ReleaseContext, [.context]

        clc
        popad
        return
enddp



;_______________________________________________________________________________________________




dproc TFreshEdit.SysEventHandler, .pobj, .pEvent
begin
        pushad

        mov     esi, [.pobj]
        mov     ebx, [.pEvent]

        dispatch [ebx+TSysEvent.event]

.continue:
        stc
        popad
        return

;..............................................................................................

oncase sePaint

        xor     eax, eax
        cmp     [esi+TFreshEdit._pShadow], eax
        je      .continue

        cmp     [esi+TFreshEdit._fShadowValid], 0
        jne     @f
        execute esi, TFreshEdit.__DrawShadow
@@:
        stdcall SetClipRectangle, [ebx+TPaintEvent.context], 0

        stdcall TScrollWindow.SysEventHandler, esi, [.pEvent]

        stdcall DrawBackBuffer, [ebx+TPaintEvent.context], [esi+TFreshEdit._pShadow], 0, 0
        clc
        popad
        return

;..............................................................................................

oncase seScroll
        cmp     [ebx+TScrollEvent.ScrollBar], scrollX
        je      .xscroll

; yscroll
        xor     edx, edx
        mov     ecx, [ebx+TScrollEvent.Value]
        cmp     [ebx+TScrollEvent.ScrollCmd], scTrack
        je      .track

        cmp     [ebx+TScrollEvent.ScrollCmd], scWheelUp
        je      .scrollwheelup
        cmp     [ebx+TScrollEvent.ScrollCmd], scWheelDn
        je      .scrollwheeldn

        cmp     [ebx+TScrollEvent.ScrollCmd], scUp
        je      .scrollup
        cmp     [ebx+TScrollEvent.ScrollCmd], scDown
        je      .scrolldn

        jmp     .continue

; scroll down
.scrollwheelup:
        neg     ecx

.scrollwheeldn:
        imul    ecx, [FreshEditTheme.MouseWheel]

.scrolldn:
.scrollup:
        mov     eax, [esi+TFreshEdit._VScroller.Pos]
        add     eax, ecx
        jns     .vsignok
        xor     eax, eax
.vsignok:
        cmp     eax, [esi+TFreshEdit._VScroller.Max]
        jbe     .vmaxok
        mov     eax, [esi+TFreshEdit._VScroller.Max]
.vmaxok:
        mov     [esi+TFreshEdit._VScroller.Pos], eax
        jmp     .refresh

.track:
;        mov     [esi+TFreshEdit._VScroller.Pos], ecx
        jmp     .refresh

.xscroll:
        jmp     .refresh


.refresh:
        mov     [esi+TFreshEdit._fShadowValid], 0
        execute esi, TWindow.Refresh
        clc
        popad
        return


;..............................................................................................

oncase seMoveResize

        stdcall TScrollWindow.SysEventHandler, esi, [.pEvent]

        cmp     [esi+TFreshEdit._pShadow], 0
        je      @f
        stdcall DestroyBackBuffer, [esi+TFreshEdit._pShadow]
@@:
        stdcall Get, esi, TScrollWindow.FreeArea        ; compute the free area.
        mov     ecx, [eax+TBounds.width]
        mov     edx, [eax+TBounds.height]

        stdcall CreateBackBuffer, [esi+TFreshEdit.handle], ecx, edx
        mov     [esi+TFreshEdit._pShadow], eax
        mov     [esi+TFreshEdit._fShadowValid], 0

        stdcall TFreshEdit.__UpdateScrollbars

        clc
        popad
        return

enddp









proc TFreshEdit.__UpdateScrollbars
begin
        push    eax ebx ecx edx

; vertical

        mov     ebx, [esi+TFreshEdit._pLines]
        mov     ecx, [ebx+TArray.count]
        test    ecx, ecx
        jz      .yok

        dec     ecx
        mov     eax, [ebx+TArray.array+4*ecx]

        mov     ecx, [eax+TEditorLine.LineY]
        add     ecx, [eax+TEditorLine.LineH]

.yok:
        mov     edx, [esi+TFreshEdit._pShadow]
        mov     edx, [edx+TBackBuffer.height]
        sub     ecx, edx
        jns     .yok2
        xor     ecx, ecx
.yok2:

        mov     [esi+TFreshEdit._VScroller.Max], ecx
        mov     [esi+TFreshEdit._VScroller.Page], edx
        cmp     [esi+TFreshEdit._VScroller.Pos], ecx
        jbe     .pos_ok
        mov     [esi+TFreshEdit._VScroller.Pos], ecx
        mov     [esi+TFreshEdit._fShadowValid], 0
.pos_ok:

; horizontal

        mov     ebx, [esi+TFreshEdit._pLengths]
        mov     eax, [ebx+TArray.count]
        mov     edx, [esi+TFreshEdit._pShadow]
        mov     edx, [edx+TBackBuffer.width]
        sub     edx, [esi+TFreshEdit.__LeftMargin]
        sub     eax, edx

        mov     eax, 1000   ; TEST ONLY!!!


        mov     [esi+TFreshEdit._HScroller.Max], eax
        mov     [esi+TFreshEdit._HScroller.Page], edx
        cmp     [esi+TFreshEdit._HScroller.Pos], eax
        jbe     @f
        mov     [esi+TFreshEdit._HScroller.Pos], eax
        mov     [esi+TFreshEdit._fShadowValid], 0
@@:
        pop     edx ecx ebx eax
        return
endp










; Computes the wrap positions for the given line of text and returns (possibly reallocated)
; array with the line wrap positions. If the line does not need wrapping - returns 0 and
; frees passed in [.pSublines] array.
;
; Arguments:
;     .Data - the string with the line text.
;     .pSublines - previously created dword array with wrap positions.
;                  the subroutine tries to use it and it is not possible, resize it accordingly.
;     .RigthMargin - width of the sublines.
;

proc __CreateSublines, .hText, .pSublines, .RightMargin
begin
        pushad

        stdcall StrPtr, [.hText]
        mov     esi, eax

        xor     edi, edi        ; count of the lines...

.outer_loop:
        xor     ebx, ebx        ; the last wrap position.
        xor     ecx, ecx        ; current x position.

.loop:
        stdcall DecodeUtf8, [esi]
        inc     ecx
        test    eax, eax
        jz      .end_string

        cmp     eax, ' '
        jne     .not_space

        lea     ebx, [esi+edx]
.next:
        add     esi, edx
        jmp     .loop

.not_space:
        cmp     ecx, [.RightMargin]
        jbe     .next

        test    ebx, ebx
        jnz     .wraphere

        mov     ebx, esi

.wraphere:
        push    ebx
        mov     esi, ebx
        inc     edi
        jmp     .outer_loop

.end_string:
        mov     esi, [.pSublines]
        test    edi, edi
        jnz     .fill_sublines

        test    esi, esi
        jz      .exit_empty

        stdcall FreeMem, esi

.exit_empty:
        popad
        xor     eax, eax
        return                          ; there is no need for pSublines


.fill_sublines:
        test    esi, esi
        jz      .allocate

        cmp     edi, [esi]
        jbe     .array_ok

        stdcall FreeMem, esi

.allocate:
        lea     eax, [4*edi+4]
        stdcall GetMem, eax
        mov     esi, eax

.array_ok:
        mov     [esi], edi

        stdcall StrPtr, [.hText]

.fill:
        popd    [esi+4*edi]
        sub     [esi+4*edi], eax
        dec     edi
        jnz     .fill

        mov     [esp+4*regEAX], esi
        popad
        return
endp





proc __SearchLine, .pLines, .y
begin
        pushad

        mov     esi, [.pLines]
        xor     ecx, ecx
        mov     edx, [esi+TArray.count]
        dec     edx

.loop:
        cmp     ecx, edx
        jg      .not_found

        lea     ebx, [ecx+edx]
        shr     ebx, 1

        mov     edi, [esi+TArray.array+4*ebx]
        mov     eax, [edi+TEditorLine.LineY]

        cmp     [.y], eax
        jl      .less

        add     eax, [edi+TEditorLine.LineH]
        cmp     [.y], eax
        jge     .more

.found:
        mov     eax, [.y]
        sub     eax, [edi+TEditorLine.LineY]
        mov     [esp+4*regECX], ebx     ; index of the line.
        mov     [esp+4*regEDX], eax     ; offset of the line.
        clc
        popad
        return

.less:
        lea     edx, [ebx-1]
        jmp     .loop

.more:
        lea     ecx, [ebx+1]
        jmp     .loop

.not_found:
        stc
        popad
        return
endp





Added freshlib/FreshEdit/FreshEditTest.asm.









































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
include "%lib%/freshlib.inc"

@BinaryType GUI

options.DebugMode = 0

include '%lib%/freshlib.asm'

include 'FreshEdit2.asm'
include "fasm_syntax.asm"

iglobal
frmMainForm:
        ObjTemplate  tfParent or tfEnd, Form, frmMain, \
                     x, 100,        \
                     y, 50,         \
                     width, 640,    \
                     height, 480,   \
                     borderKind, borderFull,    \
                     Visible, TRUE, \
                     Caption, 'FreshEdit test application.'

        ObjTemplate  tfParent, Form, Toolbar,           \
                     x, 0, y, 0,                        \
                     width, 100, height, 20,            \
                     Align, waBottom,                   \
                     borderKind, borderNone,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnOpen,  \
                     x, 112, y, 2,                        \
                     width, 64, height, 21,            \
                     Align, waLeft,                     \
                     Caption, 'Open',                   \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnOpenFile,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnSave,  \
                     x, 180, y, 2,                     \
                     width, 64, height, 21,            \
                     Align, waLeft,                     \
                     Caption, 'Save',                   \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnSaveFile,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnNumbers,  \
                     x, 180, y, 2,                     \
                     width, 21, height, 21,            \
                     Align, waLeft,                     \
                     Caption, '#',                  \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnNumbers,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnZebra,  \
                     x, 180, y, 2,                     \
                     width, 21, height, 21,            \
                     Align, waLeft,                     \
                     Caption, 'Z',                  \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnZebra,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnTheme,  \
                     x, 180, y, 2,                     \
                     width, 21, height, 21,            \
                     Align, waLeft,                     \
                     Caption, 'T',                  \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnTheme,         \
                     Visible, TRUE

        ObjTemplate  tfEnd, Edit, FilenameEdit,         \
                     x, 2, y, 2,                        \
                     width, 100, height, 21,            \
                     Align, waClient,                     \
                     Visible, TRUE

        ObjTemplate tfEnd, FreshEdit, Editor,   \
                    Visible, TRUE,              \
                    x, 8, y, 8,                 \
                    width, 624, height, 464,    \
                    Align, waClient

  SampleText file 'unicode_test.txt'
             dd   0

endg


;--------------------------------------------------------------------------

start:
        InitializeAll

; TEST CODE - to be removed later ---------------------------------------
        stdcall Output, '00000000001111111111222222222233333333334444444444555555555566666666667777777777'
        stdcall Output, <'01234567890123456789012345678901234567890123456789012345678901234567890123456789',13, 10>

        stdcall PrintWrappedLine, cTestString, 25
        stdcall PrintWrappedLine, cTestString2, 25
        stdcall PrintWrappedLine, cTestString2, 60

; END OF THE TEST CODE ---------------------------------------------------


        stdcall Create, CApplication
        jc      .start_error
        mov     [pApplication], ebx

        stdcall [lprTextLine.Initialize]

        stdcall CreateFromTemplate, frmMainForm, 0
        mov     ecx, [pApplication]
        mov     [ecx+TApplication.MainWindow], frmMain

        execute [Editor], TFreshEdit.LoadFromFile, 'unicode_test.txt'

        execute [Editor], TFreshEdit.AppendLine, 'This is Test line'
        execute [Editor], TFreshEdit.AppendLine, 'This is Test line number 2'
        execute [Editor], TFreshEdit.AppendLine, 'This is the third test line.'

        stdcall Set, [Editor], TFreshEdit._procSyntax, SyntaxFASM
;        stdcall Set, [Editor], TFreshEdit.OnControlKey, procKeyPress
;        stdcall Set, [Editor], TFreshEdit.Text, SampleText


; TEST CODE - to be removed later ---------------------------------------
        stdcall SaveTheme, 'test.cfg', FreshEditTheme, pThemePath1
        stdcall TFETheme.SetDefaultThemeClassic, FreshEditTheme
        stdcall SaveTheme, 'test.cfg', FreshEditTheme, pThemePath2

iglobal
  pThemePath1 dd 'EThm', 'tWin', 0
  pThemePath2 dd 'EThm', 'tCls', 0
endg
; END OF THE TEST CODE ---------------------------------------------------


        stdcall Run

.terminate:
        stdcall [lprTextLine.Finalize]

        FinalizeAll
        stdcall Terminate, 0

.start_error:
        DebugMsg "Can't create application object."
        jmp      .terminate



var FreshEditSetTheme = TFETheme.SetDefaultThemeWindows


proc OnTheme, .self, .mousebtn
begin
        xor     [FreshEditSetTheme], TFETheme.SetDefaultThemeWindows xor TFETheme.SetDefaultThemeClassic
        stdcall [FreshEditSetTheme], FreshEditTheme
        xor     [SynTheme], fasm_colors_classic xor fasm_colors_windows
        execute [Editor], TFreshEdit.Refresh
        return
endp


proc OnZebra, .self, .mousebtn
begin
        xor     [FreshEditTheme.Options], eoStripedBackground
        execute [Editor], TFreshEdit.Refresh
        return
endp


proc OnNumbers, .self, .mousebtn
begin
        xor     [FreshEditTheme.Options], eoLineNumbers
        execute [Editor], TFreshEdit.Refresh
        return
endp


cErrorTitleOpen text "Error open file."
cErrorTitleSave text "Error save file."

proc OnSaveFile, .self, .mousebtn
begin
        pushad

;        stdcall Get, [FilenameEdit], TEdit.Text
;        push    eax
;        stdcall StrPtr, eax
;        mov     edi, eax
;
;        stdcall Get, [Editor], TFreshEdit.Text
;        jc      .finish
;
;        push    eax
;        stdcall StrPtr, eax
;
;        stdcall SaveBinaryFile, edi, eax, [eax+string.len]
;        jnc     .end_save
;
;        stdcall GetErrorString, eax
;        mov     esi, eax
;        stdcall ShowMessage, [frmMain], smiError, cErrorTitleSave, esi, smbOK
;        stdcall FreeErrorString, esi
;
;.end_save:
;        stdcall StrDel ; from the stack
;.finish:
;        stdcall StrDel ; from the stack
        popad
        return
endp


proc OnOpenFile, .self, .mousebtn
begin
        pushad
; Load test file
;        stdcall Get, [FilenameEdit], TEdit.Text
;        push    eax
;
;        stdcall StrPtr, eax
;        stdcall LoadBinaryFile, eax
;        jnc     .loaded
;
;        stdcall GetErrorString, eax
;        mov     esi, eax
;        stdcall ShowMessage, [frmMain], smiError, cErrorTitleOpen, esi, smbOK
;        stdcall FreeErrorString, esi
;        jmp     .exit
;
;.loaded:
;        push    eax
;        stdcall Set, [Editor], TFreshEdit.Text, eax
;        stdcall FreeMem ; from the stack
;
;.exit:
;        stdcall StrDel ; from the stack
;
;        mov     eax, [Editor]
;        mov     [eax+TFreshEdit._xCaret], 0
;        mov     [eax+TFreshEdit._yCaret], 0
;        mov     [eax+TFreshEdit._xSelection], 0
;        mov     [eax+TFreshEdit._ySelection], 0
;
;;        stdcall ParseFolding, [eax+TFreshEdit._pLines]
;
;        execute [Editor], TFreshEdit.Refresh
;        execute [Editor], TFreshEdit.Focus
        popad
        return
endp




proc procKeyPress, .self, .keyevent
begin

        return
;        mov     ebx, [.keyevent]
;
;        mov     eax, [ebx+TKeyboardEvent.key]
;
;        cmp     eax, $03        ; ctrl+C
;        je      .copy
;        cmp     eax, $16        ; ctrl+V
;        je      .paste
;        cmp     eax, 12 ; ctrl+L
;        je      .length_list
;        cmp     eax, 18 ; ctrl+R
;        je      .clipright
;        cmp     eax, 19 ; ctrl+S == save
;        je      .save
;        cmp     eax, 20 ; ctrl+T
;        je      .test_something
;
;        cmp     [ebx+TKeyboardEvent.scancode], keyF2
;        je      .toggle_breakpoint
;
;.finish:
;        mov     eax, chgfNoClearSelection
;.exit:
;        return
;
;.copy:
;        stdcall Get, [.self], TFreshEdit.Selection
;        test    eax, eax
;        jz      .end_copy
;        stdcall ClipboardWrite, eax
;        stdcall StrDel, eax
;.end_copy:
;        mov     eax, chgfNoClearSelection
;        return
;
;.paste:
;        stdcall ClipboardRead
;        test    eax, eax
;        jz      .end_paste
;
;        stdcall Set, [.self], TFreshEdit.Selection, eax
;        stdcall StrDel, eax
;
;        mov     eax, chgfNeedRefresh
;.end_paste:
;        return
;
;
;.save:
;        stdcall OnSaveFile, [.self], 0
;        xor     eax, eax
;        return
;
;.length_list:
;        xor     eax, eax
;        return
;
;.clipright:
;        stdcall Get, esi, TFreshEdit.CurrentLine
;        jc      .finish
;        stdcall StrClipSpacesR, [eax+TEditorLine.Data]
;        mov     eax, chgfNeedRefresh
;        return
;
;.test_something:
;        mov     eax, chgfNeedRefresh
;        return
;
;
;.toggle_breakpoint:
;        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
;        jne     .finish
;
;        stdcall Get, esi, TFreshEdit.CurrentLine
;        jc      .finish
;
;        xor     [eax+TEditorLine.flags], lfBreakpoint
;        mov     eax, chgfNeedRefresh or chgfNoClearSelection
;        return
;
;
;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

endp





proc PrintWrappedLine, .hString, .width
begin
        pushad

        stdcall StrPtr, [.hString]
        mov     ebx, eax

        stdcall __CreateSublines, ebx, 0, [.width]
        mov     edi, eax
        push    eax

        xor     esi, esi
        mov     ecx, [edi]
        add     edi, 4

.loop1:
        mov     eax, [edi]
        sub     eax, esi
        lea     edx, [esi+ebx]
        stdcall FileWrite, [STDOUT], edx, eax
        stdcall FileWrite, [STDOUT], cCRLF, 2
        mov     esi, [edi]
        add     edi, 4
        dec     ecx
        jnz     .loop1

        lea     edx, [esi+ebx]
        stdcall StrLen, edx
        stdcall FileWrite, [STDOUT], edx, eax
        stdcall FileWrite, [STDOUT], cCRLF, 2
        stdcall FileWrite, [STDOUT], cCRLF, 2

        stdcall FreeMem ; from the stack

        popad
        return
endp


cTestString text 'This is test string that has to be word wrapped on some position as a test ', \
                 'for the word wrap formatting procedure. This procedure creates an array ',    \
                 'with offsets to the begining of the sublines where the string has to be wrap.'
cTestString2 text 'This_is_test_string_that_has_to_be_word_wrapped_on_some_position_as_a_test_', \
                 'for_the_word_wrap_formatting_procedure._This_procedure_creates_an_array_',    \
                 'with_offsets_to_the_begining_of_the_sublines_where_the_string_has_to_be_wrap.'
cCRLF       text 13, 10


@AllImportSection
@AllDataSection

Added freshlib/FreshEdit/FreshEditTest.fpr.

cannot compute difference between binary files

Changes to freshlib/FreshEdit/FreshEditThemes.asm.

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
struct TShortcut
  .key        dd  ?     ; if .key is <> 0 the scancode and .kbdStatus are not used.
  .scancode   dd  ?
  .kbdStatus  dd  ?
  .maskStatus dd  ?     ; what bits from the kbdStatus to be compared
ends


macro Shortcut .key, .scancode, .kbdstatus, .maskstatus {
        dd  .key
        dd  .scancode
        dd  .kbdstatus
        dd  .maskstatus
}



















eoAutoIndents       = 1
eoSaveWithTabs      = 2
eoVerticalCaret     = 4
eoStripedBackground = 8
eoLeftMargin        = 16
eoLineNumbers       = 32


struct TFETheme
; colors

  .clBackground      dd ?       ; background color of the editor field.
  .clAltBack         dd ?       ; althernative background (when eoStripedBackground is true)
  .clSimpleText      dd ?       ; The default color of the text, when no syntax highlighter is attached.
  .clProtectedText   dd ?       ; the color of the protected line text.

  .clSelBack         dd ?       ;
  .clSelMode         dd ?       ;

  .clLeftMargin      dd ?       ; the color of the left margin field.
  .clLeftMarginBorder dd ?       ; left margin border color.
  .clLeftMarginText  dd ?
  .clLeftMarginTree  dd ?

  .clBookmarkBack    dd ?       ; background of the left margin when the bookmark is set.
  .clWrapColumn      dd ?       ; color of the line that marks word wrap column.






; options and behavior
  .Options           dd ?       ; flags eoLineSeparator, eoAutoIndents, eoSaveWithTabs, eoVerticalCaret
  .MouseWheel        dd ?       ; the count of the lines, one mouse wheel event scrolls.
  .WrapPos           dd ?       ; word wrap position for the lines that have lfWordWrap flag set.
  .UndoLevels        dd ?       ; how many levels of undo/redo to be remembered.

; keyboard shortcuts:

; navigation
  .shortcuts:
  .keyUp             TShortcut
  .keyDown           TShortcut







<







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
|
|
<
<

|
|

|
|
|
|

|
|

>
>
>
>
>

|
|
|
|







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
struct TShortcut
  .key        dd  ?     ; if .key is <> 0 the scancode and .kbdStatus are not used.
  .scancode   dd  ?
  .kbdStatus  dd  ?
  .maskStatus dd  ?     ; what bits from the kbdStatus to be compared
ends


macro Shortcut .key, .scancode, .kbdstatus, .maskstatus {
        dd  .key
        dd  .scancode
        dd  .kbdstatus
        dd  .maskstatus
}


ffBold       = 1
ffItalic     = 2
ffUnderlined = 4
ffStrikeOut  = 8


struct TThemeFont
  .ptrFace    dd ?       ; pointer to the font face string.
  .size       db ?       ; in pixels height.
  .flags      db ?       ; flag - normal, bold, italic, etc.
  .family     db ?       ; fixed, proportional
  .reserved   db ?

  .handle     dd ?      ; created on the first use.
ends


eoAutoIndents       = 1
eoSaveWithTabs      = 2
eoVerticalCaret     = 4
eoStripedBackground = 8
eoLeftMargin        = 16
eoLineNumbers       = 32


struct TFETheme
; colors
  .clAfterBackground  dd  ?       ; the background after the end of the text.
  .clBackground       dd  ?       ; background color of the editor field.
  .clAltBack          dd  ?       ; althernative background (when eoStripedBackground is true)



  .clSelBack          dd  ?       ; background color for selections
  .clSelAltBack       dd  ?       ; althernative background for selections (when eoStripedBackground is true)

  .clLeftMargin       dd  ?       ; the color of the left margin field.
  .clLeftMarginBorder dd  ?       ; left margin border color.
  .clLeftMarginText   dd  ?
  .clLeftMarginTree   dd  ?

  .clBookmarkBack     dd  ?       ; background of the left margin when the bookmark is set.
  .clWrapColumn       dd  ?       ; color of the line that marks word wrap column.

  .clSyntax           rd  32      ; 32 syntax colors - more than needed, but...

  .FontsSyntax        TThemeFont  ; 32 syntax fonts - more than needed, but... (640K are enough for everyone)
                      rb  31*sizeof.TThemeFont

; options and behavior
  .Options            dd  ?       ; flags eoXXXXX (see above).
  .MouseWheel         dd  ?       ; the count of the pixels, one mouse wheel event scrolls.
  .WrapPos            dd  ?       ; word wrap position for the lines that have lfWordWrap flag set.
  .UndoLevels         dd  ?       ; how many levels of undo/redo to be remembered.

; keyboard shortcuts:

; navigation
  .shortcuts:
  .keyUp             TShortcut
  .keyDown           TShortcut
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
; Control
  .ToggleInsMode     TShortcut
  .ToggleSelMode     TShortcut
  .shortcuts.count = ($ - .shortcuts)/sizeof.TShortcut
ends



















iglobal
  if used FreshEditThemeKeys
    FreshEditThemeKeys:
        ; colors

          dd    TFETheme.clBackground,          'cBKG'
          dd    TFETheme.clAltBack,             'cABK'
          dd    TFETheme.clSimpleText,          'cTXT'
          dd    TFETheme.clProtectedText,       'cPRT'
          dd    TFETheme.clSelBack,             'cSBK'
          dd    TFETheme.clSelMode,             'cSMD'
          dd    TFETheme.clLeftMargin,          'cMrg'
          dd    TFETheme.clLeftMarginBorder,    'cMBr'


































          dd    TFETheme.clLeftMarginText,      'cMTx'
          dd    TFETheme.clLeftMarginTree,      'cMTr'
          dd    TFETheme.clBookmarkBack,        'cBMB'
          dd    TFETheme.clWrapColumn,          'cWrC'

































          dd    TFETheme.Options,               'Opts'
          dd    TFETheme.MouseWheel             'nWhl'
          dd    TFETheme.WrapPos,               'WrPs'
          dd    TFETheme.UndoLevels,            'UdLv'

        ; keyboard shortcuts:
        ; navigation
          dd    TFETheme.keyUp,                 'kkUp'
          dd    TFETheme.keyDown,               'kkDn'
          dd    TFETheme.keyLeft,               'kLft'
          dd    TFETheme.keyRight,              'kRgt'
          dd    TFETheme.keyPgUp,               'kPUp'
          dd    TFETheme.keyPgDn,               'kPDn'
          dd    TFETheme.keyHome,               'kHom'
          dd    TFETheme.keyEnd,                'kEnd'
          dd    TFETheme.keyPageBegin,          'kPgB'
          dd    TFETheme.keyPageEnd,            'kPgE'
          dd    TFETheme.keyTextBegin,          'kTxB'
          dd    TFETheme.keyTextEnd,            'kTxE'
          dd    TFETheme.keyWordLeft,           'kWdL'
          dd    TFETheme.keyWordRight,          'kWdR'

        ; Edit
          dd    TFETheme.Delete,                'kDel'
          dd    TFETheme.DelLine,               'kDLn'
          dd    TFETheme.Backspace,             'kBkS'

        ; Formating
          dd    TFETheme.ToggleWordWrap,        'kWWr'
          dd    TFETheme.ToggleBookmark,        'kBkm'
          dd    TFETheme.ToggleInsMode,         'kIMd'
          dd    TFETheme.ToggleSelMode,         'kSMd'
          dd    0
  end if
endg



iglobal







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




>
|
|
<
<
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
|
|
|



|
|
|
|
|
|
|
|
|
|
|
|
|
|


|
|
|


|
|
|
|







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
; Control
  .ToggleInsMode     TShortcut
  .ToggleSelMode     TShortcut
  .shortcuts.count = ($ - .shortcuts)/sizeof.TShortcut
ends


struct TCfgInfo
  .key    dd ?
  .offset dw ?
  .type   dw ?
ends


macro cfginfo  offset, key, type {
      dd key
      dw offset
      dw type
}

cfgInteger = 0
cfgFont    = 1
cfgShortcut = 2

iglobal
  if used FreshEditThemeKeys
    FreshEditThemeKeys:
        ; colors
          cfginfo    TFETheme.clAfterBackground,     'cAFB', cfgInteger
          cfginfo    TFETheme.clBackground,          'cBKG', cfgInteger
          cfginfo    TFETheme.clAltBack,             'cABK', cfgInteger


          cfginfo    TFETheme.clSelBack,             'cSBK', cfgInteger
          cfginfo    TFETheme.clSelAltBack,          'cSAB', cfgInteger
          cfginfo    TFETheme.clLeftMargin,          'cMrg', cfgInteger
          cfginfo    TFETheme.clLeftMarginBorder,    'cMBr', cfgInteger
          cfginfo    TFETheme.clLeftMarginText,      'cMTx', cfgInteger
          cfginfo    TFETheme.clLeftMarginTree,      'cMTr', cfgInteger
          cfginfo    TFETheme.clBookmarkBack,        'cBMB', cfgInteger
          cfginfo    TFETheme.clWrapColumn,          'cWrC', cfgInteger

          cfginfo    TFETheme.clSyntax,              'cS00', cfgInteger
          cfginfo    TFETheme.clSyntax+4,            'cS01', cfgInteger
          cfginfo    TFETheme.clSyntax+8,            'cS02', cfgInteger
          cfginfo    TFETheme.clSyntax+12,           'cS03', cfgInteger
          cfginfo    TFETheme.clSyntax+16,           'cS04', cfgInteger
          cfginfo    TFETheme.clSyntax+20,           'cS05', cfgInteger
          cfginfo    TFETheme.clSyntax+24,           'cS06', cfgInteger
          cfginfo    TFETheme.clSyntax+28,           'cS07', cfgInteger
          cfginfo    TFETheme.clSyntax+32,           'cS08', cfgInteger
          cfginfo    TFETheme.clSyntax+36,           'cS09', cfgInteger
          cfginfo    TFETheme.clSyntax+40,           'cS10', cfgInteger
          cfginfo    TFETheme.clSyntax+44,           'cS11', cfgInteger
          cfginfo    TFETheme.clSyntax+48,           'cS12', cfgInteger
          cfginfo    TFETheme.clSyntax+52,           'cS13', cfgInteger
          cfginfo    TFETheme.clSyntax+56,           'cS14', cfgInteger
          cfginfo    TFETheme.clSyntax+60,           'cS15', cfgInteger
          cfginfo    TFETheme.clSyntax+64,           'cS16', cfgInteger
          cfginfo    TFETheme.clSyntax+68,           'cS17', cfgInteger
          cfginfo    TFETheme.clSyntax+72,           'cS18', cfgInteger
          cfginfo    TFETheme.clSyntax+76,           'cS19', cfgInteger
          cfginfo    TFETheme.clSyntax+80,           'cS20', cfgInteger
          cfginfo    TFETheme.clSyntax+84,           'cS21', cfgInteger
          cfginfo    TFETheme.clSyntax+88,           'cS22', cfgInteger
          cfginfo    TFETheme.clSyntax+92,           'cS23', cfgInteger
          cfginfo    TFETheme.clSyntax+96,           'cS24', cfgInteger
          cfginfo    TFETheme.clSyntax+100,          'cS25', cfgInteger
          cfginfo    TFETheme.clSyntax+104,          'cS26', cfgInteger
          cfginfo    TFETheme.clSyntax+108,          'cS27', cfgInteger
          cfginfo    TFETheme.clSyntax+112,          'cS28', cfgInteger
          cfginfo    TFETheme.clSyntax+116,          'cS29', cfgInteger
          cfginfo    TFETheme.clSyntax+120,          'cS30', cfgInteger
          cfginfo    TFETheme.clSyntax+124,          'cS31', cfgInteger

          cfginfo    TFETheme.FontsSyntax+0*sizeof.TThemeFont,    'fS00', cfgFont
          cfginfo    TFETheme.FontsSyntax+1*sizeof.TThemeFont,    'fS01', cfgFont
          cfginfo    TFETheme.FontsSyntax+2*sizeof.TThemeFont,    'fS02', cfgFont
          cfginfo    TFETheme.FontsSyntax+3*sizeof.TThemeFont,    'fS03', cfgFont
          cfginfo    TFETheme.FontsSyntax+4*sizeof.TThemeFont,    'fS04', cfgFont
          cfginfo    TFETheme.FontsSyntax+5*sizeof.TThemeFont,    'fS05', cfgFont
          cfginfo    TFETheme.FontsSyntax+6*sizeof.TThemeFont,    'fS06', cfgFont
          cfginfo    TFETheme.FontsSyntax+7*sizeof.TThemeFont,    'fS07', cfgFont
          cfginfo    TFETheme.FontsSyntax+8*sizeof.TThemeFont,    'fS08', cfgFont
          cfginfo    TFETheme.FontsSyntax+9*sizeof.TThemeFont,    'fS09', cfgFont
          cfginfo    TFETheme.FontsSyntax+10*sizeof.TThemeFont,   'fS10', cfgFont
          cfginfo    TFETheme.FontsSyntax+11*sizeof.TThemeFont,   'fS11', cfgFont
          cfginfo    TFETheme.FontsSyntax+12*sizeof.TThemeFont,   'fS12', cfgFont
          cfginfo    TFETheme.FontsSyntax+13*sizeof.TThemeFont,   'fS13', cfgFont
          cfginfo    TFETheme.FontsSyntax+14*sizeof.TThemeFont,   'fS14', cfgFont
          cfginfo    TFETheme.FontsSyntax+15*sizeof.TThemeFont,   'fS15', cfgFont
          cfginfo    TFETheme.FontsSyntax+16*sizeof.TThemeFont,   'fS16', cfgFont
          cfginfo    TFETheme.FontsSyntax+17*sizeof.TThemeFont,   'fS17', cfgFont
          cfginfo    TFETheme.FontsSyntax+18*sizeof.TThemeFont,   'fS18', cfgFont
          cfginfo    TFETheme.FontsSyntax+19*sizeof.TThemeFont,   'fS19', cfgFont
          cfginfo    TFETheme.FontsSyntax+20*sizeof.TThemeFont,   'fS20', cfgFont
          cfginfo    TFETheme.FontsSyntax+21*sizeof.TThemeFont,   'fS21', cfgFont
          cfginfo    TFETheme.FontsSyntax+22*sizeof.TThemeFont,   'fS22', cfgFont
          cfginfo    TFETheme.FontsSyntax+23*sizeof.TThemeFont,   'fS23', cfgFont
          cfginfo    TFETheme.FontsSyntax+24*sizeof.TThemeFont,   'fS24', cfgFont
          cfginfo    TFETheme.FontsSyntax+25*sizeof.TThemeFont,   'fS25', cfgFont
          cfginfo    TFETheme.FontsSyntax+26*sizeof.TThemeFont,   'fS26', cfgFont
          cfginfo    TFETheme.FontsSyntax+27*sizeof.TThemeFont,   'fS27', cfgFont
          cfginfo    TFETheme.FontsSyntax+28*sizeof.TThemeFont,   'fS28', cfgFont
          cfginfo    TFETheme.FontsSyntax+29*sizeof.TThemeFont,   'fS29', cfgFont
          cfginfo    TFETheme.FontsSyntax+30*sizeof.TThemeFont,   'fS30', cfgFont
          cfginfo    TFETheme.FontsSyntax+31*sizeof.TThemeFont,   'fS31', cfgFont

          cfginfo    TFETheme.Options,               'Opts', cfgInteger
          cfginfo    TFETheme.MouseWheel,            'nWhl', cfgInteger
          cfginfo    TFETheme.WrapPos,               'WrPs', cfgInteger
          cfginfo    TFETheme.UndoLevels,            'UdLv', cfgInteger

        ; keyboard shortcuts:
        ; navigation
          cfginfo    TFETheme.keyUp,                 'kkUp', cfgShortcut
          cfginfo    TFETheme.keyDown,               'kkDn', cfgShortcut
          cfginfo    TFETheme.keyLeft,               'kLft', cfgShortcut
          cfginfo    TFETheme.keyRight,              'kRgt', cfgShortcut
          cfginfo    TFETheme.keyPgUp,               'kPUp', cfgShortcut
          cfginfo    TFETheme.keyPgDn,               'kPDn', cfgShortcut
          cfginfo    TFETheme.keyHome,               'kHom', cfgShortcut
          cfginfo    TFETheme.keyEnd,                'kEnd', cfgShortcut
          cfginfo    TFETheme.keyPageBegin,          'kPgB', cfgShortcut
          cfginfo    TFETheme.keyPageEnd,            'kPgE', cfgShortcut
          cfginfo    TFETheme.keyTextBegin,          'kTxB', cfgShortcut
          cfginfo    TFETheme.keyTextEnd,            'kTxE', cfgShortcut
          cfginfo    TFETheme.keyWordLeft,           'kWdL', cfgShortcut
          cfginfo    TFETheme.keyWordRight,          'kWdR', cfgShortcut

        ; Edit
          cfginfo    TFETheme.Delete,                'kDel', cfgShortcut
          cfginfo    TFETheme.DelLine,               'kDLn', cfgShortcut
          cfginfo    TFETheme.Backspace,             'kBkS', cfgShortcut

        ; Formating
          cfginfo    TFETheme.ToggleWordWrap,        'kWWr', cfgShortcut
          cfginfo    TFETheme.ToggleBookmark,        'kBkm', cfgShortcut
          cfginfo    TFETheme.ToggleInsMode,         'kIMd', cfgShortcut
          cfginfo    TFETheme.ToggleSelMode,         'kSMd', cfgShortcut
          dd    0
  end if
endg



iglobal
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

proc TFETheme.SetDefaultThemeWindows, .ptrTheme
begin
        push    ebx ecx esi edi
        mov     ebx, [.ptrTheme]

; colors


        mov     [ebx+TFETheme.clBackground], $ffffff
        mov     [ebx+TFETheme.clAltBack],    $e8e8e8

        mov     [ebx+TFETheme.clSimpleText], $000000
        mov     [ebx+TFETheme.clProtectedText], $a0a000

        mov     [ebx+TFETheme.clSelBack], $ffff7f
        mov     [ebx+TFETheme.clSelMode], cmXor

        mov     [ebx+TFETheme.clLeftMargin],       $d0d0d8
        mov     [ebx+TFETheme.clLeftMarginBorder], $606060
        mov     [ebx+TFETheme.clLeftMarginText],   $000000
        mov     [ebx+TFETheme.clLeftMarginTree],   $9000ff
        mov     [ebx+TFETheme.clBookmarkBack],     $ffd000




        mov     [ebx+TFETheme.clWrapColumn], $c0c0ff
        mov     [ebx+TFETheme.Options], eoLeftMargin or eoLineNumbers

        mov     [ebx+TFETheme.WrapPos], 70
        mov     [ebx+TFETheme.MouseWheel], 3

        mov     esi, TFETheme.DefaultShortcuts
        lea     edi, [ebx+TFETheme.shortcuts]
        mov     ecx, TFETheme.DefaultShortcuts.size
        rep movsd

        pop     edi esi ecx ebx
        return
endp




proc TFETheme.SetDefaultThemeClassic, .ptrTheme
begin
        push    ebx ecx esi edi
        mov     ebx, [.ptrTheme]

; colors

        mov     [ebx+TFETheme.clBackground], $000080
        mov     [ebx+TFETheme.clAltBack],    $000090

        mov     [ebx+TFETheme.clSimpleText], $ffffff
        mov     [ebx+TFETheme.clProtectedText], $a0a000

        mov     [ebx+TFETheme.clSelBack], $0000ff
        mov     [ebx+TFETheme.clSelMode], cmOr

        mov     [ebx+TFETheme.clLeftMargin],      $c0c0c0
        mov     [ebx+TFETheme.clLeftMarginBorder], $ffffff
        mov     [ebx+TFETheme.clLeftMarginText],  $000000
        mov     [ebx+TFETheme.clLeftMarginTree],  $ff0000
        mov     [ebx+TFETheme.clBookmarkBack],    $ffd000




        mov     [ebx+TFETheme.clWrapColumn], $0000ff
        mov     [ebx+TFETheme.Options], eoLeftMargin or eoLineNumbers

        mov     [ebx+TFETheme.WrapPos], 70
        mov     [ebx+TFETheme.MouseWheel], 3

        mov     esi, TFETheme.DefaultShortcuts
        lea     edi, [ebx+TFETheme.shortcuts]
        mov     ecx, TFETheme.DefaultShortcuts.size
        rep movsd

        pop     edi esi ecx ebx
        return
endp































































































































































endmodule







>
>



<
<
<
|
|







>
>
>

|


|



















>



<
<
<
|
|







>
>
>

|


|













>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535

proc TFETheme.SetDefaultThemeWindows, .ptrTheme
begin
        push    ebx ecx esi edi
        mov     ebx, [.ptrTheme]

; colors

        mov     [ebx+TFETheme.clAfterBackground], $d0d0d0
        mov     [ebx+TFETheme.clBackground], $ffffff
        mov     [ebx+TFETheme.clAltBack],    $e8e8e8




        mov     [ebx+TFETheme.clSelBack], $000080
        mov     [ebx+TFETheme.clSelAltBack], $000090

        mov     [ebx+TFETheme.clLeftMargin],       $d0d0d8
        mov     [ebx+TFETheme.clLeftMarginBorder], $606060
        mov     [ebx+TFETheme.clLeftMarginText],   $000000
        mov     [ebx+TFETheme.clLeftMarginTree],   $9000ff
        mov     [ebx+TFETheme.clBookmarkBack],     $ffd000

        mov     [ebx+TFETheme.clSyntax], $000000
        mov     [ebx+TFETheme.clSyntax+4], $808080

        mov     [ebx+TFETheme.clWrapColumn], $c0c0ff
        mov     [ebx+TFETheme.Options], eoLineNumbers or eoLeftMargin

        mov     [ebx+TFETheme.WrapPos], 70
        mov     [ebx+TFETheme.MouseWheel], 16

        mov     esi, TFETheme.DefaultShortcuts
        lea     edi, [ebx+TFETheme.shortcuts]
        mov     ecx, TFETheme.DefaultShortcuts.size
        rep movsd

        pop     edi esi ecx ebx
        return
endp




proc TFETheme.SetDefaultThemeClassic, .ptrTheme
begin
        push    ebx ecx esi edi
        mov     ebx, [.ptrTheme]

; colors
        mov     [ebx+TFETheme.clAfterBackground], $000040
        mov     [ebx+TFETheme.clBackground], $000080
        mov     [ebx+TFETheme.clAltBack],    $000090




        mov     [ebx+TFETheme.clSelBack], $c0c0c0
        mov     [ebx+TFETheme.clSelAltBack], $a0a0a0

        mov     [ebx+TFETheme.clLeftMargin],      $c0c0c0
        mov     [ebx+TFETheme.clLeftMarginBorder], $ffffff
        mov     [ebx+TFETheme.clLeftMarginText],  $000000
        mov     [ebx+TFETheme.clLeftMarginTree],  $ff0000
        mov     [ebx+TFETheme.clBookmarkBack],    $ffd000

        mov     [ebx+TFETheme.clSyntax], $ffffff
        mov     [ebx+TFETheme.clSyntax+4], $a0a000

        mov     [ebx+TFETheme.clWrapColumn], $0000ff
        mov     [ebx+TFETheme.Options], eoLineNumbers or eoLeftMargin

        mov     [ebx+TFETheme.WrapPos], 70
        mov     [ebx+TFETheme.MouseWheel], 16

        mov     esi, TFETheme.DefaultShortcuts
        lea     edi, [ebx+TFETheme.shortcuts]
        mov     ecx, TFETheme.DefaultShortcuts.size
        rep movsd

        pop     edi esi ecx ebx
        return
endp




proc SaveTheme, .ptrConfigFile, .ptrTheme, .ptrPath
.ptrDB dd ?
.newpath dd ?
begin
        pushad

        xor     esi, esi
        mov     ebx, 'THTM'

        stdcall LoadBinaryFile, [.ptrConfigFile]
        jc      .file_ok

        mov     esi, eax
        mov     ebx, -1

.file_ok:
        stdcall LoadConfigDB, esi, ebx
        mov     [.ptrDB], eax

        test    esi, esi
        jz      @f
        stdcall FreeMem, esi
@@:

        mov     esi, [.ptrTheme]
        mov     ebx, FreshEditThemeKeys

.loop:
        cmp     [ebx+TCfgInfo.key], 0
        je      .end_of_keys

        cmp     [ebx+TCfgInfo.type], cfgFont
        je      .save_font

        cmp     [ebx+TCfgInfo.type], cfgShortcut
        je      .save_shortcut

; save integer

        lea     eax, [.ptrDB]
        movzx   ecx, [ebx+TCfgInfo.offset]
        stdcall SetConfigParam, eax, [.ptrPath], [ebx+TCfgInfo.key], cdtInteger, [esi+ecx], 4

.next:
        add     ebx, sizeof.TCfgInfo
        jmp     .loop

.save_font:
        lea     eax, [.ptrDB]
        movzx   ecx, [ebx+TCfgInfo.offset]
        stdcall SetConfigParam, eax, [.ptrPath], [ebx+TCfgInfo.key], cdtConfig, eax, eax

        stdcall __CreateNewPath, [.ptrPath], [ebx+TCfgInfo.key]
        mov     [.newpath], eax

        lea     eax, [.ptrDB]
        mov     edx, [esi+ecx+TThemeFont.ptrFace]
        test    edx, edx
        jnz     @f
        mov     edx, cDefaultEditorFont
@@:
        stdcall SetConfigParam, eax, [.newpath], 'face', cdtString, edx, 0

        movzx   edx, [esi+ecx+TThemeFont.size]
        stdcall SetConfigParam, eax, [.newpath], 'size', cdtInteger, edx, 0

        movzx   edx, [esi+ecx+TThemeFont.flags]
        stdcall SetConfigParam, eax, [.newpath], 'flgs', cdtInteger, edx, 0

        movzx   edx, [esi+ecx+TThemeFont.family]
        stdcall SetConfigParam, eax, [.newpath], 'fmly', cdtInteger, edx, 0

        stdcall FreeMem, [.newpath]
        jmp     .next

.save_shortcut:
        lea     eax, [.ptrDB]
        movzx   ecx, [ebx+TCfgInfo.offset]
        stdcall SetConfigParam, eax, [.ptrPath], [ebx+TCfgInfo.key], cdtConfig, eax, eax

        stdcall __CreateNewPath, [.ptrPath], [ebx+TCfgInfo.key]
        mov     edx, eax

        lea     eax, [.ptrDB]
        stdcall SetConfigParam, eax, edx, 'ckey', cdtInteger, [esi+ecx+TShortcut.key], 0
        stdcall SetConfigParam, eax, edx, 'scan', cdtInteger, [esi+ecx+TShortcut.scancode], 0
        stdcall SetConfigParam, eax, edx, 'stat', cdtInteger, [esi+ecx+TShortcut.kbdStatus], 0
        stdcall SetConfigParam, eax, edx, 'mask', cdtInteger, [esi+ecx+TShortcut.maskStatus], 0

        stdcall FreeMem, edx
        jmp     .next


.end_of_keys:
        mov     eax, [.ptrDB]
        stdcall SaveConfigFile, [.ptrDB], [eax+TArray.lparam]
        mov     esi, eax

        mov     ecx, [esi+TArray.count]
        lea     eax, [esi+TArray.array]
        shl     ecx, 2
        stdcall SaveBinaryFile, [.ptrConfigFile], eax, ecx

        stdcall FreeMem, esi
        stdcall FreeConfigDB, [.ptrDB]
        popad
        return
endp



proc __CreateNewPath, .ptrPath, .newdir
begin
        pushad
        mov     esi, [.ptrPath]
        xor     ecx, ecx
        test    esi, esi
        jz      .end_found

.loop:
        cmp     dword [esi], 0
        je      .end_found
        add     esi, 4
        jmp     .loop

.end_found:
        sub     esi, [.ptrPath]
        mov     ecx, esi
        lea     eax, [ecx+8]

        stdcall GetMem, eax
        mov     edi, eax
        mov     ebx, eax

        shr     ecx, 2

        mov     esi, [.ptrPath]
        test    esi, esi
        jz      .root_ok

        rep movsd

.root_ok:
        mov     eax, [.newdir]
        stosd
        xor     eax, eax
        stosd

        mov     [esp+4*regEAX], ebx
        popad
        return
endp



endmodule

Added freshlib/FreshEdit/LineProcessors.asm.





















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

; the fields of this structure point to a set of procedures that
; handles one type of editor line. It can be text line or other type of line.
; The editor itself will call this procedures when some processing of the line is needed.

; some of these procedures can be NULL when not needed.

struc TLineProcessor [arg] {
common
  local offs, start
  offs = 0
  start = $

  .__Create     dd ?    ; creates line from given text.
  .__Free       dd ?    ; frees all allocated in the file resources.

  .Draw         dd ?    ; draws the line on the shadow buffer.
  .KeyEvent     dd ?    ; process keyboard events when the caret is in the line.
  .MouseEvent   dd ?    ; process mouse events on the line.

  .ToText       dd ?    ; Converts the line to cannonical type. The editing is disabled if not possible.
  .FromText     dd ?    ; Converts the line to internal representation suitable for editing.

  .Format       dd ?    ; prepares the row for painting and computes needed data structures and indexes.

  .Initialize   dd ?    ; should be called once in order to initialize this line type.
  .Finalize     dd ?    ; should be called once in order to finalize this line type.
forward
  if ~arg eq
    store dword arg at start+offs
    offs = offs + 4
  end if
}

virtual at 0
  TLineProcessor TLineProcessor
end virtual




include "TextLineProcessor.asm"

Added freshlib/FreshEdit/TextLineProcessor.asm.

















































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
lprTextLine TLineProcessor   textLineCreate,            \
                             textLineFree,              \
                             textLineDraw,              \
                             textLineKeyEvent,          \
                             textLineMouseEvent,        \
                             textLineToText,            \
                             textLineFromText,          \
                             textLineFormat,            \
                             textLineInit,              \
                             textLineFinish


; Rendering character information for .pRenderInfo array.
struct TCharInfo
  .x   dd ?     ; x coordinate relative to the upper left edge of the line.
  .y   dd ?     ; y coordinate relative to the upper left edge of the line.
  .w   dw ?     ; width of the character.
  .h   dw ?     ; height of the character.
  .b   dw ?     ; base offset of the character.
  .c   db ?     ; color of the character as an index in the syntax colors.
  .f   db ?     ; font of the character as an index in the syntax fonts.
ends



cDefaultEditorFont text 'Fixedsys Excelsior 3.01'
;cDefaultEditorFont text 'Droid sans mono'



proc textLineCreate, .pLine, .hString
begin
        push    eax esi

        mov     esi, [.pLine]
        stdcall StrDup, [.hString]
        mov     [esi+TEditorLine.pData], eax

        pop     esi eax
        return
endp



proc textLineFree, .pLine
begin
        push    eax
        mov     eax, [.pLine]
        stdcall StrDel, [eax+TEditorLine.pData]
        mov     [eax+TEditorLine.pData], 0
        pop     eax
        return
endp



proc textLineDraw, .context, .pEditor, .pLine, .x, .y
begin
        pushad

        add     [.y], 12        ; font base line;

        mov     esi, [.pLine]

        test    [esi+TEditorLine.flags], lfFormatted
        jnz     .so_draw_it

        stdcall textLineFormat, [.context], [.pEditor], esi

.so_draw_it:
        stdcall StrLen, [esi+TEditorLine.pData]
        mov     ecx, eax
        stdcall StrPtr, [esi+TEditorLine.pData]
        mov     edi, eax
        mov     ebx, [esi+TEditorLine.pRenderInfo]      ; pointer to TArray of TCharInfo
        lea     ebx, [ebx+TArray.array]

.draw_loop:
        stdcall DecodeUtf8, [edi]
        add     edi, edx

        test    eax, eax
        jz      .end_of_string

        movzx   eax, [ebx+TCharInfo.c]
        movzx   ecx, [ebx+TCharInfo.f]
        mov     eax, [FreshEditTheme.clSyntax+4*eax]
        mov     ecx, [FreshEditTheme.FontsSyntax+4*ecx]

        push    eax ecx         ; color and font

        mov     eax, [.x]
        mov     ecx, [.y]
        add     eax, [ebx+TCharInfo.x]
        add     ecx, [ebx+TCharInfo.y]

        stdcall DrawString, [.context], edi, edx, eax, ecx ; remaining from the stack.

        add     ebx, sizeof.TCharInfo
        jmp     .draw_loop

.end_of_string:
        popad
        return
endp



proc textLineKeyEvent, .pLine, .pEvent
begin

        return
endp


proc textLineMouseEvent,.pLine, .pEvent
begin
        return
endp



proc textLineToText, .pLine
begin
        return
endp



proc textLineFromText, .pLine
begin
        return
endp



proc textLineFormat, .context, .pEditor, .pLine
  .x    dd ?  ; current X coordinate.
  .y    dd ?  ; current Y coordinate.
  .maxh dd ?  ; maximal height of the subline.

  .wrap dd ?
begin
        pushad

        mov     ebx, [.pLine]
        cmp     [ebx+TEditorLine.pRenderInfo], 0
        je      .info_ok
        stdcall FreeMem, [ebx+TEditorLine.pRenderInfo]

.info_ok:
        stdcall CreateArray, sizeof.TCharInfo
        mov     [ebx+TEditorLine.pRenderInfo], eax

        stdcall StrLenUtf8, [ebx+TEditorLine.pData]
        mov     ecx, eax

        stdcall AddArrayItems, [ebx+TEditorLine.pRenderInfo], ecx
        mov     [ebx+TEditorLine.pRenderInfo], edx

        mov     eax, [.pEditor]
        stdcall [eax+TFreshEdit._procSyntax], [ebx+TEditorLine.pData], edx, [ebx+TEditorLine.syn_context]
        mov     [ebx+TEditorLine.syn_context], eax

        stdcall StrPtr, [ebx+TEditorLine.pData]
        mov     esi, eax
        mov     edi, [ebx+TEditorLine.pRenderInfo]
        lea     edi, [edi+TArray.array]

.render_loop:
        stdcall DecodeUtf8, [esi]
        add     esi, edx

        test    eax, eax
        jz      .end_of_string

        mov     eax, [.x]
        mov     edx, [.y]
        mov     [edi+TCharInfo.x], eax
        mov     [edi+TCharInfo.y], edx

        movzx   eax, [edi+TCharInfo.f]
        stdcall GetTextBounds, [.context], esi, edx, [FreshEditTheme.FontsSyntax+4*eax]

        mov     [edi+TCharInfo.w], ax
        mov     [edi+TCharInfo.h], dx

        cmp     [.maxh], edx
        jae     @f
        mov     [.maxh], edx
@@:
        add     eax, [.x]
        test    [ebx+TEditorLine.flags], lfWordWrap
        jz      .wrap_ok

        cmp     eax, [.wrap]
        jb      .wrap_ok

        mov     eax, [.maxh]
        add     [.y], eax
        xor     eax, eax
        mov     [.maxh], eax

.wrap_ok:
        mov     [.x], eax


        jmp     .render_loop

.end_of_string:
        popad
        return
endp



proc textLineInit
begin
; Main Font settings.
;        stdcall FontCreate, cDefaultEditorFont, 0, 0, ffMonospaced
;        mov     [hTextFont], eax
        return
endp



proc textLineFinish
begin
;        stdcall FontDestroy, [hTextFont]
;        mov     [hTextFont], 0
        return
endp

Changes to freshlib/FreshEdit/fasm_syntax.asm.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module "FASM syntax highlighter"

ttText = 0
ttRem  = 1
ttStr  = 2
ttNum  = 3
ttChar = 4



iglobal

  var SynTheme = fasm_colors_windows

; Windows theme.







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module "FASM syntax highlighter"

ttText = 0
ttRem  = 1
ttStr  = 2
ttNum  = 3
ttChar = 4
ttNewLine = $80000000


iglobal

  var SynTheme = fasm_colors_windows

; Windows theme.
67
68
69
70
71
72
73







74
75
76
77
78
79
80
; Returns:
;       eax - output context of the highligher.
;
proc SyntaxFASM, .hString, .pAttr, .SynContext
.Quo rb 4
.start dd ?
begin








        mov     edi, [.pAttr]
        mov     ebx, [SynTheme]

        stdcall StrPtr, [.hString]
        mov     esi, eax
        mov     [.start], eax







>
>
>
>
>
>
>







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
; Returns:
;       eax - output context of the highligher.
;
proc SyntaxFASM, .hString, .pAttr, .SynContext
.Quo rb 4
.start dd ?
begin
        pushad

        test    [.SynContext], ttNewLine
        jz      @f
        mov     [.SynContext], ttText
@@:
        and     dword [.SynContext], ttNewLine-1

        mov     edi, [.pAttr]
        mov     ebx, [SynTheme]

        stdcall StrPtr, [.hString]
        mov     esi, eax
        mov     [.start], eax
158
159
160
161
162
163
164

165

166
167
168
169
170
171
172
.next:
        add     edi, sizeof.TCharAttr
        inc     esi
        stdcall ScanForwardUtf8
        jmp     .loop

.end_of_line:

        mov     eax, ttText

        return
endp


.CharInSymbols:
        push    edi ecx








>
|
>







165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
.next:
        add     edi, sizeof.TCharAttr
        inc     esi
        stdcall ScanForwardUtf8
        jmp     .loop

.end_of_line:
        popad
;        mov     eax, ttText
        mov      eax, [.SynContext]
        return
endp


.CharInSymbols:
        push    edi ecx

Deleted freshlib/FreshEdit/forth_link.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
iglobal
FreshEditKeyScript file 'keyboard.forth'
                   dd   0
endg



ForthBlock __FreshEditForthWords


forthword 'Left'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        push    ecx

        mov     ecx, [esi+TFreshEdit._xCaret]
        jecxz   .exit

        dec     ecx
        mov     [esi+TFreshEdit._xCaret], ecx

        mov     ecx, [esi+TFreshEdit._LeftColumn]
        cmp     [esi+TFreshEdit._xCaret], ecx
        ja      .exit

        mov     ecx, [esi+TFreshEdit._cols]
        shr     ecx, 2
        test    ecx, ecx
        jnz     @f
        inc     ecx
@@:
        sub     [esi+TFreshEdit._LeftColumn], ecx
        jns     @f

        mov     [esi+TFreshEdit._LeftColumn], 0
@@:

.exit:
        clc
        pop     ecx
        return
endfw



forthword 'Right'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        push    ecx edx

        mov     ecx, [esi+TFreshEdit._xCaret]
        inc     ecx
        mov     [esi+TFreshEdit._xCaret], ecx

        mov     edx, [esi+TFreshEdit._cols]
        add     edx, [esi+TFreshEdit._LeftColumn]
        cmp     ecx, edx
        jae     .scroll_left

.finish:
        clc
        pop     edx ecx
        return

.scroll_left:
        mov     ecx, [esi+TFreshEdit._cols]
        shr     ecx, 2
        test    ecx, ecx
        jnz     @f
        inc     ecx
@@:
        add     [esi+TFreshEdit._LeftColumn], ecx
        jmp     .finish
endfw



forthword 'Up'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        push    ecx

        cmp     [esi+TFreshEdit._yCaret], 0
        je      .exit

        dec     [esi+TFreshEdit._yCaret]

        mov     ecx, [esi+TFreshEdit._TopLine]
        cmp     [esi+TFreshEdit._yCaret], ecx
        jl      .scrollup

.exit:
        clc
        pop     ecx
        return

.scrollup:
        mov     ecx, [esi+TFreshEdit._TopLine]
        jecxz   .exit
        dec     [esi+TFreshEdit._TopLine]
        jmp     .exit
endfw



TFreshEdit.__CommandScrollLockUp:
forthword 'ScrLockUp'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        push    ecx

        cmp     [esi+TFreshEdit._yCaret], 0
        je      .exit

        dec     [esi+TFreshEdit._yCaret]

        mov     ecx, [esi+TFreshEdit._TopLine]
        jecxz   .exit

        dec     [esi+TFreshEdit._TopLine]

.exit:
        clc
        pop     ecx
        return
endfw



forthword 'ScrollUp'
begin
        push    ecx
        cmp     [esi+TFreshEdit._TopLine], 0
        je      .finish
        dec     [esi+TFreshEdit._TopLine]
.finish:
        clc
        pop     ecx
        return
endfw




TFreshEdit.__CommandDown:
forthword 'Down'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        push    ecx edx

        mov     edx, [esi+TFreshEdit._pIndex]

        mov     ecx, [esi+TFreshEdit._yCaret]
        inc     ecx
        cmp     ecx, [edx+TArray.count]
        jae     .exit

        mov     [esi+TFreshEdit._yCaret], ecx

        mov     ecx, [esi+TFreshEdit._TopLine]
        add     ecx, [esi+TFreshEdit._rows]
        cmp     [esi+TFreshEdit._yCaret], ecx
        jae     .scrolldn

.exit:
        clc
        pop     edx ecx
        return

.scrolldn:
        mov     ecx, [esi+TFreshEdit._TopLine]
        inc     ecx
        cmp     ecx, [edx+TArray.count]
        jae     .exit

        mov     [esi+TFreshEdit._TopLine], ecx
        jmp     .exit
endfw




TFreshEdit.__CommandScrollLockDown:
forthword 'ScrLockDown'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        push    ecx edx

        mov     edx, [esi+TFreshEdit._pIndex]

        mov     ecx, [esi+TFreshEdit._yCaret]
        inc     ecx
        cmp     ecx, [edx+TArray.count]
        jae     .exit

        mov     [esi+TFreshEdit._yCaret], ecx

        mov     ecx, [esi+TFreshEdit._TopLine]
        inc     ecx
        add     ecx, [esi+TFreshEdit._rows]
        cmp     ecx, [edx+TArray.count]
        ja      .exit

        inc     [esi+TFreshEdit._TopLine]

.exit:
        clc
        pop     edx ecx
        return

endfw



forthword 'ScrollDown'
begin
        push    ecx edx
        mov     edx, [esi+TFreshEdit._pIndex]

        mov     ecx, [esi+TFreshEdit._TopLine]
        inc     ecx
        add     ecx, [esi+TFreshEdit._rows]
        cmp     ecx, [edx+TArray.count]
        ja      .finish

        inc     [esi+TFreshEdit._TopLine]

.finish:
        clc
        pop     edx ecx
        return

endfw





forthword 'PgDown'
begin
        push    ecx
        mov     ecx, [esi+TFreshEdit._rows]

@@:
        call    TFreshEdit.__CommandScrollLockDown
        jc      .finish
        loop    @b

.finish:
        pop     ecx
        return
endfw



forthword 'PgUp'
begin
        push    ecx
        mov     ecx, [esi+TFreshEdit._rows]
@@:
        call    TFreshEdit.__CommandScrollLockUp
        jc      .finish
        loop    @b

.finish:
        pop     ecx
        return
endfw




forthword 'LineBegin'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        cmp     [esi+TFreshEdit._xCaret], 0
        je      .end

        mov     [esi+TFreshEdit._xCaret], 0

        cmp     [esi+TFreshEdit._LeftColumn], 0
        je      .end

        mov     [esi+TFreshEdit._LeftColumn], 0

.end:
        clc
        return
endfw





forthword 'LineEnd'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        push    ebx ecx

        mov     ecx, [esi+TFreshEdit._yCaret]
        mov     ebx, [esi+TFreshEdit._pIndex]

        cmp     ecx, [ebx+TArray.count]
        jae     .end

        mov     ecx, [ebx+TArray.array+4*ecx]

        shl     ecx, TEditorLine.shift
        add     ecx, [esi+TFreshEdit._pLines]
        add     ecx, TArray.array

        stdcall StrLenUtf8, [ecx+TEditorLine.Data], -1

        cmp     [esi+TFreshEdit._xCaret], eax
        je      .end

        mov     [esi+TFreshEdit._xCaret], eax

        mov     ecx, [esi+TFreshEdit._cols]
        lea     ecx, [ecx*3]
        shr     ecx, 2

        cmp     eax, [esi+TFreshEdit._LeftColumn]
        jg      .leftok

        sub     eax, ecx
        jns     @f
        xor     eax, eax
@@:
        mov     [esi+TFreshEdit._LeftColumn], eax
        jmp     .end

.leftok:
        add     ecx, [esi+TFreshEdit._LeftColumn]
        sub     ecx, [esi+TFreshEdit._xCaret]
        jge     .end

        sub     [esi+TFreshEdit._LeftColumn], ecx

.end:
        clc
        pop     ecx ebx
        return
endfw



TFreshEdit.__CommandBeginOfScreen:
forthword 'ScreenBegin'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        mov     eax, [esi+TFreshEdit._TopLine]
        cmp     eax, [esi+TFreshEdit._yCaret]
        je      .end

        mov     [esi+TFreshEdit._yCaret], eax
.end:
        return
endfw


forthword 'ScreenEnd'
begin
        call    TFreshEdit.__FitCaretInWindow
        jz      @f

        stc
        return

@@:
        call    TFreshEdit.__CommandBeginOfScreen

        mov     ecx, [esi+TFreshEdit._rows]
        jecxz   .end
        dec     ecx
        jecxz   .end

@@:
        call    TFreshEdit.__CommandDown
        jc      .end
        loop    @b

.end:
        return
endfw


forthword 'FileBegin'
begin

        return
endfw


forthword 'FileEnd'
begin

        return
endfw


forthword 'WordPrev'
begin

        return
endfw


forthword 'WordNext'
begin

        return
endfw



forthword 'GetSelMode'
begin

        return
endfw



forthword 'SetSelMode'
begin

        return
endfw



forthword 'GetInsMode'
begin

        return
endfw


forthword 'SetInsMode'
begin

        return
endfw


forthword 'GetRowCount'
begin

        return
endfw



forthword 'ToggleSelMode'
begin
        mov     eax, [esi+TFreshEdit._SelMode]
        inc     eax
        cmp     eax, 2
        jbe     @f
        xor     eax, eax
@@:
        mov     [esi+TFreshEdit._SelMode], eax
        return
endfw



EndForthBlock

;_________________________________________________________________________________________
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/FreshEdit/keyboard.forth.

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
( This file contains ForthScript definitions for navigation and control keys in FreshEdit.
  The name of the words is actually the name of the pressed key, as returned by CreateKeyName procedure
  defined in the library SysEvents.asm
  The words can return a value through the stack top value. It is
  1 - means the
)

: keyUp Up 0 ;
: keyShift+Up Up 1 ;

: keyDown Down 0 ;
: keyShift+Down Down 1 ;

: keyLeft Left 0 ;
: keyShift+Left Left 1 ;

: keyRight Right 0 ;
: keyShift+Right Right 1 ;

: keyPgUp PgUp 0 ;
: keyShift+PgUp PgUp 1 ;

: keyPgDn PgDown 0 ;
: keyShift+PgDn PgDown 1 ;

: keyHome LineBegin 0 ;
: keyShift+Home LineBegin 1 ;

: keyEnd LineEnd 0 ;
: keyShift+End LineEnd 1 ;

: keyCtrl+Alt+Ins ToggleSelMode 1 ;
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































Added freshlib/FreshEdit/notes.txt.



































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
FreshEdit target features:

#. Unicode text encoding - UTF-8 based.

#. Very big files - only memory limited - without decreasing the performance of the editor.

#. Display of line numbers.

#. Temporal highlighting part of the text with any color (until the user press any key) It is
   for pointing errors.

#. Read-only files (works like a browser) and read-only lines (for example, autogenerated by
   the IDE lines).

#. Bookmarks, saveable to the file.

#. Word wrap for some of the lines (user selectable and saveable to the file)

#. Additional information attached to the text lines - for example debug information.

#. Multilevel code folding - user selectable and automatic.

#. Two modes of selections - char and block selections and cut/copy/paste operations.

#. Context depending syntax highlighting. (for syntaxes that are not line based - for example
   for HTML, C++, etc.)

#. Unlimited UNDO/REDO operations possible.





Coordinate systems:

1. [A] LineNumber, CharNumber
  1.1. LineNumber, ByteNumber

Needed for text editing purposes - insert text, delete text, selections replace, etc.

2. [B] LineNumber, SublineNumber, X coordinate

Needed for text display purposes.


3. [C] Y coordinate, X coordinate

Needed for mouse operations - mouse clicks to other types of coordinates.

Added freshlib/FreshEdit/unicode_test.txt.











































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
;This is example text, aimed simply to show the features of the FreshEdit control. ;w:F#;

;1. Word-wrap feature. It works only for the lines formated with word-wrap format. You can set/remove word-wrap format by Ctrl+W key.;w:F#;

;2. FreshEdit can save the format into the source file. The formating is transparent for FASM compiler, so you can compile the files without removing formating.;w:F#;

;3. FreshEdit uses UTF-8 encoding - see following samples:

;Russian: Я могу есть стекло, оно мне не вредит.
;Yoruba: Mo lè je̩ dígí, kò ní pa mí lára.
;Greek: Μπορώ να φάω σπασμένα γυαλιά χωρίς να πάθω τίποτα.
;Québécois: J'peux manger d'la vitre, ça m'fa pas mal.
;Ukrainian: Я можу їсти скло, і воно мені не зашкодить.
;English: I can eat glass and it doesn't hurt me.

;5. The bookmarks are saved with the text as well. Use Ctrl+B to set/remove a bookmark.;bw:F#;

;6. Also FreshEdit, has code folding feature.
proc SomeTestProcedure
begin
        nop
        mov     eax, 1234
        return
endp

;7. also, there are line numbers and breakpoint icons on the left margin of the editor. You can set/remove breakpoint with F2 key.;w:F#;

        nop
        nop
        int3

; 8. Color themes: Click on "T" button to switch the color theme for the editor.;w:F#;

; 9. Zebra background - if you like such eye-candy things. Click on "Z" button in order to switch it on/off.;w:F#;

proc AnotherTestProcedure
begin
        xor     eax, eax

locals  ; We have of course several folding levels.
  .x  dd  ?
  .y  dd  ?
  .rect TBounds
endl

        mov     ecx, 'ABCD'
        return
endp

; 10. Click "#" to turn on/off the line numbers.
; 11. Ctrl-T will switch ON/OFF the whole left margin field.
; 12. Alt+Ins will switch the type of selection - line, char and block are supported for now.;w:F#;

Deleted freshlib/License.txt.

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
The Fresh Artistic License

Preamble

The intent  of  this document is to  state the conditions under which a
Package may be  copied,  such that the  Copyright Holder maintains some
semblance of  artistic control  over the  development  of  the package,
while giving  the users  of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.

Definitions:

    * "Package" refers  to  the  collection of files distributed by the
      Copyright Holder,  and derivatives  of that  collection  of files
      created through textual modification.
    * "Standard Version"  refers  to  such a Package if it has not been
      modified,  or has  been modified in accordance with the wishes of
      the Copyright Holder.
    * "Copyright Holder"  is  whoever  is  named  in  the  copyright or
      copyrights for the package.
    * "You"  is  you,  if you're thinking about copying or distributing
      this Package.
    * "Reasonable copying fee" is whatever you can justify on the basis
      of media cost,  duplication charges, time of people involved, and
      so on. (You  will  not be required to justify it to the Copyright
      Holder, but  only to the computing community at large as a market
      that must bear the fee.)
    * "Freely Available"  means  that  no  fee  is charged for the item
      itself,  though  there may be fees involved in handling the item.
      It  also  means  that recipients of the  item may redistribute it
      under the same conditions they received it.

IMPORTANT NOTE: 
    FASM compiler itself,  which  is  integral  part of this package is 
    distributed under  different  license.  All  source  files  of FASM 
    compiler are separated in "source\fasm\" directory. Please read and 
    apply "source\fasm\license.txt" for FASM license.

1. You may make and give away verbatim copies of the source form of the
   Standard Version  of this Package without restriction, provided that
   you duplicate all  of the  original copyright notices and associated
   disclaimers.

2. You may apply bug fixes, portability fixes  and other  modifications 
   from the Copyright Holder  or those  derived  from the Public Domain 
   and approved by the  Copyright Holder.  A Package modified in such a 
   way shall still be considered the Standard Version.

3. You  may  otherwise  modify  your  copy  of this Package in any way,
   provided  that you  insert  a prominent notice  in each changed file
   stating how and when you changed that file, and provided that you do
   at least ONE of the following:

    a) place your modifications in the Public Domain or  otherwise make
       them Freely Available, such as by posting said  modifications to
       Usenet or an equivalent medium, or placing the  modifications on
       a major  archive site  such as  ftp.uu.net,  or by  allowing the
       Copyright Holder  to include  your modifications in the Standard
       Version of the Package.

    b) use   the  modified  Package  only  within  your  corporation or
       organization.

    c) rename any non-standard executables so the names do not conflict
       with  standard  executables,  which  must  also be provided, and
       provide a separate manual page for each  non-standard executable
       that clearly documents how it differs from the Standard Version.

    d) make other distribution arrangements with the Copyright Holder.

4. You may  distribute  the programs  of this Package in object code or
   executable form, provided that you do at least ONE of the following:

    a) distribute  a  Standard  Version  of the executables and library
       files,  together  with  instructions  ( in  the  manual  page or
       equivalent) on where to get the Standard Version.

    b) accompany  the  distribution with the machine-readable source of
       the Package with your modifications.

    c) accompany any non-standard executables with their  corresponding
       Standard    Version   executables,   giving   the   non-standard
       executables  non-standard  names,  and  clearly  documenting the
       differences  in  manual  pages  (or equivalent),  together  with
       instructions on where to get the Standard Version.

    d) make other distribution arrangements with the Copyright Holder.

5. You may charge a reasonable copying fee for any distribution of this
   Package.  You  may  charge  any  fee  you choose for support of this
   Package. You may not charge a fee for this  Package itself. However,
   you may  distribute  this  Package in aggregate with other (possibly
   commercial)  programs  as  part  of  a  larger (possibly commercial)
   software  distribution  provided  that  you  do  not  advertise this
   Package as a product of your own.

6. The executable and library files supplied as input to or produced as
   output from the  programs  of this Package do not automatically fall
   under  the  copyright  of  this  Package,  but  belong  to  whomever
   generated  them, and may be sold commercially, and may be aggregated
   with this Package.

7. You may not use this package,  nor files created as output from this
   package,  nor  products  derived  from  this  package for producing,
   distrubuting  or  in  any   way   contribute   to  the  creation  or
   distribution of "unwanted advertisement" (known as SPAM).

8. The name  of  the  Copyright  Holder  may  not be used to endorse or
   promote  products  derived from this software without specific prior
   written permission.

9. THIS PACKAGE IS PROVIDED "AS IS"  AND WITHOUT ANY EXPRESS OR IMPLIED
   WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
   MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

The End
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































Deleted freshlib/TestFreshLib.fpr.

cannot compute difference between binary files

Deleted freshlib/_doc/FreshLibRefMan.odt.

cannot compute difference between binary files

Deleted freshlib/_doc/Fresh_IDE.wiki.

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
<table class="index" align="right">
<tr><td class="index">
<b>Index</b><br>
[http://fresh.flatassembler.net | Fresh home]<br>
[FreshLib reference | FreshLib reference]<br>
[Fresh user guide | Fresh tips&tricks]<br>
</td></tr>
</table>

Fresh is a visual assembly language IDE with built-in FASM assembler.

The main goal of Fresh is to make programming in assembly as fast and
efficient as in other visual languages, without sacrificing the small
application size and the raw power of assembly language.

Because Fresh is the logical continuation of the FASM project in the
area of visual programming, it is perfectly compatible with FASM and you
can use all your knowledge about FASM to program in Fresh.

Of course, you can use Fresh not only for Windows programming, but also
to create programs for any OS that FASM supports - DOS, Linux, FreeBSD,
BeOS, MenuetOS - the same way as you do this in FASM.

Now, the main direction of Fresh development is towards creating FreshLib - freely portable library, that to
provide portability for Fresh and programs created with Fresh to number of different OSes. 
Initially for Win32 and Linux.

This site is [http://www.fossil-scm.org|fossil] repository of Fresh sources.
You can clone the repository with following fossil command:
<pre><b>fossil clone http://chiselapp.com/user/johnfound/repository/FreshIDE/ Fresh.fossil</b></pre>

In order to use more functionality in this site, please [/login|login] as "anonimous" user.
Particularly you will be able to follow the links in the source tree, to download code and to fill bug reports and feature requests.

If you want to contribute to the project, please contact me (johnfound) on [http://board.flatassembler.net|FASM message board]

In order to download compiled FreshIDE, visit [http://fresh.flatassembler.net|Fresh IDE home page.]

You can report bugs, or make some feature requests here, in the [/reportlist|Tickets system]
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































Deleted freshlib/_doc/Fresh_and_Linux.wiki.

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
<h4>Running and debugging Linux applications in Windows with Fresh IDE</h4>

Fresh can compile applications for Linux. But how to run and debug these applications? 

There are different approaches, including virtual machines, second computer, running Linux, or rebooting every time you want to test compiled project.

Fresh provides one very simple way of testing Linux applications. This method is to use [http://andlinux.org|andLinux]. andLinux is complete Ubuntu distribution, that uses coLinux kernel in order to allow running of Linux inside Windows OS.

How to setup andLinux to work with Fresh?

  <b>Step 1.</b> Download andLinux package from [http://andlinux.org/downloads.php|andLinux download page].

  There are two packages: "KDE version" and "minimal/XFCE version" available. For using with Fresh IDE, it is not important what version you will choose.

  KDE package is very big and very slow distribution that contains many bundled programs and tools, but in general you will not need them. The size of KDE package is 500MB download and 5GB installed.

  The XFCE package is relatively smaller and faster. Relatively means 200MB downloaded file and 2GB installed on the disk.

  It is obvious that the right choice is to use XFCE package.

  <b>Step 2.</b> Run the downloaded setup file and answer to the different questions of the setup wizard.

  The important features that we need are:

  *  coLinux version - choose the stable version (0.7.4 in my case) instead of latest (0.8.0) - we shall work with andLinux, not to play.

  *  Memory size - 256MB RAM (or maybe more - if you can afford it).

  *  Install XMing server on your primary screen.

  *  Sound - you can enable or disable sound in Linux option - it is harmless although it is one more running server.

  *  Startup type + Panel - select "run andLinux automatically as a NT service + use Windows shortcuts"; It is not very important, but can save you a little manual work and troubles later.

  *  andLinux login - just select your user name and password for Linux root.

  *  Windows File Access - it is important! - select "using CoFS", no matter it is not recommended.

  * File Access Using CoFS - important! - create one new directory somewhere and select it to be mount via CoFS. This will be the shared directory, visible from Windows and from Linux in the same time.

  All other features you can choose freely or simply leave them to default state.

  When you start installation, the installer will try to install network driver. It is possible Windows will protest and will atempt to mislead you by asking to not install not certified driver. You must ignore these attempts and firmly click "install".

  After installation of andLinux you have to restart Windows and probably andLinux will not run. :D It is because of the Windows firewall. All new network adapters are firewalled by default. As long as installed adapter (named TAP-Colinux) is virtual and local, you will not need any firewall so, go to control panel/Windows firewall/Advanced and uncheck "TAP-Colinux" adapter from the list of adapters.

  Then you can run some Linux program - in the Windows tray, there is a andLinux menu icon that have shortcuts to several Linux programs.

  <b>Step 3.</b> Install several additional Linux tools. You will need additionally debugger and come decent terminal emulator. I choose xterm for terminal, because it is small and white by default. ;) You can choose to use the built-in terminal named in the simple Linux manner: "xfce4-terminal" and console debugger "gdb". In this case you have skip this step.

  Start "Synaptic" - package manager for Ubuntu from the tray menu. You have to enter root password you choose on install.

  When Synaptic is started, click "Reload" to refresh the package list from the network and then use search to locate needed programs. I personally recommend "xterm" as terminal and "ddd" as a GUI front end to "gdb". 

  Well, I recommend "ddd" only because it is only Linux debugger that I was able to run under andLinux and able to show disassembled code of the program.
  
  Mark selected programs for install, click on Apply button and wait until downloading and installation. 

  Here you can encounter only one problem - your computer is behind a proxy server. 
  
  If the proxy is normal proxy, you simply have to set its address and port in the Synaptic preferences and it should work. 

  Completely another story is when the proxy is MS ISA server configured with NTLM user authorization. 

  Most Linux programs can't work with such authorization and Synaptic is not an exception.

  Fortunately, there is a workaround of this situation. You need [http://ntlmaps.sourceforge.net/|ntlmaps] authorization proxy server. 
  
  Setting up of this server is out of the scope of this article. On the ntlmaps home page you can read complete documentation and explanations.

  OK, we are ready with andLinux. Now you have working copy of Ubuntu inside your Windows box.

  It's time to configure Fresh to run Linux applications inside andLinux. Continue with:

  <b>Step 4.</b> Fresh IDE configuration.

  Run Fresh and open "Options|IDE options" dialog. Select "Debuggers and Emulators" page.

  Then select following directories and commands: 
  
  *  "andLinux directory" - the directory where you installed andLinux.

  *  "andLinux shared directory" - shared directory you selected during andLinux installation.

  *  "Linux debugger" - Enter "ddd" (or whatever debugger you choose).

  *  "Linux terminal" - Enter "xterm -hold +mesg -e" - note the options. 

  <h4>And voila! You finished the configuration!</h4>

  Now you can load the source of some Linux program (look at Fresh examples) and run it with shift+F9 or load it in the debugger with shift+F8. 
  
  Fresh will detect when you compiled ELF executable and will run it in andLinux instead of Windows.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































Deleted freshlib/_doc/GUI.wiki.

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
<nowiki>

<a name="GUI"><h1>FreshLib directory: GUI</h1></a>

<p>GUI library defines many data structures and procedures that together form
something that conditionally can be called "OOP". It is object oriented, as
long as it deals with GUI "objects" - forms, controls, menus etc.
All these objects are in fact structures of data. For every created object,
the library allocates some memory and fills this memory with object parameters
data.</p>

<p>There are two types of data structures that describe GUI objects - classes
and instances.</p>

<p>The class is a structure that contains data commonly used by all objects of given type - for example all buttons use one class structure CButton.</p>

<p>The instance is data structure that describes the properties and behavior of particular GUI object - for example button with icon "open file" that opens a file when the user click on it.</p>

<a name="Classes"><h2>Classes</h2></a>

<p>"Class" in FreshLib is a data structure, that have the following definition:</p>

<pre class="fasm-code">
struct TObjectClass
  .ptrParent           dd 0   
  .dataSize            dd 0   
  .procCreate          dd 0
  .procDestroy         dd 0
  .procGetParam        dd 0
  .procSetParam        dd 0
  .procExecCmd         dd 0
  .procSysEventHandler dd 0
ends
</pre>

<p><span class="variable">.ptrParent</span> is a pointer to other TObjectClass structure, that appears as a parent class for the given class.</p>
<p><span class="variable">.dataSize</span> contains the size of the object instance structure.</p>

<p>The following fields are the pointers to procedures that provides the "work" of the object. All of these pointers as a rule can be <span class="constant">NULL</span>, if there is no need for such processing.</p>

<a name="Create"><h4>Create</h4></a>
<p><span class="variable">.procCreate</span> is a procedure that creates instance object of the given class. This 
field can be <span class="constant">NULL</span>. It has the following definition:</p>
<pre class="fasm-code">
proc Create, .obj
</pre>
<p>This procedure sets needed values in the object instance data structure.</p>

<a name="Destroy"><h4>Destroy</h4></a>
<p><span class="variable">.procDestroy</span> is a procedure that destroys an instance of the given class.</p>
<pre class="fasm-code">
proc Destroy, .obj
</pre>
<p>Destroys the object passed in <span class="variable">[.obj]</span> and frees all memory allocated for this object.</p>

<a name="GetParam"><h4>GetParam</h4></a>
<p><span class="variable">.procGetParam</span> is a pointer to the procedure that retrieves and returns the properties of the object.</p>
<pre class="fasm-code">
proc GetParam, .obj, .paramID
</pre>
<p>Returns the value of the object <span class="variable">[.obj]</span> parameter with ID=<span class="variable">[.paramID]</span></p>

<a name="Set"><h4>Set</h4></a>
<p><span class="variable">.procSetParam</span> is a pointer to the procedure that set the properties of the object.</p>
<pre class="fasm-code">
proc Set, .obj, .paramID, .value
</pre>
<p>For object <span class="variable">[.obj]</span>, set the value of the parameter with ID=<span class="variable">[.paramID]</span></p>

<h4>ExecCmd</h4>
<p><span class="variable">.procExecCmd</span> is a pointer to the procedure that executes object method.</p>
<pre class="fasm-code">
proc ExecCmd, .obj, .method
</pre>
<p>For the object [.obj] this procedure executes the method with method ID in [.method].</p>
<p>The methods can have arbitrary number of arguments, that are defined in the "object" definition (see below). 
When the method is executed, the procedure <span class="procedure">[.procExecCmd]</span> accepts pointer to the arguments array in <span class="register">[ebx]</span></p>
<p>The user is supposed to call methods of the object with the macro "execute"
The macro is defined following way:</p>
<pre class="fasm-code">
macro execute obj*, meth*, [arg]
</pre>


<a name="SysEventHandler"><h4>SysEventHandler</h4></a>
<p><span class="variable">.procSysEventHandler</span> is a pointer to the procedure that process the system events that are send to the object, i.e. mouse events, keyboard events etc.</p>
<pre class="fasm-code">
proc SysEventHandler, .obj, .pEvent
</pre>
<p>Process one system event for object <span class="variable">[.obj]</span>. <span class="variable">[.pEvent]</span> contains pointer to the system event.</p>

<p>All of these procedures are called internally and should not be used by the user of the library. 
How these procedure are called will be described later.</p>

<p>TObjectClass structure is defined statically in memory in compile time, only once for every object class. Its definition is located in the library for the respective GUI element. For example CButton class structure is defined in the file TButton.asm that contains the code and data of the object class Button.</p>

<p>In order to make construction of such structures easy, macro with name ObjectClass is defined in objects.asm</p>

<a name="ObjectClass"><h3>ObjectClass Macro</h3></a>
<pre class="fasm-code">
macro ObjectClass name*, parent*, procCreate*, procDestroy*, procGetParam*, procSetParam*, procExecCmd*, procSysEvents*
</pre>

<p>Every defined ObjectClass have a label that points to the begin of the structure. The name of this label is the name of the class, prefixed with "C".</p>

<p>One example of ObjectClass definition is the definition of Window object class:</p>
<pre class="fasm-code">
ObjectClass Window,             \
            Object,             \
            TWindow.Create,     \
            TWindow.Destroy,    \
            TWindow.Get,        \
            TWindow.Set,        \
            TWindow.ExecCmd,    \
            TWindow.SysEventHandler
</pre>

<p>This definition creates following data structure:</p>
<pre class="fasm-code">
CWindow:
            dd  CObject         
            dd  sizeof.TWindow             
            dd  TWindow.Create
            dd  TWindow.Destroy    
            dd  TWindow.Get      
            dd  TWindow.Set,        
            dd  TWindow.ExecCmd
            dd  TWindow.SysEventHandler
</pre>



<a name="Object structure"><h3>Object structure</h3></a>
<p>Object instance is data structure that contains different fields. By that it is very similar to the normal FASM structures. As structures, the object is only description of the data but not the data itself. </p>
<p>Objects can inherit field definitions by its parent objects.
The memory instance of the object is allocated dynamically in runtime, when the object is created by call to the respective FreshLib functions.</p>
<p>The definition of the object looks like following:</p>

<pre class="fasm-code">
object TObject
  .ptrClass     dd ? 

  .OnCreate     dd ? 
  .OnDestroy    dd ?

  method .AddChild, .objchild
endobj


object TWindow, TObject
  .handle       dd ?   
  .Fcaption     dd ?    
  .Fcursor      dd ?    

  param .x
  param .y
  param .width
  param .height
  param .visible
  param .caption
  param .parent
  param .cursor

  method .Refresh
endobj


object TButton, TWindow
  .state      dd ?
  .Ficon      dd ?
  .FiconAlign dd ?
  .Ftextalign dd ?

  .OnClick dd ?

  param .TextAlign
  param .Icon
  param .IconPosition
endobj
</pre>

<p>By convention the names of the objects begin with "T".</p>
<p>You can see that the object TWindow contains data fields, parameters and methods. 
The parameters defined by "param" macro are compile time constants which values are assigned automatically. 
There constants are local labels for the object structure. They are also inherited from the parent structure.</p>
<p>The methods are very similar to parameters, in that they are constants, defined in compile time. 
But besides the constant, the method also have list of arguments, passed to the method, when executed.</p>


<p>In the above example, <span class="variable">TButton.width</span> parameter is inherited from <span class="variable">TWindow</span> and have the same value as <span class="variable">TWindow.width</span> parameter.</p>
<p>Also, <span class="variable">TWindow</span> have all fields of TObject defined as well.</p>
<p>If we have to translate TWindow definition in plain FASM syntax it will looks like this:</p>

<pre class="fasm-code">
struc TWindow {
  .ptrClass     dd ? 

  .OnCreate     dd ? 
  .OnDestroy    dd ?

  .handle       dd ?   
  .Fcaption     dd ?    
  .Fcursor      dd ?    

  .x       = $80000000
  .y       = $80000001
  .width   = $80000002
  .height  = $80000003
  .visible = $80000004
  .caption = $80000005
  .parent  = $80000006
  .cursor  = $80000007
}
virtual at 0
  TWindow TWindow
  sizeof.TWindow = $
end virtual
</pre>

<p>This directory contains the libraries providing portable GUI for assembly programming.</p>
<p class="note">Note that this libraries are in very early stage of development, so the description in this chapter is preliminary and probably will be changed in one or another way in the near future.</p>
<p>Later in this text, the whole GUI subsystem of FreshLib will be called FreshGUI</p>

<h2>FreshGUI structure</h2>
<p>The main idea behind the FreshGUI is to make one small OS dependent layer of functions, that to serve as an interface between the OS and the OS independent layer of the library.</p> 
<p>The first will translate OS events, such as mouse, keyboard, timers etc to one common standard of OS independent event handlers of the user interface objects – windows, buttons and other widgets.</p>
<p>The biggest advantage of this approach is that the portability of the library is very easy – most of the code is OS independent and only little  part of it have to be write in order to port the whole library to a new OS.</p>
<p>The biggest drawback of this approach is the bigger size of the library, because, with this architecture, all controls in the library have to be created  from scratch. It is impossible to use graphic controls that the OS provides – particularly Win32 controls - buttons, simple text editors, labels, combo boxes list and tree view controls etc.</p>
<p>FreshGUI is not aimed to use all complex GUI system of the target OS. At first time, the goal of FreshGUI is to provide minimal but decent functionality that will do the job – writing portable applications in assembly language.</p>
<h3>Graphics library</h3>
<p>The graphics library provides procedures that draw graphics images and text on the screen. The library is OS dependent and is placed in the directory "graphics" in the root directory of FreshLib. The main conception of this library is ".raster" - represented by handle, object where the drawing happens. The exact meaning for this object is different for the different OS – in Win32 it is named "device context", in Linux it is "drawable" - window or pixmap.</p>

<h3>Event translation layer</h3>

<h4>Library "sysevents.asm"</h4>
<p>This library contains event codes and data structures for FreshGUI OS independent events. For now only several events are defined:</p>
<pre class="fasm-code">
seMouseMove        
seMouseEnter       
seMouseLeave       
seMouseBtnPress    
seMouseBtnRelease  
seMouseBtnClick    
seMouseBtnDblClick 

seTimer            

seKbdKeyPress      
seKbdKeyRelease    
seKbdStatusChanged 
seKbdChar          

sePaint 
</pre>           
<p>These events cover mouse, keyboard, timers and paint events.</p>
<p>Every event have some arguments that have to be sent to the recipient event handler. The event code and the event arguments are contained in data structure, defined for every kind of events.</p>
<p>The first dword of the event structure is the field <span class="variable">.event</span> that contains the event code.</p>
<p>Here are the structures defined in sysevents.asm</p>
<pre class="fasm-code">
struct TSysEvent
  .event  dd  ?
ends
</pre>
<p>The base event structure.</p>

<pre class="fasm-code">
struct TMouseMoveEvent
  . TSysEvent
  .x         dd ?
  .y         dd ?
ends
</pre>
<p>The event is generated when the mouse cursor moves over some window or control. <span class="variable">.x</span> and <span class="variable">.y</span> contains the coordinates of the mouse cursor relative to the control this message is sent to.</p>

<pre class="fasm-code">
 struct TMouseButtonEvent
  . TSysEvent
  .Button    dd ?
  .kbdStatus dd ?
ends
</pre>
<p>This event is generated when some of the mouse buttons changes its state. The button that changes its state is specified in the field <span class="variable">.Button</span></p>
<p>This field can accept following values:</p>
<table style="margin-left: 40px;">
	<tr><td><span class="constant">mbLeft</span>  </td> <td align="right">= 0</td></tr>
	<tr><td><span class="constant">mbMiddle</span></td> <td align="right">= 1</td></tr>
	<tr><td><span class="constant">mbRight</span> </td> <td align="right">= 2</td></tr>
</table>
<p>The field <span class="variable">.kbdStatus</span> contains the status of remaining mouse buttons and keyboard modifying buttons. These buttons are represented by bits in the field:</p> 
<table style="margin-left: 40px;">
	<tr><td><span class="constant">maskBtnLeft</span>   </td> <td align="right">= $01</td></tr>
	<tr><td><span class="constant">maskBtnMiddle</span> </td> <td align="right">= $02</td></tr>
	<tr><td><span class="constant">maskBtnRight</span>  </td> <td align="right">= $04</td></tr>
	<tr><td><span class="constant">maskCtrl</span>      </td> <td align="right">= $08</td></tr>
	<tr><td><span class="constant">maskShift</span>     </td> <td align="right">= $10</td></tr>
</table>
<pre class="fasm-code">
struct TMouseEnterEvent
  . TSysEvent
ends
</pre>
<p>This event is generated when the mouse cursor enters or leaves some control. There is no additional parameters besides the event code.</p>

<pre class="fasm-code">
struct TKeyboardEvent
  . TSysEvent
  .key       dd  ?
  .kbdStatus dd  ?
ends
</pre>
<p>This event is generated on keyboard button press/release. The field <span class="variable">.key</span> contains the code of the pressed button. <span class="variable">.kbdStatus</span> have the same meaning and the same values as in TMouseButtonEvent.</p>

<pre class="fasm-code">
struct TTimerEvent
  . TSysEvent
ends
</pre>
<p>TTimerEvent is generated on timer events. :)</p>

<pre class="fasm-code">
struct TPaintEvent
  . TSysEvent
  .raster dd ?  ; ID of the raster where you should paint.
  .rect   RECT
ends  
</pre>
<p>TPaintEvent is generated when given control have to be repainted. The field <span class="variable">.raster</span> contains the handle to the graphic surface where the program have to draw. This handle have different meanings in the different target OS, but it simply need to be understandable by the graphics procedures from the OS dependent library graphics.asm.</p>
<p>The field <span class="variable">.rect</span> is the rectangle of the control that needs to be repainted.</p>

<h3>Library "main.asm"</h3>

<a name="Run"><h4>proc Run</h4></a>
<p>This procedure is the main program loop of the GUI application.</p>
<p>The procedure Run process all pending system events, then calls once the OnIdle event handler of the application object and then sleeps until new events are sent by the OS.</p>
<p>When the OS terminates the application – the procedure returns an exit code.</p>
<p>The user uses this procedure following way:</p>
<pre class="fasm-code">
        stdcall Run
        jmp     ExitApplication
</pre>

<a name="ProcessSystemEvents"><h4>proc ProcessSystemEvents</h4></a>
<p>This procedure process the events generated by the OS. If there are waiting events in the queue, the procedure reads them, translates them to FreshGUI  event data structures and calls the event handlers of the respective controls.</p>
<p>If there is no pending events in the queue, ProcessSystemEvents ends with <span class="flag">CF=0</span></p>
<p>The second task this procedure serves is to detect the end of the application. In this case it ends with <span class="flag">CF=1</span>.</p>
<p>This procedure is call from the main event loop of the application. Also, the user can periodically call this procedure in order to not allow hanging of the user interface during long processing of some data.</p>

<a name="WaitForSystemEvent"><h4>proc WaitForSystemEvent</h4></a>
<p>This procedure waits until some system message is posted to the application event queue. Then it exits. During the wait, very low CPU power is consumed by the application.</p>

<a name="Terminate"><h4>proc Terminate</h4></a>
<p>It provides all finalization tasks and ends the application. The exit code is provided in <span class="register">EAX</span>.</p>

<a name="Template engine"><h3>Template engine</h3></a>
<p>The template engine provides creation of complex window structures with tree layout from memory data structure, called template. The templates makes creation of dialog windows  containing children windows and non visual objects.</p>
<p>Templates can be visually created and edited. The template format used by FreshLib is flexible and allows all parameters and fields of the objects to be set to needed values during creation of the window.</p>
<p>The template engine is located in the file ObjTemplates.asm</p>

<a name="Template data structure"><h4>Template data structure</h4></a>
<p>The template is consisted from one or more data structures of type TObjTemplate, defined following way:</p>
<pre class="fasm-code">
struct TObjTemplate
  .flags     dd  ?     
  .class     dd  ?
  .ptrVar    dd  ?     
  .paramsize dd  ?
  .params:
ends
</pre>
<p><span class="variable">.flags</span> – controls what is the place of the object in the whole tree structure.</p>
<p>Can accept one or both of the following values, combined with OR:</p>
<table style="margin-left: 40px;">
	<tr><td><span class="constant">tfChild</span> </td><td>=0</td> <td>means the object is child of the last object with tfParent set.</td></tr>
	<tr><td><span class="constant">tfParent</span>  </td><td>=1</td> <td>means the given object is parent and there will be next TObjTemplate structure that will be a child object.</td></tr>
	<tr style="vertical-align: top;"><td><span class="constant">tfEnd</span>   </td><td> =2</td> <td>means the given object is the last child of its parent. Note, that one object can be parent and child in the same time. If the current template is at root level – the processing of template stops, after creating the current element and all its children.</td></tr>
</table>

<p><span class="variable">.class</span> – pointer to TObjectClass data structure for the created object.</p>
<p><span class="variable">.ptrVar</span> – pointer to dword variable that to accept the pointer to the created object.</p>
<p><span class="variable">.paramsize</span> – the size of the additional data to the end of the template. Note, that TObjTemplate is variable length structure, not fixed. sizeof.TObjTemplate contains the size of the header part of the structure.</p>
<p><span class="variable">.params</span>: after the header fields there can be arbitrary count of dword pairs: (<span class="variable">paramID</span>, <span class="variable">Value</span>) that to be set the the object during creation. This sequence ends with dword <span class="constant">$FFFFFF</span> (<span class="constant">-1</span>) value for paramID. </p>

<p>Easy creation of templates is provided with macro ObjTemplate:</p>
<pre class="fasm-code">
macro ObjTemplate  flags, class, name, [id, param]
</pre>
<p>This macro allows use of string values for params and computes automatically the values for <span class="variable">TObjTemplate.paramsize</span></p>
<p><span class="variable">flags</span> – set of (<span class="constant">tfParent</span>, <span class="constant">tfEnd</span>) constants.</p>
<p><span class="variable">class</span> – the base name of the object class (without prefix C) – i.e. Form, Window, Button, etc.</p>
<p><span class="variable">name</span> – label of the variable to receive the pointer to the created object.</p>
<p><span class="variable">id</span> – parameter ID or offset in the object structure.</p>
<p><span class="variable">param</span> – value of the parameter. Can be dword number or string constant. In the case the parameter value is string, it will be automatically created in the memory and the pointer to this string will be placed as a param value.</p>
<p>One simple example of template structure:</p>
<pre class="fasm-code">
ObjTemplate  tfParent or tfEnd, Form, frmMain, \
			 visible, TRUE, \
			 x, 100,        \
			 y, 50,         \
			 width, 640,    \
			 height, 480,   \
			 caption, 'Fresh portable Win32/Linux application test.'

  ObjTemplate  tfChild, Button, btnChild1,          \
			 visible, TRUE, \
			 x, 64,         \
			 y, 48,         \
			 width, 64,     \
			 height, 24,    \
			 caption, 'Button1',        \
			 OnClick, Button1Click

  ObjTemplate  tfChild or tfEnd, Button, btnChild2,          \
			 x, 136,         \
			 y, 48,         \
			 width, 64,     \
			 height, 24,        \
			 caption, 'Button2' ,\
			 visible, TRUE
</pre>

<a name="Template engine procedures"><h4>Template engine procedures</h4></a>
<p>Actually the procedure is one:</p>
<pre class="fasm-code">
proc CreateFromTemplate, .ptrTemplate, .parent
</pre>

<p>This procedure creates all objects from the template, pointed by <span class="variable">[.ptrTemplate]</span> as a parent of <span class="variable">[.parent]</span> argument.</p>
<p><span class="variable">.ptrTemplate</span> points to TObjTemplate structure.</p>
<p><span class="variable">.parent</span> points to TObject descendant structure. In most cases it will be actually descendant of TWindow or <span class="constant">NULL</span> if the created object is not a child of any window.</p>
<p>Returns: <span class="register">EBX</span> contains a pointer to the topmost of the created object (it is first of the created objects)</p>
<p>All pointers of the objects are stored in the specified in the template variables ( i.e. <span class="variable">[TObjTemplate.ptrVar]</span>)</p>
</nowiki>

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/_doc/compiler.wiki.

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
<nowiki>
<a name="data"><h1>FreshLib directory: compiler</h1></a>
<p>This directory contains only one macro library: "executable.inc"</p>
<p>This library defines the macros that are going to be used for creating the main structure of the program. These macros are OS dependent as long as the type of the executable file is OS dependent: PE for Win32 and ELF for Linux.</p>
<p>Every one of the macros from this library should be used only once in the program.</p>

<h3>FreshLib Executable macros</h3>
<p>This macro library contains:</p>
<a name="_BinaryType"><h4>_BinaryType</h4></a>
<pre class="fasm-code">macro _BinaryType type</pre>
<p>This macro sets the type of the executable. The argument <span class="variable">type</span> can accept one of the following values: <span class="constant">GUI</span>, <span class="constant">console</span> or <span class="constant">DLL</span>.</p>
<p>This macro defines also the entry label of the program. This label is fixed to <span class="constant">start:</span></p>
<p>For example, following code will tell the compiler to compile the program as a GUI application:</p>
<pre class="fasm-code">
include 'compiler/executable.inc'
_BinaryType GUI
</pre>

<a name="_CodeSection"><h4>_CodeSection</h4></a>
<pre class="fasm-code">macro _CodeSection</pre>
<p>This macro defines the section where the code of the program to be  placed.</p>
<p>Actually this section is the main section of the project. Here should be included all used libraries and other project files.</p>

<a name="_DataSection"><h4>_DataSection</h4></a>
<pre class="fasm-code">macro _DataSection</pre>

<p>This macro defines the section where the data of the program to be  placed. The common way to use this section is to use inside the macro <span class="procedure">IncludeAllGlobals</span> that will allow you to use data defining macros from every place inside the source and leave the compiler to order this data properly for you.</p>
<p>For details on using global data definition macros see: <a href="macros.html#_globals">_globals.inc</a></p>

<a name="_ImportSection"><h4>_ImportSection</h4></a>
<pre class="fasm-code">macro _ImportSection</pre>
<p>This macro defines the section where to be inserted the list with functions dynamically imported from external libraries.</p>
<p>Usually you only have to include here the library "allimports.asm"  and the compiler will import for you only those functions that are used in the project.</p>
</nowiki>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































Deleted freshlib/_doc/data.wiki.

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
<nowiki>
<table class="index" align="right">
	<tr><td class="index"><p></p>
		<b><a href="freshlib_reference.wiki">FreshLib</a>:Data:</b><br />
		<a href="#Arrays">Arrays</a><br />
		<a href="#Strings">Strings</a><br />
	</p></td></tr>
</table>
<a name="data"><h1>FreshLib directory: data</h1></a>
<p>This directory contains data handling routines and useful data structures. Actually it contains two abstract data structures: Arrays and Strings.</p>
<p class="note">Current implementation is fully portable: it does not contain any OS dependent code.</p>
<a name="Arrays"><h2>FreshLib Arrays</h2></a>
<p>The FreshLib <b>Arrays</b> data structure handles dynamic arrays that contain elements of arbitrary size.</p>
<h3>Structure</h3>
<p>The following structure represents the header of the array. The actual array will have arbitrary size, depending on the element count and size.</p>
<pre class="fasm-code">
struct TArray
  .count     dd ?
  .capacity  dd ?
  .itemsize  dd ?
  .lparam    dd ?
  label .array dword
ends
</pre>

<p>The first element of the array begins on offset <span class="variable">TArray.array</span> from the begining of the memory block.</p>
<p>The field <span class="variable">TArray.count</span> contains the current element count of the array.</p>
<p>The field <span class="variable">TArray.capacity</span> contains the current capacity of the array. It is because the library usually allocates more memory than is needed for the array element count. This approach reduces memory allocations and reallocations and thus increases the speed of inserting and deleting elements in the array. How many memory will be allocated depends on the user setting of the variable <span class="variable">ResizeIt</span> (defined in <a  href="system.html#memory">memory.asm</a>). This variable contains a pointer to the procedure that simply increases the value of <span class="register">ECX</span> to the next suitable value.</p>
<p>The field <span class="variable">TArray.itemsize</span> contains the size in bytes of one array element. Changing of this value is not recommended.</p>
<p>The field <span class="variable">TArray.lparam</span> is for user defined parameter, associated with the array.</p>

<h3>Procedures</h3>

<a name="CreateArray"><h4>CreateArray</h4></a>
<pre class="fasm-code">
proc CreateArray, .itemSize
</pre>
<p>This procedure creates new array with item size <span class="variable">[.ItemSize]</span></p>
<p>The procedure returns <span class="flag">CF=0</span> if the array is properly created and pointer to the array is placed in <span class="register">EAX</span>.</p>
<p>In case the memory cannot be allocated, the procedure returns <span class="flag">CF=1</span>.</p>
<p>The array must be freed after use. There is no special procedure for array free. Use <span class="procedure">FreeMem</span> procedure to free array memory after use.</p>

<a name="AddArrayItems"><h4>AddArrayItems</h4></a>
<pre class="fasm-code">
proc AddArrayItems, .ptrArray, .count
</pre>
<p>This procedure adds new array items at the end of the array pointed by <span class="variable">[.ptrArray]</span></p>
<p>The procedure returns two values:</p>
<p><span class="register">EAX</span> contains pointer to the first of the new appended elements.</p>
<p><span class="register">EDX</span> contains pointer to the array (in the process of appending of the new element, it is possible the whole array to be moved to the new address in memory, so the programmer should store the value of <span class="register">EDX</span> for the future reference to the array.</p>
<p>In case, the new memory can not be allocated, the procedure returns <span class="flag">CF=1</span> and <span class="register">EDX</span> contains the proper pointer to the original array.</p>

<a name="InsertArrayItems"><h4>InsertArrayItems</h4></a>
<pre class="fasm-code">
proc InsertArrayItems, .ptrArray, .iElement, .count
</pre>
<p>This procedure inserts [.count] new elements at the <span class="variable">[.iElement]</span> position of the array pointed by <span class="variable">[.ptrArray]</span></p>
<p>If <span class="variable">[.iElement]</span> is larger or equal to <span class="variable">[TArray.count]</span> the elements are appended at the end of the array. (Just like AddArrayItems)  Otherwise, all elements are moved  to make room for the new elements.</p>
<p>The procedure returns exactly the same results as <span class="procedure">AddArrayItems</span> procedure  <span class="register">EDX</span>  points to the array and <span class="register">EAX</span>  points to the first of the new inserted elements.</p>
<p><span class="flag">CF</span> is error flag.</p>

<a name="DeleteArrayItems"><h4>DeleteArrayItems</h4></a>
<pre class="fasm-code">
proc DeleteArrayItems, .ptrArray, .iElement, .count
</pre>
<p>This procedure deletes [.count] items with begin index <span class="variable">[.iElement]</span> the <span class="variable">[.ptrArray]</span> dynamic array.  If the capacity of the array is bigger than the recommended for the new count, then the array is resized. The recommended size is calculated using ResizeIt procedure from memory library.</p>
<p>Returns <span class="register">EDX</span> - pointer to the TArray. In the most cases this pointer will not be changed, but this also depends on the current OS memory allocation API, so it is safer to store the pointer for future use, instead of one passed to the procedure.</p>
<p>This procedure can not fail, because deleting element is always possible. In some rare cases it can fail to reallocate smaller memory block, but this is not a problem for the array consistency.</p>

<a name="VacuumArray"><h4>VacuumArray</h4></a>
<pre class="fasm-code">
proc VacuumArray, .ptrArray
</pre>
<p>This procedure removes the reserved memory from the array in order to make it as small as possible. This operation should be executed only if there will be no more inserts in the array. The memory economized this way depends on reallocation strategy and can be from 25 to 100% in some cases.</p>

<a name="ListIndexOf"><h4>ListIndexOf</h4></a>
<pre class="fasm-code">
proc ListIndexOf, .ptrList, .Item
</pre>
<p>The list is a special case of array with item size equal to 4 bytes (dword). This procedure searches the list <span class="variable">[.ptrList]</span> for item equal to <span class="variable">[.Item]</span> and returns the index of the element in <span class="register">EAX</span>. In case of error  <span class="flag">CF=1</span>.</p>

<a name="ListFree"><h4>ListFree</h4></a>
<pre class="fasm-code">
proc ListFree, .ptrList, .FreeProc
</pre>
<p>Frees all elements of the list <span class="variable">[.ptrList]</span>, calling <span class="variable">[.FreeProc]</span> for every element of the list.</p>
<p>FreeProc callback procedure have one argument of type dword that is the value of the current list element. The definition of the callback procedure is similar to following:</p>
<pre class="fasm-code">
proc FreeMyListItem, .ptrItem
begin
	;do something with the item being freed
	return
endp
</pre>

<a name="Strings"><h2>FreshLib Strings</h2></a>
<p>Using strings in assembler was often problematic for programmers - static strings can't be resized, so they had to reserve as many bytes as they thought user could need, and it still could be not enough. Thus we created StrLib - a library that operates on dynamic strings, that are automatically resized when needed. Also, StrLib contains many functions that perform string comparison, inserting one string into another, and more. And most of this functions can operate on static strings too. StrLib uses "memory.asm" library for memory allocations and does not contains any OS dependent code.</p>
<p class="note">FreshLib Strings uses FreshLib Arrays to handle the list with pointers to allocated string memory.</p>

<h3>StrLib string format</h3>
<p>The strings used in StrLib are implemented using a specific structure, compatible but not equal to AsciiZ, used by Windows API. The string structure is defined in the following way:</p>
<pre class="fasm-code">
struc string {
  .capacity dd ?
  .len      dd ?
  label .data byte
}

virtual at -(sizeof.string)
  string string
  sizeof.string = $-string
end virtual
</pre>

<p>The string data is placed on offset 0 to the pointer of the string. Its label is "string.data". The string data always is terminated by at least one zero byte and the length of the memory buffer is always dword aligned. 
It is safe to process the string data by dword instructions.</p>
<p>On offset [string-4] is located a dword field, that contains the length of the string data, not including the terminating zero bytes.</p>
<p>On offset [string-8] is located a dword with the capacity of the memory allocated for the string.</p>
<p>These fields are accessible by its symbolic names: string.len and string.capacity; This fields are for internal use only  it is not safe for the user to change the values of these fields.</p>
<p>Using special field that to keep the length of the string makes some of the string operations extremely fast, because searching for the terminating zero is very slow operation. </p>
<p>All procedures in StrLib compute the proper value for <span class="variable">[.len]</span> field and never search for the terminating zeros, except for the AsciiZ strings that are external towards StrLib  those returned from the OS API functions or by string constants in memory.</p>

<h3>StrLib string handles</h3>
<p>The string in StrLib is identified not with its pointer, but by a handle. While the pointer can be changed when the string memory is reallocated, the handle is always a constant for the whole life cycle of the string.</p>
<p>There is a procedure that extracts the current pointer of the string by its handle.</p>
<p>	Because handle values never collides with memory addresses, almost all StrLib procedures can work with handles and with memory pointers at the same time.</p>
<p>For the strings passed to the procedures with memory pointer, StrLib assumes they are static strings from memory, or returned from the OS. </p>
<p>Because of this assumption, StrLib process these strings safely and slowly  scans the string to determine the length, assumes it is byte aligned etc. In other words it process it as a standard AsciiZ string.</p>

<h3>StrLib procedures</h3>
<a name="StrNew"><h4>StrNew</h4></a>
<pre class="fasm-code">proc StrNew</pre>
<p>Creates new string and returns handle in <span class="register">EAX</span>.</p> 

<a name="StrPtr"><h4>StrPtr</h4></a>
<pre class="fasm-code">proc StrPtr, .hString</pre>
<p>Returns the current pointer to the string with handle <span class="variable">[.hString]</span>.</p>
<p>If <span class="variable">[.hString]</span> looks like a valid handle, but it is not found in the strings table, the procedure returns <span class="flag">CF=1</span>.</p>

<a name="StrDel"><h4>StrDel</h4></a>
<pre class="fasm-code">proc StrDel, .hString</pre>
<p>Deletes the string with handle <span class="variable">[.hString]</span> and frees all allocated memory. If <span class="variable">[.hString]</span> is a pointer, it tries to search the strings table for the given handle and deletes it.</p>
<p>If a string is not found, the procedure does not return an error.</p>

<a name="StrDup"><h4>StrDup</h4></a>
<pre class="fasm-code">proc StrDup, .hSource</pre>
<p>Creates a duplicate of the string <span class="variable">.hSource</span>. Returns a handle to the new created string in <span class="register">EAX</span>.</p>

<a name="StrLen"><h4>StrLen</h4></a>
<pre class="fasm-code">proc StrLen, .hString</pre>
<p>Returns the length of the string <span class="variable">[.hString]</span>. If the handle is valid, it returns the value of the field <span class="variable">[string.len]</span>. If <span class="variable">[.hString]</span> is a pointer, it computes the length by scanning the string up to the zero terminator.</p>

<a name="StrFixLen"><h4>StrFixLen</h4></a>
<pre class="fasm-code">proc StrFixLen, .hString</pre>
<p>This procedure scans the length of zero terminated string and "fixes" <span class="variable">[string.len]</span> field. StrFixLen should be call when the content of the string is created by an external call, for example a Win32 API function.</p>

<a name="StrSetCapacity"><h4>StrSetCapacity</h4></a>
<pre class="fasm-code">proc StrSetCapacity, .hString, .capacity</pre>
<p>If the capacity of <span class="variable">[.hString]</span> is larger than the requested capacity it does nothing.</p>
<p>If the capacity of <span class="variable">[.hString]</span> is smaller than the requested capacity, it sets the capacity of the string to the requested value.</p>
<p>Returns a pointer to the string after reallocation in <span class="register">EAX</span>.</p>
<p><span class="variable">.hString</span> is a handle to the string that have to be resized. Pointers are not acceptable here.</p>
<p><span class="variable">.capacity</span> contains requested capacity for the string.</p>
<p>If returns <span class="flag">CF=1</span> the reallocation failed. <span class="register">EAX</span> still contains the pointer to the string, but the string was not resized.</p>

<a name="StrCopy"><h4>StrCopy</h4></a>
<pre class="fasm-code">proc StrCopy, .dest, .source</pre>
<p>Copies the content of <span class="variable">[.source]</span> string to <span class="variable">[.destination]</span> string.</p>

<a name="StrCompCase"><h4>StrCompCase</h4></a>
<pre class="fasm-code">proc StrCompCase, .str1, .str2</pre>
<p>Compares the content of two strings <span class="variable">[.str1]</span> and <span class="variable">[.str2]</span> case sensitive.</p>
<p>Returns:</p> 
<p><span class="flag">CF=1</span> if the strings are EQUAL.</p>  
<p><span class="flag">CF=0</span> if the strings are NOT equal.</p> 

<a name="StrCompNoCase"><h4>StrCompNoCase</h4></a>
<pre class="fasm-code">proc StrCompNoCase, .str1, .str2</pre>
<p>Compares the content of two strings <span class="variable">[.str1]</span> and <span class="variable">[.str2]</span> case NOT sensitive.</p>
<p>Returns:</p>
<p><span class="flag">CF=1</span> if the strings are EQUAL</p>
<p><span class="flag">CF=0</span> if the strings are NOT equal.</p>

<a name="SetString"><h4>SetString</h4></a>
<pre class="fasm-code">proc SetString, .ptrHString, .ptrSource</pre>
<p>Creates string and assigns it to variable. If the variable already contains string handle, the old string will be  reused. Copies the content of <span class="variable">[.ptrSource]</span> to the string variable.</p>
<p>Arguments:</p>
<p><span class="variable">.ptrHString</span>  pointer to the variable that contains string handle.</p>
<p><span class="variable">.ptrSource</span>  pointer to the source for string.</p>

<a name="StrCat"><h4>StrCat</h4></a>
<pre class="fasm-code">proc StrCat, .dest, .source</pre>
<p>Concatenates two strings. The operation is: destination = destination + source.</p>
<p>The destination string <span class="variable">[.dest]</span> can be only handle. <span class="variable">[.source]</span> can be handle or pointer.</p>

<a name="StrCharPos"><h4>StrCharPos</h4></a>
<pre class="fasm-code">proc StrCharPos, .hString, .char</pre>
<p>StrCharPos returns a pointer to the first occurrence of a given char in specified string.</p>
<p>Arguments:</p>
<p><span class="variable">.hString</span> -  string to search</p>
<p><span class="variable">.char</span> - char to look for</p>
<p>Returns:</p>
<p>A pointer to the char in source, or <span class="constant">NULL</span> if char doesn't occur in the given string.</p>

<a name="StrPos"><h4>StrPos</h4></a>
<pre class="fasm-code">proc StrPos, .hString, .hPattern</pre>
<p>StrPos returns a pointer to the first occurrence of a <span class="variable">.hPattern</span> string in <span class="variable">.hString</span>.
<p>Arguments:</p>
<p>hPattern - 'pattern' string</p>
<p>hString -  string to search</p>
<p>Returns:</p>
<p>Pointer to the pattern string in source, or <span class="constant">NULL</span> if pattern string doesn't occur in the string to search.</p>

<a name="StrCopyPart"><h4>StrCopyPart</h4></a>
<pre class="fasm-code">proc StrCopyPart, .dest, .source, .pos, .len</pre>
<p>Copies part of the source string to the destination string.</p>
<p>Arguments:</p>
<p><span class="variable">.dest</span>  handle to destination string.</p>
<p><span class="variable">.source</span>  handle or pointer to the source string.</p>
<p><span class="variable">.pos</span>  Source part start position.</p>
<p><span class="variable">.len</span>  length of the copied part.</p>
<p>Returns nothing.</p>

<a name="StrExtract"><h4>StrExtract</h4></a>
<pre class="fasm-code">proc StrExtract, .string, .pos, .len</pre>
<p>The same as StrCopyPart, but creates and returns new string with extracted part of the source <span class="variable">[.string]</span></p>
<p>Returns the new created string in <span class="register">EAX</span>.</p>

<a name="StrSplit"><h4>StrSplit</h4></a>
<pre class="fasm-code">proc StrSplit, .hString, .pos</pre>
<p>Splits the string on two strings, at position <span class="variable">[.pos]</span></p>
<p>Arguments:
<p><span class="variable">.hString</span>  handle of the string to be split.</p>
<p><span class="variable">.pos</span>      -  position where to split the string.</p>
<p>Returns:
<p><span class="register">EAX</span> - handle to the new created string with second part of the string. The original string does not reallocate memory and it's capacity and the pointer will remains the same.</p>

<a name="StrInsert"><h4>StrInsert</h4></a>
<pre class="fasm-code">proc StrInsert, .dest, .source, .pos</pre>
<p>Inserts the string <span class="variable">[.source]</span> into the string <span class="variable">[.dest]</span> at position [.pos]</span></p>

<a name="StrLCase"><h4>StrLCase</h4></a>
<pre class="fasm-code">proc StrLCase, .hString</pre>
<p>Converts <span class="variable">[.hString]</span> to lower case.</p>


<a name="StrUCase"><h4>StrUCase</h4></a>
<pre class="fasm-code">proc StrUCase, .hString</pre>
<p>Converts <span class="variable">[.hString]</span> to upper case.</p>

<a name="NumToStr"><h4>NumToStr</h4></a>
<pre class="fasm-code">proc NumToStr, .num, .flags</pre>
<p>Converts the given number to a string representing it.</p>
<p><span class="variable">[.flags]</span> controls how the number to be converted.</p> 
<p>The procedure returns a handle to the string in <span class="register">EAX</span> and direct pointer to the string in <span class="register">EAX</span>.</p>
<p>The <span class="variable">[.flags]</span> is a dword with following format:</p>
<p>The LSB contains the number of digits, the number must have, if ntsFixedWidth flag is specified.</p>
<p>Second byte of <span class="variable">[.flags]</span> contains the radix that to be used for conversion.</p>
<p>The third and the fourth bytes are reserved for bit flags.</p>
<p>Following constants are predefined in StrLib in order to set the value for <span class="variable">[.flags]</span>:</p>
<table style="margin-left: 40px;">
<tr><td><span class="constant">ntsSigned</span></td><td>converts number in signed format.</td><td align="right">$00000</td></tr>
<tr><td><span class="constant">ntsUnsigned</span></td><td>converts number in unsigned format.</td><td align="right">$10000</td></tr>
<tr><td><span class="constant">ntsFixedWidth</span></td><td>the count of the digits is fixed.</td><td align="right">$20000</td></tr>
<tr><td><span class="constant">ntsBin</span></td><td>for binary number</td><td align="right">$0200</td></tr>
<tr><td><span class="constant">ntsQuad</span></td><td>for quad number</td><td align="right">$0400</td></tr>
<tr><td><span class="constant">ntsOct</span></td><td>for octal number</td><td align="right">$0800</td></tr>
<tr><td><span class="constant">ntsDec</span></td><td>for decimal number</td><td align="right">$0a00</td></tr>
<tr><td><span class="constant">ntsHex</span></td><td>for hexadecimal number</td><td align="right">$1000</td></tr>
</table>
<p>Example:</p>
<pre class="fasm-code">stdcall NumToStr,<span class="register">EAX</span>,	ntsDec or ntsFixedWidth or 8</pre>
<p>This example will convert the number in <span class="register">EAX</span> to a signed decimal number with exactly 8 digits. If <span class="register">EAX</span> contains <span class="constant">$00000080</span>, the result string will be <span class="constant">'00000128'</span>.</p>

<a name="StrCharCat"><h4>StrCharCat</h4></a>
<pre class="fasm-code">proc StrCharCat, .hString, .char</pre>
<p>This procedure appends up to 4 characters at the end of the string <span class="variable">[.hString]</span>. The characters are contained in the dword argument <span class="variable">[.char]</span></p>

<a name="StrCharInsert"><h4>StrCharInsert</h4></a>
<pre class="fasm-code">proc StrCharInsert, .hString, .char, .pos</pre>
<p>Inserts up to 4 characters <span class="variable">[.char]</span> at position <span class="variable">[.pos]</span> in the string <span class="variable">[.hString]</span></p>

<a name="StrHash"><h4>StrHash</h4></a>
<pre class="fasm-code">proc StrHash, .hString</pre>
<p>Computes 32 bit hash value from the string <span class="variable">[.hString]</span>. This procedure implements the hash algorithm FNV-1b. Returns the result in <span class="register">EAX</span>.</p>
</nowiki>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































Deleted freshlib/_doc/equates.wiki.

1
2
3
4
5
<nowiki>
<a name="data"><h1>FreshLib directory: equates</h1></a>
<p>This directory contains the equates library "allequates.inc". This library defines all constants and structures needed for OS dependent parts of FreshLib.</p> 
<p>The user should never use these constants and structures in the portable program.</p>
</nowiki>
<
<
<
<
<










Deleted freshlib/_doc/freshlib.css.

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
body {
	margin: 0px auto 0px auto;
	padding: 2px;
	text-align: justify;
}

p {
	padding-left: 20px;
}

td {
	padding: 2px 8px 2px 8px;
}

span.register {
	margin: 0px;
	padding: 2px;
}

span.variable {
	margin: 0px;
	padding: 2px;
}

span.flag {
	margin: 0px;
	padding: 2px 2px 2px 2px;
}

span.constant {
	margin: 0px;
	padding: 2px 2px 2px 2px;
}

span.procedure {
	margin: 0px;
	padding: 2px 2px 2px 2px;
	font-weight: bold;
}

p.note {
	margin: 0px;
	padding: 2px 2px 2px 26px;
}

p.todo {
	margin: 0px;
	padding: 2px 2px 2px 26px;
}

pre.fasm-code {
	margin: 4px 4px 4px 20px;
	padding: 2px 6px 2px 6px;
}

@media screen {
	body {
		background-color: #ffffe8;
		max-width: 1024px;
		font: "fresh";
		font-family: FreeSans, Verdana, sans-serif;
		font-size: 10pt;
	}

	/* The project logo in the upper left-hand corner of each page */
	div.logo {
		display: table-cell;
		text-align: center;
		vertical-align: bottom;
		font-weight: bold;
		color: #000000;
		min-width: 100px;
	}

	/* The page title centered at the top of each page */
	div.title {
		display: table-cell;
		font-size: 20px;
		font-weight: bold;
		text-align: left;
		padding: 0 0 0 1em;
		color: black;
		vertical-align: middle;
		width: 100% ;
	}

	/* The main menu bar that appears at the top of the page beneath
	** the header */
	div.mainmenu {
		padding: 5px 10px 5px 10px;
		font-size: 12px;
		font-weight: bold;
		text-align: center;
		letter-spacing: 1px;
		background-color: #ff7000;
		border: 1px solid red;
		color: white;
	}

	/* The submenu bar that *sometimes* appears below the main menu */
	div.submenu {
		padding: 2px 10px 2px 10px;
		margin: 3px 0px 3px 0px;
		font-size: 12px;
		text-align: center;
		background-color: #ffff70;
		color: #000080;
		border: 1px solid red;
	}
	div.mainmenu a, div.mainmenu a:visited {
		padding: 3px 10px 3px 10px;
		color: white;
		text-decoration: none;
	}

	div.submenu a, div.submenu a:visited {
		padding: 1px 10px 1px 10px;
		color: black;
		text-decoration: none;
	}


	div.mainmenu a:hover {
		color: #558195;
		background-color: white;
	}


	div.submenu a:hover {
		color: black;
		background-color: #40ffa0;
	}

	/* All page content from the bottom of the menu or submenu down to
	** the footer */
	div.content {
		padding: 8px 8px 8px 8px;
		font-size: 12px;
		max-width: 800px;
		margin: 4px auto 4px auto;
		background-color: white;
		border: 1px #a0a0a0 solid;
	}

	/* The footer at the very bottom of the page */
	div.footer {
		font-size: 12px;
		margin-top: 2px;
		padding: 5px 10px 5px 10px;
		text-align: right;
		background-color: #ff7000;
		border: 1px solid red;
		color: white;
	}

	td {
		font: "fresh";
		font-family: "helvetica";
		font-size: 10pt;
	}

	span.register {
		background-color: #FFCCFF;
	}

	span.variable {
		background-color: #CCFFFF;
	}

	span.flag {
		background-color: #FFFFCC;
	}

	span.constant {
		background-color: #CCFFCC;
	}

	span.procedure {
		font-weight: bold;
	}

	p.note {
		background-color: #FFFFCC;
		border: 1px solid #FFCCCC;
	}

	p.todo {
		background-color: #FFCCCC;
		border: 1px solid #FF9999;
	}

	pre.fasm-code {
		max-width: 700px;
		background-color: #F3F3F3;
		border: 1px dashed #C0C0C0;
		font-size: 9pt;
	}

}

@media print {
	body {
		background-color: none;
		font-family: FreeSans, Verdana, sans-serif;
	}
	div.mainmenu {
		visibility: hidden;
	}
		
	div.submenu {
		visibility: hidden;
	}

	a {
		text-decoration: none;
	}

}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































































Deleted freshlib/_doc/freshlib_reference.wiki.

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
<nowiki>
<table class="index" align="right">
	<tr><td class="index"><p></p>
		<b><a href="/home">Home</a>:FreshLib:</b><br />
		<a href="compiler.wiki">compiler</a><br />
		<a href="data.wiki">data</a><br />
		<a href="equates.wiki">equates</a><br />
		<a href="graphics.wiki">graphics</a><br />
		<a href="GUI.wiki">GUI</a><br />
		<a href="imports.wiki">imports</a><br />
		<a href="macros.wiki">macros</a><br />
		<a href="simpledebug.wiki">simpledebug</a><br />
		<a href="system.wiki">system</a><br />
	</p></td></tr>
</table>
<h3>Overview</h3>

<p>FreshLib is an assembly library aimed to ease the development of rapid assembly language applications, freely portable between different platforms, such as Win32 or Linux.</p>
<p>The  library is coded in flat assembler syntax <a href="http://www.flatassembler.net">(fasm)</a> and is intended to be easily used within <a href="http://fresh.flatassembler.net">Fresh IDE</a> although it could be used for plain fasm development.</p>

<p>The library consists of two layers: one that is OS dependent and a second one that is OS independent. The OS dependent layer is very small, in order to help porting it for different OS. This layer only makes interface to the core OS functions, such as memory allocations, file access, drawing functions, simple window management etc.</p>

<p>The OS independent layer is responsible for the main application functionality allowing creation of different kind of windows and controls, user interaction with the program and interaction between particular windows and other GUI elements.</p>
<p>FreshLib is mainly intended for developing GUI applications, as they are the most challenging to be ported across different platforms. FreshLib is also created with visual programming in mind, so it contains a flexible, event driven and OS independent template engine allowing visual creation of application user interfaces.</p>
<p>FreshLib is in early development stage and probably will be changed many times in order to reach their objectives: to be small, fast and easy to use.</p>

<p>The main intention is to keep the bloat off the library, but containing all necessary accessories for comfortable programming of a very wide range of applications.</p>

<p>The architecture of FreshLib is open and it can be freely expanded with other libraries without increasing the size of applications. In other words, only those parts of the library that are effectively used will be compiled on the final executable.</p>

<h3>About this manual</h3>

<p class="todo">This manual is a "work in progress". Any part of it can be changed at any time.</p>
<p>Of course, some of the libraries described in this document are more stable and finished like the macro, system and data libraries. Therefore, the chapters about these libraries are less likely to be changed. Other libraries (like graphics and GUI), will be heavily modified  so the manual will be changed accordingly.</p>

<h3>Structure of the library</h3>
<p>FreshLib contains many code and macros libraries, structured hierarchically and depending on each other. Here is the directory tree of the library:</p>
<ul>
<li><a href="compiler.wiki">compiler</a></li>
<li><a href="data.wiki">data</a></li>
<li><a href="equates.wiki">equates</a></li>
<li><a href="graphics.wiki">graphics</a></li>
<li><a href="GUI.wiki">GUI</a></li>

<li><a href="imports.wiki">imports</a></li>
<li><a href="macros.wiki">macros</a></li>
<li><a href="simpledebug.wiki">simpledebug</a></li>
<li><a href="system.wiki">system</a></li>
</ul>
<p>The library is structured to support different platforms transparently. The platform dependient code is contained in a subdirectory of each library component. For example, "system" subdirectory contains libraries for accessing system resources  such as memory, files, etc. Inside "system" there several subdirectories that contain OS dependent code  these directories are named after the platform they serve.</p>
<p class="note">Currently, only Win32 and Linux platforms are supported.</p>
<h3>Getting started</h3>
<p>FreshLib main scope is to provide a fast and easy framework to start programming multiplatform assembly applications. Now, <a href="starting.wiki">what is needed to start writing applications?</a></p>
<h3>Tutorials</h3>
<ul>
	<li><a href="starting.wiki#simplest">Simplest Application</a></li>
	<li><a href="starting.wiki#files">Creating Files</a></li>
	<li><a href="starting.wiki#console">Basic Console</a></li>
	<li><a href="starting.wiki#GUI">Basic GUI</a></li>
</ul>
</nowiki>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































Deleted freshlib/_doc/imports.wiki.

1
2
3
4
5
6
<nowiki>
<a name="data"><h1>FreshLib directory: imports</h1></a>
<p>Another directory that contains only OS dependent definitions is "imports" with a library file to be included in the project: "allimports.asm"</p> 
<p>This file have to be included in the _IncludeSection of the application. Then it will generate the proper import section, depending on the target platform and functions used by the OS dependent parts of FreshLib.</p>
<p>The user should never call directly imported functions from inside the portable application.</p>
</nowiki>
<
<
<
<
<
<












Deleted freshlib/_doc/index.wiki.

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
<nowiki>
<table class="index" align="right">
<tr><td class="index">
<p><b>Index</b><br />
<a href="http://fresh.flatassembler.net">Fresh home</a><br />
<a href="/doc/FreshLibDev/freshlib/_doc/freshlib_reference.wiki">FreshLib reference</a><br />
<a href="/doc/trunk/doc/fresh_user_guide.html">Fresh tips&amp;tricks</a><br />
</p></td></tr>
</table>

<p>Fresh is a visual assembly language IDE with built-in FASM assembler.
</p>

<p>The main goal of Fresh is to make programming in assembly as fast and
efficient as in other visual languages, without sacrificing the small
application size and the raw power of assembly language.
</p>

<p>Because Fresh is the logical continuation of the FASM project in the
area of visual programming, it is perfectly compatible with FASM and you
can use all your knowledge about FASM to program in Fresh.
</p>

<p>Of course, you can use Fresh not only for Windows programming, but also
to create programs for any OS that FASM supports - DOS, Linux, FreeBSD,
BeOS, MenuetOS - the same way as you do this in FASM.
</p>

<p>This site is <a href="http://www.fossil-scm.org">fossil</a> repository of Fresh sources.
You can clone the repository with following fossil command:
<pre><b>fossil clone http://chiselapp.com/user/johnfound/repository/FreshIDE/ Fresh.fossil</b></pre>
</p>

<p>In order to use more functionality in this site, please <a href="/login">login</a> as "anonimous" user.
Particularly you will be able to follow the links in the source tree, to download code and to fill bug reports and feature requests.
</p>

<p>If you want to contribute to the project, please contact me (johnfound) on <a href="http://board.flatassembler.net">FASM message board</a>
</p>

<p>In order to download compiled FreshIDE, visit <a href="http://fresh.flatassembler.net">Fresh IDE home page.</a>
</p>

<p>You can report bugs, or make some feature requests here, in the <a href="/reportlist">Tickets system</a>
</p>
</nowiki>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































Deleted freshlib/_doc/macros.wiki.

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
<nowiki>
<table class="index" align="right">
	<tr><td class="index"><p></p>
		<b><a href="freshlib_reference.wiki">FreshLib</a>:Macros:</b><br />
		<a href="#_stdcall">_stdcall.inc</a><br />
		<a href="#_globals">_globals.inc</a><br />
		<a href="#_struct">_struct.inc</a><br />
		<a href="#_display">_display.inc</a><br />
	</p></td></tr>
</table>
<a name="macros"><h1>FreshLib directory: macros</h1></a>
<p>This directory contains several libraries that provides common convenience functions to be used with big assembly projects. All libraries can be included in the project at once from the file "allmacros.inc".</p>
<p>There is no overhead at including all those libraries because there is no code to be generated, just macros. There is a little delay in compile time but thanks to fasm's speed, it is barely noticeable.</p>
<p>Lets examine each one of these libraries.</p>
<a name="_stdcall"><h2>FreshLib _stdcall.inc</h2>
<p>In general this library provides ways of definition and invoking of the procedures with argument passing through the stack. It supports STDCALL and CCALL calling conventions.</p>
<pre class="fasm-code">
macro proc name, [arg]
macro begin
macro endp
macro return
macro cret
macro locals
macro endl
</pre>
<p>These macros define a procedure, creates a stack frame for the local variables and defines symbolic names for the arguments. The macro "proc" defines the global label "name" as a name for the procedure. All arguments and local variables are defined as a local labels with regard to the name of the procedure. That is why all arguments and local variables must have names beginning with dot.</p>
<p>Between the line with "proc" and "begin", any number of local variables can be defined. The macro "begin" marks the begining of the procedural code.</p>
<p>The macro "endp" marks the end of the procedural code.</p>
<p>The return from procedure instruction is provided by macros "return" or "cret" depending on the calling convention we want to use: "return" clears the arguments from the stack and "cret" do not.</p>
<p>Inside the procedure, a secondary stack frame can be allocated with the pair "locals" and "endl".  All data definitions, enclosed between these macros will define a secondary stack frame that is a continuation of the stack frame defined between "proc" and "begin".</p>

<p>Any number of "locals" and "endl" pairs can be used, but all of these secondary stack frames will overlap between each other. This feature is specially intended to provide savings of stack space and at the same time, to provide talking variable names for the different parts of more complex procedures.</p>
<p>For example (in Win32) if we have complex window procedure that have to process multiple messages: One of the message handlers may need one variable <span class="variable">.rect</span>. Another message handler may need two variables called <span class="variable">.point1</span> and <span class="variable">.point2</span>. But the procedure as a whole is never going to need all those variables at the same time, because it process only one message at a time. On the other hand it may need the variable <span class="variable">.ctrldata</span> for every message processed. The optimal solution is to define the variables in the following way:</p>
<pre class="fasm-code">
proc CtrlWinProc,.hwnd,.wmsg,.wparam,.lparam
.ctrldata dd ?
begin
    invoke GetWindowLong, [.hwnd], GWL_USERDATA
    mov    [.ctrldata], eax

    cmp    [.wmsg], WM_MESSAGE1
    je     .message1
    cmp    [.wmsg], WM_MESSAGE2
    je     .message2
    return

.message1:
locals
  .rect RECT
endl
    return

.message2:
locals
  .point1 POINT
  .point2 POINT
endl
    return
endp
</pre>
<p>In the above example, <span class="variable">.ctrldata</span> is defined on <span class="register">[EBP-4]</span>; <span class="variable">.rect</span> is defined on <span class="register">[EBP-20]</span>; <span class="register">.point1</span> is also defined on <span class="register">[EBP-20]</span>  and <span class="variable">.point2</span> is defined on <span class="register">[EBP-12]</span>.<p>
<table class="stack" style="margin-left: 40px; border: 1px solid black;">
	<tr><td>[EBP-04]</td><td colspan=2>.ctrldata</span></td></tr>
	<tr><td>[EBP-08]</td><td>.rect.bottom</td><td>.point2.y</td></tr>
	<tr><td>[EBP-12]</td><td>.rect.right</td><td>.point2.x</td></tr>
	<tr><td>[EBP-16]</td><td>.rect.top</td><td>.point1.y</td></tr>
	<tr><td>[EBP-20]</td><td>.rect.left</td><td>.point1.x</td></tr>
</table>
<p>As you can see, <span class="variable">.rect</span> occupies the same memory as <span class="variable">.point1</span> and <span class="variable">.point2</span>, but <span class="variable">.ctrldata</span> is never overlapped and exists independently.<p>
<p>As a general rule, you have to use the definitions between "proc" and "begin" for local variables that are used in every call of the procedure and separate locals/endl definitions for variables needed for the particular branches inside the procedure.<p>
<p>This approach will always provide the optimal size for the locals stack frame.</p>

<pre class="fasm-code">
macro initialize
macro finalize
</pre>
<p>The macros "initialize" and "finalize" defines one special type of procedures that during compilation are registered in a two separate lists - one for "initialize" and one for "finalize" procedures.</p>
<p>After that using the macros "InitializeAll" and "FinalizeAll", all these procedures can be call at once. "initialize" procedures are call in the order of their definition and "finalize" procedures in reverse order.</p>
<p>These macros provides standard and consistent way to process the initialization and the finalization of the libraries and modules of the application.</p>
<p>Procedures defined with "initialize" and "finalize" must have no any arguments.</p>
<p>FreshLib uses this mechanism and the user is free to use it also.
<pre class="fasm-code">
macro stdcall proc, [arg]
macro ccall proc, [arg]
macro invoke proc, [arg]
macro cinvoke proc, [arg]
</pre>
<p>This macros call the procedures with STDCALL and CCALL calling convention.</p>
<p>"stdcall" macro pushes the arguments to the stack in reverse order and then call the procedure with label "proc". As long as the macro "stdcall" does not provide any stack cleanup (this duty is assigned to the procedure) the arguments can be pushed in free manner using, for example, separate push instructions for part of the arguments and arguments in the stdcall line for the remaining arguments. This can be very convenient in some cases. For example see the following source:</p>
<pre class="fasm-code">
    stdcall CreateSomeObject   
    push	    eax   			
    stdcall DoSomething
    stdcall DeleteSomeObject
</pre>
<p>Here, the procedure DoSomething  changes the value of eax, so the handle is saved in the stack. The procedure DeleteSomeObject needs one argument - a handle of the object. But as long as the proper value is already in the stack, it is mindless to pop the value and then to push it again. So the source calls DeleteSomeObject without any arguments. The procedure knows the proper number of arguments (one in this example) and clean the stack properly.</p>
<p>The standard (and wrong) approach is to pop the argument from the stack and then to pass it to the procedure explicitly is the stdcall statement:</p>
<pre class="fasm-code">
    stdcall	CreateSomeObject
    push	     eax   ; save the handle.
    stdcall  DoSomething
    pop      eax             ; ??? Why ???
    stdcall  DeleteSomeObject, eax
</pre>
<p>This source will generate the meaningless instructions sequence:</p>
<pre class="fasm-code">
    pop      eax       
    push     eax       	
</pre>
<p>"invoke" macro is the same as "stdcall" with the only difference - it calls the procedure indirectly (call [proc] instead of call proc).</p>
<p>This mechanism is used to call the functions imported from external dynamic linked libraries.</p>
<p>"ccall" macro calls a procedure with CCALL convention. This means that the procedure returns with simple "retn", without cleaning the parameters from the stack. Then "ccall" macro provides instructions that remove the arguments from the stack.</p>
<p>Because ccall have to know the exact count of passed arguments, all arguments have to be passed explicitly as a values in the ccall statement.</p>
<p>Tricks as described above will not work properly and leads to stack not properly cleaned after the call.</p>
<p>"cinvoke" is the same as ccall, but using indirect call. The reason is the same as with "invoke" macro. </p>
<p class="note">About the calling conventions: While  all Win32 dynamic linked libraries uses STDCALL convention, most (if not all) of Linux libraries uses CCALL convention.<br />
All code libraries of Fresh use STDCALL calling convention and it is platform independient.</p>

<a name="_globals"><h2>FreshLib _globals.inc</h2>
<p>This library defines several macros intended to deal with data definitions.</p>
<p>Usually all data definitions have to be placed in special section of the executable file. This is not very convenient, because the code that process this data and the data definitions must reside in separate places of the source code, and in most cases even in different files.</p>
<p>The idea of globals.inc macro library is to allow the data definition to be described anywhere in the source code, but these definitions to be defined at once, at the place the programmer wants - usually in the data section of the program.</p>
<pre class="fasm-code">
macro uglobal
macro iglobal
macro endg
macro IncludeAllGlobals
</pre>
<p>"uglobal" begins block for undefined data definition. The block ends with "endg" macro. Between "uglobal" and "endg" macro any count of data definitions can be inserted.</p>
<p>Note that because uglobal block defines undefined data, it is only the labels and the size of data that have meaning inside this block. Any data defined with data definition directive will not be included in the binary file.</p>
<p>The undefined data will be defined later at the place where "IncludeAllGlobals" macro resides.</p>
<p>The undefined data is always placed at the end of all data definitions, so it will never increase the size of the executable file.</p>

<p>"iglobal" macro, again combined with "endg" defines initialized data. The data defined in the block will be created at "IncludeAllGlobals" statement.</p>
<p>This block increases the size of the executable file, because it contains sensible data, that have to be included in the file.</p>
<p>Actually, neither uglobal, nor iglobal blocks defines any data immediately.</p>
<p>Instead, the data definitions are stored in a list.  The real definition occurs later, when IncludeAllGlobals macro is invoked.</p>
<p>For this reason, IncludeAllGlobals must be placed  in the source  after all used global data blocks.</p>

<pre class="fasm-code">struc text [val]</pre>

<p>The macro "text" is actually a structure. It needs to be preceded by some label name.</p>
<p>This macro defines a zero terminated string constant, and also a local label for this string in the "sizeof" global label.</p>
<p>The "text" macro, similar to iglobal and uglobal simply stores string data for defer definition.</p>
<p>This definition, as for all global data macros, occur in IncludeAllGlobals invocation.</p>
<p>Why to define separate macro for the strings and not to use the normal iglobal block? The thing is that the macro "text" was planned to check the strings and to not define any string more than once. In the case of repetitive strings, this macro should return the pointer to the already defined string constant.</p>
<p>In that case, it would be very convenient and harmless to use string constants in the function calling macros - stdcall, ccall etc.</p>
<p class="todo">Unfortunately, regardless of the power of fasm macro language, this functionality cannot be implemented. Or, more precisely, it can be implemented, but the implementation is too slow for any real project use.<br />
This ineffective implementation is still leaved inside the file _globals.inc - commented block that defines macro with name "InitStringList". If someone have ideas about fixing this problem, please send it to me!</p>

<a name="_struct"><h2>FreshLib _struct.inc</h2>
<p>This library contains only one simple macro:</p>
<a name=""><h4></h4></a>
<pre class="fasm-code">
macro struct name
ends
</pre>
<p>This macro is aimed to provide easy creation of data structures. The "struc" directive in FASM is known to not create actual labels, but only the template for the label definitions. So, we need to create an instance of the data structure in order to have addresses and offsets of its fields.</p>
<p>But very often we don't have static data structure of the given type, but data structure, pointed by some of the registers. In this case in order to use offsets to the fields of the data structure, we need to define at least one virtual  instance of the structure at address 0. Then we can use the values of the fields as an offsets in the instructions - for example: mov eax, [esi+RECT.right].</p>
<p>So, this is exactly what "struct" macro does. Besides it defines the "struc" structure with the given fields, it creates a single virtual instance of this structure, in order to be used later for register addressing. In all remaining functionality it behaves exactly as the struc directive.</p>
<p>The syntax of struct macro is the following:</p>
<pre class="fasm-code">
struct StructureName
  .field1 dd ?
  .field2 RECT
  .fieldN:
ends
</pre>
<p>The definition begins with "struct" followed by the structure name. The definition ends with "ends" directive. Between both, any local label definition becomes a member of the structure.</p>

<a name="_display"><h2>FreshLib _display.inc</h2>
<p>This library contains macros that enhance the functionality of standard FASM "display" directive.</p>
<a name=""><h4></h4></a>
<pre class="fasm-code">macro disp [arg]</pre>
<p>The macro "disp" displays the strings given in the arguments, just as "display" FASM directive does</p>
<pre class="fasm-code">disp &lt;number, radix&gt;</pre>
<p>The macro here is used to display numbers in any radix.</p>

<pre class="fasm-code">macro DispSize Text, Sz</pre>
<p>"DispSize" macro is very specialized macro, that displays the text and number in the following form:</p>

<pre class="fasm-code">Size of [Text] is: Sz bytes</pre>

<p>The size number is automatically scaled to bytes or kbytes, depending on the value of Sz.</p>
<p>This macro allows easy display and control of the sizes of particular areas of the program - data structures, subroutines etc.</p>

<a name="Fresh display"><h4>How Fresh implements "display" directive</h4></a>
<p>There are some specifics in Fresh, concerning message displaying. The "display" directive in Fresh works in a different way than original FASM directive. It outputs text in Fresh message window. Each message can have one of six icons, or it can have no icon at all. And because message window is implemented as a TreeView control, you can organize your messages into groups (directories). Implementation is a bit "tricky" - when you display a character whose code is less than 16, it is interpreted in a special way. Characters from 1 to 6 set an icon of current message. It sounds complicated, but it is quite simple. Try:</p>
<pre class="fasm-code">
    display 2, "some message"
</pre>
<p>It will display "some message" with an error icon. Another codes are used for controlling directory structure. Try to type following lines and see what would happen:</p> 
<pre class="fasm-code">
    display 3, "message at root", 0x09
    display 3, "child message1", 0x0a
    display 3, "child message2", 0x0d
    display 3, "again at root", 0x0a
</pre>
<p>Of course you don't have to put each message in separate display directive, you can, with the same result write:</p>
<pre class="fasm-code">
display 3, "at root",$09,3,"child1",$0a,3,"child2", $0d,3,"again at root",$0a 
</pre>
<p>Here is the complete list of all special characters and their meanings:</p>
<table style="margin-left: 40px;">
	<tr><td><span class="constant">$01</span></td><td>set current icon to "warning"</td></tr>
	<tr><td><span class="constant">$02</span></td><td>set current icon to "error"</td></tr>
	<tr><td><span class="constant">$03</span></td><td>set current icon to "info"</td></tr>
	<tr><td><span class="constant">$04</span></td><td>set current icon to "find"</td></tr>
	<tr><td><span class="constant">$05</span></td><td>set current icon to "none"</td></tr>
	<tr><td><span class="constant">$06</span></td><td>set current icon to "debug"</td></tr>
	<tr><td><span class="constant">$08</span></td><td>end current row and set one level back.</td></tr>
	<tr><td><span class="constant">$09</span></td><td>end current row and set it as new directory.</td></tr>
	<tr><td><span class="constant">$0a</span></td><td>end current row and keep current level</td></tr>
	<tr><td><span class="constant">$0d</span></td><td>end current row and set current level to root level</td></tr>
</table>
</nowiki>

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































































































































Deleted freshlib/_doc/porting.wiki.

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
<h3>Porting FreshLib to other platforms.</h3>

<h4>Minimal system requirements</h4>

  *  Some kind of heap management. Currently FreshLib uses heap functions in Win32 and libc functions
in Linux.

Although, if it is impossible for the OS to provide dynamic memory allocation, it can be implemented
using some other heap manager - for example vid's one from FASMLIB. In this case, the OS should provide only
one big memory block.

However, this solution can greatly complicate the porting process.

  *  Some kind of process management. Threads.

  *  Timer - FreshLib needs one timer that to be able to interrupt the main program loop.

  *  Graphics - FreshLib needs basic graphics functions in order to work. Lines, Rectangles and text drawing
should be enough.

  *  Graphics Text rendering - FreshLib needs UTF-8 support at least on level of conversion of UTF-8 to
the OS internal format (as is with Win32). As long as ASCII (0..$7f) is valid UTF-8 code, if the OS uses
only plain ASCII it is possible for text rendering to provide only ASCII text drawing.

In Win32 FreshLib uses Windows unicode support with conversion. In Linux it uses XFT library, that supports
direct use of UTF-8 strings.

  *  Console text output - FreshLib needs output to the console window - (native or emulated) for debuging
purposes.

  *  Windows - FreshLib uses only one base type of window, able to accept the system events and to be displayed
on the screen. This window should be able to appear on the screen and to be able to have children of the same type.

In Win32 FreshLib uses its own window class "FreshWin". In Linux (XLib) uses usual XLib window.



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































Deleted freshlib/_doc/simpledebug.wiki.

1
2
3
4
5
6
<nowiki>

<a name="data"><h1>FreshLib directory: simpledebug</h1></a>
<p>This directory contains debugging utilities.</p>
</nowiki>

<
<
<
<
<
<












Deleted freshlib/_doc/starting.wiki.

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
<nowiki>
<a name="setup"><h2>Setting Up</h2></a>

<p>The first thing to do is to download <a href="http://www.flatassembler.net">fasm</a> in your platform of choice.
 Fasm does not require installation nor do you need special administrative privileges or a root account in order to start using it.</p>
<p>The second thing is to get a copy of <a href="http://chiselapp.com/user/johnfound/repository/FreshIDE/zip/FreshLib.zip?uuid=FreshLib">FreshLib</a>. FreshLib is just fasm source code, simply save it in a directory of choice.</p>
<p>FreshLib needs an environment variable called <span class="variable">TargetOS</span> 
in order to know the target platform of the generated application.
 Currently, the allowed values are: <span class="constant">Win32</span> and <span class="constant">Linux</span>.</p>
<p>A second environment variable is suggested called <span class="variable">lib</span> having the full path to FreshLib. The library does not need this, but it will make your own sources more portable.</p> 
<p>From Linux:</p>
<pre class="fasm-code">
export TargetOS=Linux
export lib=/home/test/freshlib
</pre>
<p>From Windows:</p>
<pre class="fasm-code">
set TargetOS=Win32
set lib=c:\projects\freshlib
</pre>

<p>That's all. Now it is time to produce the first FreshLib application using just Fasm.</p>

<a name="simplest"><h3>Hello World</h3></a>

<pre class="fasm-code">
include '%lib%/compiler/executable.inc'
include '%lib%/macros/allmacros.inc'
include '%lib%/equates/allequates.inc'

_BinaryType console

include '%lib%/system/process.asm'
include '%lib%/simpledebug/debug.asm'

_CodeSection

start:

        InitializeAll

        DebugMsg 'Hello world!'

        FinalizeAll
        call    Terminate

_ImportSection

include '%lib%/imports/allimports.asm'

_DataSection

IncludeAllGlobals
</pre>

<p>The most important thing to note is that regardless the platform you have chosen, the code is exactly the same.
In other words, if you change the value of your environment variable <span class="variable">TargetOS</span>,
the same code will produce a different executable file targeting that platform.
This is the main characteristic of the FreshLib and this is the first design criteria that you will
want to follow to have a truly platform independent application.</p>

<p class="note">This is a highly portable development environment, perhaps the most portable
among non interpreted languages. The entire development process could run from removable media
and the same set of source code files could be used from Win32 and Linux to produce binaries for either of them.</p>

<a name="files"><h3>Creating Files</h3></a>

<pre class="fasm-code">
include '%lib%/compiler/executable.inc'
include '%lib%/macros/allmacros.inc'
include '%lib%/equates/allequates.inc'

_BinaryType console

include '%lib%/simpledebug/debug.asm'
include '%lib%/system/files.asm'
include '%lib%/system/process.asm'

_CodeSection

start:

        InitializeAll

        DebugMsg 'FreshLib Tutorials - Module: Files'

iglobal
        filename        db './tut01.txt',0
        sizeof.filename = $-filename
endg

uglobal
        hFile   dd ?
endg

        stdcall FileCreate, filename
        jc      .error
        mov     [hFile], eax
        DebugMsg "A new file was created:"
        stdcall OutputNumber, [hFile], 16, 2
        DebugMsg " is the handle of the file"

        stdcall FileWrite, [hFile], filename, sizeof.filename
        jc      .error
        stdcall OutputNumber, eax, 10, 2
        DebugMsg " bytes were written into the file"

        stdcall FileClose, [hFile]
        jc      .error
        DebugMsg "The file was properly closed"

        stdcall FileDelete, filename
        jc      .error
        DebugMsg "The file was finally deleted"
        jmp     .exit

.error:
        DebugMsg "Sorry, an error occurred"

.exit:
        FinalizeAll
        stdcall Terminate, 0

_ImportSection

include '%lib%/imports/allimports.asm'

_DataSection

IncludeAllGlobals
</pre>

<a name="console"><h3>Simple Console</h3></a>

<pre class="fasm-code">
</pre>

<a name="GUI"><h3>Basic GUI</h3></a>

<pre class="fasm-code">
</pre>

</nowiki>

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































Deleted freshlib/_doc/system.wiki.

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
<nowiki>
<a name="data"><h1>FreshLib directory: system</h1></a>
<p>This directory contains two libraries: "memory.asm" and "files.asm". They constitute the interface to the overlaying system for the rest of the FreshLib modules.</p>
<a name="memory"><h2>FreshLib Memory</h2></a>
<p>This library contains simple but pretty complete functions for dynamic memory allocation, reallocation and release.</p>
<p>The Win32 implementation of the library uses the process heap, returned by GetProcessHeap to manage the memory allocations. Linux implementation uses libc functions: "malloc", "free" and "realloc".</p>

<a name="GetMem"><h4>GetMem</h4></a>
<pre class="fasm-code">
proc GetMem, .size
</pre>
<p>This procedure allocates dynamic memory block with size in bytes in the argument <span class="variable">[.size]</span></p>
<p>If there is no error the procedure returns <span class="flag">CF=0</span> and pointer to the requested memory in <span class="register">EAX</span>. If the memory cannot be allocated, the procedure returns <span class="flag">CF=1</span></p>

<a name="FreeMem"><h4>FreeMem</h4></a>
<pre class="fasm-code">
proc FreeMem, .ptr
</pre>
<p>This procedure frees the memory block pointed by <span class="variable">[.ptr]</span> argument.</p>

<a name="ResizeMem"><h4>ResizeMem</h4></a>
<pre class="fasm-code">
proc ResizeMem, .ptr, .newsize
</pre>
<p>This procedure tries to resize the memory block pointed by <span class="variable">[.ptr]</span> to the new size, given by <span class="variable">[.newsize]</span> argument.</p>


<a name="files"><h2>FreshLib Files</h2></a>
<p>This library provides simple file access procedures.</p>

<a name="FileOpen"><h4>FileOpen</h4></a>
<pre class="fasm-code">
proc FileOpen, .filename
</pre>
<p>This procedure opens the file with a filename in the string pointed by <span class="variable">[.filename]</span> argument.</p>
<p>On success (<span class="flag">CF=0</span>) <span class="procedure">FileOpen</span> returns a handle of the open file. On error (<span class="flag">CF=1</span>) returns error code.</p>

<a name="FileCreate"><h4>FileCreate</h4></a>
<pre class="fasm-code">
proc FileCreate, .filename
</pre>
<p>This procedure creates new empty file with a filename in the string pointed by <span class="variable">[.filename]</span> argument.</p>
<p>On success (<span class="flag">CF=0</span>) FileCreate returns a handle of the open file. On error (<span class="flag">CF=1</span>) returns error code in <span class="register">EAX</span>.</p>

<a name="FileClose"><h4>FileClose</h4></a>
<pre class="fasm-code">
proc FileClose, .handle
</pre>
<p>This procedure closes the open file with a handle in <span class="variable">[.handle]</span>  argument.</p>
<p>On success (<span class="flag">CF=0</span>) does not return any value and preserves <span class="register">EAX</span>.</p>
<p>On error (<span class="flag">CF=1</span>) returns error code in <span class="register">EAX</span>.</p>

<a name="FileRead"><h4>FileRead</h4></a>
<pre class="fasm-code">
proc FileRead, .handle, .buffer, .count
</pre>
<p>This procedure reads <span class="variable">[.count]</span> bytes  from the file <span class="variable">[.handle]</span> in the buffer pointed by <span class="variable">[.buffer]</span> arguments.</p>
<p>On success (<span class="flag">CF=0</span>) returns the count of actually read bytes in <span class="register">EAX</span>.</p>
<p>On error (<span class="flag">CF=1</span>) returns error code in <span class="register">EAX</span>.</p>

<a name="FileWrite"><h4>FileWrite</h4></a>
<pre class="fasm-code">
proc FileWrite, .handle, .buffer, .count
</pre>
<p>This procedure writes <span class="variable">[.count]</span> bytes  from the buffer pointed by <span class="variable">[.buffer]</span> argument to the file [.handle] that have to be open for write.</p>
<p>On success (<span class="flag">CF=0</span>) returns the count of actually read bytes in <span class="register">EAX</span>.</p>
<p>On error (<span class="flag">CF=1</span>) returns error code in <span class="register">EAX</span>.</p>

<a name="FileSeek"><h4>FileSeek</h4></a>
<pre class="fasm-code">
proc FileSeek, .handle, .dist, .direction
</pre>
<p>This procedure moves the file pointer to the some position. The handle of the file is in <span class="variable">[.handle]</span>, the target position is in <span class="variable">[.dist]</span> and the direction of the move is in <span class="variable">[.direction]</span> arguments.</p>
<p><span class="variable">[.direction]</span> accept one of the following values: <span class="constant">fsFromBegin</span>, <span class="constant">fsFromEnd</span> and <span class="constant">fsFromCurrent</span>.</p>
<p>The exact values of these constants may vary between different OSes, so the programmer have to use the symbolic names, predefined in "files.asm" library.</p>
<p>On success (<span class="flag">CF=0</span>) returns the new position of the file in <span class="register">EAX</span>.</p>
<p>On error (<span class="flag">CF=1</span>) returns error code in <span class="register">EAX</span>.</p>

<a name="FileDelete"><h4>FileDelete</h4></a>
<pre class="fasm-code">
proc FileDelete, .filename
</pre>
<p>This procedure deletes a file with name in pointed by <span class="variable">[.filename]</span> argument.</p>
<p>On success (<span class="flag">CF=0</span>) no value.</p>
<p>On error (<span class="flag">CF=1</span>) returns error code in <span class="register">EAX</span>.</p>

<a name="GetErrorString"><h4>GetErrorString</h4></a>
<pre class="fasm-code">
proc GetErrorString, .code
</pre>
<p>This procedure returns in <span class="register">EAX</span> a pointer to a human readable error string for the error code passed in <span class="variable">[.code]</span>. The string is dynamically allocated by the OS and should be released after use with the procedure <span class="procedure">FreeErrorString</span>.</p>

<a name="FreeErrorString"><h4>FreeErrorString</h4></a>
<pre class="fasm-code">
proc FreeErrorString, .ptrString
</pre>
<p>This procedure frees the memory allocated for error string from the procedure <span class="procedure">GetErrorString</span>.</p>

<a name="LoadBinaryFile"><h4>LoadBinaryFile</h4></a>
<pre class="fasm-code">
proc LoadBinaryFile, .ptrFileName
</pre>
<p>This procedure allocates needed memory and loads the whole file with filename pointed by <span class="variable">[.ptrFileName]</span> to the allocated buffer.</p>
<p>The memory is allocated with the library <a href="system.html#memory">memory.asm</a>, so the user have to free the memory after use with the procedure <span class="procedure">FreeMem</span>. 
<p>On success (<span class="flag">CF=0</span>) the procedure returns a pointer to the allocated memory in <span class="register">EAX</span> and the count of bytes read in <span class="register">ECX</span>.</p>
<p>On error (<span class="flag">CF=1</span>) the procedure returns nothing.</p>

<a name="SaveBinaryFile"><h4>SaveBinaryFile</h4></a>
<pre class="fasm-code">
proc SaveBinaryFile, .ptrFileName, .aptr, .size
</pre>
<p>This procedure creates new file with the name pointed by <span class="variable">[.ptrFileName]</span> and saves <span class="variable">[.size]</span> bytes from the buffer pointed by  <span class="variable">[.aptr]</span>.</p>
<p>The procedure returns error flag in <span class="flag">CF</span>.</p>

<a name="FileExists"><h4>FileExists</h4></a>
<pre class="fasm-code">
proc FileExists, .ptrFileName
</pre>
<p>This procedure checks whether the file with name pointed by <span class="variable">[.ptrFileName]</span> exists on disk.</p>
<p>The procedure returns <span class="flag">CF=0</span> if the file exists, otherwise it returns<span class="flag">CF=1</span>.</p>
</nowiki>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































Deleted freshlib/_pending/FBasDx01/FASMBas.txt.

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
   Well it's something like qbasic, meaning that it's a lot like most basic's...

   You can only have one basic command per line. The exception is a comment / remark starts with a semi colon and can be at the end of a line 

Print "example"     ;This is an example

   Basic commands can be all caps, all small or start with a cap.

PRINT
print
Print

   FASM Basic does not use line numbers.

   Right now FASM Basic only supports a few variable types.

Short = 8 bit number
Integer = 16 bit number
Long = 32 bit number
String = text

   All variables must be defined. They are case sensitive.

DEF     A, Short    ,32         
DEF     B, Integer  ,12312      
DEF     C, Long     ,2000000    
DEF     D, String   ,"String variable"

   INPUT, only works with strings right now, but you can also print text with the input command.

Input D			; Waits for the user to type in text and hit enter, The text is stored in D
Input "Enter: ",D	; Prints 'Enter: ' then waits for user input
Input D,E,F		; Would wait for user to enter text 3 times, hitting enter after each
Input "Text"            ; Will just print the word 'Text'
Input "Enter1: ",D," Enter2: ",E," Enter3: ",F
			; Puts up the text and inputs 3 entries

   PRINT, puts text or variables on the screen. /n causes a print command to start a new line.

Print "text"		; Puts the word 'text' on the screen
Print A			; Puts the value stored in A on the screen at the current location
Print A,B		; Puts the value of A then the B on the screen, with no space between them
Print "Numbers 1 & 2 : ",A," ",B
			; puts the text in quotes on the screen, then A, then a space, then B
Print "Line1",/n,"Line2"; puts text on 2 lines

   BEEP, makes the computer beep once

   CLS, clears the screen, 0 the entire screen, 2 a line at bottom is left, 3 three lines at bottom
	4 a line at top is left, 5 three lines at the top are left
	the second and third numbers set the text color

Cls		; clears the screen
cls 0		; clears the screen
Cls 2		; clears everything except a line of text at the bottom
Cls 3   	; clears everything except three lines at the bottom
Cls 4		; clears everything except a line of text at the top
cls 5		; clears everything except three lines at the top
cls 0, 8, 4	; clears everything, sets the text color to gray and background to red

   COLOR, First number sets text color. Second sets the background color
	(new text, what's on the screen stays the same Color )
	Last number sets the color for the border / over scan area
	Add 16 to the text number to make it blink
        |  Text       |  Text
	| Background  | Background  |  Text            |   Text
        |  Border     |  Border     |                  |
        |-------------|-------------|------------------|-------------------
	| 0 = black   | 4 = red     | 8 = grey         | 12 = light red
	| 1 = blue    | 5 = magenta | 9 = light blue   | 13 = light magenta
	| 2 = green   | 6 = brown   | 10 = light green | 14 = yellow
	| 3 = cyan    | 7 = white   | 11 = light cyan  | 15 = bright white

Color 7		; white text, black background, black border
Color 14, 1     ; yellow test on a blue background with a black border
Color 8, 4, 4   ; gray text on a red background with a red border
Color 24, 4, 4  ; blinking gray text on a red background with a red border

   END_PROGRAM, must be the last line of your program

   GOTO, takes the program from where it is and continues execution at a label.

...					; some random program lines 
...
Goto NewStuff				; tells program to go to the label 'NewStuff'
Print "Text that will never get printed"; so this line gets skipped
NewStuff:				; and the program keeps going here
...
...

   GOSUB, goes to a label, but returns 
...
...
Gosub New stuff
Print "This gets printed second",/n
...
...
New stuff:
Print "This line gets printed first",/n
Return
...
...

   RETURN, returns from a gosub command

   LET, well it doesn't do any thing right now....

   LOCATE, the screen location to put text at

Locate 0,0		; text will start printing on the screen in the upper left corner

   PEEK, puts the value of a memory location into register al

Peek 123456

   POKE, puts a value to a memory location

Poke 123456,255

   REBOOT, reboots the computer

   IN_PORT, puts the value of a port into register al

In_port 245

   OUT_PORT, outputs a value to a port

Out_port 245,128

   SLEEP, the computer waits until a key is pressed to do any thing, the key pressed ends up in reg AX
	or if a number is given it waits that many clock ticks.

Sleep		; waits for a key press
Sleep 37	; waits 37 clock ticks, about 2 seconds

   SCREEN, sets the screen mode
	0 = Standard Dos text mode
	1 = 320 x 200 4 color
	2 = 640 x 200 2 color
	7 = 320 x 200 16 color
	8 = 640 x 200 16 color
	9 = 640 x 350 4 color
	11 = 640 x 480 2 color
	12 = 640 x 480 16 color
	13 = 320 x 200 256 color
	14 = DexOS Text mode
	15 = Vesa text mode 132 x 60
	100 = 640 x 400 256 color	; only 0-15 fully working right now
	101 = 640 x 480 256 color
	103 = 800 x 600 256 color
	105 = 1024 x 768 256 color
	107 = 1280 x 1024 256 color
	110 = 320 x 200 16m color
	112 = 640 x 480 16m color
	115 = 800 x 600 16m color
	118 = 1024 x 768 16m color
	119 - 1280 x 1024 16m color

Screen 14	; puts you in DexOS text mode	

   SOUND, makes a tone, the frequency of the tone is the first number and the duration is the second

Sound 45,18	; 45 hrz tone for about one second

   CURSORON, turns the cursor on

   CURSOROFF, turns the cursor off

   CURSOR, turns the cursor off or on

Cursor TRUE	; turns on the cursor
Cursor FALSE	; turns the cursor off

   PAUSE, pauses the computer for a given time, 18.5 is about one second (you can only use integers)

Pause 37	; pauses for about 2 seconds


Reserved words: 
	Other then the asm and basic command words any thing starting with "_grfx" should be avoided, unless you intend to mess with the basic macro functions.

_grfxMode:      read only, is set to what ever graphics mode you are in
		needs to be set by the macro and be right

_grfxScreen:    Should probably only be read, unless you want to do some sort of double buffer
		This is the start of memory for the screen

_grfxCls:       This is the screen size (in dword) for the mode you are in

_grfxLL:        line length (dword) for the mode you are in

_grfxScreen_x   Cursor location
_grfxScreen_y   Cursor location, or if changed, where the macros assume the cursor to be

_grfxColor	The color all new text will be displayed with, 
		byte format = BBBCTTTT,
		B = Background color, C = Blinking or not, T = Text color

Added asm functions: (use instead of the dex functions when using the basic macros)

_grfxPrintString: Prints a 0 terminated string pointed to by ESI

_grfxPrint_char:  Prints the ASCII char in al

_grfxLocate:      moves the cursor to location al, ah


Thanks to rCX for starting this project, TonyMac and Dex for starting it in DexOS. A really big thanks to every one at the FASM board for endless great info on FASM and to Tomasz Grysztar for the great toy, um I mean tool :)

Steve
http://home.comcast.net/~dexos/

DexOS home page:
http://www.dex4u.com/
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































Deleted freshlib/_pending/FBasDx01/fbasic.inc.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
; ====================================
; | Fasm Basic ver 0.10 Beta  oct 09 |
; ====================================

; QBASIC.inc was written by rCX (converted to run on DexOS, by Dex)
; added to by TonyMac & now added to by Steve, who also changed the name

Beep            fix BEEP        ; Done
beep            fix BEEP
cls             fix CLS         ; Done for text mode, oops need to put cursor in right spot
Cls             fix CLS
color           fix COLOR       ; Done in text mode
Color           fix COLOR
end_program     fix END_PROGRAM ; Done
End_program     fix END_PROGRAM
End_Program     fix END_PROGRAM
gosub           fix GOSUB       ; Done
Gosub           fix GOSUB
GoTo            fix GOTO        ; Done
Goto            fix GOTO
goto            fix GOTO
input           fix INPUT       ; Done (just does strings, at this time)
Input           fix INPUT
let             fix LET         ; Needs lots of work, not included at this time
Let             fix LET
locate          fix LOCATE      ; Done
Locate          fix LOCATE
peek            fix PEEK        ; Done
Peek            fix PEEK
poke            fix POKE        ; Done
Poke            fix POKE
print           fix PRINT       ; Done
Print           fix PRINT
return          fix RETURN      ; Done
Return          fix RETURN
reboot          fix REBOOT      ; Done
Reboot          fix REBOOT
In_Port         fix IN_PORT     ; Done (need to redo so it works with 8, 16 & 32)
In_port         fix IN_PORT
in_port         fix IN_PORT
Out_Port        fix OUT_PORT    : Done ( need to redo so it works with 8, 16 & 32)
Out_port        fix OUT_PORT
out_port        fix OUT_PORT
Sleep           fix SLEEP       ; Done
sleep           fix SLEEP
Screen          fix SCREEN      ; Done in text. enters graphics modes
screen          fix SCREEN
Sound           fix SOUND       ; done (crash if below min, need to add a minimum check)
sound           fix SOUND
def             fix DEF         ; need to work on strings, make definable size and pad out
Def             fix DEF
cursoron        fix CURSORON    ; done
Cursoron        fix CURSORON
CursorOn        fix CURSORON
cursoroff       fix CURSOROFF   ; done
Cursoroff       fix CURSOROFF
CursorOff       fix CURSOROFF
pause           fix PAUSE       ; done
Pause           fix PAUSE
cursor          fix CURSOR      ; done
Cursor          fix CURSOR

 ;--------------------;
 ; Set up DexOS stuff ;
 ;--------------------;

use32
        ORG 0x400000           ; where our program gets loaded
        jmp @f                 ; jump over ver tag
        db 'DEX2'              ; Mark it a DexOS ver3 file.
@@:
        mov ax,18h             ; set ax to nonlinear base
        mov ds,ax              ; set ds to nonlinear base
        mov es,ax              ; set es to nonlinear base.
        mov edi,Functions      ; address of jump table (in dex.inc)
        mov ax,0x0a00          ; load table wih DexOS function addresses
        int 40h

        jmp   SkipQBASIC       ; jump over all the macros

 ;---------------------------------;
 ; Dam, a run time lib             ;
 ; not sure how to get around this ;
 ;---------------------------------;
_grfxLocate:
        cmp   [_grfxMode],byte 15
        je    @f
        cmp   al,80             ; did they put in to high a x for mode 0,14
        jb    @f
        ret                     ; out of range do nothing
@@:
        cmp   al,132            ; is the x to high for mode 15
        jb    @f
        ret                     ; out of range do nothing
@@:
        cmp   [_grfxMode],byte 14
        je    @f
        cmp   ah,25             ; y to high for mode 0
        jb    @f
        ret                     ; out of range do nothing
@@:
        cmp   [_grfxMode],byte 15
        je    @f
        cmp   ah,50             ; y to high for mode 14
        jb    @f
        ret                     ; out of range do nothing
@@:
        cmp   ah,60             ; y to high for mode 15
        jb    @f
        ret                     ; out of range do nothing
@@:
        mov   [_grfxScreen_x],al
        mov   [_grfxScreen_y],ah
_grfxLocate2:
        pushad
        xor   ebx,ebx
        mov   bl,[_grfxScreen_x]; figure out where the cursor is now
        mov   ecx,ebx
        mov   bl,[_grfxScreen_y]
        mov   eax,[_grfxLL]     ; line length (dword, half color half char)
        shl   eax,1             ; line length (in bytes of char)
        mul   bx
        add   eax,ecx
        mov   edx,0x3d4         ; video card register index port
        mov   ecx,eax
        mov   al,0x0f           ; set for cursor register (lsb)
        out   dx,al
        mov   eax,ecx           ; cursor location
        add   edx,1             ; video card register port
        out   dx,al
        mov   al,0x0e           ; set for cursor register (msb)
        sub   edx,1             ; video card registr index port
        out   dx,al
        mov   al,ch             ; cursor location
        add   edx,1             ; video card reg port
        out   dx,al
        popad
        ret

_grfxPrintString:
        pop   esi                       ; get address of data off the stack
        push  eax
_grfxPrintString_Loop:
        lodsb                           ; load al, inc esi to next char
        cmp   al,0                      ; 0x00 = end of string
        jne   @f
        call  _grfxLocate2              ; End of string so place cursor and leave
        pop   eax
        jmp   esi                       ; out of data so this address should be next instruction
@@:
        cmp   al,0x0d                   ; 0x0d = CR ( = \n )
        je    @f
        call  _grfxPrintChar            ; not a control, so must need printing
        jmp   _grfxPrintString_Loop
@@:
        call  _grfxCR                   ; do the CR (next line)
        jmp   _grfxPrintString_Loop

_grfxCR:
        push  eax
        mov   [_grfxScreen_x],byte 0
        mov   ah,[_grfxScreen_y]
        cmp   ah,24                     ; no reason to scroll if less then 24th line
        jb    _grfxCR_NoScroll
        cmp   [_grfxMode],byte 0
        je    @f
        cmp   ah,49                     ; less then line 49 and mode 14 or 15, no reason to scroll
        jb    _grfxCR_NoScroll
        cmp   [_grfxMode],byte 14
        je    @f
        cmp   ah,59                     ; mode 15 and less then 59, no reason to scroll
        jb    _grfxCR_NoScroll
@@:
        push  ecx
        push  esi
        push  edi
        mov   edi,[_grfxScreen]         ; Address of the screen
        mov   esi,edi
        movzx eax,byte [_grfxLL]        ; line size (in dword)
        shl   eax,2                     ; make it bytes
        add   esi,eax                   ; address of 2nd line to be new 1st line
        movzx ecx,word [_grfxCls]       ; screen size
        cli                             ; can't have something writing to screen during a scroll
        rep   movsd                     ; move the text
        sti
        pop   edi
        pop   esi
        pop   ecx
        pop   eax
        ret
_grfxCR_NoScroll:                       ; don't need to scroll, so just go down one line
        add   [_grfxScreen_y],byte 1
        pop   eax
        ret

_grfxPrintChar:
        pushad
        push  ax                        ; put char in a safe place
        movzx eax,word [_grfxLL]        ; line size (dword)
        movzx ebx,byte [_grfxScreen_y]
        shl   eax,1                     ; line size (word)
        mul   bx                        ; number of lines times line size
        movzx ebx,byte [_grfxScreen_x]
        add   ebx,eax                   ; screen mem moves (word size)
        shl   ebx,1                     ; screen mem moves (byte size)
        add   ebx,[_grfxScreen]         ; add that to the screen base mem location
        pop   ax                        ; char to print
        mov   ah,[_grfxColor]           ; the color text we want
        mov   [ebx],ax                  ; put the text and color on screen
        mov   al,[_grfxLL]              ; load up the line size
        shl   al,1                      ; convert line size to bytes of text
        add   [_grfxScreen_x],byte 1    ; set new text location
        cmp   [_grfxScreen_x],al        ; is new x location to large
        jb    @f
        call  _grfxCR
@@:
        popad
        ret


 ;-----------------------;
 ; The Fasm Basic macros ;
 ;-----------------------;

;___________CLS______________________
macro CLS clrmode,_opt2,_opt3           ; just for textmode right now
{
        push ecx
        push eax
        push edx
        push edi
        mov  edi,[_grfxScreen]          ; start address of screen fill
        if clrmode eq
        else if clrmode eq 4            ; start cls one line down
                movzx eax,word [_grfxLL]
                shl   eax,2
                add   edi,eax
        else if clrmode eq 5            ; Start cls two lines down
                movzx eax,word [_grfxLL]
                mov   edx,12
                mul   edx
                add   edi,eax
        end if
        if _opt2 eq
                mov  eax,0x0f200f20     ; char to fill screen with (0f=color 20=blank)
        else
                mov  ah,_opt3           ; Background color 0-7
                shl  ah,4
                add  ah,_opt2           ; Text color 0-31
                cmp  ah,0               ; was there no color set
                jne  @f
                        mov  ah,0x0f    ; set a color
                @@:
                mov  al," "             ; a blank space
                mov  cx,ax              ; now fill up eax
                shl  eax,16
                mov  ax,cx
        end if
        movzx ecx,word [_grfxCls]       ; how many dwords to write
        if clrmode in <2,4>
                sub  cx,[_grfxLL]       ; leave 1 line uncleared
        else if clrmode in <3,5>
                sub  cx,[_grfxLL]       ; leave 3 lines uncleared
                sub  cx,[_grfxLL]
                sub  cx,[_grfxLL]
        end if
        cli                             ; can't be changing the screen while clearing it
        rep stosd                       ; put blanks on screen
        sti
        pop edi
        pop edx
        pop eax
        pop ecx
        Locate 0,0
}

;___________CURSOR__________________
macro CURSOR option*            ;Turns on cursor if option = TRUE, off if option = FALSE.
{
        pushf
        pusha
        mov   ch,0x0b           ;Turns on cursor if option = TRUE
        mov   cl,0x0c
        if option = FALSE
                mov   ch,0x1c   ;turns it off if option = FALSE.
                mov   cl,0x1b
        end if
        mov   ah,1              ;Set cursor status
        call  [RealModeInt10h]
        popa
        popf
}


;_____________CURSOROFF________________
macro CURSOROFF
{
   push  cx
   push  ax
   mov   ch,00110000b
   mov   cl,00010000b
   mov   ah,01h
   call  [RealModeInt10h]
   pop   ax
   pop   cx
}

;_______________CURSORON_______________
macro CURSORON
{
   push  cx
   push  ax
   mov   ch,00010000b
   mov   cl,00010000b
   mov   ah,01h
   call  [RealModeInt10h]
   pop   ax
   pop   cx
}

;_______________PAUSE__________________
macro PAUSE time
{
   push  ax
   mov   ax,time
   call  [SetDelay]
   pop   ax
}

;________________COLOR_________________
macro COLOR _opt1,_opt2,_opt3

{
        push  eax
        push  ebx
        if _opt2 eq
                   mov  al,0
        else
                   mov  al,_opt2          ; Background color 0-7
                   shl   al,4
        end if
        add   al,_opt1                    ; Text color 0-31
        mov   [_grfxColor],al             ; Set the text color
        if _opt3 eq
        else
                   mov   ah,0
                   mov   al,_opt3         ; Border color 0-3Fh
                   shl   eax,16           ; top 16 of eax are bx in 16 bit dos mode
                   mov   ax,0B00h         ; Set border color
                   call  [RealModeInt10h]
        end if
        pop   ebx
        pop   eax
}

;_________________END___________________
macro END_PROGRAM
{
        call  [SetDex4uFonts]
        mov   cx,0
        call  [InterruptTimer]; restore timer
        ret
include 'Dex.inc'             ; Dex inc file
}

;_______________LOCATE_________________
macro LOCATE row,col
{
        push eax
        local  .temp
        if col eq ah
                mov  .temp,byte col
                mov  ah,row
                mov  al, .temp
        else
                mov  ah,row
                mov  al,col
        end if
        call _grfxLocate
        pop  eax
}


;_______________PRINT_________________
macro PRINT [String]
{
        if String eqtype ""
                local .a
                        push esi
                        call _grfxPrintString   ; call print & push address of data to stack
                        .a db String,0          ; String to print
                        pop  esi
        else if String eq /n
                local .a
                        push esi
                        call _grfxPrintString
                        .a db 13,0
                        pop  esi
        else if String eq /N
                local .a
                        push esi
                        call _grfxPrintString
                        .a db 13,0
                        pop  esi
        else
                local .NotDone
                local .Done
                local .Start
                local .NotString
                        push esi
                        pushad
                        mov  esi,String
                        cmp  [esi],byte 9       ; is it a string varable
                        jne  .NotString
                        add  esi,3
                @@:
                        mov   al,[esi]
                        add   esi,1
                        cmp   al,0              ; 0x00 = end of string
                        je    .Done
                        call  _grfxPrintChar    ; not a control, so must need printing
                        jmp   @b
                .NotString:
                        mov   ebx,String
                        cmp   [ebx],byte 0      ; is data a byte
                        jne   @f
                        add   ebx,1
                        movzx eax,byte [ebx]    ; store it in eax (make it a dword)
                        jmp   .Start
                @@:
                        cmp   [ebx],byte 1      ; is data a word
                        jne    @f
                        add   ebx,1
                        movzx eax,word [ebx]    ; store it in eax (make it a dword)
                        jmp   .Start
                @@:
                        add   ebx,1             ; data must be a dword
                        mov   eax,[ebx]         ; store it in eax
                .Start:
                        mov  ebx,1000000000           ; 32 bit can only be 10 ascii digits
                @@:
                        cmp  eax,0                    ; need to check if it's 0
                        jnz  @f                       ; if it's not 0 go figure out what it is
                        mov  al,"0"                   ; put ascii 0 in al
                        call _grfxPrintChar           ; and write it to screen
                        jmp  .Done
                @@:
                        mov  ecx,1                    ; a flag to blow off leading 0's
                        mov  esi,10                   ; we are working in base 10
                .NotDone:
                        cmp  ebx,0                    ; are we done counting off digits
                        jnz  @f
                        jmp  .Done
                @@:
                        cmp  eax,ebx                  ; is this digit a non zero one
                        jb   @f
                        xor  ecx,ecx                  ; clear the flag to start printing 0's
                @@:
                        mov  edx,0
                        div  ebx                      ; digit to write ends up in al, rest of number in edx
                        cmp  ecx,1                    ; do we need to write yet
                        je   @f
                        add  al,"0"                   ; make al an ASCII digit
                        call _grfxPrintChar           ; and write it to screen
                @@:
                        push edx                      ; put the rest of number in a safe place
                        xor  edx,edx
                        mov  eax,ebx                  ; put the digit count in eax
                        div  esi                      ; reduce digit count one place
                        mov  ebx,eax                  ; digit count back in ebx
                        pop  eax                      ; get number back in eax
                        jmp  .NotDone                 ; try next digit
                .Done:
                popad
                pop   esi
                call  _grfxLocate2      ; End of string so place cursor and leave
        end if
}

;_______________INPUT_________________
Macro INPUT [String]
{
        if String eqtype ""
                local .a
                        push esi
                        call _grfxPrintString
                        .a db String,0
                        pop  esi
        else if String eq /n
                local .a
                        push esi
                        call _grfxPrintString
                        .a db 13,0
                        pop  esi
        else if String eq /N
                local .a
                        push esi
                        call _grfxPrintString
                        .a db 13,0
                        pop  esi
        else
                local .loop
                local .done
                push edi
                push eax
                mov  edi,String
                cmp  [edi],byte 9       ; is the varable a string
                jne  .done              ; major bug if they don't use a string
                add  edi,3              ; skip over varable type and size
        .loop:
                call [WaitForKeyPress]  ; need to not let them enter to much
                cmp  al,13
                je   .done
                mov  [edi],al           ; <----need to make a string move
                inc  edi
                call _grfxPrintChar
                call _grfxLocate2
                jmp  .loop
        .done:
                mov byte [edi], 0        ;zero-terminate the string
                pop  eax
                pop  edi
        end if
}

;_______________SCREEN_________________
macro SCREEN mode         ;need to add active and working page....
{
        push eax
        mov  ah,0h
        mov  [_grfxMode],byte mode

        if mode = 0
                mov  al,3h                       ; text 80 x 25
                call [RealModeInt10h]
                mov  [_grfxScreen],dword 0xb79e0 ; start address of screen
                mov  [_grfxCls],word 1000        ; size of screen (in dword)
                mov  [_grfxLL],word 40           ; screen width (in dword)
        else if mode = 1
                mov  al,04h
                call [RealModeInt10h]
        else if mode = 2
                mov  al,06h
                call [RealModeInt10h]
        else if mode = 7
                mov  al,0Dh
                call [RealModeInt10h]
        else if mode = 8
                mov  al,0Eh
                call [RealModeInt10h]
        else if mode = 9
                mov  al,10h
                call [RealModeInt10h]
        else if mode = 11
                mov  al,11h
                call [RealModeInt10h]
        else if mode = 12
                mov  al,12h
                call [RealModeInt10h]
        else if mode = 13
                mov  al,13h
                call [RealModeInt10h]
        else if mode = 14                        ; DexOS text 80 x 50
                call [SetDex4uFonts]
                mov  [_grfxScreen],dword 0xb79e0 ; start address of screen
                mov  [_grfxCls],word 2000        ; screen size
                mov  [_grfxLL],word 40           ; screen width
        else if mode = 15                        ; text 132 x 60
                push cx
                mov  cx,0x10c
                call [SetVesaMode]
                mov  [_grfxScreen],dword 0xb79e0 ; Start address of screen
                mov  [_grfxCls],word 3960        ; screen size
                mov  [_grfxLL],word 66           ; screen width
                pop  cx
                mov  [_grfxScreen],dword 0xb79e0 ; start address of screen
        ;---------256 color modes-------------
        else if mode = 100
                push  ecx
                push  edi
                mov   cx,0x4100 ; gfx 640 x 400
        else if mode = 101
                push  ecx
                push  edi
                mov   cx,0x4101 ; gfx 640 x 480
        else if mode = 103
                push  ecx
                push  edi
                mov   cx,0x4103 ; gfx 800 x 600
        else if mode = 105
                push  ecx
                push  edi
                mov   cx,0x4105 ; gfx 1024 x 768
        else if mode = 107
                push  ecx
                push  edi
                mov   cx,0x4101 ; gfx 1280 x 1024 ; oops need to fix
        ;---------32bit color modes-------------
        else if mode = 110
                push  ecx
                push  edi
                mov   cx,0x410f ; gfx 320 x 200
        else if mode = 112
                push  ecx
                push  edi
                mov   cx,0x410f ; gfx 640 x 480
        else if mode = 115
                push  ecx
                push  edi
                mov   cx,0x4115 ; gfx 800 x 600
        else if mode = 118
                push  ecx
                push  edi
                mov   cx,0x4118 ; gfx 1024 x 768
        else if mode = 119
                push  ecx
                push  edi
                mov   cx,0x411B ; gfx 1280 x 1024
        end if
        if mode in <100,101,103,105,107,110,112,115,118,119>
                call  [SetVesaMode]               ; set the mode
                call  [LoadVesaInfo]              ; load vesa into to esi
                mov   edi,VESA_Info               ; where to put vesa info
                mov   ecx,193                     ; size of vesa info
                cld                               ; clear direction flag, string instructions forward
                cli                               ; turn off int
                rep   movsd                       ; copy the vesa info 32 bits at a time
                sti                               ; turn on int
                mov   edi,[ModeInfo_PhysBasePtr]  ; location of vid memory
                sub   edi,0x621                   ; magic number for DexOS offset
                mov   [_grfxScreen],edi           ; start of vid mem.
                pop   edi
                pop   ecx
        end if
        if mode in <0,14,15>                      ; if we are in text mode
                xor   eax,eax                     ; put cursor at 0,0
                call  _grfxLocate
        end if
        pop eax
}

;________________SLEEP_________________
macro SLEEP time
{
;Output:
;       ah = BIOS scancode of key pressed
;       al = ASCII character of key pressed
   push ax
   if time eq
      call  [WaitForKeyPress]
   else
      mov   ax,time
      call  [SetDelay]
   end if
   pop ax
}

;________________GOTO__________________
Macro GOTO _op1
{
        jmp _op1
}

;________________GOSUB_________________
Macro GOSUB _subname
{
        call _subname
}

;________________RETURN________________
Macro RETURN
{
        ret
}

;________________PEEK__________________
Macro PEEK _op1
{
        mov al, [_op1]          ;put value of address in eax
}

;________________POKE__________________
Macro POKE _op1, _op2           ; need to check type, so they can use a varable not just number
{
        push edx
        mov edx, _op1
        mov byte [edx], _op2    ;put _op2 into address _op1
        pop edx
}

;________________OUT___________________
Macro OUT_PORT _op1, _op2            ; need to check type, so they can use a varable not just number
{
        push dx
        push al
        mov dx, _op1
        mov al, _op2
        out word dx,al          ;put _op2 into port _op1
        pop al
        pop dx
}

;________________IN____________________
Macro IN_PORT _op1
{
        mov al, [_op1]          ;put value of address in eax
}

;________________REBOOT________________
Macro REBOOT
{
        call [ExitSystem]
}

;________________SOUND_________________
Macro SOUND _opt1,_opt2
{
        push  ax
        push  bx
        push  dx
        mov   al,0xB6           ; Init channel 2 of timer
        out   0x43,al
        mov   dx,0x12           ; clock frequency /
        mov   ax,0x34DD
        mov   bx,_opt1          ; Frequency
        div   bx                ; = timer clock ticks
        out   0x42,al           ; Load timer
        mov   al,ah
        out   0x42,al
        in    al,0x61           ; get value port 61h
        or    al,00000011b      ; Set bits to turn speaker on
        out   0x61,al
        mov   ax,_opt2          ; sound duration in clock ticks
        call  [SetDelay]
        in    al,0x61           ; turn off speaker
        and   al,11111100b
        out   0x61,al
        pop   dx
        pop   bx
        pop   ax
}

;________________BEEP__________________
Macro BEEP
{
        push  ax
        push  bx
        push  dx
        mov   bx,0x200
        mov   ax,0x34dd
        mov   dx,0x0012
        div   bx                ; **** pre calc this number ***
        mov   bx,ax
        in    al,0x61           ; get value of port 61h
        test  al,3              ; is the speaker turned on
        jnz   @f                ; skip the init and turning on if it's on
        or    al,3
        out   0x61,al           ; speaker on
        mov   al,0xb6
        out   0x43,al           ; Init port
@@:
        mov   al,bl             ; set timer to frequency
        out   0x42,al
        mov   al,bh
        out   0x42,al
        mov   ax,8              ; wait about 1/2 second
        call  [SetDelay]
        in    al,0x61           ; turn off speaker
        and   al,11111100b
        out   0x61,al
        pop   dx
        pop   bx
        pop   ax
}

;________________DEF___________________
Macro DEF  _varname, _vartype, _varval
{
        if _vartype = Short
           _varname     db 0
                        db _varval
        else if _vartype = Integer
           _varname     db 1
                        dw _varval
        else if _vartype = Long
           _varname     db 2
                        dd _varval
        else if _vartype = String
           _varname     db 9
                        dw 128        ;need to let it be defined several ways<----------**
                        db _varval,0
        end if
}

Short       equ 0
Integer     equ 1
Long        equ 2
Float       equ 3
String      equ 9
FALSE       equ 0
False       equ 0
false       equ 0
TRUE        equ 1
True        equ 1
true        equ 1

 ;---------------------------------;
 ; Dam, bunch of run time data     ;
 ; not sure how to get around this ;
 ;---------------------------------;

_grfxMode:      db 14           ; the graphics mode we are in
_grfxScreen:    dd 0xb79e0      ; the base address of the screen
_grfxCls:       dw 2000         ; screen size (dwords)
_grfxLL:        dw 40           ; line size (dword)
_grfxScreen_x   db 0            ; cursor location on screen
_grfxScreen_y   db 0            ; cursor location on screen
_grfxColor      db 0Fh          ; text color

SkipQBASIC:
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/_pending/FBasDx01/test.asm.

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
include 'FBASIC.INC'
cls
print "print in quits works "

goto humm
print "this shouldn't get printed"
humm:

gosub DoSub

color 1
print "color 1"
color 2
print "color 2"
locate 5,5
color 3
print "color 3 at new location"
sleep

screen 0
print "Dos text mode works, locate is off location"
sleep
screen 15
print "decided to add hi res vesa text mode here"
sleep
screen 14
print "decided to add Dexos text mode here"
sleep

PRINT /n,"Quoted String"," on the same line",/n,"or on the next line",/n,/n ; /n = next line
PRINT "Short ",A,/n
PRINT "Integer ",B,/n
PRINT "Long ",C,/n
PRINT D,/n,/n
BEEP
SLEEP

Print "Sounds:"
Sound 32,4
Sound 64,4
Sound 128,4
Sound 256,4
Sound 512,4
Sound 1024,4
Sound 2048,4
Sound 4096,4
Print /n,"cursor is now off"
CursorOff
Sleep
Print /n,"cursor is now back on"
CursorOn
Sleep

Input /n,"an input with no input",/n,/n
Input "input a new D ",D
Print /n,/n,"the old string over writen: ",D
Sleep

Print /n,/n,"Now lets wait a moment.",/n
Pause 37
Print "We are back.",/n
sleep

screen 14
print "Back to Dexos mode. Fasm Basic doesn't leave the title block at a screen change"
PRINT /n,/n,"but cls does have a few options"
sleep

screen 0
cls 0,7,5
gosub TwentyFive
sleep
cls 2,7,3
sleep
cls 0,7,5
gosub TwentyFive
sleep
cls 3,7,3
sleep
cls 0,7,5
gosub TwentyFive
sleep
cls 4,7,3
sleep
cls 0,7,5
gosub TwentyFive
sleep
cls 5,7,3
sleep
cls 0,7,5
gosub TwentyFive
Sleep

goto stop

DoSub:
        print "gosub and return work"
Return

TwentyFive:
	color 7,5,5
	Print "1",/n,"2",/n,"3",/n,"4",/n,"5",/n,"6",/n,"7",/n,"8",/n,"9",/n
	Print "10",/n,"11",/n,"12",/n,"13",/n,"14",/n,"15",/n,"16",/n,"17",/n,"18",/n,"19",/n
	Print "20",/n,"21",/n,"22",/n,"23",/n,"24",/n,"25"
Return

DEF     A, Short    ,32         ; Examples of "Def" command
DEF     B, Integer  ,12312      ;
DEF     C, Long     ,2000000    ;
DEF     D, String   ,"String Varable"

stop:
end_program
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































Deleted freshlib/_pending/lzss/readme.txt.

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
LZSS compression library for Flat Assembler
by Mateusz Tymek

1. Introduction
LZSS is a library that provides you with simple routines for data compression. The 
algorithm is based on oryginal idea of Lempel and Ziv, with the modyfications suggeted by 
Storer and Szymanski (that's why its name is LZSS). You can search the Web for "LZSS 
compression" if you need any further information. This implementation uses binary search
trees to speed up compression. It is based on the code of the Allegro Library 
(http://alleg.sourceforge.net), and it have similar (a bit better actually) compression 
ratio. All source code is included. The library is written in FASM, and it uses Fresh
macro library. 
It is distributed under the terms of Fresh Artistic License 
(see http://www.decard.net/license.php).

2. Using LZSS library
To use LZSS library, first you have to include its files in your source. You have to 
include "lzss.inc" file somewhere in the beginning (it contains some definitions, not
the code), and then "lzss.asm" (anywhere in the code section). See "lzsspack.asm" file.
Now you can use the library functions. They can compress/decompress the data, and save
or load it from file.
In next part those functions are covered with more details.

2.1. LZSS Function Reference

proc lzssFreeData, lzss_data
Frees memory occupied by given lzss data. As lzss_data parameter you should use value
returned by lzssPackData.

proc lzssLoadFile, file_name, ptr_size
Loads packed file of given name, decompresses it and returns pointer to unpacked data.
Usually you will want to obtain size of the data after decompression, in such case you 
have to pass a pointer to dword variable as "ptr_size" parameter. If you pass NULL, 
its also OK but then you won't know unpacked data size.

proc lzssPackData, data_to_pack,data_size
Compresses given data of given size. Returns pointer to LZSSData in eax.


proc lzssSaveFile, file_name, buffer, size
Compresses given data of given size and stores it in specified file. If given file
already exists, it will be overwritten. Function returns zero on fail, and non-zero value
on success.

proc lzssUnpackData, lzss_data
Decompresses packed data. lzss_data should be the value returned by lzssPackData.


3. lzsspack.exe
lzsspack is a simple utility that preforms file compression. It is a command line utility. 
To pack some file just type: 
    >lzsspack source_file output_file
source is your file with data to be packed, and output is a name of file to be generated.
To unpack, type: 
    >lzsspack -u packed_file output_file
and it will decompress given file.

lzsspack's source code is included in the package.

4. Changelog

26.10.2004 - fixed serious bug that was causing data loss.
27.10.2004 - optimizations to bitstream library.
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































Deleted freshlib/_pending/lzss/source/bits.asm.

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
; creates bits stream and returns pointer
proc BitsCreateNew, .buf_size
        begin
        push    ebx edi
        invoke  GetProcessHeap
        mov     edi,eax
        invoke  HeapAlloc,eax,HEAP_ZERO_MEMORY,sizeof.BitStream
        or      eax,eax
        jz      .finish
        mov     ebx,eax
        invoke  HeapAlloc,edi,HEAP_ZERO_MEMORY,[.buf_size]
        or      eax,eax
        jz      .finish
        mov     [ebx+BitStream.buf],eax
        mov     [ebx+BitStream.ptr],eax
        mov     [ebx+BitStream.bit_ptr],0
        mov     eax,ebx
        pop     edi ebx
     .finish:
        return
endp

; create bitstream over existing buffer
proc BitsCreateFrom, .bitbuf
        begin
        push    ebx edi
        invoke  GetProcessHeap
        mov     edi,eax
        invoke  HeapAlloc,eax,HEAP_ZERO_MEMORY,sizeof.BitStream
        or      eax,eax
        jz      .finish
        mov     ebx,eax
        mov     eax,[.bitbuf]
        mov     [ebx+BitStream.buf],eax
        mov     [ebx+BitStream.ptr],eax
        mov     [ebx+BitStream.bit_ptr],0
        mov     eax,ebx
        pop     edi ebx
     .finish:
        return
endp

; destroys given bitstream, but not the buffer (!)
proc BitsDestroy, .stream
       begin
       push     eax
       invoke   GetProcessHeap
       invoke   HeapFree,eax,0,[.stream]
       pop      eax
       return
endp

; destroys given bitstream with buffer
proc BitsDestroyBuf, .stream
       begin
       push     eax ebx
       invoke   GetProcessHeap
       mov      ebx,eax
       mov      eax,[.stream]
       mov      eax,[eax+BitStream.buf]
       invoke   HeapFree,ebx,0,eax
       invoke   HeapFree,ebx,0,[.stream]
       pop      ebx eax
       return
endp


; sets given stream to position 0
proc BitsReset, .stream
        begin
        push    eax ebx
        mov     ebx,[.stream]
        mov     [ebx+BitStream.bit_ptr],0
        mov     eax,[ebx+BitStream.buf]
        mov     [ebx+BitStream.ptr],eax
        pop     ebx eax
        return
endp

; puts given number of bits into stream
proc BitsPut, .stream,.bits,.bit_count
        begin
        push    eax ebx ecx edx esi edi
        ; generate mask in edi:esi
        xor     eax,eax
        dec     eax
        mov     esi,eax
        mov     edi,eax
        mov     ebx,[.stream]
        mov     ecx,[.bit_count]
        shl     esi,cl
        mov     ecx,[ebx+BitStream.bit_ptr]
        shld    edi,esi,cl
        shld    esi,eax,cl
        ; load new bits into edx:ecx; at this point ecx==[ebx+BitStream.bit_ptr]
        xor     edx,edx
        mov     eax,[.bits]
        shld    edx,eax,cl
        shl     eax,cl
        mov     ecx,eax
        ; finally, store new bits using
        mov     ebx,[ebx+BitStream.ptr]
        and     [ebx],esi
        or      [ebx],ecx
        add     ebx,4
        and     [ebx],edi
        or      [ebx],edx
        ; and fix the pointers
        mov     ebx,[.stream]
        mov     eax,[.bit_count]
        add     [ebx+BitStream.bit_ptr],eax
        cmp     [ebx+BitStream.bit_ptr],32
        jb      .finish
        sub     [ebx+BitStream.bit_ptr],32
        add     [ebx+BitStream.ptr],4
      .finish:
        pop     edi esi edx ecx ebx eax
        return
endp

; reads given number of bits form the stream
proc BitsGet, .stream,.bit_count
        begin
        push    ebx ecx edx esi
        ; generate mask (in esi)
        xor     esi,esi
        dec     esi
        mov     ecx,[.bit_count]
        shl     esi,cl
        not     esi
        mov     ebx,[.stream]
        mov     eax,[ebx+BitStream.ptr]
        mov     edx,[eax+4]
        mov     eax,[eax]
        mov     ecx,[ebx+BitStream.bit_ptr]
        shrd    eax,edx,cl
        and     eax,esi
        ; fix the pointers
        mov     ebx,[.stream]
        mov     edx,[.bit_count]
        add     [ebx+BitStream.bit_ptr],edx
        cmp     [ebx+BitStream.bit_ptr],32
        jb      .finish
        sub     [ebx+BitStream.bit_ptr],32
        add     [ebx+BitStream.ptr],4
     .finish:
        pop     esi edx ecx ebx
        return
endp

; returns size (in bytes) of given stream
proc BitsGetSize, .stream
        begin
        push    ebx edx
        mov     ebx,[.stream]
        xor     edx,edx                         ; get number of bytes in additional bits
        mov     eax,[ebx+BitStream.bit_ptr]
        or      eax,eax
        jz      .no_extra_bits
        shr     eax,3
        inc     eax
        mov     edx,eax
     .no_extra_bits:
        mov     eax,[ebx+BitStream.ptr]
        sub     eax,[ebx+BitStream.buf]
        add     eax,edx
        pop     edx ebx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































Deleted freshlib/_pending/lzss/source/bits.inc.

1
2
3
4
5
struct BitStream
  .buf dd ?
  .ptr dd ?
  .bit_ptr dd ?
ends
<
<
<
<
<










Deleted freshlib/_pending/lzss/source/cmdln.asm.

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
; ------------------------------
; Base64 encoding program v1.0
; by Mateusz Tymek (c) 2004
;
; ------------------------------
; cmdln.asm
;   command line parsing
; ------------------------------


iglobal
; command line variables
cmdln:
  .argc   dd ?
  .argv   rd 0x10    ; 16 parameters limit
  .params rb 0x100

  .input_fname  dd ?
  .output_fname dd ?
  .switches     rd 8
  .out_buf      rb 0x50
endg


; strlen - returns length of given string
; from Fresh Standard Library
proc strlen, .str
        begin
        push    ebx
        mov     eax,[.str]
        mov     ebx,eax
  .scan:
        cmp     byte[eax],0
        lea     eax,[eax+1]
        jne     .scan
        sub     eax,ebx
        dec     eax         ; return value in eax
        pop     ebx
        return
endp

; strlen - returns length of given string
; from Fresh Standard Library
proc strcpy, .dest, .source
        begin
        push    esi edi eax ecx
        mov     edi,[.dest]
        mov     esi,[.source]
        stdcall strlen, esi
        mov     ecx,eax
        cld
        rep     movsb               ; copy strings
.finish:
        pop     ecx eax edi esi
        return
endp


; splits command line into single parameters
; (argv table)
proc parse_command_line, .cmdline
        begin
        push    eax ebx esi edi
        mov     [cmdln.argc],0
        mov     ebx,cmdln.argv
        mov     edi,cmdln.params
        mov     esi,[.cmdline]
     .load:
        mov     al,[esi]
        inc     esi
     .scan:
        cmp     al,0x20
        je      .load
        or      al,al
        jz      .finish
        inc     [cmdln.argc]
        mov     [ebx],edi
        add     ebx,4
        cmp     al,'"'
        je      .copy_quoted
     .copy_param:
        mov     [edi],al
        inc     edi
        mov     al,[esi]
        inc     esi
        cmp     al,0x20
        je      .param_copied
        or      al,al
        jz      .param_copied
        jmp     .copy_param
     .param_copied:
        mov     byte[edi],0
        inc     edi
        jmp     .scan
     .copy_quoted:
        mov     al,[esi]
        inc     esi
        cmp     al,'"'
        je      .end_quoted
        or      al,al
        jz      .param_copied
        mov     [edi],al
        inc     edi
        jmp     .copy_quoted
     .end_quoted:
        mov     al,[esi]
        inc     esi
        jmp     .param_copied
     .finish:
        pop     edi esi ebx eax
        return
endp


proc arrange_cmdline, .cmdline,.def_output_ext
        begin
        stdcall parse_command_line, [.cmdline]
        mov     esi,cmdln.switches
        xor     edx,edx
        xor     ecx,ecx

     .scan_param:
        inc     ecx
        cmp     ecx,[cmdln.argc]
        jae     .params_scanned
        mov     eax,[cmdln.argv+ecx*4]
        cmp     byte[eax],'-'
        je      .switch
        or      edx,edx
        jnz     .output_name
        mov     [cmdln.input_fname],eax
        inc     edx
        jmp     .scan_param
     .output_name:
        mov     [cmdln.output_fname],eax
        inc     edx
        jmp     .scan_param
     .switch:
        mov     [esi],eax
        add     esi,4
        jmp     .scan_param

     .params_scanned:
        cmp     [cmdln.argc],1
        je      .got_output_fname
        mov     dword[esi],0

        cmp     edx,2
        jae     .got_output_fname
        stdcall strcpy, cmdln.out_buf,[cmdln.input_fname]
        stdcall replace_ext, cmdln.out_buf,[.def_output_ext]
        mov     [cmdln.output_fname],cmdln.out_buf
     .got_output_fname:
        return
endp


; replaces extension of given filename to specified one.
; if ext is NULL, then the extension is removed
proc replace_ext, .filename,.ext
        begin
        mov     edi,[.filename]
        stdcall strlen, [.filename]
        add     edi,eax
        mov     ebx,edi
        dec     edi
    .scan:
        mov     al,[edi]
        cmp     al,'.'
        je      .got_extension
        cmp     al,'\'
        je      .append
        cmp     al,'/'
        je      .append
        cmp     al,':'
        je      .append
        or      al,al
        jz      .append
        dec     edi
        jmp     .scan

    .append:
        mov     edi,ebx
        mov     byte[edi],'.'
        inc     edi
        jmp     .get_new_ext

    .got_extension:
        inc     edi
    .get_new_ext:
        mov     esi,[.ext]
        or      esi,esi
        jz      .remove_ext
    .copy_ext:
        mov     al,[esi]
        mov     [edi],al
        inc     esi
        inc     edi
        or      al,al
        jnz     .copy_ext
    .finish:
        return
    .remove_ext:
        dec     edi
        xor     al,al
        mov     [edi],al
        jmp     .finish
endp


; replaces filename in given path
; if fname is NULL, then the file name is removed
proc replace_fname, .path,.fname
        begin
        mov     edi,[.path]
        stdcall strlen, [.path]
        or      eax,eax
        jz      .prepare_copy
        add     edi,eax
        mov     ebx,edi
        dec     edi
    .scan:
        mov     al,[edi]
        cmp     al,'\'
        je      .got_fname
        cmp     al,'/'
        je      .got_fname
        cmp     al,':'
        je      .got_fname
        or      al,al
        jz      .got_fname
        dec     edi
        jmp     .scan

    .got_fname:
        inc     edi
    .prepare_copy:
        mov     esi,[.fname]
    .copy_fname:
        mov     al,[esi]
        mov     [edi],al
        inc     esi
        inc     edi
        or      al,al
        jnz     .copy_fname
    .finish:
        return
endp


proc get_switch_w
        begin
        push    ebx edx
        mov     ebx,cmdln.switches
     .check:
        cmp     dword[ebx],0
        je      .false
        mov     edx,[ebx]

        cmp     word[edx],ax
        je      .true
        add     ebx,4
        jmp     .check
     .false:
        xor     eax,eax
        pop     edx ebx
        return
     .true:
        xor     eax,eax
        inc     eax
        pop     edx ebx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































































































































































































































































































































Deleted freshlib/_pending/lzss/source/lzss.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
;  lzss compression library
;  copyright (c) 2004 Mateusz Tymek
;
;  17.03.2004
;  last updated 27.10.2004
;  version 1.01


uglobal

lzss:
  .rnode rd LZSS_DICTIONARY_SIZE + 1 + 0x100
  .lnode rd LZSS_DICTIONARY_SIZE + 1
  .parent rd LZSS_DICTIONARY_SIZE + 1
  sizeof.trees = $-lzss.rnode

  .dictionary rb LZSS_DICTIONARY_SIZE + LZSS_MAX_COUNT
  sizeof.dictionary = $-lzss.dictionary

  .best_match_len dd ?
  .best_match_pos dd ?
endg

iglobal
  lzss.packer_func dd 0
endg

; creates new empty LZSSData structure
proc lzssNewData
        begin
        invoke  GetProcessHeap
        invoke  HeapAlloc, eax,HEAP_ZERO_MEMORY,sizeof.LZSSData         ; alloc mem for LZSSData struc
        return
endp


; destroys givem LZSSData structure
proc lzssFreeData, .lzss_data
        begin
        push    eax ebx
        invoke  GetProcessHeap
        mov     ebx,eax
        mov     eax,[.lzss_data]
        invoke  HeapFree, ebx,0,[eax+LZSSData.data]
        invoke  HeapFree, ebx,0,[.lzss_data]
        pop     ebx eax
        return
endp

;-----------------------------------------------------------------------------------------------


proc lzss_new_tree
        begin
        push    eax ecx esi edi
        mov     eax,LZSS_NO_TREE
        mov     ecx,LZSS_DICTIONARY_SIZE + 1
        mov     esi,lzss.lnode
        mov     edi,lzss.parent
     .clear:
        mov     [esi],eax
        mov     [edi],eax
        add     edi,4
        add     esi,4
        dec     ecx
        jnz     .clear
        mov     edi,lzss.rnode
        mov     ecx,LZSS_DICTIONARY_SIZE + 0x101
     .clear_btrees:
        mov     [edi],eax
        add     edi,4
        dec     ecx
        jnz     .clear_btrees
        pop     edi esi ecx eax
        return
endp


proc lzss_insert_node, .buffer_pos    ; inserts string at text_buf+[buf_pos] into the tree
        begin
        push    eax ebx ecx edx esi edi
        xor     eax,eax
        mov     [lzss.best_match_len],eax
        mov     [lzss.best_match_pos],eax

        mov     eax,[.buffer_pos]
        mov     edx,eax
        add     eax,lzss.dictionary
        movzx   eax,byte[eax]
        lea     ebx,[LZSS_DICTIONARY_SIZE+1+eax]
        mov     edx,1           ; edx will hold comparision result
        mov     eax,LZSS_NO_TREE
        mov     [lzss.rnode+edx*4],eax
        mov     [lzss.lnode+edx*4],eax

  .search_tree:
        or      edx,edx
        js      .left_node
     .right_node:
        cmp     [lzss.rnode+ebx*4],LZSS_NO_TREE
        je      .put_right

        mov     ebx,[lzss.rnode+ebx*4]
        jmp     .node_ok
     .put_right:
        mov     eax,[.buffer_pos]
        mov     [lzss.rnode+ebx*4],eax
        mov     [lzss.parent+eax*4],ebx
        jmp     .finish
     .left_node:
        cmp     [lzss.lnode+ebx*4],LZSS_NO_TREE
        je      .put_left

        mov     ebx,[lzss.lnode+ebx*4]
        jmp     .node_ok
     .put_left:
        mov     eax,[.buffer_pos]
        mov     [lzss.lnode+ebx*4],eax
        mov     [lzss.parent+eax*4],ebx
        jmp     .finish
     .node_ok:
        push    esi edi
        lea     edi,[lzss.dictionary+ebx]
        mov     esi,[.buffer_pos]
        lea     esi,[lzss.dictionary+esi]
        mov     ecx,LZSS_MAX_COUNT-1
        inc     esi     ;  we know that first character
        inc     edi     ;  already matches
        xor     edx,edx
        xor     eax,eax
     .compare:
        mov     dl,[esi]
        mov     al,byte[edi]
        sub     edx,eax
        or      edx,edx
        jnz     .compared
        inc     edi
        inc     esi
        dec     ecx
        jnz     .compare
     .compared:
        pop     esi edi

        mov     eax,LZSS_MAX_COUNT-1
        dec     ecx
        sub     eax,ecx
        cmp     eax,[lzss.best_match_len]
        jbe     .search_tree
        mov     [lzss.best_match_len],eax
        mov     [lzss.best_match_pos],ebx

        cmp     eax,LZSS_MAX_COUNT
        jae     .got_max_count

        jmp     .search_tree

     .got_max_count:
        mov     eax,[.buffer_pos]
        mov     edx,[lzss.parent+ebx*4]
        mov     [lzss.parent+eax*4],edx

        mov     edx,[lzss.lnode+ebx*4]
        mov     [lzss.lnode+eax*4],edx
        mov     [lzss.parent+edx*4],eax

        mov     edx,[lzss.rnode+ebx*4]
        mov     [lzss.rnode+eax*4],edx
        mov     [lzss.parent+edx*4],eax

        mov     edx,[lzss.parent+ebx*4]
        cmp     [lzss.rnode+edx*4],ebx
        je      .right
     .left:
        mov     [lzss.lnode+edx*4],eax
        jmp     .ok
     .right:
        mov     [lzss.rnode+edx*4],eax
     .ok:
        mov     eax,LZSS_NO_TREE
        mov     [lzss.parent+ebx*4],eax
        mov     [lzss.lnode+ebx*4],eax
        mov     [lzss.rnode+ebx*4],eax

     .finish:
        pop     edi esi edx ecx ebx eax
        return
endp


; removes tree node at [buffer_pos]
proc lzss_delete_node, .buffer_pos
        begin
        push    eax ebx ecx edx
        mov     eax,[.buffer_pos]
        cmp     dword[lzss.parent+eax*4],LZSS_NO_TREE   ; empty?
        je      .finish

        cmp     dword[lzss.rnode+eax*4],LZSS_NO_TREE
        je      .empty_right
        cmp     dword[lzss.lnode+eax*4],LZSS_NO_TREE
        je      .empty_left


        ; if we are here then none of children is empty

        mov     ebx,[lzss.lnode+eax*4]
        cmp     [lzss.rnode+ebx*4],LZSS_NO_TREE
        je      .got_free_rnode
      .find_free_rnode:
        mov     ebx,[lzss.rnode+ebx*4]
        cmp     [lzss.rnode+ebx*4],LZSS_NO_TREE
        jne     .find_free_rnode

        mov     edx,[lzss.parent+ebx*4]
        mov     ecx,[lzss.lnode+ebx*4]
        mov     [lzss.rnode+edx*4],ecx
        mov     [lzss.parent+ecx*4],edx

        mov     edx,[lzss.lnode+eax*4]
        mov     [lzss.lnode+ebx*4],edx
        mov     [lzss.parent+edx*4],ebx

  .got_free_rnode:

        mov     edx,[lzss.rnode+eax*4]
        mov     [lzss.rnode+ebx*4],edx
        mov     [lzss.parent+edx*4],ebx

        jmp     .remove

  .empty_left:
        mov     ebx,[lzss.rnode+eax*4]
        jmp     .remove
  .empty_right:
        mov     ebx,[lzss.lnode+eax*4]

  .remove:

        mov     edx,[lzss.parent+eax*4]         ; now edx holds parent of node being removed
        mov     [lzss.parent+ebx*4],edx

        ; now fix the valid child
        cmp     [lzss.rnode+edx*4],eax
        je      .fix_right_child
  .fix_left_child:
        mov     [lzss.lnode+edx*4],ebx
        jmp     .clear
  .fix_right_child:
        mov     [lzss.rnode+edx*4],ebx

  .clear:       ; clear the node that is being removed
        mov     [lzss.parent+eax*4],LZSS_NO_TREE
        mov     [lzss.rnode+eax*4],LZSS_NO_TREE
        mov     [lzss.lnode+eax*4],LZSS_NO_TREE

  .finish:

        pop     edx ecx ebx eax
        return
endp


proc lzssPackData, .buffer,.buffer_size
.lzss_data dd ?
.bitstream dd ?
        begin
        push    ebx ecx edx esi edi
        ; fill the dictionary with zeroes
        mov     edi,lzss.dictionary
        mov     ecx,(LZSS_DICTIONARY_SIZE + LZSS_MAX_COUNT)/2
        xor     eax,eax
      .clear_dictionary:
        mov     [edi],ax
        add     edi,2
        dec     ecx
        jnz     .clear_dictionary

        stdcall lzssNewData
        or      eax,eax
        jz      .finish
        mov     [.lzss_data],eax
        mov     edi,eax
        invoke  GetProcessHeap
        mov     ebx,eax
        mov     eax,[.buffer_size]       ; calculate maximum memory that can be needed by
        shr     eax,3                   ; compressed data. It is data_size + data_size/8 ...
        inc     eax                     ; and one more byte just to be sure :)
        add     eax,[.buffer_size]       ;
        invoke  HeapAlloc, ebx,HEAP_ZERO_MEMORY,eax
        or      eax,eax
        jz      .finish
        mov     [edi+LZSSData.data],eax
        mov     ecx,[.buffer_size]
        mov     [edi+LZSSData.unpacked_size],ecx
        mov     eax,[.buffer]            ; esi will point to input buffer
        add     eax,ecx         ; add eax,[buffer_size]
        stdcall BitsCreateFrom, [edi+LZSSData.data]
        mov     [.bitstream],eax

        ; edi will point to the end of the dictionary...
        mov     edi,LZSS_DICTIONARY_SIZE-LZSS_MAX_COUNT
        ; ... and esi will mark the start
        xor     esi,esi
        stdcall lzss_new_tree


        xor     edx,edx
     .read_first_bytes:
        mov     eax,[.buffer]
        mov     al,[eax]
        inc     [.buffer]
        mov     [lzss.dictionary+edi+edx],al
        inc     edx
        cmp     edx,LZSS_MAX_COUNT
        jae     .got_first_bytes
        dec     [.buffer_size]
        jz      .got_first_bytes
        jmp     .read_first_bytes
     .got_first_bytes:

        or      edx,edx
        jz      .packed

        mov     ecx,LZSS_MAX_COUNT-1
        mov     eax,edi
        dec     eax
     .prepare_tree:
        stdcall lzss_insert_node,eax
        dec     eax
        dec     ecx
        jnz     .prepare_tree
        stdcall lzss_insert_node,edi         ; insert the string just read; best_match_len and best_match_pos are set

     .packer_loop:
        cmp     [lzss.best_match_len],edx    ; best_match_len may be too long near the end
        jbe      .lzss.best_match_len_ok
        mov     [lzss.best_match_len],edx
     .lzss.best_match_len_ok:

        cmp     [lzss.best_match_len],LZSS_THRESHOLD   ; send unpacked byte or ofs-length pair?
        ja      .send_packed
        stdcall BitsPut, [.bitstream],0,1       ; send "unpacked data" flag
        mov     al,[lzss.dictionary+edi]
        stdcall BitsPut, [.bitstream],eax,8     ; send byte directly
        mov     [lzss.best_match_len],1              ; mark that we have processed just one byte

        jmp     .item_packed
     .send_packed:
        stdcall BitsPut, [.bitstream],1,1       ; "packed data" flag
        stdcall BitsPut, [.bitstream],[lzss.best_match_pos],LZSS_OFFSET_BITS
        mov     eax,[lzss.best_match_len]
        sub     eax,LZSS_THRESHOLD+1
        stdcall BitsPut, [.bitstream],eax,LZSS_COUNT_BITS


     .item_packed:
        xor     ecx,ecx
        mov     ebx,[lzss.best_match_len]    ; ebx will hold value of "last match length"
        cmp     [.buffer_size],0
        je      .new_bytes_ok
     .get_new_bytes:
        cmp     ecx,ebx                 ; compare ecx to [last_match_len]
        jae     .new_bytes_ok
        dec     [.buffer_size]
        jz      .new_bytes_ok
        stdcall lzss_delete_node,esi
        mov     eax,[.buffer]
        inc     [.buffer]
        mov     al,[eax]
        mov     [lzss.dictionary+esi],al        ; put new byte in the dictionary
        cmp     esi,LZSS_MAX_COUNT
        jae     .no_extra
        mov     [lzss.dictionary+esi+LZSS_DICTIONARY_SIZE],al
     .no_extra:
        inc     esi
        inc     edi
        mov     eax,LZSS_DICTIONARY_SIZE
        dec     eax
        and     esi,eax
        and     edi,eax

        stdcall lzss_insert_node,edi         ; insert new string

        inc     ecx
        jmp     .get_new_bytes
     .new_bytes_ok:
        cmp     ecx,ebx
        jae     .packed
        inc     ecx
        stdcall lzss_delete_node,esi
        inc     esi
        inc     edi
        mov     eax,LZSS_DICTIONARY_SIZE
        dec     eax
        and     esi,eax
        and     edi,eax
        dec     edx
        jz      .new_bytes_ok

        stdcall lzss_insert_node,edi
        jmp     .new_bytes_ok
     .packed:

        or      edx,edx
        jnz     .packer_loop

        mov     ebx,[.lzss_data]
        stdcall BitsGetSize, [.bitstream]
        mov     [ebx+LZSSData.packed_size],eax
     .finish:

        mov     eax,[.lzss_data]
        pop     edi esi edx ecx ebx
        return
endp


;iglobal
;  szOutFile db "out.dat", 0
;  szOutFile2 db "out2.dat", 0
;endg
;

;-----------------------------------------------------------------------------------------------



; debug lines
;iglobal
;  szDictionary db "ofs: %d, len: %d", 13, 10, 0
;  szDirect     db "direct byte: %d ('%c')", 13, 10, 0
;  szEndMarker  db "eof", 13, 10, 0
;endg


; unpacks given LZSSData structure and returns pointer
; when you have finished with this data, you should
; free this memory using HeapFree()
proc lzssUnpackData, .lzss_data
.uncompressed dd ?
.size         dd ?
        begin
        push    ebx ecx edx esi edi

        ; fill the dictionary with zeroes
        mov     edi,lzss.dictionary
        mov     ecx,(LZSS_DICTIONARY_SIZE + LZSS_MAX_COUNT)/2
        xor     eax,eax
      .clear_dictionary:
        mov     [edi],ax
        add     edi,2
        dec     ecx
        jnz     .clear_dictionary

        mov     ebx,[.lzss_data]
        invoke  GetProcessHeap
        invoke  HeapAlloc, eax,HEAP_ZERO_MEMORY,[ebx+LZSSData.unpacked_size]
        mov     [.uncompressed],eax
        mov     edi,eax
        stdcall BitsCreateFrom, [ebx+LZSSData.data]
        mov     esi,eax
        mov     eax,[ebx+LZSSData.unpacked_size]
        mov     [.size],eax
        mov     edx,LZSS_DICTIONARY_SIZE - LZSS_MAX_COUNT

   .unpack:
        stdcall BitsGet,esi,1
        or      eax,eax
        jnz     .from_dictionary
        stdcall BitsGet,esi,8

     ; debug lines
;     pusha
;     cinvoke printf, szDirect, eax,eax
;     popa
        mov     [edi],al
        inc     edi

        mov     [lzss.dictionary+edx],al
        inc     edx
        mov     eax,LZSS_DICTIONARY_SIZE
        dec     eax
        and     edx,eax
        dec     [.size]
        jz      .finish
        jmp     .unpack


    .from_dictionary:
        stdcall BitsGet, esi,LZSS_OFFSET_BITS         ; load position
;     push    eax  ; debug line
        mov     ebx,eax    ; no, unpack portion
        stdcall BitsGet, esi,LZSS_COUNT_BITS          ; load counter
        mov     ecx,eax
        add     ecx,LZSS_THRESHOLD+1
        sub     [.size],ecx

; debug lines
;     pop     eax
;     pusha
;     cinvoke printf, szDictionary, eax,ecx
;     popa

     .copy:
        mov     al,[lzss.dictionary+ebx]
        mov     [edi],al
        mov     [lzss.dictionary+edx],al
        inc     ebx
        inc     edi
        inc     edx
        mov     eax,LZSS_DICTIONARY_SIZE
        dec     eax
        and     edx,eax
        and     ebx,eax

        dec     ecx
        jnz     .copy
        cmp     [.size],0

        je      .finish
        jmp     .unpack
     .finish:

;  debug lines
;     pusha
;     cinvoke printf, szEndMarker
;     popa

        stdcall BitsDestroy, esi


;        invoke  CreateFile, szOutFile2,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0
;        mov     ebx,eax
;        invoke  WriteFile,eax,lzss.dictionary,sizeof.dictionary,tmp,0
;        invoke  CloseHandle,ebx
;

        mov     eax,[.uncompressed]


        pop     edi esi edx ecx ebx
        return
endp



; file routines

; compress data and store it in given file; returns 0 on fail
proc lzssSaveFile, .file_name,.buffer,.size
.hdr LZSSFileHeader
.tmp dd ?
        begin
        push    ebx ecx edx esi
        mov     eax,[lzss.packer_func]
        or      eax,eax
        jnz     .packer_func_ok
        mov     [lzss.packer_func],lzssPackData
     .packer_func_ok:
        stdcall [lzss.packer_func], [.buffer],[.size]
        mov     esi,eax
        mov     [.hdr.id],"LZSS"
        mov     eax,[.size]
        mov     [.hdr.unpacked_size],eax
        invoke  CreateFile, [.file_name],GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0
        cmp     eax,INVALID_HANDLE_VALUE
        je      .error
        mov     ebx,eax
        lea     eax,[.hdr]
        lea     edx,[.tmp]
        invoke  WriteFile,ebx,eax,sizeof.LZSSFileHeader,edx,0
        mov     ecx,[esi+LZSSData.packed_size]
        mov     eax,[esi+LZSSData.data]
        invoke  WriteFile,ebx,eax,ecx,tmp,0
        invoke  CloseHandle,ebx
        stdcall lzssFreeData,esi
        xor     eax,eax
        dec     eax
     .finish:
        pop     esi edx ecx ebx
        return
     .error:
        xor     eax,eax
        jmp     .finish
endp


; loads packed data from given file, unpacks it and returns pointer
; (0 on fail); ptr_size should be a pointer to dword variable
; that will contain unpacked data size
proc lzssLoadFile, .file_name, .ptr_size
.input_buf  dd ?
.input_size dd ?
        begin
        push    ebx ecx edx esi edi
        invoke  CreateFile, [.file_name],GENERIC_READ,0,0,OPEN_EXISTING,0,0
        cmp     eax,INVALID_HANDLE_VALUE
        je      .error
        mov     ebx,eax
        invoke  SetFilePointer,ebx,0,0,FILE_END
        mov     [.input_size],eax
        mov     esi,eax
        invoke  GetProcessHeap
        invoke  HeapAlloc, eax,HEAP_ZERO_MEMORY,esi
        or      eax,eax
        jz      .finish
        mov     [.input_buf],eax
        invoke  SetFilePointer, ebx,0,0,FILE_BEGIN
        invoke  ReadFile, ebx,[.input_buf],esi,tmp,0
        invoke  CloseHandle,ebx
        stdcall lzssNewData
        or      eax,eax
        jz      .finish
        mov     esi,eax
        mov     eax,[.input_buf]
        add     eax,sizeof.LZSSFileHeader
        mov     [esi+LZSSData.data],eax
        mov     eax,[.input_buf]
        mov     eax,[eax+LZSSFileHeader.unpacked_size]
        mov     [esi+LZSSData.unpacked_size],eax
        stdcall lzssUnpackData, esi
        or      eax,eax
        jz      .finish
        mov     ebx, eax

        mov     eax,[.ptr_size]
        or      eax,eax
        jz      .no_size_ptr
        mov     edx,[esi+LZSSData.unpacked_size]
        mov     [eax],edx
     .no_size_ptr:
        stdcall lzssFreeData,esi
        mov     eax,ebx
     .finish:
        pop     edi esi edx ecx ebx
        return
     .error:
        xor     eax,eax
        jmp     .finish
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/_pending/lzss/source/lzss.inc.

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
; packed data structure
struct LZSSData
  .packed_size     dd ?
  .unpacked_size   dd ?
  .data            dd ?
ends


; packed file header
struct LZSSFileHeader
  .id            dd ?
  .unpacked_size dd ?
ends


; lzss settings

LZSS_THRESHOLD       = 2

LZSS_COUNT_BITS      = 4
LZSS_OFFSET_BITS     = 12

LZSS_DICTIONARY_SIZE = (2 shl (LZSS_OFFSET_BITS-1))
LZSS_MAX_COUNT       = (2 shl (LZSS_COUNT_BITS-1)) + LZSS_THRESHOLD

LZSS_NO_TREE = LZSS_DICTIONARY_SIZE
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































Deleted freshlib/_pending/lzss/source/lzsspack.asm.

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
format PE console
entry start
include "%finc%/win32/win32a.inc"
include "%finc%/libs/strlib.inc"
include "bits.inc"
include "lzss.inc"
include "lzssstat.inc"

..ShowSkipped = 0

section '.code' code readable executable

include "%finc%/libs/strlib.asm"
include "bits.asm"
include "cmdln.asm"
include "lzss.asm"
include "lzssstat.asm"


  start:
        invoke  GetCommandLine
        stdcall arrange_cmdline, eax,szDefExt

        mov     ax,'-u'
        call    get_switch_w
        or      eax,eax
        jz      pack_file


     unpack_file:
        cmp     [cmdln.input_fname],0
        je      usage
        stdcall replace_ext, [cmdln.output_fname],szDefOutExt
        stdcall lzssLoadFile,[cmdln.input_fname],unp_size
        push    eax
        invoke  CreateFile, [cmdln.output_fname],GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0
        mov     ebx,eax
        pop     eax
        invoke  WriteFile,ebx,eax,[unp_size],tmp,0
        invoke  CloseHandle,ebx
        stdcall lzssFreeData, esi
        jmp     finish

     pack_file:
        cmp     [cmdln.input_fname],0
        je      usage
        invoke  CreateFile, [cmdln.input_fname],GENERIC_READ,0,0,OPEN_EXISTING,0,0
        cmp     eax,INVALID_HANDLE_VALUE
        je      finish
        mov     ebx,eax
        invoke  SetFilePointer, ebx,0,0,FILE_END
        mov     [input_size],eax
        mov     esi,eax
        invoke  GetProcessHeap
        invoke  HeapAlloc, eax,HEAP_ZERO_MEMORY,esi
        or      eax,eax
        jz      finish
        mov     [input_buf],eax
        invoke  SetFilePointer, ebx,0,0,FILE_BEGIN
        invoke  ReadFile, ebx,[input_buf],esi,tmp,0
        invoke  CloseHandle, ebx
        mov     [lzss.packer_func],lzssStatPack
        mov     ebx,[cmdln.argv]
        stdcall lzssSaveFile, [cmdln.output_fname],[input_buf],[input_size]
        cinvoke printf, szStatus, [lzss_stat.time],[lzss_stat.kbytes_per_sec],\
                                  [lzss_stat.size],[lzss_stat.packed_size],[lzss_stat.ratio],\
                                  [lzss_stat.total_items],[lzss_stat.direct_bytes],\
                                  [lzss_stat.dictionary_entries]
        jmp     finish

     usage:
        cinvoke printf, szUsage
     finish:
        invoke  ExitProcess, 0



iglobal
  szDefExt    db "lzss", 0
  szDefOutExt db "out", 0

  szUsage db "usage:", 13, 10, "  to compress: lzsspack input [output]", 13, 10
          db "  to decompress: lzsspack -u input output", 13, 10, 0

  szStatus db "status: ", 13, 10
           db "   total compression time: %d seconds", 13, 10
           db "            average speed: %d kbytes/sec", 13, 10
           db "       unpacked file size: %d bytes", 13, 10
           db "         packed data size: %d bytes", 13, 10
           db "        compression ratio: %d percent", 13, 10
           db 13, 10
           db "              total items: %d", 13, 10
           db "  direct (unpacked) bytes: %d", 13, 10
           db "       dictionary entries: %d", 13, 10, 0

endg


uglobal
  input_buf   dd ?
  input_size  dd ?
  output_name dd ?
  tmp         dd ?
  unp_size    dd ?
  argc        dd ?
  argv        dd ?
  env         dd ?
  hdr         LZSSFileHeader
  name_buf    rb 0x100
endg

;data fixups
;end data

section '.data' data readable writeable
IncludeAllGlobals


section '.idata' import data readable

library kernel32,"KERNEL32.DLL",\
        crtdll,"CRTDLL.DLL"

include "%finc%/win32/apia/kernel32.inc"

import crtdll,\
       __getmainargs,"__GetMainArgs",\
       printf,"printf",\
       flushall,"_flushall"
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































Deleted freshlib/_pending/lzss/source/lzsspack.fpr.

cannot compute difference between binary files

Deleted freshlib/_pending/lzss/source/lzssstat.asm.

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
proc lzssStatPack, .buffer, .buffer_size
        begin
        ; pack the data and count the time of the process
        invoke  GetTickCount
        mov     edi,eax
        stdcall lzssPackData, [.buffer],[.buffer_size]
        mov     ebx,eax
        invoke  GetTickCount
        sub     eax,edi
        xor     edx,edx

        mov     esi,1000
        div     esi
        mov     [lzss_stat.time],eax
        mov     esi,eax
        mov     eax,[.buffer_size]
        xor     edx,edx
        or      esi,esi
        jz      @f
        div     esi
    @@:
        shr     eax,10          ; divide eax by 1024
        mov     [lzss_stat.kbytes_per_sec],eax

        xor     eax,eax
        mov     [lzss_stat.total_items],eax
        mov     [lzss_stat.direct_bytes],eax
        mov     [lzss_stat.dictionary_entries],eax

        ; calculate ratio
        mov     edi,[.buffer_size]
        mov     [lzss_stat.size],edi
        mov     eax,[ebx+LZSSData.packed_size]
        mov     [lzss_stat.packed_size],eax
        mov     esi,100
        mul     esi
        div     edi
        mov     [lzss_stat.ratio],eax
        mov     edi,[ebx+LZSSData.unpacked_size]
        ; now scan compressed data
        stdcall BitsCreateFrom, [ebx+LZSSData.data]
        mov     esi,eax
   .unpack:
        inc     [lzss_stat.total_items]
        stdcall BitsGet,esi,1
        or      eax,eax
        jnz     .from_dictionary
        inc     [lzss_stat.direct_bytes]
        stdcall BitsGet,esi,8
        dec     edi
        jz      .finish
        jmp     .unpack
    .from_dictionary:
        stdcall BitsGet, esi,LZSS_OFFSET_BITS         ; load position
        inc     [lzss_stat.dictionary_entries]
        stdcall BitsGet, esi,LZSS_COUNT_BITS          ; load counter
        sub     edi,eax
        sub     edi,LZSS_THRESHOLD+1
        jz      .finish
        js      .finish
        jmp     .unpack
     .finish:
        stdcall BitsDestroy, esi

        mov     eax,ebx
        return
endp

uglobal
  lzss_stat:
    .time               dd ?
    .kbytes_per_sec     dd ?
    .size               dd ?
    .packed_size        dd ?
    .ratio              dd ?

    .total_items        dd ?
    .direct_bytes       dd ?
    .dictionary_entries dd ?
endg
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































Deleted freshlib/_pending/lzss/source/lzssstat.inc.

Deleted freshlib/_pending/profiling/data.asm.

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
include '%lib%/compiler/executable.inc'

include '%lib%/macros/allmacros.inc'
include '%lib%/equates/allequates.inc'

GlobalAPI equ ascii
_BinaryType console

_CodeSection

include '%lib%/system/process.asm'
include '%lib%/simpledebug/debug.asm'
include '%lib%/system/memory.asm'
include '%lib%/system/files.asm'
include '%lib%/data/arrays.asm'
include '%lib%/data/strlib.asm'

; very simple CPU clock cycles counter:

macro START
{
        align  4
        push   ecx
        push   ebx
        cpuid  ;cpuid has different execution times the first two times
        xor    eax, eax ; Flush the pipeline
        fwait
        cpuid
        rdtsc  ;Get RDTSC counter in edx:eax
        push   edx
        push   eax
        cpuid
}

macro STOP ; CPU cycles in edx:eax
{
        fwait
        cpuid
        rdtsc
        pop    ebx
        pop    ecx
        clc
        sub    eax,ebx
        sub    eax,144h ; Cut measurement overhead 
        sbb    edx,ecx
        pop    ebx
        pop    ecx
}

start:

        InitializeAll

iglobal
        msg1    db 0ah,'Profiling FreshLib: data module',0ah,0ah,0
        sizeof.msg1 = $-msg1
        msg2    db 'This string is going to be used and abused:',0ah
                db '[español, français] {áèïôü} (1234567890)',0ah
                db '< @ # ¡ ! $ % & * - + " / | \ ', "' = ¿ ? >",0ah,0
        sizeof.msg2 = $-msg2
        msg3    db 'used ',0
        testfile db '../../UnicodeSample.txt',0
endg

uglobal
        array1  dd ?
        file1	dd ?
        string1 dd ?
        string2 dd ?
        string3 dd ?
        string4 dd ?
        string5 dd ?
        string6 dd ?
        string7 dd ?
endg

        stdcall  Output,msg1
        DebugMsg 'Cycles to create the first string:'
START
        stdcall  SetString, string1, msg1
STOP
        stdcall  OutputRegister, regEAX, 10
        DebugMsg 'Cycles to create the second string:'
START
        stdcall  SetString, string2, msg2
STOP
        stdcall  OutputRegister, regEAX, 10

        DebugMsg 'Cycles to load a file to a new string:'

START
		push     esi
		stdcall  FileOpen, testfile
		mov      [file1], eax
        stdcall  FileSeek, [file1], 0, fsFromEnd
        mov      ecx, eax
        stdcall  FileSeek, [file1], 0, fsFromBegin
		stdcall  StrNew
		mov      [string7], eax
		stdcall  StrSetCapacity, eax, ecx
		mov      esi, eax
		stdcall  FileRead, [file1], esi, ecx
		stdcall  FileClose, [file1]
		stdcall  StrFixLen, string7
STOP
        stdcall  OutputRegister, regEAX, 10
        stdcall  Output, esi
        pop      esi
        DebugMsg ''

        DebugMsg 'Cycles to extract and create a new string:'
START
        stdcall  StrExtract, [string2], 27, 15
        mov      [string4], eax
STOP
        stdcall  OutputRegister, regEAX, 10



        stdcall  StrPtr, [string4]
        stdcall  Output, eax
        DebugMsg ' <- should be: used and abused'

        stdcall  StrNew
        mov      [string6], eax
        stdcall  StrCopy, [string6], [string2]
        stdcall  SetString, string5, msg3
        stdcall  StrPos, [string6], [string5]
        mov      esi, eax
        stdcall  StrSplit, [string6], 42
        stdcall  Output, esi
        DebugMsg ' <- should be: used and abused'
        
        DebugMsg 'Cycles to measure string lenght:'
START
        stdcall  StrPtr,[string2]
        stdcall  StrLen,eax
        mov      esi, eax
STOP
        stdcall  OutputRegister, regEAX, 10
        DebugMsg 'Lenght of the string:'
        mov      eax,esi
        stdcall  OutputRegister, regEAX, 10

        DebugMsg 'Original string for the following tests:'
		stdcall  Output,msg2

        DebugMsg 'Cycles to ucase the loaded string:'
START
        stdcall  StrUCase2,[string7]
STOP
        stdcall  OutputRegister, regEAX, 10
        stdcall  StrPtr, [string7]
        stdcall  Output, eax

        DebugMsg 'Cycles to lcase the loaded string:'
START
        stdcall  StrLCase2,[string7]
STOP
        stdcall  OutputRegister, regEAX, 10
        stdcall  StrPtr, [string7]
        stdcall  Output, eax

        DebugMsg "**** testing pelaillo's case functions ****"
        stdcall  SetString,string3,msg2

        DebugMsg 'Cycles to ucase the third string:'
START
        stdcall  StrUCase2,[string3]
STOP
        stdcall  OutputRegister, regEAX, 10
        stdcall  StrPtr, [string3]
        stdcall  Output, eax

        DebugMsg 'Cycles to lcase the third string:'
START
        stdcall  StrLCase2,[string3]
STOP
        stdcall  OutputRegister, regEAX, 10
        stdcall  StrPtr, [string3]
        stdcall  Output, eax


        jmp      .exit
        stdcall  CreateArray, 20h
        jc       .error
        mov      [array1],eax
        DebugMsg 'Step2: Array Created'
        stdcall  NumToStr,eax,ntsHex
        stdcall  StrPtr, eax
        stdcall  Output, eax
        stdcall  StrNew
        mov      [string1],eax

        stdcall  AddArrayItem,[array1]
        jmp      .exit

.error:
        DebugMsg 'An error occurred'

.exit:
        FinalizeAll
        stdcall  Terminate,0

_ImportSection

include '%lib%/imports/allimports.asm'

_DataSection

IncludeAllGlobals
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































Deleted freshlib/_pending/tutorial/files.asm.

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
include '%lib%/compiler/executable.inc'
include '%lib%/macros/allmacros.inc'
include '%lib%/equates/allequates.inc'

GlobalAPI equ ascii
_BinaryType console

include '%lib%/simpledebug/debug.asm'
include '%lib%/system/files.asm'
include '%lib%/system/process.asm'

_CodeSection

start:

        InitializeAll

        DebugMsg 'FreshLib Tutorials - Module: Files'

iglobal
        filename        db './tut01.txt',0
        sizeof.filename = $-filename
endg

uglobal
        hFile   dd ?
endg

        stdcall FileCreate, filename
        jc      .error
        mov     [hFile], eax
        DebugMsg "A new file was created:"
        stdcall OutputNumber, [hFile], 16, 2
        DebugMsg " is the handle of the file"

        stdcall FileWrite, [hFile], filename, sizeof.filename
        jc      .error
        stdcall OutputNumber, eax, 10, 2
        DebugMsg " bytes were written into the file"

        stdcall FileClose, [hFile]
        jc      .error
        DebugMsg "The file was properly closed"

        stdcall FileDelete, filename
        jc      .error
        DebugMsg "The file was finally deleted"
        jmp     .exit

.error:
        DebugMsg "Sorry, an error occurred"

.exit:
        FinalizeAll
        stdcall Terminate, 0

_ImportSection

include '%lib%/imports/allimports.asm'

_DataSection

IncludeAllGlobals
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































Deleted freshlib/_pending/tutorial/gui.asm.

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
include '%lib%/compiler/executable.inc'
_BinaryType GUI


include '%lib%/macros/allmacros.inc'
include '%lib%/equates/allequates.inc'
include '%lib%/GUI/SysEvents.asm'


_CodeSection

include '%lib%/simpledebug/debug.asm'
include '%lib%/system/process.asm'

include '%lib%/system/memory.asm'
include '%lib%/system/files.asm'
include '%lib%/data/arrays.asm'
include '%lib%/data/strlib.asm'

include '%lib%/timers/timers.asm'

include '%lib%/graphics/context.asm'
include '%lib%/graphics/text.asm'
include '%lib%/graphics/draw.asm'
include '%lib%/graphics/images.asm'
include '%lib%/graphics/giflib.asm'

include '%lib%/mouse/mouse.asm'
include '%lib%/GUI/GUI.asm'


iglobal
frmMainForm:
        ObjTemplate  tfParent or tfEnd, Form, frmMain, \
                     x, 100,        \
                     y, 50,         \
                     width, 320,    \
                     height, 200,   \
                     visible, TRUE, \
                     caption, 'Very simple window'

          ObjTemplate  tfChild or tfEnd, Button, btnChild1,          \
                     x, 48,         \
                     y, 48,         \
                     width, 80,     \
                     height, 48,    \
                     TextAlign, dtfAlignLeft or dtfAlignMiddle or dtfCRLF or dtfWordWrap,\
                     caption, 'Hello',        \
                     visible, TRUE, \
                     OnClick, Button1Click
endg

start:
        InitializeAll

        stdcall Create, CApplication
        jc      .start_error
        mov     [pApplication], ebx

uglobal
  test_timer1 dd ?
endg

DebugMsg 'After initializing.'

        stdcall CreateFromTemplate, frmMainForm, 0
        mov     ecx, [Application]
        mov     [ecx+TApplication.MainWindow], ebx

        DebugMsg 'After attaching window.'


        stdcall TimerCreate
        mov     [test_timer1], eax
        mov     [eax+TTimer.interval], 10
        mov     [eax+TTimer.Callback], procTestTimer1
        mov     [eax+TTimer.flags], tmfCallProc
        or      [eax+TTimer.flags], tmfRunning


        stdcall Run

        FinalizeAll
        stdcall Terminate, eax

.start_error:
        stdcall Terminate, 1

proc Button1Click, .self, .button
begin
        DebugMsg 'Button1 clicked'
        return
endp

iglobal
  test_counter dd 0
endg


proc procTestTimer1, .ptrTimer
begin
        add [test_counter],1
        cmp [test_counter],100
        jbe .not_yet
        stdcall OutputNumber,[test_counter],10,10
        stdcall Destroy,[frmMainForm]
  .not_yet:
        return
endp



_ImportSection

include '%lib%/imports/allimports.asm'

_DataSection
IncludeAllGlobals
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































Deleted freshlib/_pending/tutorial/hello.asm.

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
include '%lib%/compiler/executable.inc'
include '%lib%/macros/allmacros.inc'
include '%lib%/equates/allequates.inc'

GlobalAPI equ ascii
_BinaryType console

include '%lib%/system/process.asm'
include '%lib%/simpledebug/debug.asm'

_DataSection

IncludeAllGlobals

_CodeSection

start:

	InitializeAll

	DebugMsg 'Hello world!'

	FinalizeAll

	stdcall Terminate,0

_ImportSection

include '%lib%/imports/allimports.asm'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































Deleted freshlib/_trash/Common/header.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description:
;
;  Target OS:
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________
<
<
<
<
<
<
<
<
<
<
<
<
<


























Deleted freshlib/_trash/SurplusSources/Linux/TButtonLinux.asm.

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

proc TButton.Create, .obj, .parent
begin
        push    eax ecx edx esi edi

        mov     ebx, [.obj]

        mov     eax, [.parent]
        test    eax, eax
        jz      .root

        mov     eax, [eax+TWindow.handle]
        jmp     .parentok

.root:
        mov     eax, [hRootWindow]

.parentok:
        cinvoke XCreateSimpleWindow, [hApplicationDisplay], eax, 0, 0, 1, 1, 0, 0, $d4d0c8
        mov     [ebx+TButton.handle], eax

        stdcall _SetWindowStruct, eax, ebx

        cinvoke XSelectInput, [hApplicationDisplay], [ebx+TButton.handle], ExposureMask or       \
                                                                           EnterWindowMask or    \
                                                                           LeaveWindowMask or    \
                                                                           ButtonPressMask or    \
                                                                           ButtonReleaseMask


        pop     edi esi edx ecx eax
        return
endp





proc TButton.SysEventHandler, .ptrEvent

begin
        push    esi edi

        mov     esi, [.ptrEvent]

        stdcall _GetWindowStruct, [esi+XEvent.window]
        mov     edi, eax

        mov     eax, [esi+XEvent.type]
        cmp     eax, Expose
        je      .expose
        cmp     eax, LeaveNotify
        je      .leave
        cmp     eax, EnterNotify
        je      .enter
        cmp     eax, ButtonPress
        je      .button_press
        cmp     eax, ButtonRelease
        je      .button_release


.finish:
        pop   edi esi
        stc
        return

.button_release:
        cmp     [esi+XButtonPressedEvent.button], 1
        jne     .finish

        cinvoke XUngrabPointer, [hApplicationDisplay], CurrentTime

        mov     [edi+TButton.state], btnPointed
        jmp     .needrepaint

.button_press:
        cmp     [esi+XButtonPressedEvent.button], 1
        jne     .finish

        cinvoke XGrabPointer, [hApplicationDisplay], [esi+XButtonEvent.window], FALSE,          \
                              ButtonReleaseMask or EnterWindowMask or LeaveWindowMask,          \
                              GrabModeAsync, GrabModeAsync, None, None, CurrentTime

        mov     [edi+TButton.state], btnPressed
        jmp     .needrepaint

.leave:
        cmp     [edi+TButton.state], btnPressed
        je      .end_mouse

        mov     [edi+TButton.state], btnNormal
        jmp     .needrepaint

.enter:
        cmp     [edi+TButton.state], btnPressed
        je      .end_mouse

        mov     [edi+TButton.state], btnPointed

.needrepaint:
locals
  .event XExposeEvent
endl
        lea     eax, [.event]
        mov     ecx, [hApplicationDisplay]
        mov     edx, [esi+XEvent.window]
        mov     [eax+XExposeEvent.type], Expose
        mov     [eax+XExposeEvent.display], ecx
        mov     [eax+XExposeEvent.window], edx

        cinvoke XSendEvent, ecx, edx, FALSE, ExposureMask, eax

.end_mouse:
        pop     edi esi
        clc
        return

.expose:
        stdcall _DrawBtnFace, [esi+XEvent.window], [edi+TButton.state]
        clc
        pop     edi esi
        return
endp







proc _DrawBtnFace, .hwin, .state
.attr XWindowAttributes
.name dd ?
.font dd ?
.direction dd ?
.ascent    dd ?
.descent   dd ?
.overall   XCharStruct

begin
        pushad

        lea     ecx, [.attr]
        cinvoke XGetWindowAttributes, [hApplicationDisplay], [.hwin], ecx
        dec     [.attr.width]
        dec     [.attr.height]

        cinvoke XCreateGC, [hApplicationDisplay], [.hwin], 0, 0
        mov     ebx, eax

; clear the background
        cinvoke XSetForeground, [hApplicationDisplay], ebx, $d4d0c8
        cinvoke XFillRectangle, [hApplicationDisplay], [.hwin], ebx, 1, 1, [.attr.width], [.attr.height]

; draw button frame
        mov     eax, $ffffff
        mov     ecx, $000000

        cmp     [.state], btnPointed
        je      .border_ok

        xchg    eax, ecx

        cmp     [.state], btnPressed
        je      .border_ok

; normal state.
        mov     eax, $e0e0e0
        mov     ecx, $808080

.border_ok:
        stdcall DrawBtnFrame, ebx, [.hwin], eax, ecx, 0, 0, [.attr.width], [.attr.height]

        cinvoke XSetForeground, [hApplicationDisplay], ebx, $000000
        cinvoke XLoadQueryFont, [hApplicationDisplay], cGUIfont
        mov     [.font], eax
        cinvoke XSetFont, [hApplicationDisplay], ebx, [eax+XFontStruct.fid]

        lea     ecx, [.name]
        cinvoke XFetchName, [hApplicationDisplay], [.hwin], ecx

        stdcall StrLength, [.name]
        mov     edi, eax
        lea     ecx, [.direction]
        lea     edx, [.ascent]
        lea     eax, [.descent]
        lea     esi, [.overall]
        cinvoke XTextExtents, [.font], [.name], edi, ecx, edx, eax, esi

        xor     eax, eax
        mov     ax, [.overall.ascent]
        add     ax, [.overall.descent]
        movsx   eax, ax
        sub     eax, [.attr.height]
        add     eax, 1
        neg     eax
        sar     eax, 1
        movsx   ecx, [.overall.ascent]
        lea     eax, [eax+ecx+1]  ; this is the baseline.
        mov     [.attr.y], eax

        mov     ax, [.overall.width]
        movsx   eax, ax
        sub     eax, [.attr.width]
        add     eax, 1
        neg     eax
        sar     eax, 1
        add     eax, 1
        cmp     eax, 1
        jge     @f
        mov     eax, 1
@@:
        mov     [.attr.x], eax

; debug only
;        cinvoke XDrawLine, [hApplicationDisplay], [.hwin], ebx, [.attr.x], 1, [.attr.x], [.attr.height]
;        cinvoke XDrawLine, [hApplicationDisplay], [.hwin], ebx, 1, [.attr.y], [.attr.width], [.attr.y]

        stdcall StrLength, [.name]
        cinvoke XDrawString, [hApplicationDisplay], [.hwin], ebx, [.attr.x], [.attr.y], [.name], eax

        cinvoke XFree, [.name]
        cinvoke XFreeFont, [hApplicationDisplay], [.font]
        cinvoke XFreeGC, [hApplicationDisplay], ebx

        popad
        return
endp


proc DrawBtnFrame, .GC, .hwin, .upcolor, .dncolor, .left, .top, .right, .bottom
begin
        cinvoke XSetForeground, [hApplicationDisplay], [.GC], [.upcolor]
        cinvoke XDrawLine, [hApplicationDisplay], [.hwin], [.GC], [.left], [.top], [.right], [.top]
        cinvoke XDrawLine, [hApplicationDisplay], [.hwin], [.GC], [.left], [.top], [.left],  [.bottom]

        cinvoke XSetForeground, [hApplicationDisplay], [.GC], [.dncolor]
        cinvoke XDrawLine, [hApplicationDisplay], [.hwin], [.GC], [.left], [.bottom], [.right], [.bottom]
        cinvoke XDrawLine, [hApplicationDisplay], [.hwin], [.GC], [.right], [.bottom], [.right],  [.top]

        return
endp






iglobal
  cGUIfont     db '*helvetica-medium-r*--12*', 0        ;'*lucida-medium-r*-sans-12*',0
endg


proc StrLength, .name
begin
        push    ecx
        mov     ecx, [.name]
        xor     eax, eax
        jecxz   .exit

        dec     eax
.loop:
        inc     eax
        cmp     byte [ecx+eax], 0
        jne     .loop
.exit:
        pop     ecx
        return
endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/Linux/TFormLinux.asm.

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
proc TForm.Create, .obj, .parent
begin
        push    eax ecx edx esi edi

        mov     ebx, [.obj]

        mov     eax, [.parent]
        test    eax, eax
        jz      .root
        mov     eax, [eax+TWindow.handle]
        jmp     .parentok

.root:
        mov     eax, [hRootWindow]

.parentok:
        cinvoke XCreateSimpleWindow, [hApplicationDisplay], eax, 0, 0, 1, 1, 1, 0, $d4d0c8
        mov     [ebx+TForm.handle], eax

        stdcall _SetWindowStruct, eax, ebx

        cinvoke XSetWMProtocols, [hApplicationDisplay], [ebx+TForm.handle], wmdelete_atom, 1
        cinvoke XSelectInput, [hApplicationDisplay], [ebx+TForm.handle], ExposureMask or KeyPressMask or KeyReleaseMask or SubstructureNotifyMask

        pop     edi esi edx ecx eax
        return
endp



proc TForm.Get, .obj, .idparam
begin
        stc
        return
endp


proc TForm.Set, .obj, .idparam, .value
begin
        stc
        return
endp




proc TForm.SysEventHandler, .ptrEvent
begin
        push    esi edi

        stdcall _GetWindowStruct, [esi+XEvent.window]
        mov     edi, eax

        mov     esi, [.ptrEvent]

        mov     eax, [esi+XEvent.type]

        cmp     eax, Expose
        je      .expose

        cmp     eax, DestroyNotify
        je      .destroy_notify

        cmp     eax, ClientMessage
        je      .clientmessage

.finish:
        pop   edi esi
        stc                     ; not processed
        return

.clientmessage:
        mov     eax, dword [esi+XClientMessageEvent.data]
        mov     ecx, [wmdelete_atom]
        cmp     eax, ecx
        je      .do_destroy

        clc
        pop     edi esi
        return

.do_destroy:
        cinvoke XDestroyWindow, [hApplicationDisplay], [esi+XClientMessageEvent.window]
        clc
        pop     edi esi
        return

.destroy_notify:
        stdcall FreeMem, edi

        clc
        pop     edi esi
        return

.expose:
        stc
        pop     edi esi
        return
endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































Deleted freshlib/_trash/SurplusSources/Linux/_common.asm.

Deleted freshlib/_trash/SurplusSources/Linux/allutils.asm.

1
include '_common.asm'
<


Deleted freshlib/_trash/SurplusSources/OldLibs/lists.asm.

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
;------------------------------------------------------------------
; Creates TList dynamic list
; or init existing one.
; if ptrList = NULL, the memory for the list will be allocated.
; Returns: pointer to TList structure, properly initialized.
;------------------------------------------------------------------
proc ListCreate, .ptrList
begin
        push    ebx esi
        xor     ebx, ebx
        mov     esi, [.ptrList]
        test    esi,esi
        jnz     .listok

        invoke  HeapAlloc, [hHeap], ebx, sizeof.TList
        mov     esi, eax

.listok:
        mov     [esi+TList.Count], ebx

        invoke  HeapAlloc, [hHeap], HEAP_ZERO_MEMORY, 4*cMinListCapacity
        mov     [esi+TList.ptrItems], eax

        mov     eax, esi
        pop     esi ebx
        return
endp


;--------------------------------------------
; Frees all elements of the list calling
; [FreeProc] on every element.
; (proc FreeProc, ptrItem)
; Frees the array of items
;--------------------------------------------
proc ListFree, .ptrList, .FreeProc
begin
        push    esi edi ebx

        mov     edi, [.ptrList]
        xor     ebx, ebx
        xor     esi, esi
        xchg    esi, [edi+TList.ptrItems]
        xchg    ebx, [edi+TList.Count]

        cmp     [.FreeProc], 0
        je      .endwhile

        test    esi, esi
        jz      .finish

.freeloop:
        dec     ebx
        js      .endwhile

        lea     eax, [esi+4*ebx]
        stdcall [.FreeProc], [eax]
        jmp     .freeloop

.endwhile:
        invoke  HeapFree, [hHeap], 0, esi

.finish:
        pop     ebx edi esi
        return
endp



;-----------------------------------------
; Inserts new element in the list and
; returns it's address.
; If [Index] is bigger than List.Count
; the new element will be appended as last
; element.
;-----------------------------------------
proc ListInsert, .ptrList, .Index
begin
        push    esi edi ebx

        mov     esi, [.ptrList]

        invoke  HeapSize, [hHeap], 0, [esi+TList.ptrItems]
        cmp     eax, -1
        je      .exiterror

        shr     eax, 2          ; get capacity
        mov     ebx, eax

        mov     edi, [.Index]
        cmp     edi, [esi+TList.Count]
        jb      .indexok
        mov     edi, [esi+TList.Count]

.indexok:
        cmp     [esi+TList.Count], ebx
        jb      .capacityok

        mov     eax, ebx
        shr     eax, 1
        add     eax, 2

        cmp     eax, 1024
        jbe     .incok
        mov     eax, 1024

.incok:
        add     ebx, eax
        shl     ebx, 2
        invoke  HeapReAlloc, [hHeap], 0, [esi+TList.ptrItems], ebx
        mov     [esi+TList.ptrItems], eax

.capacityok:
        mov     ecx, [esi+TList.Count]
        sub     ecx, edi ; index
        jz      .dontmove

; Move the items.
        std
        mov     eax, [esi+TList.Count]
        mov     esi, [esi+TList.ptrItems]
        lea     edi, [esi+4*eax]
        lea     esi, [edi-4]
        rep movsd
        cld

        mov     eax, edi
        jmp     .exit

.exiterror:
        xor     eax, eax
        jmp     .exit

.dontmove:
        inc     [esi+TList.Count]
        mov     eax, [esi+TList.ptrItems]
        lea     eax, [eax+4*edi]
.exit:
        pop     ebx edi esi
        return
endp



proc ListDelete, .ptrList, .Index
begin
        push    esi edi ebx

        mov     esi, [.ptrList]
        mov     edi, [.Index]

        cmp     edi, [esi+TList.Count]
        jae     .exit

        dec     [esi+TList.Count]
        mov     ecx, [esi+TList.Count]
        sub     ecx, edi
        jz      .exit

        mov     eax, [esi+TList.ptrItems]
        lea     edi, [eax+4*edi]
        lea     esi, [edi+4]

        rep movsd

.exit:
        pop     ebx edi esi
        return
endp


proc ListIndexOf, .ptrList, .Item
begin
        push    esi edi
        mov     esi, [.ptrList]
        mov     ecx, [esi+TList.Count]
        jecxz   .empty
        mov     edi, [esi+TList.ptrItems]
        lea     edi, [edi+4*ecx-4]              ; from the end
        mov     eax, [.Item]
        std
        repnz scasd
        cld
        jz      .found
.empty:
        dec     ecx
.found:
        mov     eax, ecx
        pop     edi esi
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/OldLibs/lists.inc.

1
2
3
4
5
6
7
cMinListCapacity  = 128

struct TList
  .Count    dd ?
  .ptrItems dd ?
ends

<
<
<
<
<
<
<














Deleted freshlib/_trash/SurplusSources/OldLibs/qsort.asm.

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
QuickSortLib:

;****************************************************
; Quick sort of the array in the memory.
;
;  ptrArray       - pointer to the memory array.
;  ElementSize    - size of one array element in bytes.
;  iBegin         - index of the first element
;  iEnd           - index of the last element
;  ptrCompareProc - pointer to procedure that compares two elements.
;
; ptrCompareProc have interface:
;  proc CompareSomething, ptrElement1, ptrElement2
;    returns: c=1 if elements are not properly sorted.
;             c=0 if elements are sorted, i.e.
;                 element1 should be before element2
;****************************************************


proc QSort, ptrArray, ElementSize, iBegin, iEnd, ptrCompareProc
begin
        push    esi edi ebx
        mov     esi, [ptrArray]
        mov     edi, [ptrCompareProc]
        mov     ebx, [ElementSize]

        stdcall DoQSort, [iBegin], [iEnd]
        pop     ebx edi esi
        return
endp

;*****************************************************
; Procedure for internal call from QSort procedure.
;*****************************************************
proc DoQSort, Left, Right
begin
        push    ecx

        mov     ecx, [Left]     ; i variable
        mov     eax, ecx
        mov     edx, [Right]    ; j variable
        add     eax, edx
        sar     eax, 1
        imul    eax, ebx
        imul    ecx, ebx
        imul    edx, ebx
        add     eax, esi
        add     ecx, esi
        add     edx, esi

.repeat:
        sub     ecx, ebx
        add     edx, ebx

.whylei:
        add     ecx, ebx
        stdcall edi, ecx, eax
        jnc     .whylei

.whylej:
        sub     edx, ebx
        stdcall edi, eax, edx
        jnc     .whylej

        cmp     edx, ecx
        jl      .next

        call    SwapElements

        push    edx
        cmp     eax, ecx
        je      @f
        mov     [esp], ecx
        cmp     eax, edx
        je      @f

        mov     [esp], eax
@@:
        pop     eax

        add     ecx, ebx
        sub     edx, ebx

.next:
        cmp     ecx, edx
        jle     .repeat

        mov     eax, edx
        sub     eax, esi
        cdq
        idiv    ebx

        cmp     [Left], eax
        jge     .leftok

        stdcall DoQSort, [Left], eax

.leftok:
        mov     eax, ecx
        sub     eax, esi
        cdq
        idiv    ebx

        cmp     eax, [Right]
        jge     .rightok

        stdcall DoQSort, eax, [Right]

.rightok:
        pop     ecx
        return
endp



;********************************************
; Swaps two elements of the array with
; pointers in:
;   Element1 - ecx
;   Element2 - edx
;   ElementSize - ebx
;********************************************
proc SwapElements
begin
        push    esi eax

        xor     esi, esi
.loop:
        mov     al, [ecx+esi]
        xchg    al, [edx+esi]
        mov     [ecx+esi], al

        inc     esi
        cmp     esi, ebx
        jne     .loop

        pop     eax esi
        return
endp




proc CompareIntAscending, ptrElement1, ptrElement2
begin
        push    eax esi edi

        mov     esi, [ptrElement1]
        mov     edi, [ptrElement2]

        mov     eax, [esi]
        cmp     eax, [edi]
        jl      .qfalse

        stc
        pop     edi esi eax
        return


.qfalse:
        clc
        pop     edi esi eax
        return
endp



DispSize 'QSort lib', $ - QuickSortLib
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/OldLibs/strlib.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
;************************************************************
; FASM dynamic string library.
;
; (c)2003 John Found
; (c)2003 Mateusz Tymek (aka decard)
; (c)2003 Victor Loh (aka roticv)
;
; You can use and modify this library, as long as modifyed
; versions are clearly marked (author of the modification
; and what is changed), copyright notice is not
; removed and the library remains free.
; Copyright for the library concept and parts written by
; me, remains to me, John Found
; Copyright for the modifyed/new parts remains to their
; authors.
;
; Versions:
;   dd.mm.yyyy  version   author of modification
;     - description
;--------------------------------------------------------
;   09.07.2003  v1.0    John Found
;     - the first public version.
;   15.07.2003  v1.0.1  John Found
;     - minor bug with string table expand. Look in NewStr
;   17.09.2003  v1.1.0  Mateusz Tymek
;     - made all functions stdcall
;     - added StrCat and StrPos, and modified StrLen
;   25.09.2003  v1.1.2  Mateusz Tymek, Victor Loh
;     - added StrLCase, StrUCase, StrCopyMMX, StrInsert
;     - added new NumToStr, old version renamed to _NumStr
;     - some small optimizations & bugfixes
;   26.09.2003 v1.1.3  JohnFound
;     - some bug fixes and style corections.
;   29.09.2003 v1.1.4  John Found, Mateusz Tymek
;     - library rewtiten to use John Found's stdcall macros
;     - added two new low-level NumToStr routines: NumToStrF and NumToStrUF
;     - NumToStr rewriten
;     - some small bugfixes & modifications
;     - added StrExtract
;   01.11.2003 v1.1.4.1 Mateusz Tymek
;     - preserved ecx in StrDel (it was destroyed by API calls)
;   21.11.2003 v1.1.5 John Found
;     - StrComp splitted to 2 functions: StrCompCase and StrCompNoCase
;       IMPORTANT: inversed return result: CARRY = 1 mean strings equal.
;       This is because the using is more natural this way:
;            stdcall  StrCompCase, str1, str2
;            jc       .equal
;   27.11.2003 v1.2 John Found
;     - Added function StrHash, that produces 32bit hash value of the string.
;       The hash function is based on FASM hash function and have to be compatible.
;   03.12.2003 v1.2.3 Mateusz Tymek
;     - Added StrCharPos and StrToNum
;   13.12.2003 v1.2.4 Materusz Tymek
;     - added StrCharCat and StrInsertChar
;   04.01.2005 v1.2.5 John Found
;     - Fixed bug in StrSetLength
;     - Added function StrURLEncode
;*************************************************************************************


;--< How to use it >-----------------------------------------------------------------
; 1. Include "strutils.inc" somewhere in the begining of main file.
; 2. Define structure "StrTable" of type "TStrTable" somewhere in data section.
; 3. Before using of library functions, call "InitStrings"
; 4. After last use of the library (probably on close of application),
;    call "FreeStrings" to free all used memory.
; 5. Some functions are with register parameter passing, other with "stdcall"
;    parameter passing. Read the header descriptions of the functions.
;------------------------------------------------------------------------------------

; Global variable, storing parameters of dynamic strings list.
uglobal
  StrTable        TStrTable      ; StrLib library variable.
endg


; < Library functions >

;************************************************************************************
; Allocates memory for string table and allocates memory for strings.
; Start it before any work with strings.
; Returns 0 if failed to allocate needed memory.
;************************************************************************************
initialize InitStrings
begin
        StrLib = 1

        push    esi ebx
        mov     esi,StrTable
        invoke  GetProcessHeap
        test    eax,eax
        jz      .finish
        mov     [StrTable.heap],eax
        invoke  HeapAlloc,[StrTable.heap],HEAP_ZERO_MEMORY, STR_MINCOUNT * 4
        test    eax,eax
        jz      .finish
        mov     [StrTable.ptr],eax
        mov     [StrTable.LastHandle], 0
        mov     [StrTable.count], STR_MINCOUNT
        or      dword [eax], -1
.finish:
        pop     ebx esi
        return
endp

;**************************************************************************************
; Frees all memory used for strings library
; Call it before exit of the program.
;**************************************************************************************
finalize FreeStrings
begin
        push    edi esi ebx
        mov     esi,[StrTable.ptr]
        mov     edi,[StrTable.count]
        xor     ebx,ebx
.freeloop:
        mov     ebx, [esi]
        test    ebx,ebx
        jz      .nxt
        js      .nxt
        invoke  HeapFree,[StrTable.heap],0,ebx
.nxt:
        add     esi,4
        dec     edi
        jnz     .freeloop
        invoke  HeapFree,[StrTable.heap],0, [StrTable.ptr]
        xor     ebx,ebx
        mov     [StrTable.heap],ebx
        mov     [StrTable.ptr],ebx
        mov     [StrTable.count],ebx
        pop     ebx esi edi
        return
endp

;**************************************************************************************
;  Returns the pointer in memory of the hString, or NULL on error
;**************************************************************************************
proc StrPtr         ; proc StrPtr [hString]
        begin
        mov     eax,[esp+4]             ; mov eax,[hString]
        test    eax,$ffff0000
        jnz     .finish                 ; It's pointer, go to finish.
        cmp     eax,[StrTable.count]
        jae     .notfound
        push    ebx
        mov     ebx, [StrTable.ptr]
        mov     eax, [4*eax+ebx]
        pop     ebx
.finish:
        ret     4
.notfound:
        xor     eax,eax
        ret     4
endp

;**************************************************************************************
;  Creates new empty string and returns handle
;  Return: handle of the new created string.
;**************************************************************************************
proc StrNew
begin
        push    ebx ecx edx esi edi

; Find first empty place.
        mov     ecx,[StrTable.count]
        mov     ebx,[StrTable.ptr]
        mov     esi,[StrTable.LastHandle]
        xor     edx,edx

.search:
        inc     esi
        cmp     esi, [StrTable.count]
        jne     @f
        xor     esi,esi
        inc     esi
@@:
        cmp     [4*esi+ebx],edx
        je      .found
        dec     ecx
        jnz     .search

.notfound:                              ; expands the table. esi is right.
        mov     esi, [StrTable.count]
        mov     eax, esi
        shl     eax,1
        add     eax, esi
        shr     eax,1                   ; count = count * 1.5
        inc     eax
        mov     [StrTable.count],eax
        shl     eax,2
        invoke  HeapReAlloc,[StrTable.heap],HEAP_ZERO_MEMORY, [StrTable.ptr],eax
        mov     [StrTable.ptr],eax
        mov     ebx, eax                ; 15.07.2003 this added to repair bug with table expanding

.found:                                 ; [4*esi+ebx] points to StrTable entry.
        mov     [StrTable.LastHandle], esi
        invoke  HeapAlloc, [StrTable.heap], HEAP_ZERO_MEMORY, STR_MINSTRLEN
        mov     dword [eax], 0
        mov     [4*esi+ebx],eax
        mov     eax,esi
        pop     edi esi edx ecx ebx
        return
endp

;**************************************************************************
; Deletes the string if it is possible.
;**************************************************************************
proc StrDel, .hString
        begin
        push    eax ebx ecx edx esi
        mov     esi, [StrTable.ptr]
        mov     eax,[.hString]               ; mov eax,[hString]
        test    eax, eax
        jz      .finish
        test    eax,$ffff0000
        jz      .process
; Find the pointer in the table.
        mov     ecx, [StrTable.count]
        xor     ebx,ebx
.search:
        cmp     [esi+4*ebx],eax
        je      .free
        inc     ebx
        dec     ecx
        jnz     .search
        jmp     .finish

.process:
        mov     ebx, eax
        stdcall StrPtr,eax
        test    eax,eax
        jz      .finish
.free:
        invoke  HeapFree, [StrTable.heap], 0, eax
        mov     dword [esi+4*ebx], NULL        ; Set the cell of the table to null.
.finish:
        pop     esi edx ecx ebx eax
        return
endp


;**************************************************************************
; Duplicates given string, and returns a handle to new one
;**************************************************************************
proc StrDup         ; proc StrDup [hBaseStr]
begin
        mov     eax,[esp+4]             ; mov eax,[esp+4]
        or      eax,eax
        jz      .exit
        stdcall StrNew
        stdcall StrCopy, eax,dword[esp+4]    ; stdcall StrCopy, [hBaseStr]
.exit:  ret     4
endp

;**************************************************************************
; Returns the length of the string.
; Arguments:
;  hString - handle or pointer to the string (static or dynamic)
;**************************************************************************
proc StrLen, .hString    ; proc StrLen [hString]
        begin
        push    ebx
        stdcall StrPtr, [.hString]
        mov     ebx,eax
  .scan:
        cmp     byte[eax],0
        lea     eax,[eax+1]
        jne     .scan
        sub     eax,ebx
        dec     eax         ; return value in eax
        pop     ebx
        return
endp

;***************************************************************************
; If the hString is larger than length - do nothing
; If the hString is smaller than length -> set the length of string to length
; returns pointer to the new (old) string
;
; Arguments:
;   hString - string handle. /not pointer!/
;   length - new string length.
; Returns: pointer to the string.
;***************************************************************************
proc StrSetLength, .hString, .length   ; proc StrSetLength [hString], [length]
        begin
        push    ebx ecx edx esi edi     ; esp=esp-20

        mov     ebx, [.length]          ; mov ecx,[length]
        lea     ebx, [ebx+4]            ; the string have to be at least 1 dword bigger than the length specified.

        mov     eax,[.hString]          ; mov eax,[hString]
        test    eax,$ffff0000   ; if eax is pointer then error
        jnz     .error
        cmp     eax,[StrTable.count]    ; invalid handle.
        jge     .error

        mov     edi,[StrTable.ptr]
        lea     edi,[4*eax+edi]         ; points to the address of table pointer of destination string
        mov     esi,[edi]
        test    esi,esi                 ; Error string not defined
        jz      .error                  ;

        invoke  HeapSize, [StrTable.heap], 0, esi
        cmp     eax,-1
        je      .error
        cmp     eax,ebx
        jl      .resize
        mov     eax,esi
        jmp     .finish

.resize:
        invoke  HeapReAlloc, [StrTable.heap], HEAP_GENERATE_EXCEPTIONS or HEAP_ZERO_MEMORY, esi, ebx
        mov     [edi], eax
        jmp     .finish

.error:
        xor     eax,eax

.finish:
        pop     edi esi edx ecx ebx
        return
endp


;***************************************************************************************
;  Copyes source to destination string.
;  Arguments:
;     source - destination string (handle only)
;     dest -  source string (handle or pointer)
;***************************************************************************************
proc StrCopy, .dest, .source
        begin
        push    esi edi eax ecx
        mov     edi,[.dest]
        test    edi,$ffff0000   ; if edi is pointer go to finish.
        jnz     .finish
        mov     esi,[.source]
        test    esi,esi
        jz      .finish
        stdcall StrPtr, esi
        mov     esi,eax
        test    esi, esi
        jz      .finish
        stdcall StrLen, eax
        inc     eax
        mov     ecx,eax
        stdcall StrSetLength, edi,eax
        test    eax,eax
        jz      .finish
        stdcall StrPtr, edi
        mov     edi,eax
        cld
        rep movsb               ; copy strings
.finish:
        pop     ecx eax edi esi
        return
endp

;***************************************************************************************
; Compares two strings - case sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;***************************************************************************************
proc StrCompCase, .str1, .str2
begin
        push    eax esi edi

        cmp     [.str1], 0
        je      .noteq
        cmp     [.str2], 0
        je      .noteq

        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax
.loop:
        mov     al, [esi]
        lea     esi, [esi+1]
        cmp     al, [edi]
        lea     edi, [edi+1]
        jne     .noteq

        test    al, al
        jnz     .loop

        stc
        pop     edi esi eax
        return

.noteq:
        clc
        pop     edi esi eax
        return
endp


;***************************************************************************************
; Compares two strings - case NOT sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;***************************************************************************************
proc StrCompNoCase, .str1, .str2
begin
        push    eax esi edi
        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax

.cmploop:
        mov     al, [esi]
        lea     esi, [esi+1]
        mov     ah, [edi]
        lea     edi, [edi+1]

        test    al,al
        jz      .eos
        test    ah,ah
        jz      .noteq

        or      eax, $2020
        cmp     al, ah
        je      .cmploop

.noteq:
        clc
        pop     edi esi eax
        return

.eos:
        test    ah,ah
        jnz     .noteq

        stc
        pop     edi esi eax
        return
endp



;*******************************************************************************
; Get the text of the [Control] using WM_GETTEXT and put it to the string with
; handle (only) in [string].
;
; if [string] = NULL creates new string and returns the handle.
; if [string] <> NULL just copyes the text.
;*******************************************************************************
proc GetControlText, .Control, .string
.res dd ?
.len dd ?
begin
        push    ebx edi
        mov     eax,[.string]
        test    eax,eax
        jnz     @f
        stdcall StrNew
@@:
        mov     [.res],eax
        invoke  SendMessage, [.Control], WM_GETTEXTLENGTH, 0, 0
        add     eax, 16
        mov     [.len], eax
        stdcall StrSetLength, [.res], eax
        test    eax,eax
        jz      .error
        invoke  SendMessage, [.Control], WM_GETTEXT, [.len], eax
        mov     eax,[.res]
.error:
        pop     edi ebx
        return
endp

;*******************************************************************************
; Sets the text in control using WM_SETTEXT from string with handle or pointer
; in [string].
;*******************************************************************************
proc SetControlText, .Control, .string
begin
        push    eax ecx edx
        stdcall StrPtr, [.string]
        invoke  SendMessage, [.Control], WM_SETTEXT, 0, eax
        pop     edx ecx eax
        return
endp

;**********************************************************
;  Creates string and assigns it to variable. If variable
;  already contains string handle, the old string will be
;  deleted.
;  Arguments:
;    [ptrHString] - variable containing string handle.
;    ptrSource - pointer to the source for string.
;**********************************************************
; Bug fix 26.09.2003 JohnFound
proc SetString, .ptrHString, .ptrSource
begin
        push    eax esi
        mov     esi, [.ptrHString]

        cmp     dword [esi], 0
        je      @f
        stdcall StrDel, [esi]
@@:
        stdcall StrNew
        mov     [esi], eax
        stdcall StrCopy, eax, [.ptrSource]
        pop     esi eax
        return
endp

;**********************************************************************************
; StrCat appends one string to another
; Arguments:
;   dest - destination string (handle only)
;   source - source string
;**********************************************************************************
proc StrCat, .dest, .source
begin
        push    eax ebx ecx

        stdcall StrLen, [.dest]
        mov     ebx,eax                 ; store dest length in ebx

        stdcall StrLen, [.source]
        add     eax, ebx
        inc     eax                     ; new dest length
        stdcall StrSetLength, [.dest], eax
        add     ebx, eax                ; calculate end of old dest in ebx
        stdcall StrPtr, [.source]
.copy:
        mov     cl,[eax]
        inc     eax
        mov     [ebx],cl
        inc     ebx
        or      cl,cl
        jnz     .copy
        pop     ecx ebx eax
        return
endp


;**********************************************************************************
; StrCharPos returns a pointer to the first occurence of a given char
;   in specified string
; Arguments:
;   Char - char to look for
;   hString -  string to search
; Returns: a pointer to the char in source, or NULL if char doesn't occur
;   in given string
;**********************************************************************************
proc StrCharPos, .hPattern, .char
        begin
        push    esi
        stdcall StrPtr,[.hPattern]
        mov     esi,eax
        mov     eax,[.char]
        xchg    al,ah
     .search:
        mov     al,[esi]
        inc     esi
        or      al,al
        je      .not_found
        cmp     al,ah
        jne     .search
        mov     eax,esi
        dec     eax
        pop     esi
        return
     .not_found:
        xor     eax,eax
        pop     esi
        return
endp


;**********************************************************************************
; StrPos returns a pointer to the first occurence of a pattern string
;   in another string
; Arguments:
;   hPattern - 'pattern' string
;   hString -  string to search
; Returns: a pointer to the pattern string in source , or NULL if pattern string
; doesn't occur in the string to search
;**********************************************************************************
proc StrPos         ; proc StrPos [hString], [hPattern]
begin
        push    ebx ecx edx esi edi     ; esp = esp -20
        mov     esi,[esp+20+8]          ; mov esi,[hPattern]
        mov     edi,[esp+20+4]          ; mov edi,[hString]
        stdcall StrLen, edi
        mov     ebx,eax                 ; now ebx holds lenght of the string to search
        stdcall StrLen, esi
        mov     edx,eax                 ; now edx holds length of the pattern string
        stdcall StrPtr, esi
        mov     esi,eax                 ; put pointer to the pattern str in esi
        stdcall StrPtr,edi
        mov     edi,eax                 ; put pointer to the search str in edi
        lodsb                           ; load first character of the pattern
        mov     ecx,ebx                 ;
        mov     ebx,edx                 ; put str_len(pattern)-1 in ebx
        dec     ebx                     ;
  .search:
        repne   scasb
        jne     .not_found
        cmp     ecx,ebx
        jb      .not_found
        push    edi esi ecx
        or      ebx,ebx                 ; ebx==0 means that we were searching for one
        jz      .got_it                 ; character. We found it, so we stop.
        mov     ecx,ebx
        repe    cmpsb
        jne     .not_match
  .got_it:
        pop     ecx esi edi
        dec     edi
        mov     eax,edi
  .ret:
        pop     edi esi edx ecx ebx
        ret     8
  .not_match:
        pop     ecx esi edi
        jmp     .search
  .not_found:
        xor     eax,eax
        jmp     .ret
endp

;**********************************************************************************
; StrInsert inserts one string into another at specified pos
; Arguments:
;   dest - destination where the source will be inserted (handle only)
;   source -  string to insert
;**********************************************************************************
proc StrInsert      ; proc StrInsert [dest], [source], [pos]
        begin
        push    eax ebx ecx esi edi     ; esp = esp-20
        stdcall StrLen, dword[esp+20+4] ; stdcall StrLen,[dest]
        cmp     eax,dword[esp+20+12]    ; cmp eax,[pos]
        jb      .ret                    ; don't insert a string if pos>StrLen(dest)
        inc     eax
        mov     ecx,eax
        stdcall StrNew                  ; create temporary string...
        mov     ebx,eax                 ; ... and store its handle in ebx
        stdcall StrSetLength, ebx,ecx
        stdcall StrPtr, dword[esp+20+4] ; stdcall StrPtr,[dest]
        mov     esi,eax
        stdcall StrPtr, ebx
        mov     edi,eax
        mov     ecx,dword[esp+20+12]    ; mov ecx,[pos]
        jz      @f
        rep     movsb
  @@:   stdcall StrCat, ebx,dword[esp+20+8]     ; stdcall StrCat, ebx,[source]
        stdcall StrCat, ebx,esi
        mov     eax,dword[esp+24]
        stdcall StrCopy, eax,ebx
        stdcall StrDel, ebx
  .ret:
        pop     edi esi ecx ebx eax
        ret     12
endp

;**********************************************************************************
; Converts strings to Lower Case
; First parameter = String to Convert to lower case
; corrupts eax
;**********************************************************************************
proc StrLCase               ; proc StrLCase [hString]
        begin
        push    edi
        stdcall StrPtr, [esp+4+1*4]
        xchg    edi, eax
._lowercaseloop:
        mov     al, [edi]
        cmp     al, 'A'
        jc      @F
        cmp     al, 'Z'
        ja      @F
        or      byte[edi], 20h
@@:
        cmp     byte[edi],0
        lea     edi, [edi+1]
        jnz     ._lowercaseloop
        pop     edi
        retn    4
endp


;**********************************************************************************
; Converts strings to Upper Case
; First parameter = String to Convert to upper case
; corrupts eax
;**********************************************************************************
proc StrUCase       ; proc StrUCase [hString]
        begin
        push    edi
        stdcall StrPtr, [esp+4+1*4]
        xchg    edi, eax
._uppercaseloop:
        mov     al, [edi]
        cmp     al, 'a'
        jc      @F
        cmp     al, 'z'
        ja      @F
        sub     byte[edi], 20h
@@:
        cmp     byte[edi], 0
        lea     edi, [edi+1]
        jnz     ._uppercaseloop
        pop     edi
        retn    4
endp

;**********************************************************************************
; String copy mmx version for long strings does by copying qword at a time
; First parameter = String destination
; Second parameter = String source
;**********************************************************************************
proc StrCopyMMX     ; proc StrCopyMMX [str1], [str2]
        begin
        push    eax
        push    ebx
        push    ecx
        push    edx
        stdcall StrPtr, [esp+4+4*4]
        xchg    eax, edx
        stdcall StrPtr, [esp+8+4*4]
        mov     ecx,eax
        stdcall StrLen,eax
        stdcall StrSetLength, [esp+4+4*4+4], eax
        mov     eax,ecx
        xor     ecx,ecx
        pxor    MM7, MM7
.MMX_loop:
        movq    MM0, [eax+ecx]
        movq    MM1, MM0
        pcmpeqb MM0, MM7
        packsswb MM0, MM0
        movd    ebx, MM0
        test    ebx, ebx
        jnz     .normal_copy
        movq    [edx+ecx], MM1
        add     ecx, 8
        jmp     .MMX_loop
.normal_copy:
        mov     bl, [eax+ecx]
        mov     [edx+ecx], bl
        inc     ecx
        test    bl, bl
        jnz     .normal_copy
        pop     edx
        pop     ecx
        pop     ebx
        pop     eax
        retn    8
endp

;**********************************************************************************
; StrExtract copies the part of [str] from [index] with lenght in [len]
; Returns handle to new created string.
;**********************************************************************************
proc StrExtract, .string, .index, .len
begin
        push    ebx ecx esi edi
        stdcall StrLen,[.string]
        cmp     eax,[.index]
        jbe     .error
        stdcall StrNew
        mov     ebx,eax
        mov     ecx,[.len]
        stdcall StrSetLength, eax,ecx   ; stdcall StrSetLength, eax,[len]
        stdcall StrPtr, eax
        mov     edi,eax
        stdcall StrPtr, [.string]
        add     eax,[.index]
        mov     esi,eax
    @@: mov     al,[esi]
        mov     [edi],al
        inc     esi
        inc     edi
        or      al,al
        jz      .copied
        dec     ecx
        jnz     @b
        xor     al,al
        mov     [edi],al
  .copied:
        mov     eax,ebx
        pop     edi esi ecx ebx
        return
  .error:
        xor     eax,eax
        pop     edi esi ecx ebx
        return
endp

;**********************************************************************************
; _NumToStr converts the number in eax to the string in any radix approx. [2..26]
; Arguments:
;   [edi] - pointer to the string buffer
;   ecx - radix
;   eax - number to convert.
; There is no parameter check, so be careful.
; returns: edi points to the end of a converted number
;**********************************************************************************
proc _NumToStr
begin
    test  eax,eax
    jns   _NumToStrU
    neg   eax
    mov   byte [edi],"-"
    inc   edi
endp

proc _NumToStrU
begin
    cmp   eax,ecx
    jb    .lessA
    xor   edx,edx
    div   ecx
    push  edx
    call  _NumToStrU
    pop   eax
.lessA:
    cmp   al, 10
    sbb   al, 69h
    das
    stosb
    return
endp

;*****************************************************
; NumToStrF:
;   Converts signed integer value to string.
; NumToStrUF:
;   Converts unsigned integer value to string.
;
; edi - pointer to string buffer
; eax - Number to convert
; ecx - radix from 2 to $ff
; esi - length of the number in chars
;
; returns: edi - pointer to the end of converted num
;
; Note: Don't use 1 as radix.
;*****************************************************
proc NumToStrF
begin
        test    eax,eax
        jns     NumToStrUF
        neg     eax
        mov     byte [edi],'-'
        push    esi
        dec     esi
        add     edi,esi
        push    edi
        jmp     NumToStrUF.loopc
endp

proc NumToStrUF
        begin
        push    esi
        add     edi, esi
        push    edi
        dec     edi
.loopc:
        xor     edx,edx
        div     ecx
        xchg    al,dl
        cmp     al,$0a
        sbb     al,$69
        das
        mov     [edi],al
        dec     edi
        xchg    al,dl
        dec     esi
        jnz     .loopc
        pop     edi
        pop     esi
        return
endp


;***********************************************************
; NumToStr - converts number to any radix.
; num - number to convert
; str - handle of the string. If NULL - creates new string.
; index - Offset in string where to put converted number.
; flags:
;   byte 0 - number of digits if ntsFixedWidth is set.
;   byte 1 - contains radix for the convertion.
;   byte 2,3 - flags.
; Returns:
;   eax - handle of the string (new one or passed in [str])
;   edx - pointer to the string.
;***********************************************************
proc NumToStr, .num, .strng, .index, .flags
.max_len dd ?
.len_tab rb 20      ; table that holds maximum number of digits in given system
        begin
        push    ebx ecx edx esi edi

        mov     [.len_tab+2],32+2       ; binary number - max. 32 digits (+2 bytes for '-' character and NULL terminator)
        mov     [.len_tab+4],16+2       ; quad number - max. 16 digits
        mov     [.len_tab+8],11+2       ; octal number - max. 11 digits
        mov     [.len_tab+10],9+2       ; decimal number - max. 9 digits
        mov     [.len_tab+16],8+2       ; hexadecimal number - max. 8 digits
        movzx   ebx,byte [.flags+1]     ; load radix into ebx
        movzx   eax,byte[.len_tab+ebx]
        mov     [.max_len],eax          ; store max. number of digits
        mov     eax,[.strng]
        or      eax,eax
        jnz     .string_exists
        stdcall StrNew
        mov     [.strng],eax
  .string_exists:
        test    eax,0xffff0000
        jnz     @f                      ; don't resize if [str] isn't a handle
        mov     ebx,eax
        mov     eax,[.max_len]
        add     eax,[.index]
        mov     edx,eax
        stdcall StrLen,ebx
        cmp     eax,edx
        ja      @f                      ; don't resize string if it has enough place for converted number

        stdcall StrSetLength,ebx, edx

  @@:   ; determine which conversion func to use
        mov     eax,[.flags]
        mov     edx,eax
        and     eax,ntsFixedWidth
        jnz     .fixed_width
        mov     eax,edx
        and     eax,ntsUnsigned
        jnz     .unsigned
        mov     ebx,_NumToStr
        jmp     .got_func
  .unsigned:
        mov     ebx,_NumToStrU
        jmp     .got_func

  .fixed_width:
        movzx   esi, byte [.flags]         ; load fixed width into esi
        mov     eax, edx
        and     eax, ntsUnsigned
        jnz     .fixed_unsigned
        mov     ebx,NumToStrF
        jmp     .got_func
  .fixed_unsigned:
        mov     ebx,NumToStrUF
  .got_func:
        stdcall StrPtr, [.strng]
        add     eax,[.index]
        mov     edi,eax
        movzx   ecx,byte [.flags+1]       ; load radix into ecx
        mov     eax, [.num]
        call    ebx                     ; call low-level convertion routine
        mov     eax, [.flags]
        and     eax, ntsZeroTerminated
        jz      .ret
        mov     byte [edi], 0

  .ret:
        pop     edi esi edx ecx ebx
        mov     eax, [.strng]
        return
endp


;-------------------------------------------------
; function StrHash
;   Computes 32 bit hash value from the string.
;   The function is compatible with FASM hash
;   function if OrMask = 0.
;
; Arguments:
;   hString - handle/pointer of the string.
;   OrMask  - every byte from the string will be ORed
;             with this value (byte)
; Return:
;   eax - 32bit hash value.
;-------------------------------------------------
proc StrHashOld, .hString, .OrMask
begin
        push    esi ebx ecx

        stdcall StrPtr, [.hString]
        mov     esi, eax

        xor     ebx, ebx
        xor     eax, eax
.hashloop:
        rol     eax, 12
        mov     ecx, eax
        shr     eax, 8
        and     ecx, 1111b
        or      eax, ecx
        movzx   ecx, byte [esi+ebx]
        jecxz   .endloop
        or      cl, byte [.OrMask]
        add     eax, ecx
        inc     ebx
        jmp     .hashloop

.endloop:
        and     eax,0FFFFFFh
        shl     ebx,24
        or      eax,ebx
        pop     ecx ebx esi
        return
endp


proc StrHash, .hString, .OrMask
begin
        push    esi edi ebx ecx edx

        stdcall StrPtr, [.hString]
        mov     esi, eax

        xor     ebx, ebx
        mov     eax,2166136261          ; FNV offset basis
        xor     ecx, ecx
        mov     edi, 16777619                ; FNV prime
.hashloop:
        mov     cl, [esi+ebx]
        jecxz   .endstring
        inc     bl
        or      cl, byte [.OrMask]
        xor     al,cl                   ; FNV-1a hashing
        mul     edi
        jmp     .hashloop

.endstring:
        mov     edx,eax
        and     eax,0FFFFFFh            ; xor-fold to 24 bits
        shr     edx,24
        xor     eax,edx
        shl     ebx,24                  ; the length of the string
        or      eax,ebx                 ; store length in high 8 bits
        pop     edx ecx ebx edi esi
        return
endp



;-------------------------------------------------------
; function StrToNum
;   Converts specified string into a number
;
; Arguments:
;   hString - handle/pointer of the string containing
;     number to convert. It doesn't have to be ended by
;     NULL, any other character will stop conversion.
;     Number to convert must be decimal.
;
; Return:
;   eax - converted number
;
; Note: in case of failture (first char of given pointer
;   isn't a number) function returns -1.
;-------------------------------------------------------
proc StrToNum, .hString
        begin
        push    ebx edx esi
        xor     ebx,ebx         ; ebx will store our number
        stdcall StrPtr, [.hString]
        mov     esi,eax
        xor     eax,eax
        mov     al,[esi]
        cmp     al,'0'
        jb      .error
        cmp     al,'9'
        jbe     .digit
        jmp     .error
     .digit:
        sub     al,'0'
        add     ebx,eax
        inc     esi
        mov     al,[esi]
        cmp     al,'0'
        jb      .finish
        cmp     al,'9'
        ja      .finish
        mov     edx,ebx         ; multiply ebx by 10
        shl     ebx,3
        add     ebx,edx
        add     ebx,edx
        jmp     .digit
     .finish:
        mov     eax,ebx
        pop     esi edx ebx
        return

     .error:
        xor     eax,eax
        dec     eax
        pop     esi edx ebx
        return
endp

;-------------------------------------------------------
; function StrCharCat
;   Addes specified char to the end of a string
;
; Arguments:
;   hString - string to append
;   char - char to add
;-------------------------------------------------------
proc StrCharCat, .hString, .char
begin
        push    eax ebx ecx
        mov     ebx, [.hString]
        stdcall StrLen, ebx
        mov     ecx, eax
        inc     eax
        stdcall StrSetLength, ebx, eax
;        stdcall StrPtr, ebx                    ; StrSetLength returns a pointer to the string
        add     ecx, eax
        mov     eax, [.char]
        mov     [ecx], al
        inc     ecx
        mov     byte [ecx], 0
        pop     ecx ebx eax
        return
endp

;------------------------------------------------------------
; function StrInsertChar
;   Inserts specified char into given position ot the string
;
; Arguments:
;   hString - string to append
;   char    - char to add
;   pos     - position where to add the char
;-------------------------------------------------------------
proc StrInsertChar, .hString, .char, .pos
        begin
        push    eax ebx ecx
        mov     ebx, [.hString]
        stdcall StrLen, ebx
        cmp     eax, [.pos]
        jb      .finish
        je      .append
        mov     ecx,eax
        inc     eax
        stdcall StrSetLength, ebx, eax
        stdcall StrPtr, ebx
        add     ecx, eax
        mov     ebx, eax
        add     ebx, [.pos]
        mov     byte [ecx+1], 0     ; add NULL-terminator in the end of our string
  .shift:
        mov     al, [ecx-1]
        mov     [ecx], al
        dec     ecx
        cmp     ecx, ebx
        jne     .shift
        mov     eax, [.char]
        mov     [ebx], al
  .finish:
        pop     ecx ebx eax
        return
  .append:
        stdcall StrCharCat, ebx, [.char]
        jmp     .finish
endp





proc StrURLEncode, .hstr
.res dd ?
begin
        push    ebx ecx edx esi edi
        stdcall StrPtr, [.hstr]
        mov     esi, eax

        stdcall StrLen, esi
        mov     ecx, eax
        lea     edx, [2*eax+eax]        ; the encoded string can be max 3x long as original string.

        stdcall StrNew
        mov     [.res], eax
        jecxz   .finish

        stdcall StrSetLength, eax, edx
        mov     edi, eax
        xor     edx, edx
        xor     ebx, ebx

.encode:
        lodsb
        cmp     al, $80
        jae     .store          ; it is a hack, but I hope save enough.

        mov     dl, al
        mov     bl, al
        shr     edx, 5
        and     ebx, $1f
        bt      dword [URLCharTable+4*edx], ebx
        jnc     .store

        mov     ah, al
        mov     al, '%'
        stosb
        mov     al, ah
        shr     al, 4
        cmp     al, $0a
        sbb     al, $69
        das
        stosb
        mov     al, ah
        and     al, $0f
        cmp     al, $0a
        sbb     al, $69
        das

.store:
        stosb
        loop    .encode
.end:
        xor     al, al
        stosb
.finish:
        mov     eax, [.res]
        pop     edi esi edx ecx ebx
        return
endp

; Contains 1 where the character must be % encoded and 0 where it is save to pass it directly
URLCharTable db 11111111b       ;
             db 11111111b       ;
             db 11111111b       ;
             db 11111111b       ; 0..31 -control chars | encoded
             db 11111111b       ; $27 - $20: '&%$#"!   | encoded
             db 11111111b       ; $2f - $28: /.-,+*)(  | encoded
             db 00000000b       ; $37 - $30: 76543210  | not encoded
             db 11111100b       ; $3f - $38: ?>=<;:98  | partially
             db 00000001b       ; $47 - $40: GFEDCBA@  | partially
             db 00000000b       ; $4f - $48: ONMLKJIH  | not encoded
             db 00000000b       ; $57 - $50: WVUTSRQP  | not encoded
             db 11111000b       ; $5f - $58: _^]\[ZYX  | partially
             db 00000001b       ; $67 - $60: gfedcba`  | partially
             db 00000000b       ; $6f - $68: onmlkjih  | not encoded
             db 00000000b       ; $77 - $70: wvutsrqp  | not encoded
             db 11111000b       ; $7f - $78:  ~}|{zyx  | partially
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/OldLibs/strlib.inc.

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
STR_MINCOUNT = 10       ; minimum 10 strings in the table
STR_MINSTRLEN = 16      ; 16 bytes minimum string length

struct TStrTable
  .count    dd 0           ; max count of the strings in table.
  .LastHandle dd 0         ; last allocated handle.
  .ptr      dd 0           ; pointer to the table data
  .heap     dd 0           ; handle of strings heap
ends


; NumToStr flags
ntsSigned = $00000
ntsUnsigned = $10000
ntsZeroTerminated = $20000
ntsFixedWidth     = $40000

ntsBin  = $0200
ntsQuad = $0400
ntsOct  = $0800
ntsDec  = $0a00
ntsHex  = $1000


;-------------------------------------
; It is stand-alone macroses
;-------------------------------------
macro IndexedStrings [lparam, string] {
  forward
    local ..lbl
    dd  ..lbl, lparam
  common
    dd  0
  forward
..lbl db string, 0
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































Deleted freshlib/_trash/SurplusSources/Win32/TFormWin32.asm.

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
;************************************************************
;*   Form class library                                     *
;*                                                          *
;*   This file is part of Fresh base library                *
;*   This is base window class for "Fresh" created project  *
;*                                                          *
;*   (C)2003, 2004 John Found                               *
;************************************************************






;;*********************************************************************************************
;; Main window procedure for 'TForm' window class.
;;*********************************************************************************************
;winproc FormMessageProc
;begin
;        push    ebx edi esi
;        mov     ebx, [.wmsg]
;
;ondefault
;        invoke  DefWindowProc, [.hwnd],[.wmsg],[.wparam],[.lparam]
;        pop     esi edi ebx
;        return
;
;;------------------------------------------------------------------------
;onmessage WM_SYSCOMMAND
;        mov     eax, [.wparam]
;        and     eax, $fff0
;
;        cmp     eax, SC_KEYMENU
;        jne     .ondefault
;
;        invoke  GetParent, [.hwnd]
;        mov     ebx, eax
;        test    eax, eax
;        jnz     .resendmessage
;
;; Get the main application window.
;        mov     eax, [Application]
;        mov     eax, [eax+TApplication.MainWindow]
;        test    eax, eax
;        jz      .ondefault
;
;        cmp     eax, [.hwnd]
;        je      .ondefault
;
;        mov     ebx, eax
;
;        invoke  GetMenu, [.hwnd]
;        test    eax, eax
;        jnz     .ondefault
;
;        invoke  GetFocus
;        mov     [hLastBeforeMenu], eax
;
;        invoke  SetFocus, ebx
;
;.resendmessage:
;        invoke  SendMessage, ebx, [.wmsg], [.wparam], [.lparam]
;
;        xor     eax, eax
;        pop     esi edi ebx
;        return
;
;;------------------------------------------------------------------------
;onmessage WM_ERASEBKGND
;locals
;  .rect    RECT
;endl
;        lea     eax, [.rect]
;        invoke  GetClientRect, [.hwnd], eax
;
;        invoke  GetSysColor, COLOR_BTNFACE
;
;.colorok:
;        and     eax, $ffffff
;        invoke  CreateSolidBrush, eax
;        push    eax
;        lea     ecx, [.rect]
;        invoke  FillRect, [.wparam], ecx, eax
;        invoke  DeleteObject ; from the stack.
;        xor     eax, eax
;        inc     eax
;        pop     esi edi ebx
;        return
;
;;------------------------------------------------------------------------
;onmessage WM_CLOSE
;
;        mov     eax, [Application]
;        mov     eax, [eax+TApplication.MainWindow]
;        cmp     eax, [.hwnd]
;        jne     .ondefault
;
;        invoke  PostQuitMessage, 0
;        jmp     .ondefault
;
;;------------------------------------------------------------------------
;onmessage WM_EXITMENULOOP
;        cmp     [hLastBeforeMenu], 0
;        je      @f
;
;        invoke  SetFocus, [hLastBeforeMenu]
;@@:
;        xor     eax, eax
;        mov     [hLastBeforeMenu], eax
;        pop     esi edi ebx
;        return
;
;endwp
;
;
;
;proc GetFocusedControl, .hwnd
;begin
;        push    esi ebx
;        invoke  GetFocus
;        mov     esi, eax
;
;.parentloop:
;        mov     ebx, eax
;        invoke  GetParent, eax
;        test    eax, eax
;        jnz     .parentloop
;
;;        xor     eax, eax     ; eax is zero here...
;        cmp     ebx, [.hwnd]
;        jne     .endfocused
;        mov     eax, esi
;.endfocused:
;        pop     ebx esi
;        return
;endp
;
;
;;*********************************************************************************************
;; Shows given form in modal form.
;; Returns modal result
;; This is first version so behaviour is not very proper.
;;*********************************************************************************************
;
;proc ShowModal, .hwnd, .flags
;
;.rect RECT
;
;        begin
;        push    esi edi ebx
;
;        invoke  GetFocus
;        push    eax      ; the parameter for SetFocus at the end of the procedure.
;
;        lea     eax, [.rect]
;        invoke  GetWindowRect, [.hwnd], eax
;
;        mov     esi, [.rect.left]
;        mov     edi, [.rect.top]
;
;        test    [.flags], MSF_HCENTER
;        jz      @f
;
;        invoke  GetSystemMetrics, SM_CXSCREEN
;        sub     eax, [.rect.right]
;        add     eax, [.rect.left]
;        sar     eax,1
;        mov     esi, eax
;@@:
;        test    [.flags], MSF_VCENTER
;        jz      @f
;
;        invoke  GetSystemMetrics, SM_CYSCREEN
;        sub     eax, [.rect.bottom]
;        add     eax, [.rect.top]
;        sar     eax,1
;        mov     edi, eax
;
;@@:
;        invoke  SendMessage, [.hwnd], WM_INITDIALOG, 0, 0
;        invoke  SetWindowPos, [.hwnd], HWND_TOP, esi, edi, 0, 0, SWP_NOSIZE
;        invoke  ShowWindow, [.hwnd], SW_SHOW
;;        invoke  SendMessage, [.hwnd], AM_CHILDRESIZED, 0, 0
;
;        invoke  GetWindow, [.hwnd], GW_OWNER
;        mov     ebx, eax
;
;; Disables window owner and all other windows owned by window owner.
;
;        invoke  EnableWindow, ebx, FALSE
;        stdcall EnableAllOwnedWindows, ebx, FALSE       ; This is useless if all top level windows
;                                                        ; are TForm, but it is important if not...
;
;        invoke  EnableWindow, [.hwnd], TRUE              ; IMPORTANT: re-enable modal window.
;
;        invoke  GetNextDlgTabItem, [.hwnd], NULL, FALSE
;        test    eax, eax
;        jz      @f
;        invoke  SetFocus, eax
;@@:
;        invoke  SetProp, [.hwnd], [propModalResult], MR_NONE
;
;; Special message loop for modal window. It not finish until window becomes invisible.
;.modalloop:
;        call    ProcessMessages
;
;        invoke  IsWindowVisible, [.hwnd]
;        test    eax,eax
;        jz      .endloop
;
;        invoke  GetProp, [.hwnd], [propModalResult]
;        test    eax,eax              ; mrNone = 0
;        jnz     .endloop
;
;        invoke  SendMessage, [.hwnd], AM_ONIDLE, 0, 0
;
;        invoke  WaitMessage
;        jmp     .modalloop
;
;.endloop:
;        stdcall EnableAllOwnedWindows, ebx, TRUE
;        invoke  EnableWindow, ebx, TRUE
;        invoke  ShowWindow, [.hwnd], SW_HIDE
;
;        invoke  SetFocus                       ; the parameter is in stack
;
;        invoke  GetProp, [.hwnd], [propModalResult]
;        pop     ebx edi esi
;        return
;endp
;
;
;;-------------------------------------------------------------
;; Enables or disables all windows owned by specifyed window.
;;
;; fEnable - TRUE = enable
;;           FALSE = disable
;;-------------------------------------------------------------
;proc EnableAllOwnedWindows, .hwnd, .fEnable
;        begin
;
;        mov     eax, _EnableOwnedProc
;        cmp     [.fEnable], FALSE
;        jne     @f
;        mov     eax, _DisableOwnedProc
;@@:
;        invoke  EnumWindows, eax, [.hwnd]
;        return
;endp
;
;
;; callback procedure used in EnableAllOwnedWindows
;proc _EnableOwnedProc, .hwnd, .owner
;begin
;
;        invoke  GetWindow, [.hwnd], GW_OWNER
;        cmp     eax, [.owner]
;        jne     .ready
;        invoke  EnableWindow, [.hwnd], TRUE
;
;.ready:
;        mov     eax, 1
;        return
;endp
;
;
;; callback procedure used in EnableAllOwnedWindows
;proc _DisableOwnedProc, .hwnd, .owner
;begin
;        invoke  GetWindow, [.hwnd], GW_OWNER
;
;        cmp     eax, [.owner]
;        jne     .ready
;        invoke  EnableWindow, [.hwnd], FALSE
;.ready:
;        mov     eax, 1
;        return
;endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/Win32/_chainmsg.asm.

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
winmessage WM_SUBCLASSED   ;(ptrProcedure, Tag) the window receives this message immediately after subclassing with AddWinProc.

struct TChainElement
  .WinProc dd ?
  .Tag     dd ?
  .count   dd ?
  .next    dd ?
ends


iglobal
  winproperty propWinProcChain, 'WinProcChain'
endg


;initialize InitChainMessages
;begin
;        stdcall CreateWinProperty, propWinProcChain
;        return
;endp
;
;
;finalize FinalChainMessages
;begin
;        stdcall DestroyWinProperty, propWinProcChain
;        return
;endp
;


proc AddWinProc, .hwnd, .winproc, .tag
begin
        push    esi edi

        stdcall SearchChainElement, [.hwnd], [.winproc], [.tag]
        jc      .addit

; The message handler exists, just inc the count
        inc     [esi+TChainElement.count]
        jmp     .exit

; Add new message handler.
.addit:
        stdcall GetMem, sizeof.TChainElement
        mov     esi, eax

        mov     eax, [.winproc]
        mov     ecx, [.tag]
        mov     [esi+TChainElement.WinProc], eax
        mov     [esi+TChainElement.Tag], ecx
        mov     [esi+TChainElement.count], 1

        invoke  GetProp, [.hwnd], [propWinProcChain]
        test    eax, eax
        jz      .newchain

        mov     [esi+TChainElement.next], eax
.save:
        invoke  SetProp, [.hwnd], [propWinProcChain], esi
.exit:
        invoke  SendMessage, [.hwnd], WM_SUBCLASSED, [.winproc], [.tag]
        pop     edi esi
        return

.newchain:
        stdcall GetMem, sizeof.TChainElement
        mov     edi, eax

        invoke  GetWindowLong, [.hwnd], GWL_WNDPROC
        mov     [edi+TChainElement.WinProc], eax
        mov     [esi+TChainElement.next], edi
        invoke  SetWindowLong, [.hwnd], GWL_WNDPROC, ChainWinProc
        jmp     .save
endp




;----------------------------------------------------
; if [.winproc] <> 0 removes the message handle with
; specified [.winproc], [.tag] from the handler chain
; if [.winproc] = 0 removes the first handler from
; the chain.
;----------------------------------------------------
proc RemoveWinProc, .hwnd, .winproc, .tag
begin
        push    edi esi

        stdcall SearchChainElement, [.hwnd], [.winproc], [.tag]
        jc      .exit

        dec     [esi+TChainElement.count]
        jnz     .exit                           ; don't remove, someone needs it.

        test    edi, edi
        jz      .first

        mov     ecx, [esi+TChainElement.next]
        jecxz   .exit   ; can't be removed the original handler.

        mov     [edi+TChainElement.next], ecx

.free:
        stdcall FreeMem, esi
.exit:
        pop     esi edi
        return

.first:
        mov     edi, [esi+TChainElement.next]
        cmp     [edi+TChainElement.next], 0
        je      .removechain

        invoke  SetProp, [.hwnd], [propWinProcChain], edi
        jmp     .free

.removechain:
        invoke  SetWindowLong, [.hwnd], GWL_WNDPROC, [edi+TChainElement.WinProc]
        invoke  RemoveProp, [.hwnd], [propWinProcChain]
        stdcall FreeMem, edi
        jmp     .free
endp



;-----------------------------------------------
; Arguments:
;   .hwnd - handle of the window
;   .winproc - user winproc (if 0 - returns the first in chain)
;   .tag     - user defined value.
; Returns:
;   CF = 0 -> element found.
;   esi - TChainElement
;   edi - previous in chain
;   CF = 1 -> element not found.
;     esi = 0
;     edi = 0 -> the window is not subclassed
;     edi <> 0 -> TChainElement of original winproc
;-----------------------------------------------
proc SearchChainElement, .hwnd, .winproc, .tag
begin
        xor     edi, edi

        invoke  GetProp, [.hwnd], [propWinProcChain]
        mov     esi, eax
        test    eax, eax
        jz      .exit

        cmp     [.winproc], 0
        je      .found

.loop:
        mov     ecx, [esi+TChainElement.WinProc]
        mov     eax, [esi+TChainElement.Tag]

        cmp     ecx, [.winproc]
        jne     .next
        cmp     ecx, [.tag]
        jne     .next

.found:
        clc
        return

.next:
        mov     edi, esi
        mov     esi, [esi+TChainElement.next]
        test    esi, esi
        jnz     .loop

.exit:
        stc
        return
endp


;--------------------------------------------------------------
; This is universal message handler for subclassed windows.
; Saves registers and provides call to the previous handler.
;--------------------------------------------------------------
proc ChainWinProc, .hwnd, .wmsg, .wparam, .lparam
begin
        push    ebx esi edi

        invoke  GetProp, [.hwnd], [propWinProcChain]
        mov     ecx, eax

.loop:
        jecxz   .finish

        push    [ecx+TChainElement.next]      ; in the case current handler removes itself from the chain.
        mov     edi, [ecx+TChainElement.Tag]
        cmp     [ecx+TChainElement.WinProc], 0
        jg      .procedure

        ; handle
        invoke  CallWindowProc, [ecx+TChainElement.WinProc], [.hwnd], [.wmsg], [.wparam], [.lparam]
        jmp     .next

.procedure:
        stdcall [ecx+TChainElement.WinProc], [.hwnd], [.wmsg], [.wparam], [.lparam]

.next:
        pop     ecx
        jc      .loop

.finish:
        cmp     [.wmsg], WM_DESTROY
        jne     .quit

; clear whole chain and remove the property.
        push    eax
        xor     ebx, ebx

.freeloop:
        stdcall RemoveWinProc, [.hwnd], ebx, ebx
        invoke  GetProp, [.hwnd], [propWinProcChain]
        test    eax, eax
        jnz     .freeloop
        pop     eax

.quit:
        pop     edi esi ebx
        return
endp



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/Win32/_winprops.asm.

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
;------------------------------------------------------------------------
; Macro for defining names for window properties (SetProp/GetProp)
; that to be used with and without AddAtom function.
; When the name is not added to the atom table, the first
; dword of the structure contains pointer to the string.
; If the macro is added to the application atom table
; (via CreateProperty procedure), the first dword contains
; atom handle. In both cases GetProp and SetProp uses [propname] as
; pointer to the property name.
;------------------------------------------------------------------------
macro winproperty [name, string] {
  forward
    align 4
    local ..txt
    name  dd ..txt
    TEXT ..txt, string
    dw   0
}


; Various property related string procedures
proc CreateWinProperty, .ptrProp
begin
        push    ebx
        mov     ebx, [.ptrProp]
        invoke  IsBadReadPtr, ebx, 4
        test    eax, eax
        jnz     .exit

        invoke  IsBadStringPtr, [ebx], 256
        test    eax, eax
        jnz     .exit

        invoke  AddAtom, [ebx]
        movzx   eax, ax
        mov     [ebx], eax
.exit:
        pop     ebx
        return
endp


proc DestroyWinProperty, .ptrProp
begin
        push    ebx
        mov     ebx, [.ptrProp]
        invoke  IsBadReadPtr, ebx, 4
        test    eax, eax
        jnz     .exit

        invoke  DeleteAtom, [ebx]
.exit:
        pop     ebx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































Deleted freshlib/_trash/SurplusSources/Win32/allutils.asm.

1
2
Sequence winmessage, WM_USER+$3000
winmessage.display = 1
<
<




Deleted freshlib/_trash/SurplusSources/command_tables.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
; This file is not needed anymore, but it contains very tiny implementation of Forth-like script engine.
; maybe it worths to keep it some time......

__ScriptEngine:

struct TCommandItem
  .name dd ?
  .proc dd ?
ends

macro CommandList lbl, [name, proc] {
common
  label lbl dword
forward
  local len
  dd name, proc
common
  dd 0
}


CommandList  ScriptCommands,                     \
  'l' ,   TFreshEdit.__CommandLeft,              \       ; left
  'r' ,   TFreshEdit.__CommandRight,             \       ; right
  'u' ,   TFreshEdit.__CommandUp,                \       ; up
  'd' ,   TFreshEdit.__CommandDown,              \       ; down
  'ul',   TFreshEdit.__CommandScrollLockUp,      \       ; up scroll lock
  'dl',   TFreshEdit.__CommandScrollLockDown,    \       ; down scroll lock
  'su',   TFreshEdit.__CommandScrollUp,          \       ; scroll up
  'sd',   TFreshEdit.__CommandScrollDown,        \       ; scroll down
  'pu',   TFreshEdit.__CommandPgUp,              \       ; page up
  'pd',   TFreshEdit.__CommandPgDown,            \       ; page down
  'lb',   TFreshEdit.__CommandHome,              \       ; line begin
  'le',   TFreshEdit.__CommandEnd,               \       ; line end
  'sb',   TFreshEdit.__CommandBeginOfScreen,     \       ; begin of screen
  'se',   TFreshEdit.__CommandEndOfScreen,       \       ;
  'fb',   TFreshEdit.__CommandFileBegin,         \       ; file begin
  'fe',   TFreshEdit.__CommandFileEnd,           \       ; file end
  'wp',   TFreshEdit.__CommandWordPrev,          \       ; word previous
  'wn',   TFreshEdit.__CommandWordNext,          \       ; word next
  'gsm',  TFreshEdit.__CommandGetSelectionMode,  \       ; get selection mode (0..2)
  'ssm',  TFreshEdit.__CommandSetSelectionMode,  \       ; set selection mode (0..2)
  'gim',  TFreshEdit.__CommandGetInsertMode,     \       ; get insert mode.
  'sim',  TFreshEdit.__CommandSetInsertMode,     \       ; set insert mode.
  'grc',  TFreshEdit.__CommandGetRowCount,       \       ; get row count.
\
\ ; Aritmerics
\
  '+',    __ScriptPlus,                          \
  '-',    __ScriptMinus,                         \
  '*',    __ScriptMul,                           \
  '/',    __ScriptDiv,                           \
  '%',    __ScriptMod,                           \
  'neg',  __ScriptNeg,                           \
\
\ ; Output
\
  '.',    __ScriptOutNumber,                     \
  '?',    __ScriptOutString,                     \
\
\ ; Stack operations and variables
\
  'swap', __ScriptSwap,                          \
  'pop',  __ScriptPop,                           \
  '->',   ExecScript.__assign,                   \
\
\ ; word logic
\
  'and',  __ScriptAnd,                           \
  'or',   __ScriptOr,                            \
  'xor',  __ScriptXor,                           \
  'not',  __ScriptNot,                           \
\
\ ; Loop
\
  'rep',  __ScriptRepeat,                        \
  'loop', __ScriptLoop,                          \
\
\ ; conditional
\
  'if',   ExecScript.__if,                       \
  'else', ExecScript.__else,                     \
  'then', ExecScript.__then




macro KeyScripts [scancode, modkeys, script] {
forward
local ptrscr
  dd scancode, modkeys
  if script eqtype 'A'
    dd ptrscr
  else
    dd script
  end if
common
  dd 0
forward
  if script eqtype 'A'
    ptrscr db script, 0
    align 4
  end if
}

struc script text {
  db text, 0
  align 4
}


KeyScripts                                     \
  keyUp,         0,        scrUp,      \
  keyUpNumpad,   0,        scrUp,      \
  keyDown,       0,        scrDown,    \
  keyDownNumpad, 0,        scrDown,    \
  keyLeft,       0,        scrLeft,    \
  keyLeftNumpad, 0,        scrLeft,    \
  keyRight,      0,        scrRight,   \
  keyRightNumpad,0,        scrRight,   \
  keyPgUp,       0,        scrPgUp,    \
  keyPgUpNumpad, 0,        scrPgUp,    \
  keyPgDown,     0,        scrPgDn,    \
  keyPgDnNumpad, 0,        scrPgDn,    \
  keyHome,       0,        scrHome,    \
  keyHomeNumpad, 0,        scrHome,    \
  keyEnd,        0,        scrEnd,     \
  keyEndNumpad,  0,        scrEnd,     \
  keyPgDown,     maskCtrl, scrEndOfFile,        \
  keyPgDnNumpad, maskCtrl, scrEndOfFile,        \
  keyPgUp,       maskCtrl, scrBegOfFile,        \
  keyPgUpNumpad, maskCtrl, scrBegOfFile,        \
  keyHome,       maskCtrl, scrBegOfScreen,      \
  keyHomeNumpad, maskCtrl, scrBegOfScreen,      \
  keyEnd,        maskCtrl, scrEndOfScreen,      \
  keyEndNumpad,  maskCtrl, scrEndOfScreen,      \
  keyInsert,     0,        scrToggleInsMode,    \
  keyInsNumpad,  0,        scrToggleInsMode,    \
  keyInsert,     maskAlt,  scrToggleSelectionMode


scrUp                   script 'u'
scrDown                 script 'd'
scrLeft                 script 'l'
scrRight                script 'r'
scrPgUp                 script 'pu'
scrPgDn                 script 'pd'
scrHome                 script 'lb'
scrEnd                  script 'le'
scrEndOfFile            script 'fe'
scrBegOfFile            script 'fb'
scrBegOfScreen          script 'sb'
scrEndOfScreen          script 'se'
scrToggleInsMode        script 'gim 1 xor sim'
scrToggleSelectionMode  script 'gsm 1 + 3 % ssm'




proc ExecScript, .editor, .pScript

.stack     rd 16

.pvar      dd ?
.fassign   dd ?

.changes dd ?

.errInvalidCommand = -1
.errInvalidNumber  = -2
.errStackOverflow  = -3
.errMissingQuote   = -4
.errInvalidVar     = -5
.errIfThenElse     = -6


begin
        push    ebx ecx edx esi edi

        stdcall GetMem, 65536
        mov     [.pvar], eax

        mov     ecx, 16
        lea     edi, [.stack]
        xor     eax, eax
        rep stosd

        mov     [.changes], eax
        mov     [.fassign], eax
        mov     edi, 15          ; intex to the stack bottom
        mov     esi, [.pScript]

.scriptloop:
        xor     ebx, ebx
        xor     ecx, ecx
        xor     eax, eax

.wordloop:
        movzx   eax, byte [esi]

        cmp     al, ' '
        jbe     .endofword

        cmp     al, '@'
        je      .variable

        cmp     al, "'"
        je      .string

        cmp     al, '"'
        je      .string

        cmp     al, '0'
        jb      .word
        cmp     al, '9'
        jbe     .digit

.word:
        inc     esi
        shl     eax, cl
        or      ebx, eax        ; command
        add     cl, 8
        cmp     cl, 32
        jbe     .wordloop
        jmp     .invalid_command


.variable:
        test    ecx, ecx
        jnz     .invalid_command

        mov     eax, $811C9DC5                  ; 2166136261              ; FNV offset basis

.hashloop:
        inc     esi

        movzx   edx, byte [esi]

        cmp     edx, ' '
        jbe     .endofvar

        xor     eax, edx
        imul    eax, $01000193                  ;   16777619              ; FNV prime
        jmp     .hashloop

.endofvar:
        mov     ebx, eax
        and     eax, $ffff
        shr     ebx, 16
        xor     ebx, eax
        and     ebx, $fffc
        add     ebx, [.pvar]

        cmp     [.fassign], 0
        je      .pushvar
; pop var
        mov     [.fassign], 0
        cmp     edi, 15
        jae     .stack_overflow

        inc     edi
        mov     eax, [.stack+4*edi]
        mov     [ebx], eax
        jmp     .nextchar

.pushvar:
        test    edi, edi
        js      .stack_overflow

        mov     eax, [ebx]
        mov     [.stack+4*edi], eax
        dec     edi
        jmp     .nextchar

.string:
        test    ecx, ecx
        jnz     .invalid_command

        inc     esi
        mov     ebx, esi

        xor     ecx, ecx

.lenloop:
        cmp     byte [esi], 0
        je      .missing_quote

        cmp     byte [esi], al
        je      .endofstring

        inc     esi
        inc     ecx
        jmp     .lenloop

.endofstring:
        test    edi, edi
        js      .stack_overflow

        stdcall StrNew
        mov     [.stack+4*edi], eax
        stdcall StrCopyPart, eax, ebx, 0, ecx
        stdcall StrPtr, eax

        dec     edi
        inc     esi
        jmp     .scriptloop

.digit:
        test    ecx, ecx
        jnz     .invalid_command

.numberloop:
        mov     al, [esi]
        cmp     al, ' '
        jbe     .endofnumber
        inc     esi

        cmp     al, '0'
        jb      .invalid_number
        cmp     al, '9'
        ja      .invalid_number

        and     eax, $0f
        imul    ebx, 10
        add     ebx, eax
        jmp     .numberloop

.endofnumber:
        test    edi, edi
        js      .stack_overflow

        mov     [.stack+4*edi], ebx
        dec     edi

        test    eax, eax
        jz      .endofscript

        inc     esi
        jmp     .scriptloop


.endofword:
        jecxz   .nextchar
        mov     eax, ScriptCommands - sizeof.TCommandItem

.search_command:
        add     eax, sizeof.TCommandItem

        cmp     dword [eax], 0
        je      .invalid_command

        cmp     [eax], ebx
        jne     .search_command

;.found:
        push    esi
        lea     ebx, [.stack]
        mov     esi, [.editor]
        call    [eax+TCommandItem.proc]
        pop     esi

        jc      .stack_overflow
        or      [.changes], eax

        cmp     edi, 15
        ja      .stack_overflow

.nextchar:
        inc     esi
        cmp     byte [esi-1], 0
        jne     .scriptloop

.endofscript:
        clc
        mov     eax, [.changes]

.finish:
        stdcall FreeMem, [.pvar]
        pop     edi esi edx ecx ebx
        return

; Context dependent control commands

; "->" (assign) command
.__assign:
        mov     [.fassign], 1
        xor     eax, eax
        clc
        retn

.__if:
        cmp     edi, 15
        jae     .ifok

        inc     edi
        cmp     [.stack+4*edi], 0
        jne     .ifok

; search for else of then
        mov     eax, [esp+4]    ; stored pointer to the script text
        xor     ecx, ecx

.ifloop:
        inc     eax
        mov     edx, [eax]
        cmp     edx, 'else'
        je      .else
        cmp     edx, 'then'
        je      .then
        test    edx, $ff000000
        jz      .iferror

        and     edx, $ffff
        cmp     edx, 'if'
        jne     .ifloop

        inc     ecx
        jmp     .ifloop

.else:
        jecxz   .elsehere
        dec     ecx
        jmp     .ifloop

.elsehere:
        add     eax, 4
        cmp     byte [eax], ' '
        ja      .iferror

        mov     [esp+4], eax
        jmp     .ifok

.then:
        jecxz   .thenhere
        dec     ecx
        jmp     .ifloop

.thenhere:
        add     eax, 4
        cmp     byte [eax], ' '
        ja      .iferror
        mov     [esp+4], eax

.ifok:
        xor     eax, eax
        clc
        retn

.iferror:
        stc
        mov     eax, .errIfThenElse
        retn


.__else:
; search for "then"
        mov     eax, [esp+4]    ; stored pointer to the script text
        xor     ecx, ecx

.elseloop:
        inc     eax
        mov     edx, [eax]
        cmp     edx, 'else'
        je      .else2
        cmp     edx, 'then'
        je      .then2
        test    edx, $ff000000
        jz      .iferror

        and     edx, $ffff
        cmp     edx, 'if'
        jne     .elseloop

        inc     ecx
        jmp     .elseloop

.else2:
        jecxz   .iferror
        dec     ecx
        jmp     .elseloop

.then2:
        jecxz   .thenhere2
        dec     ecx
        jmp     .elseloop

.thenhere2:
        add     eax, 4
        cmp     byte [eax], ' '
        ja      .iferror
        mov     [esp+4], eax
        jmp     .ifok

.__then:
        xor     eax, eax
        clc
        retn


; errors

.invalid_command:
        stc
        mov     eax, .errInvalidCommand
        jmp     .finish

.invalid_number:
        stc
        mov     eax, .errInvalidNumber
        jmp     .finish

.stack_overflow:
        stc
        mov     eax, .errStackOverflow
        jmp     .finish

.missing_quote:
        stc
        mov     eax, .errMissingQuote
        jmp     .finish

endp


call    ExecScript



proc __ScriptPlus
begin
        cmp     edi, 14
        jae     .end

        mov     eax, [ebx+4*edi+4]
        inc     edi
        add     [ebx+4*edi+4], eax

.end:
        xor     eax, eax
        return
endp



proc __ScriptMinus
begin
        cmp     edi, 14
        jae     .end

        mov     eax, [ebx+4*edi+4]
        inc     edi
        sub     [ebx+4*edi+4], eax

.end:
        xor     eax, eax
        clc
        return
endp



proc __ScriptMul
begin
        cmp     edi, 14
        jae     .end

        mov     eax, [ebx+4*edi+4]
        inc     edi
        imul    eax, [ebx+4*edi+4]
        mov     [ebx+4*edi+4], eax
.end:
        xor     eax, eax
        clc
        return
endp



proc __ScriptDiv
begin
        cmp     edi, 14
        jae     .end

        cmp     dword [ebx+4*edi+4], 0
        je      .err

        inc     edi
        mov     eax, [ebx+4*edi+4]
        cdq
        div     dword [ebx+4*edi]
        mov     [ebx+4*edi+4], eax

.end:
        xor     eax, eax
        clc
        return

.err:
        stc
        return
endp




proc __ScriptMod
begin
        cmp     edi, 14
        jae     .end

        cmp     dword [ebx+4*edi+4], 0
        je      .err

        inc     edi
        mov     eax, [ebx+4*edi+4]
        cdq
        div     dword [ebx+4*edi]
        mov     [ebx+4*edi+4], edx

.end:
        xor     eax, eax
        clc
        return

.err:
        stc
        return
endp



proc __ScriptOutNumber
begin
        cmp     edi, 15
        jae     .end

        inc     edi
        mov     eax, [ebx+4*edi]

        stdcall NumToStr, eax, ntsSigned or ntsDec
        push    eax

        stdcall StrPtr, eax
        stdcall Output, eax
        stdcall StrDel ; from the stack.

.end:
        xor     eax, eax
        clc
        return
endp


proc __ScriptOutString
begin
        cmp     edi, 15
        jae     .end

        inc     edi
        cmp     dword [ebx+4*edi], 0
        je      .crlf

        stdcall StrPtr, [ebx+4*edi]
        stdcall Output, eax
        stdcall StrDel, [ebx+4*edi]

.end:
        xor     eax, eax
        clc
        return

.crlf:
        stdcall Output, .scrlf
        jmp     .end

.scrlf db 13, 10, 0

endp



proc __ScriptSwap
begin
        cmp     edi, 14
        jae     .end

        pushd   [ebx+4*edi+4]
        pushd   [ebx+4*edi+8]
        popd    [ebx+4*edi+4]
        popd    [ebx+4*edi+8]

.end:
        xor     eax, eax
        clc
        return
endp


proc __ScriptPop
begin
        cmp     edi, 15
        jae     .end

        inc     edi
.end:
        xor     eax, eax
        clc
        return
endp



proc __ScriptAnd
begin
        cmp     edi, 14
        jae     .end

        mov     eax, [ebx+4*edi+4]
        inc     edi
        and     [ebx+4*edi+4], eax

.end:
        xor     eax, eax
        clc
        return
endp


proc __ScriptOr
begin
        cmp     edi, 14
        jae     .end

        mov     eax, [ebx+4*edi+4]
        inc     edi
        or      [ebx+4*edi+4], eax

.end:
        xor     eax, eax
        clc
        return
endp


proc __ScriptXor
begin
        cmp     edi, 14
        jae     .end

        mov     eax, [ebx+4*edi+4]
        inc     edi
        xor     [ebx+4*edi+4], eax

.end:
        xor     eax, eax
        clc
        return
endp




proc __ScriptNot
begin
        cmp     edi, 15
        jae     .end

        not     dword [ebx+4*edi+4]

.end:
        xor     eax, eax
        clc
        return
endp



proc __ScriptNeg
begin
        cmp     edi, 15
        jae     .end

        neg     dword [ebx+4*edi+4]

.end:
        xor     eax, eax
        clc
        return
endp



proc __ScriptRepeat
begin
        cmp     edi, 14
        jae     .end


.end:
        xor     eax, eax
        clc
        return
endp


proc __ScriptLoop
begin
        cmp     edi, 14
        jae     .end

.end:
        xor     eax, eax
        clc
        return
endp







DispSize 'Script engine', $ - __ScriptEngine

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/drafts/HashList.asm.

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
;uses memory.asm

cInitTreeSize = 256

struct THashList
  .ptrHashTree dd ?
  .TreeSize    dd ?
  .StrHeap     TStringPool
ends



proc HashListCreate, .ptrHashList
begin
        push    esi eax

        mov     esi, [.ptrHashList]

        mov     [esi+THashList.TreeSize], cInitTreeSize
        stdcall GetMem, [esi+THashList.TreeSize]
        mov     [esi+THashList.ptrHashTree], eax

        lea     esi, [esi+THashList.StrHeap]
        stdcall StringHeapCreate, esi

        pop     eax esi
        return
endp




proc HashListDestroy, .ptrHashList
begin
        push    esi
        mov     esi, [.ptrHashList]
        stdcall FreeMem, [esi+THashList.ptrHashTree]
        stdcall FreeMem, [esi+THashList.ptrStrList]
        pop     esi
        return
endp


;_______________________________________________________________________
;
; RETURNS:
; if CF=1 the string is already in the list.
; returns eax = pointer to the string in the list.
;         edx = hash of the string.
;
; if CF=0 the string is not in the list.
; in this case if fAdd=TRUE, adds the string to the list.
; returns eax = pointer to the string in the list.
;         edx = hash of the string.
;
; if fAdd = FALSE doesn't add the string to the list and
;_______________________________________________________________________
proc HashListCheck, .ptrHashList, .hString, .fAdd
begin

        return
endp



;_______________________________________________________________________
;
; function StrHash
;   Computes 32 bit hash value from the string.
;   The function is compatible with FASM hash
;   function if OrMask = 0.
;
; Arguments:
;   ptrString - pointer to PASCAL string with dword length at [ptr-4]
;
; Return:
;   eax - 32bit hash value.
;
; Changes:
;   eax
;_______________________________________________________________________
proc Hash_FNV1a, .ptrString
begin
        push    edx ecx esi

        mov     esi, [.ptrString]
        mov     eax, $811C9DC5                  ; 2166136261              ; FNV offset basis
        mov     ecx, [esi-4]                    ; length of the string
        jecxz   .exit

.hashloop:
        movzx   edx, byte [esi]
        xor     eax, edx
        inc     esi
        imul    eax, $01000193                  ;   16777619              ; FNV prime
        dec     ecx
        jnz     .hashloop

.exit:
        pop     esi ecx edx
        return
endp

DispSize "Hash_FNV1a", $-Hash_FNV1a
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































Deleted freshlib/_trash/SurplusSources/drafts/StrLibUltra.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
; ____________________________________________________________________
;|                                                                    |
;| This file is part of the project:                                  |
;|                                                                    |
;| ..::FreshLib::.. - portable, assembler library and GUI toolkit.    |
;|____________________________________________________________________|
;|                                                                    |
;|                          This file                                 |
;|                          _________                                 |
;|   Author:                                                          |
;|                                                                    |
;|   Title: StrLib.asm - OS independent string manipulation library.  |
;|                                                                    |
;|   OS:                                                              |
;|                                                                    |
;|   Notes and changes:                                               |
;|     Uses memory.asm library for memory functions.                  |
;|                                                                    |
;|                                                                    |
;|____________________________________________________________________|

; NumToStr flags
ntsSigned         = $00000000
ntsUnsigned       = $00010000
ntsZeroTerminated = $00020000
ntsFixedWidth     = $00040000

ntsBin            = $00000200
ntsQuad           = $00000400
ntsOct            = $00000800
ntsDec            = $00000a00
ntsHex            = $00001000

cStrShift     = 6
cStrChunkSize = 1 shl cStrShift

cStrChunkCount = 1024

; TChunkIndex is a dword with following format:
;  $00000000 - empty chunk
;  $pxffffff - last chunk in the string. Only $ffffff have special meaning. $fffffe for example is normal chunk number.
;              .next is unsigned 24 bit number.
;  $nxyyyyyy - first chunk in the string.       nx = not (px) - it is not NEG!
struct TChunkIndex
  .next rb 3
  .len  db ?
ends


struct TStrTableNew
  .count      dd 0      ; Count of the chunks in the string pool
  .ptrPool    dd 0      ; One big area of memory to be allocated for strings.
  .ptrIndex   dd 0      ; array of dword for every chunk in the pool: if >0 it is index of the next chunk in the string. If <0 it is occuped space in the last chunk.
  .Hint       dd ?      ; index of the fast found free chunk. From here you must start to search for the next allocation.
ends


uglobal
  _StrList    TStrTableNew
endg


initialize StrLibInit
begin
        stdcall GetMem, cStrChunkCount * cStrChunkSize
        jc      .error_init
        mov     [_StrList.ptrPool], eax

        stdcall GetMem, cStrChunkCount * 4
        jc      .error_init
        mov     [_StrList.ptrIndex], eax

        mov     [_StrList.count], cStrChunkCount
        mov     [_StrList.Hint], -1
        return

.error_init:
        int3
        return

endp




finalize StrLibDestroy
begin
        stdcall FreeMem, [_StrList.ptrPool]
        stdcall FreeMem, [_StrList.ptrIndex]
        return
endp


; ____________________________________________________________________
;| proc StrNew                                                        |
;|   Creates new dynamic string and returns the handle.               |
;| Arguments:                                                         |
;|   None                                                             |
;| Returns:                                                           |
;|   CF = 0; no error: eax contains handle of the string.             |
;|   CF = 1; error. eax = 0                                           |
;|____________________________________________________________________|
proc StrNew
begin
        push    ebx
        mov     ebx, [_StrList.ptrIndex]
        call    _search_empty_chunk
        jc      .error_new
        mov     dword [ebx+4*eax], $ffffffff    ; first chunk; last chunk; zero occupied (empty string).
        clc
        pop     ebx
        return

.error_new:
        stc
        pop     ebx
        return
endp


;__________________________________________
;
; Arguments:
;   ebx - pointer to the index.

; Returns:
;   eax - index of new empty  chunk.
;
; Returns index of a empty chunk.
; If needed, resizes memory arrays for
; chunks and for index.
; Updates _StrList as well.
;__________________________________________

proc _search_empty_chunk
begin
        push    ecx  edx

        mov     edx, [_StrList.Hint]
        mov     ecx, [_StrList.count]

.searchloop:
        inc     edx
        cmp     edx, [_StrList.count]
        jb      @f
        xor     edx, edx
@@:
        cmp     dword [ebx+4*edx], 0
        je      .free_found

        dec     ecx
        jnz     .searchloop

; the empty chunk not found. so, resize the arrays
        mov     edx, [_StrList.count]   ; that is the new string handle.

        lea     eax, [2*edx]            ; new size of the arrays. very aggressive.
        mov     [_StrList.count], eax

        shl     eax, cStrShift
        stdcall ResizeMem, [_StrList.ptrPool], eax
        jc      .finish

        mov     [_StrList.ptrPool], eax

        mov     eax, [_StrList.count]
        lea     eax, [4*eax]
        stdcall ResizeMem, [_StrList.ptrIndex], eax
        mov     [_StrList.ptrIndex], eax
        mov     ebx, eax

.free_found:
        mov     [_StrList.Hint], edx
        mov     eax, edx
.finish:
        pop     edx ecx
        return
endp



; ____________________________________________________________________
;| proc StrDel, .hString                                              |
;|   Destroys dynamic string                                          |
;| Arguments:                                                         |
;|   .hString - only handle to a string.                              |
;| Returns:                                                           |
;|   CF = 0; no error:                                                |
;|   CF = 1; error                                                    |
;|____________________________________________________________________|
proc StrDel, .hString
begin
        push    ebx edx
        mov     ebx, [_StrList.ptrIndex]
        mov     edx, [.hString]
        cmp     byte [ebx+4*edx+TChunkIndex.len], 0     ; first .len should be negative!
        jge     .invalid_handle

        mov     [_StrList.Hint], edx
        dec     [_StrList.Hint]

.del_loop:
        push    dword [ebx+4*edx]
        mov     dword [ebx+4*edx], 0    ; free chunk
        pop     edx
        and     edx, $ffffff
        cmp     edx, $ffffff
        je      .end_string

        cmp     byte [ebx+4*edx+TChunkIndex.len], 0
        jge     .del_loop                               ; every next .len should be positive.

.invalid_handle:
        stc
        pop     edx ebx
        return

.end_string:
        clc
        pop     edx ebx
        return

endp



;____________________________________________________________________
;
; proc StrCatAsciiZ, .hString, .ptrAsciiZ
;
;   Concatenates asciiz string from the memory to the given dynamic
; string.
;
; Arguments:
;   .hString - handle of a dynamic string.
;   .ptrAsciiZ - pointer to asciiz string in memory.
;
; Returns:
;   CF=1 if error.
;____________________________________________________________________

proc StrCatAsciiZ, .hString, .ptrAsciiZ
begin
        push    eax ebx ecx edx esi edi

        mov     ebx, [_StrList.ptrIndex]
        mov     eax, [.hString]

; first search to the end chunk of the string.
.endloop:
        mov     edx, eax
        mov     eax, [ebx+4*edx]
        and     eax, $ffffff
        cmp     eax, $ffffff
        jne     .endloop

        mov     eax, edx
        mov     edi, [_StrList.ptrPool]
        shl     eax, cStrShift
        add     edi, eax                 ; edi - pointer to the begin of the last chunk in string.

        movsx   ecx, byte [ebx+4*edx+TChunkIndex.len]    ; offset in the chunk.
        mov     esi, [.ptrAsciiZ]
        test    ecx, ecx
        jns     .copyloop

        not     ecx

; so, copy to the end of the chunk
.copyloop:
        cmp     ecx, cStrChunkSize
        jb      .sizeok

        call    _search_empty_chunk
        jc      .finish

; set previous chunk index.
        mov     [ebx+4*edx], eax
        mov     cl, cStrChunkSize
        cmp     edx, [.hString]
        jne     @f
        not     cl
@@:
        mov     byte [ebx+4*edx+TChunkIndex.len], cl

        mov     edi, eax
        xor     ecx, ecx  ; zero offset.
        shl     edi, cStrShift
        mov     edx, eax                ; new chunk index.
        add     edi, [_StrList.ptrPool] ; new chunk pointer

.sizeok:
        mov     al, [esi]
        inc     esi
        cmp     al, 0
        je      .endofstring
        mov     [edi+ecx], al
        inc     ecx
        jmp     .copyloop

.endofstring:
        mov     dword [ebx+4*edx+TChunkIndex.next], $00ffffff

        cmp     edx, [.hString]
        jne     @f
        not     cl
@@:
        mov     byte  [ebx+4*edx+TChunkIndex.len],  cl

.finish:
        pop     edi esi edx ecx ebx eax
        return
endp



;____________________________________________________________________
;
; proc StrCatChar, .hString, .char
;
;   Concatenates 1..4 characters to the given dynamic string.
;   Actually uses StrCatAsciiZ to do the work.
;
; Arguments:
;   .hString - handle of a dynamic string.
;   .char - dword with 1 to 4 characters.
;
; Returns:
;   CF=1 if error.
;____________________________________________________________________

proc StrCatChar, .hString, .char
.buff rd 2
begin
        push    eax
        mov     eax, [.char]
        mov     [.buff], eax
        mov     [.buff+4], 0
        lea     eax, [.buff]
        stdcall StrCatAsciiZ, [.hString], eax
        pop     eax
        return
endp




;____________________________________________________________________
;
; proc StrSplit, .hString, .pos
;
; Splits [.hString] at position [.pos].
; The left portion of the string remains in [.hString]
; The right portion forms new string that is returned by function.
; This procedure increases fragmentation of the string pool.
; In most cases it allocates one more chunk to keep the begin of
; the right part of the string.
;
; Arguments:
;   .hString - handle of string to be splitted.
;   .pos     - position for split.
; Returns:
;   CF = 1 - error.
;   CF = 0 - no error. eax contains handle of string with right part of
;            the splitted string.
;____________________________________________________________________

proc StrSplit, .hString, .pos
begin
        push    ebx ecx edx esi edi

        mov     ebx, [_StrList.ptrIndex]
        mov     edx, [.hString]
        cmp     edx, [_StrList.count]
        cmc
        jc      .finish

        movsx   eax, [ebx+4*edx+TChunkIndex.len]
        not     eax

        bt      eax, 31
        jc      .finish

        sub     [.pos], eax
        jle     .found

.lenloop:
        mov     edx, [ebx+4*edx]
        and     edx, $00ffffff
        cmp     edx, $00ffffff
        je      .exit_error

        movsx   eax, [ebx+4*edx+TChunkIndex.len]
        bt      eax, 31
        jc      .finish

        sub     [.pos], eax
        jg      .lenloop

.found:
        jl      .insertchunk

        mov     eax, [ebx+4*edx]
        and     eax, $00ffffff
        cmp     eax, $00ffffff
        je      .exit_error

        or      dword [ebx+4*edx], $00ffffff
        xor     dword [ebx+4*eax], $ff000000
        clc
        jmp     .finish

.insertchunk:
        sar     [ebx+4*edx+TChunkIndex.len], 7
        add     [.pos], eax
        mov     ecx, [.pos]   ; remaining in the left string.
        xor     [ebx+4*edx+TChunkIndex.len], cl    ; proper sign length.

        mov     esi, edx
        shl     esi, cStrShift
        add     esi, ecx        ; the offset in the pool.

        push    dword [ebx+4*edx]
        or      dword [ebx+4*edx], $00ffffff
        pop     edx
        and     edx, $00ffffff

        sub     eax, [.pos]     ; length of the remaining in the right.
        mov     ecx, eax

        call    _search_empty_chunk

        mov     [ebx+4*eax+TChunkIndex.len], cl
        xor     dword [ebx+4*eax], $ff000000    ; it is first chunk in the new string.
        or      dword [ebx+4*eax], edx          ; next chunk.

        mov     edi, eax
        shl     edi, cStrShift
        add     edi, [_StrList.ptrPool]
        add     esi, [_StrList.ptrPool]
        rep movsb
        clc
.finish:
        pop     edi esi edx ecx ebx
        return

.exit_error:
        stc
        jmp     .finish
endp



;____________________________________________________________________
;
; proc StrInsert, .hDest, .hSrc, .position
;
; Insrts [.hSrs] at [.position] inside [.hDest].
; Uses StrSplit and StrCat to do the work.
; .hStr is destroyed.
;
; Arguments:
;   .hDest - handle of destination string.
;   .hStr  - string to be inserted.
;   .position - position of insertion.
;
; Returns:
;   CF = 1 - error.
;   CF = 0 - no error.
;____________________________________________________________________

proc StrInsert, .hDest, .hSrc, .position
begin
        push    eax
        stdcall StrSplit, [.hDest], [.position]
        jc      .finish
        stdcall StrCat, [.hDest], [.hSrc]
        jc      .freeeax
        stdcall StrCat, [.hDest], eax
        jc      .strange

.finish:
        pop     eax
        return

.freeeax:
        stdcall StrCat, [.hDest], eax
        jc      .strange
        stc
        jmp     .finish

.strange:
        stdcall StrDel, eax
        stc
        jmp     .finish

endp



;____________________________________________________________________
;
; proc StrCat, .hDest, .hSrc
;
;   Concatenates two dynamic strings. The result string is [.hDest]
;   After concatenation, [.hSrc] is destroyed. If you need to keep
;   .hSrc, make copy of it with StrDup and then concatenate the
;   copy with the destination string.
;
; Arguments:
;   .hString - handle of a dynamic string.
;   .ptrAsciiZ - pointer to asciiz string in memory.
;
; Returns:
;   CF=1 if error.
;____________________________________________________________________
proc StrCat, .hDest, .hSrc
begin
        push    eax ebx ecx edx

        mov     ebx, [_StrList.ptrIndex]
        mov     eax, [.hDest]
        cmp     eax, [_StrList.count]
        cmc
        jc      .finish

        movsx   ecx, [ebx+4*eax+TChunkIndex.len]
        not     ecx
        bt      ecx, 31
        jc      .finish

.chunkloop:
        mov     edx, eax
        mov     eax, [ebx+4*edx]
        and     eax, $00ffffff
        cmp     eax, $00ffffff
        jne     .chunkloop

        mov     ecx, [.hSrc]
        cmp     ecx, [_StrList.count]
        cmc
        jc      .finish

        xor     dword [ebx+4*ecx], $ff000000
        bt      dword [ebx+4*ecx], 31
        jc      .finish

        and     dword [ebx+4*edx], $ff000000
        or      dword [ebx+4*edx], ecx

.finish:
        pop     edx ecx ebx eax
        return
endp


;____________________________________________________________________
; proc StrCompact, .hStr
;
; Compacts the string. This means, that if some chunks of the string
; are not fully used (as a result of string manipulations -
; inserts, concatenations, deletes, etc.) this function removes
; the empty spaces from the chunks and frees resulted empty chunks
; from the end of the string.
; This operation is slow if the string is fragmented and should be
; avoided without reason. Even when needed, you should call this
; procedure as later as possible, after all operations that may
; fragment the string.
;
;____________________________________________________________________
proc StrCompact, .hStr
begin


        return
endp




;____________________________________________________________________
;
; proc StrDup, .hString
;
;   Creates duplicate of the given string.
;
; Arguments:
;   .hString - handle of a dynamic string.
;
; Returns:
;   CF=1 if error.
;   CF=0 - eax = handle of the new created string.
;____________________________________________________________________
proc StrDup, .hString
.new dd ?
begin
        push    ebx ecx edx esi edi

        mov     edx, [.hString]
        mov     ebx, [_StrList.ptrIndex]
        cmp     edx, [_StrList.count]
        cmc
        jc      .finish

        movsx   ecx, [ebx+4*edx+TChunkIndex.len]
        not     ecx
        bt      ecx, 31
        jc      .finish

        call    _search_empty_chunk
        jc      .finish

        mov     [.new], eax

.chunkloop:
        mov     edi, eax
        mov     esi, edx
        shl     edi, cStrShift
        shl     esi, cStrShift
        add     edi, [_StrList.ptrPool]
        add     esi, [_StrList.ptrPool]

        mov     ecx, cStrChunkSize / 4
        rep movsd

        mov     ecx, [ebx+4*edx]
        and     ecx, $ff000000
        push    ecx

        mov     edx, [ebx+4*edx]
        and     edx, $00ffffff
        cmp     edx, $00ffffff
        je      .endofstring

        mov     ecx, eax
        call    _search_empty_chunk
        jc      .finish

        pop     dword [ebx+4*ecx]
        or      [ebx+4*ecx], eax

        jmp     .chunkloop

.endofstring:
        pop     dword [ebx+4*eax]
        or      [ebx+4*eax], edx
        mov     eax, [.new]
        clc
.finish:
        pop     edi esi edx ecx ebx
        return
endp




proc SubStr, .hString, .index, .length
begin




endp




; ____________________________________________________________________
;|                                                                    |
;| proc StrLen, .hString                                              |
;|   Returns the length of the string in bytes.                       |
;| Arguments:                                                         |
;|   .hString: pointer or handle to a string.                         |
;| Returns:                                                           |
;|    ecx - length of the strin in bytes.                             |
;|____________________________________________________________________|

proc StrLen, .hString
begin
        push    ebx edx eax

        mov     ebx, [_StrList.ptrIndex]
        mov     edx, [.hString]
        cmp     edx, [_StrList.count]
        cmc
        jc      .finish

        movsx   ecx, [ebx+4*edx+TChunkIndex.len]
        not     ecx

        bt      ecx, 31
        jc      .finish

.lenloop:
        mov     edx, [ebx+4*edx]
        and     edx, $00ffffff
        cmp     edx, $00ffffff
        je      .finish

        movsx   eax, [ebx+4*edx+TChunkIndex.len]
        bt      eax, 31
        jc      .finish

        add     ecx, eax
        jmp     .lenloop

.finish:
        pop     eax edx ebx
        return
endp


;_____________________________________________________________________
;
; proc StrFreeBuffer, .ptrBuffer
;
; Frees thestring buffer, allocated by StrPointer.
; Arguments:
;   .ptrBuffer - pointer to the buffer.
; Returns:
;   CF=1 if error. In this case, the memory is not released.
;_____________________________________________________________________

proc StrFreeBuffer, .ptrBuffer
begin
        push    eax
        mov     eax, [.ptrBuffer]
        sub     eax, 4
        stdcall FreeMem, eax
        pop     eax
        return
endp


;____________________________________________________________________________________
; proc StrPointer, .hString
;
; Extracts the string [.hString] to the allocated buffer and returns pointer
; to the allocated memory.
; Allocated memory must be freed with StrFreeBuffer.
; The buffer have dword size. The string is Zero terminated and there is guarantied
; that at least one full dword at the end is zero.
; At the [pointer - 4] is placed the length of the string in bytes.
;
; Arguments:
;   .hString - handle to a string.
; Returns:
;   esi - pointer to allocated buffer in memory.
;   CF = 1 in case of error - invalid handle of string or the memory can not be
;          allocated.
;____________________________________________________________________________________
proc StrPointer, .hString
.ptr dd ?
.len dd ?
begin
        push    eax ebx ecx edx edi

        stdcall StrLen, [.hString]
        jc      .finish

        mov     [.len], ecx
        add     ecx, 11              ; we need 8bytes more memory for length and termination
        and     cl, $fc

        stdcall GetMem, ecx
        jc      .finish

        mov     [.ptr], eax
        lea     edi, [eax+4]

        mov     ebx, [_StrList.ptrIndex]
        mov     edx, [.hString]

        cmp     dword [ebx+4*edx], 0
        je      .invalid_handle

.outerextract:
        mov     esi, edx
        shl     esi, cStrShift
        add     esi, [_StrList.ptrPool]
        movsx   ecx, [ebx+4*edx+TChunkIndex.len]
        test    ecx, ecx
        jns     .innerextract
        not     ecx

.innerextract:
        cmp     ecx, 0
        jle     .endofchunk

        movsd
        sub     ecx, 4
        jmp     .innerextract

.endofchunk:
        add     edi, ecx        ; ecx <= 0

        mov     edx, [ebx+4*edx]
        and     edx, $00ffffff
        cmp     edx, $00ffffff
        jne     .outerextract

        xor     eax, eax
        stosd                   ; terminator
        mov     esi, [.ptr]
        pushd   [.len]
        popd    [esi]
        add     esi, 4
        clc
.finish:
        pop     edi edx ecx ebx eax
        return

.invalid_handle:
        stc
        pop     edi edx ecx ebx eax
        return
endp


;_______________________________________________________________________
;
; function StrHash
;   Computes 32 bit hash value from the string.
;
; Arguments:
;   .hString - handle or pointer to the string.
;
; Return:
;   eax - 32bit hash value; FNV-1a algorithm.
;
; Changes:
;   eax
;_______________________________________________________________________
proc StrHash, .hString, .OrMask
begin
        push    edx ecx esi

        stdcall StrPtr, [.hString]
        mov     esi, eax
        mov     eax, $811C9DC5                  ; 2166136261              ; FNV offset basis
        mov     ecx, [esi-4]                    ; length of the string
        jecxz   .exit

.hashloop:
        movzx   edx, byte [esi]
        inc     esi
        or      edx, [.OrMask]
        xor     eax, edx
        imul    eax, $01000193                  ;   16777619              ; FNV prime
        dec     ecx
        jnz     .hashloop

.exit:
        pop     esi ecx edx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/drafts/StringHeap.asm.

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
cInitStringPoolSize = 1024


struct TStringPool
  .ptrPool  dd ?
  .iEnd     dd ?
ends



proc StringHeapCreate, .ptrStringPool
begin
        push    esi
        mov     esi, [.ptrStringPool]
        stdcall GetMem, cInitStringPoolSize
        mov     [esi+TStringPool.ptrPool], eax

        pop     esi
        return
endp



proc StringHeapAdd, .ptrStringPool, .ptrString
.size dd ?
begin
        push    ebx ecx edx esi edi

        mov     esi, [.ptrString]
        mov     edi, [.ptrStringPool]

        stdcall GetMemSize, [edi+TStringPool.ptrPool]
        mov     [.size], eax

        mov     ebx, [edi+TStringPool.iEnd]
        add     ebx, [esi-4]    ; length of the string.
        add     ebx, 8          ; dword len + dword zero terminator.
        cmp     ebx, [.size]    ;
        jb      .sizeok

        mov     ecx, [.size]
        sar     ecx, 2  ; 1/4 of the size.
        cmp     ecx, cInitStringPoolSize
        ja      .reserveok
        mov     ecx, cInitStringPoolSize
.reserveok:

        add     ebx, ecx
        stdcall ResizeMem, [edi+TStringPool.ptrPool], ebx
        mov     [edi+TStringPool.ptrPool], eax

.sizeok:
; size is OK, so go copy:

        mov     ebx, [edi+TStringPool.ptrPool]
        mov     ecx, [esi-4]                    ; len of the string

        mov     eax, [edi+TStringPool.iEnd]
        lea     eax, [eax+4]
        push    eax                             ; result offset.

        lea     ebx, [ebx+eax]
        mov     [ebx-4], ecx                    ; length of the string

; ebx -> pointer to the destination
; esi -> pointer to the source
; ecx -> lenght in bytes.

        mov     edx, ecx
        shr     edx, 2          ; quotient
        and     ecx, 3          ; remainder

        mov     dword [ebx+4*edx], 0        ; zero termination
        mov     dword [ebx+4*edx+4], 0        ; zero termination
        lea     eax, [ebx+4*edx+8]
        sub     eax, [edi+TStringPool.ptrPool]
        mov     [edi+TStringPool.iEnd], eax

        push    ebx esi
        lea     ebx, [ebx+4*edx]
        lea     esi, [esi+4*edx]

.looprem:
        dec     ecx
        js      .endrem
        mov     al, [esi+ecx]
        mov     [ebx+ecx], al
        jmp     .looprem

.endrem:
        pop     esi ebx

.loopdword:
        dec     edx
        js      .endcopy
        mov     eax, [esi+4*edx]
        mov     [ebx+4*edx], eax
        jmp     .loopdword

.endcopy:
        pop     eax
        pop     edi esi edx ecx ebx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































Deleted freshlib/_trash/SurplusSources/drafts/strlib.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
;************************************************************
; FASM dynamic string library.
;
; (c)2003 John Found
; (c)2003 Mateusz Tymek (aka decard)
; (c)2003 Victor Loh (aka roticv)
;
; You can use and modify this library, as long as modifyed
; versions are clearly marked (author of the modification
; and what is changed), copyright notice is not
; removed and the library remains free.
; Copyright for the library concept and parts written by
; me, remains to me, John Found
; Copyright for the modifyed/new parts remains to their
; authors.
;
; Versions:
;   dd.mm.yyyy  version   author of modification
;     - description
;--------------------------------------------------------
;   09.07.2003  v1.0    John Found
;     - the first public version.
;   15.07.2003  v1.0.1  John Found
;     - minor bug with string table expand. Look in NewStr
;   17.09.2003  v1.1.0  Mateusz Tymek
;     - made all functions stdcall
;     - added StrCat and StrPos, and modified StrLen
;   25.09.2003  v1.1.2  Mateusz Tymek, Victor Loh
;     - added StrLCase, StrUCase, StrCopyMMX, StrInsert
;     - added new NumToStr, old version renamed to _NumStr
;     - some small optimizations & bugfixes
;   26.09.2003 v1.1.3  JohnFound
;     - some bug fixes and style corections.
;   29.09.2003 v1.1.4  John Found, Mateusz Tymek
;     - library rewtiten to use John Found's stdcall macros
;     - added two new low-level NumToStr routines: NumToStrF and NumToStrUF
;     - NumToStr rewriten
;     - some small bugfixes & modifications
;     - added StrExtract
;   01.11.2003 v1.1.4.1 Mateusz Tymek
;     - preserved ecx in StrDel (it was destroyed by API calls)
;   21.11.2003 v1.1.5 John Found
;     - StrComp splitted to 2 functions: StrCompCase and StrCompNoCase
;       IMPORTANT: inversed return result: CARRY = 1 mean strings equal.
;       This is because the using is more natural this way:
;            stdcall  StrCompCase, str1, str2
;            jc       .equal
;   27.11.2003 v1.2 John Found
;     - Added function StrHash, that produces 32bit hash value of the string.
;       The hash function is based on FASM hash function and have to be compatible.
;   03.12.2003 v1.2.3 Mateusz Tymek
;     - Added StrCharPos and StrToNum
;   13.12.2003 v1.2.4 Materusz Tymek
;     - added StrCharCat and StrInsertChar
;   04.01.2005 v1.2.5 John Found
;     - Fixed bug in StrSetLength
;     - Added function StrURLEncode
;*************************************************************************************


;--< How to use it >-----------------------------------------------------------------
; 1. Include "strutils.inc" somewhere in the begining of main file.
; 2. Define structure "StrTable" of type "TStrTable" somewhere in data section.
; 3. Before using of library functions, call "InitStrings"
; 4. After last use of the library (probably on close of application),
;    call "FreeStrings" to free all used memory.
; 5. Some functions are with register parameter passing, other with "stdcall"
;    parameter passing. Read the header descriptions of the functions.
;------------------------------------------------------------------------------------


STR_MINCOUNT = 10       ; minimum 10 strings in the table
STR_MINSTRLEN = 16      ; 16 bytes minimum string length



; NumToStr flags
ntsSigned = $00000
ntsUnsigned = $10000
ntsZeroTerminated = $20000
ntsFixedWidth     = $40000


ntsBin  = $0200
ntsQuad = $0400
ntsOct  = $0800
ntsDec  = $0a00
ntsHex  = $1000


; Global variable, storing parameters of dynamic strings list.
uglobal
  StrTable  dd  ?      ; StrLib library variable.
endg


; < Library functions >

;************************************************************************************
; Allocates memory for string table and allocates memory for strings.
; Start it before any work with strings.
; Returns 0 if failed to allocate needed memory.
;************************************************************************************
initialize InitStrings
begin
        StrLib = 1

        stdcall CreateArray, 4
        jc      .finish

        stdcall AddArrayItem, eax
        mov     [StrTable], edx
        mov     [edx+TArray.lparam], 0          ; lParam is the last allocated handle number
        or      dword [eax], -1

.finish:
        return
endp

;**************************************************************************************
; Frees all memory used for strings library
; Call it before exit of the program.
;**************************************************************************************
finalize FreeStrings
begin
        mov     esi, [StrTable]
        mov     edi, [esi+TArray.count]
        xor     ebx,ebx

.freeloop:
        mov     ebx, [esi+TArray.array]
        test    ebx,ebx
        jz      .nxt
        js      .nxt

        stdcall FreeMem, ebx

.nxt:
        add     esi, 4
        dec     edi
        jnz     .freeloop

        stdcall FreeMem, [StrTable]
        mov     [StrTable], 0
        return
endp



;**************************************************************************************
;  Returns the pointer in memory of the hString, or NULL on error
;**************************************************************************************
proc StrPtr, .hString
begin
        mov     eax, [.hString]
        test    eax, $ffff0000
        jnz     .finish                 ; It's pointer, go to finish.

        push    ebx

        mov     ebx, [StrTable]
        cmp     eax, [ebx+TArray.count]
        jae     .notfound

        mov     eax, [ebx+TArray.array+4*eax]
        pop     ebx
.finish:
        return

.notfound:
        pop     ebx
        xor     eax,eax
        return
endp

;**************************************************************************************
;  Creates new empty string and returns handle
;  Return: handle of the new created string.
;**************************************************************************************
proc StrNew
begin
        push    ecx edx esi

; Find first empty place.
        mov     edx, [StrTable]
        mov     ecx,[edx+TArray.count]
        mov     esi,[edx+TArray.lparam]
        xor     eax,eax

.search:
        inc     esi
        cmp     esi, [edx+TArray.count]
        jne     @f
        xor     esi,esi
        inc     esi
@@:
        cmp     [edx+TArray.array+4*esi],eax
        je      .found
        dec     ecx
        jnz     .search

.notfound:
        mov     esi, [edx+TArray.count]
        cmp     esi, $10000
        jb      @f
        int3                    ; 65535 strings max.
@@:
        stdcall AddArrayItem, edx
        mov     [StrTable], edx

.found:
        mov     [edx+TArray.lparam], esi
        stdcall GetMem, STR_MINSTRLEN
        mov     [edx+TArray.array+4*esi], eax
        mov     eax, esi
        pop     esi edx ecx
        return
endp

;**************************************************************************
; Deletes the string if it is possible.
;**************************************************************************
proc StrDel, .hString
begin
        push    eax ebx ecx edx esi

        mov     esi, [StrTable]
        mov     eax, [.hString]
        test    eax, eax
        jz      .finish

        test    eax,$ffff0000
        jz      .process

; search the pointer in the table.
        mov     ecx, [esi+TArray.count]

.search:
        dec     ecx
        js      .finish
        cmp     [esi+TArray.array+4*ecx], eax
        jne     .search

        stdcall FreeMem, eax
        mov     [esi+TArray.array+4*ecx], 0

        jmp     .finish

.process:
        mov     ebx, eax
        stdcall StrPtr,eax
        test    eax,eax
        jz      .finish
.free:
        invoke  HeapFree, [StrTable.heap], 0, eax
        mov     dword [esi+4*ebx], NULL        ; Set the cell of the table to null.
.finish:
        pop     esi edx ecx ebx eax
        return
endp


;**************************************************************************
; Duplicates given string, and returns a handle to new one
;**************************************************************************
proc StrDup         ; proc StrDup [hBaseStr]
begin
        mov     eax,[esp+4]             ; mov eax,[esp+4]
        or      eax,eax
        jz      .exit
        stdcall StrNew
        stdcall StrCopy, eax,dword[esp+4]    ; stdcall StrCopy, [hBaseStr]
.exit:  ret     4
endp

;**************************************************************************
; Returns the length of the string.
; Arguments:
;  hString - handle or pointer to the string (static or dynamic)
;**************************************************************************
proc StrLen, .hString    ; proc StrLen [hString]
        begin
        push    ebx
        stdcall StrPtr, [.hString]
        mov     ebx,eax
  .scan:
        cmp     byte[eax],0
        lea     eax,[eax+1]
        jne     .scan
        sub     eax,ebx
        dec     eax         ; return value in eax
        pop     ebx
        return
endp

;***************************************************************************
; If the hString is larger than length - do nothing
; If the hString is smaller than length -> set the length of string to length
; returns pointer to the new (old) string
;
; Arguments:
;   hString - string handle. /not pointer!/
;   length - new string length.
; Returns: pointer to the string.
;***************************************************************************
proc StrSetLength, .hString, .length   ; proc StrSetLength [hString], [length]
        begin
        push    ebx ecx edx esi edi     ; esp=esp-20

        mov     ebx, [.length]          ; mov ecx,[length]
        lea     ebx, [ebx+4]            ; the string have to be at least 1 dword bigger than the length specified.

        mov     eax,[.hString]          ; mov eax,[hString]
        test    eax,$ffff0000   ; if eax is pointer then error
        jnz     .error
        cmp     eax,[StrTable.count]    ; invalid handle.
        jge     .error

        mov     edi,[StrTable.ptr]
        lea     edi,[4*eax+edi]         ; points to the address of table pointer of destination string
        mov     esi,[edi]
        test    esi,esi                 ; Error string not defined
        jz      .error                  ;

        invoke  HeapSize, [StrTable.heap], 0, esi
        cmp     eax,-1
        je      .error
        cmp     eax,ebx
        jl      .resize
        mov     eax,esi
        jmp     .finish

.resize:
        invoke  HeapReAlloc, [StrTable.heap], HEAP_GENERATE_EXCEPTIONS or HEAP_ZERO_MEMORY, esi, ebx
        mov     [edi], eax
        jmp     .finish

.error:
        xor     eax,eax

.finish:
        pop     edi esi edx ecx ebx
        return
endp


;***************************************************************************************
;  Copyes source to destination string.
;  Arguments:
;     source - destination string (handle only)
;     dest -  source string (handle or pointer)
;***************************************************************************************
proc StrCopy, .dest, .source
        begin
        push    esi edi eax ecx
        mov     edi,[.dest]
        test    edi,$ffff0000   ; if edi is pointer go to finish.
        jnz     .finish
        mov     esi,[.source]
        test    esi,esi
        jz      .finish
        stdcall StrPtr, esi
        mov     esi,eax
        test    esi, esi
        jz      .finish
        stdcall StrLen, eax
        inc     eax
        mov     ecx,eax
        stdcall StrSetLength, edi,eax
        test    eax,eax
        jz      .finish
        stdcall StrPtr, edi
        mov     edi,eax
        cld
        rep movsb               ; copy strings
.finish:
        pop     ecx eax edi esi
        return
endp

;***************************************************************************************
; Compares two strings - case sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;***************************************************************************************
proc StrCompCase, .str1, .str2
begin
        push    eax esi edi

        cmp     [.str1], 0
        je      .noteq
        cmp     [.str2], 0
        je      .noteq

        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax
.loop:
        mov     al, [esi]
        lea     esi, [esi+1]
        cmp     al, [edi]
        lea     edi, [edi+1]
        jne     .noteq

        test    al, al
        jnz     .loop

        stc
        pop     edi esi eax
        return

.noteq:
        clc
        pop     edi esi eax
        return
endp


;***************************************************************************************
; Compares two strings - case NOT sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;***************************************************************************************
proc StrCompNoCase, .str1, .str2
begin
        push    eax esi edi
        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax

.cmploop:
        mov     al, [esi]
        lea     esi, [esi+1]
        mov     ah, [edi]
        lea     edi, [edi+1]

        test    al,al
        jz      .eos
        test    ah,ah
        jz      .noteq

        or      eax, $2020
        cmp     al, ah
        je      .cmploop

.noteq:
        clc
        pop     edi esi eax
        return

.eos:
        test    ah,ah
        jnz     .noteq

        stc
        pop     edi esi eax
        return
endp



;*******************************************************************************
; Get the text of the [Control] using WM_GETTEXT and put it to the string with
; handle (only) in [string].
;
; if [string] = NULL creates new string and returns the handle.
; if [string] <> NULL just copyes the text.
;*******************************************************************************
proc GetControlText, .Control, .string
.res dd ?
.len dd ?
begin
        push    ebx edi
        mov     eax,[.string]
        test    eax,eax
        jnz     @f
        stdcall StrNew
@@:
        mov     [.res],eax
        invoke  SendMessage, [.Control], WM_GETTEXTLENGTH, 0, 0
        add     eax, 16
        mov     [.len], eax
        stdcall StrSetLength, [.res], eax
        test    eax,eax
        jz      .error
        invoke  SendMessage, [.Control], WM_GETTEXT, [.len], eax
        mov     eax,[.res]
.error:
        pop     edi ebx
        return
endp

;*******************************************************************************
; Sets the text in control using WM_SETTEXT from string with handle or pointer
; in [string].
;*******************************************************************************
proc SetControlText, .Control, .string
begin
        push    eax ecx edx
        stdcall StrPtr, [.string]
        invoke  SendMessage, [.Control], WM_SETTEXT, 0, eax
        pop     edx ecx eax
        return
endp

;**********************************************************
;  Creates string and assigns it to variable. If variable
;  already contains string handle, the old string will be
;  deleted.
;  Arguments:
;    [ptrHString] - variable containing string handle.
;    ptrSource - pointer to the source for string.
;**********************************************************
; Bug fix 26.09.2003 JohnFound
proc SetString, .ptrHString, .ptrSource
begin
        push    eax esi
        mov     esi, [.ptrHString]

        cmp     dword [esi], 0
        je      @f
        stdcall StrDel, [esi]
@@:
        stdcall StrNew
        mov     [esi], eax
        stdcall StrCopy, eax, [.ptrSource]
        pop     esi eax
        return
endp

;**********************************************************************************
; StrCat appends one string to another
; Arguments:
;   dest - destination string (handle only)
;   source - source string
;**********************************************************************************
proc StrCat, .dest, .source
begin
        push    eax ebx ecx

        stdcall StrLen, [.dest]
        mov     ebx,eax                 ; store dest length in ebx

        stdcall StrLen, [.source]
        add     eax, ebx
        inc     eax                     ; new dest length
        stdcall StrSetLength, [.dest], eax
        add     ebx, eax                ; calculate end of old dest in ebx
        stdcall StrPtr, [.source]
.copy:
        mov     cl,[eax]
        inc     eax
        mov     [ebx],cl
        inc     ebx
        or      cl,cl
        jnz     .copy
        pop     ecx ebx eax
        return
endp


;**********************************************************************************
; StrCharPos returns a pointer to the first occurence of a given char
;   in specified string
; Arguments:
;   Char - char to look for
;   hString -  string to search
; Returns: a pointer to the char in source, or NULL if char doesn't occur
;   in given string
;**********************************************************************************
proc StrCharPos, .hPattern, .char
        begin
        push    esi
        stdcall StrPtr,[.hPattern]
        mov     esi,eax
        mov     eax,[.char]
        xchg    al,ah
     .search:
        mov     al,[esi]
        inc     esi
        or      al,al
        je      .not_found
        cmp     al,ah
        jne     .search
        mov     eax,esi
        dec     eax
        pop     esi
        return
     .not_found:
        xor     eax,eax
        pop     esi
        return
endp


;**********************************************************************************
; StrPos returns a pointer to the first occurence of a pattern string
;   in another string
; Arguments:
;   hPattern - 'pattern' string
;   hString -  string to search
; Returns: a pointer to the pattern string in source , or NULL if pattern string
; doesn't occur in the string to search
;**********************************************************************************
proc StrPos         ; proc StrPos [hString], [hPattern]
begin
        push    ebx ecx edx esi edi     ; esp = esp -20
        mov     esi,[esp+20+8]          ; mov esi,[hPattern]
        mov     edi,[esp+20+4]          ; mov edi,[hString]
        stdcall StrLen, edi
        mov     ebx,eax                 ; now ebx holds lenght of the string to search
        stdcall StrLen, esi
        mov     edx,eax                 ; now edx holds length of the pattern string
        stdcall StrPtr, esi
        mov     esi,eax                 ; put pointer to the pattern str in esi
        stdcall StrPtr,edi
        mov     edi,eax                 ; put pointer to the search str in edi
        lodsb                           ; load first character of the pattern
        mov     ecx,ebx                 ;
        mov     ebx,edx                 ; put str_len(pattern)-1 in ebx
        dec     ebx                     ;
  .search:
        repne   scasb
        jne     .not_found
        cmp     ecx,ebx
        jb      .not_found
        push    edi esi ecx
        or      ebx,ebx                 ; ebx==0 means that we were searching for one
        jz      .got_it                 ; character. We found it, so we stop.
        mov     ecx,ebx
        repe    cmpsb
        jne     .not_match
  .got_it:
        pop     ecx esi edi
        dec     edi
        mov     eax,edi
  .ret:
        pop     edi esi edx ecx ebx
        ret     8
  .not_match:
        pop     ecx esi edi
        jmp     .search
  .not_found:
        xor     eax,eax
        jmp     .ret
endp

;**********************************************************************************
; StrInsert inserts one string into another at specified pos
; Arguments:
;   dest - destination where the source will be inserted (handle only)
;   source -  string to insert
;**********************************************************************************
proc StrInsert      ; proc StrInsert [dest], [source], [pos]
        begin
        push    eax ebx ecx esi edi     ; esp = esp-20
        stdcall StrLen, dword[esp+20+4] ; stdcall StrLen,[dest]
        cmp     eax,dword[esp+20+12]    ; cmp eax,[pos]
        jb      .ret                    ; don't insert a string if pos>StrLen(dest)
        inc     eax
        mov     ecx,eax
        stdcall StrNew                  ; create temporary string...
        mov     ebx,eax                 ; ... and store its handle in ebx
        stdcall StrSetLength, ebx,ecx
        stdcall StrPtr, dword[esp+20+4] ; stdcall StrPtr,[dest]
        mov     esi,eax
        stdcall StrPtr, ebx
        mov     edi,eax
        mov     ecx,dword[esp+20+12]    ; mov ecx,[pos]
        jz      @f
        rep     movsb
  @@:   stdcall StrCat, ebx,dword[esp+20+8]     ; stdcall StrCat, ebx,[source]
        stdcall StrCat, ebx,esi
        mov     eax,dword[esp+24]
        stdcall StrCopy, eax,ebx
        stdcall StrDel, ebx
  .ret:
        pop     edi esi ecx ebx eax
        ret     12
endp

;**********************************************************************************
; Converts strings to Lower Case
; First parameter = String to Convert to lower case
; corrupts eax
;**********************************************************************************
proc StrLCase               ; proc StrLCase [hString]
        begin
        push    edi
        stdcall StrPtr, [esp+4+1*4]
        xchg    edi, eax
._lowercaseloop:
        mov     al, [edi]
        cmp     al, 'A'
        jc      @F
        cmp     al, 'Z'
        ja      @F
        or      byte[edi], 20h
@@:
        cmp     byte[edi],0
        lea     edi, [edi+1]
        jnz     ._lowercaseloop
        pop     edi
        retn    4
endp


;**********************************************************************************
; Converts strings to Upper Case
; First parameter = String to Convert to upper case
; corrupts eax
;**********************************************************************************
proc StrUCase       ; proc StrUCase [hString]
        begin
        push    edi
        stdcall StrPtr, [esp+4+1*4]
        xchg    edi, eax
._uppercaseloop:
        mov     al, [edi]
        cmp     al, 'a'
        jc      @F
        cmp     al, 'z'
        ja      @F
        sub     byte[edi], 20h
@@:
        cmp     byte[edi], 0
        lea     edi, [edi+1]
        jnz     ._uppercaseloop
        pop     edi
        retn    4
endp

;**********************************************************************************
; String copy mmx version for long strings does by copying qword at a time
; First parameter = String destination
; Second parameter = String source
;**********************************************************************************
proc StrCopyMMX     ; proc StrCopyMMX [str1], [str2]
        begin
        push    eax
        push    ebx
        push    ecx
        push    edx
        stdcall StrPtr, [esp+4+4*4]
        xchg    eax, edx
        stdcall StrPtr, [esp+8+4*4]
        mov     ecx,eax
        stdcall StrLen,eax
        stdcall StrSetLength, [esp+4+4*4+4], eax
        mov     eax,ecx
        xor     ecx,ecx
        pxor    MM7, MM7
.MMX_loop:
        movq    MM0, [eax+ecx]
        movq    MM1, MM0
        pcmpeqb MM0, MM7
        packsswb MM0, MM0
        movd    ebx, MM0
        test    ebx, ebx
        jnz     .normal_copy
        movq    [edx+ecx], MM1
        add     ecx, 8
        jmp     .MMX_loop
.normal_copy:
        mov     bl, [eax+ecx]
        mov     [edx+ecx], bl
        inc     ecx
        test    bl, bl
        jnz     .normal_copy
        pop     edx
        pop     ecx
        pop     ebx
        pop     eax
        retn    8
endp

;**********************************************************************************
; StrExtract copies the part of [str] from [index] with lenght in [len]
; Returns handle to new created string.
;**********************************************************************************
proc StrExtract, .string, .index, .len
begin
        push    ebx ecx esi edi
        stdcall StrLen,[.string]
        cmp     eax,[.index]
        jbe     .error
        stdcall StrNew
        mov     ebx,eax
        mov     ecx,[.len]
        stdcall StrSetLength, eax,ecx   ; stdcall StrSetLength, eax,[len]
        stdcall StrPtr, eax
        mov     edi,eax
        stdcall StrPtr, [.string]
        add     eax,[.index]
        mov     esi,eax
    @@: mov     al,[esi]
        mov     [edi],al
        inc     esi
        inc     edi
        or      al,al
        jz      .copied
        dec     ecx
        jnz     @b
        xor     al,al
        mov     [edi],al
  .copied:
        mov     eax,ebx
        pop     edi esi ecx ebx
        return
  .error:
        xor     eax,eax
        pop     edi esi ecx ebx
        return
endp

;**********************************************************************************
; _NumToStr converts the number in eax to the string in any radix approx. [2..26]
; Arguments:
;   [edi] - pointer to the string buffer
;   ecx - radix
;   eax - number to convert.
; There is no parameter check, so be careful.
; returns: edi points to the end of a converted number
;**********************************************************************************
proc _NumToStr
begin
    test  eax,eax
    jns   _NumToStrU
    neg   eax
    mov   byte [edi],"-"
    inc   edi
endp

proc _NumToStrU
begin
    cmp   eax,ecx
    jb    .lessA
    xor   edx,edx
    div   ecx
    push  edx
    call  _NumToStrU
    pop   eax
.lessA:
    cmp   al, 10
    sbb   al, 69h
    das
    stosb
    return
endp

;*****************************************************
; NumToStrF:
;   Converts signed integer value to string.
; NumToStrUF:
;   Converts unsigned integer value to string.
;
; edi - pointer to string buffer
; eax - Number to convert
; ecx - radix from 2 to $ff
; esi - length of the number in chars
;
; returns: edi - pointer to the end of converted num
;
; Note: Don't use 1 as radix.
;*****************************************************
proc NumToStrF
begin
        test    eax,eax
        jns     NumToStrUF
        neg     eax
        mov     byte [edi],'-'
        push    esi
        dec     esi
        add     edi,esi
        push    edi
        jmp     NumToStrUF.loopc
endp

proc NumToStrUF
        begin
        push    esi
        add     edi, esi
        push    edi
        dec     edi
.loopc:
        xor     edx,edx
        div     ecx
        xchg    al,dl
        cmp     al,$0a
        sbb     al,$69
        das
        mov     [edi],al
        dec     edi
        xchg    al,dl
        dec     esi
        jnz     .loopc
        pop     edi
        pop     esi
        return
endp


;***********************************************************
; NumToStr - converts number to any radix.
; num - number to convert
; str - handle of the string. If NULL - creates new string.
; index - Offset in string where to put converted number.
; flags:
;   byte 0 - number of digits if ntsFixedWidth is set.
;   byte 1 - contains radix for the convertion.
;   byte 2,3 - flags.
; Returns:
;   eax - handle of the string (new one or passed in [str])
;   edx - pointer to the string.
;***********************************************************
proc NumToStr, .num, .strng, .index, .flags
.max_len dd ?
.len_tab rb 20      ; table that holds maximum number of digits in given system
        begin
        push    ebx ecx edx esi edi

        mov     [.len_tab+2],32+2       ; binary number - max. 32 digits (+2 bytes for '-' character and NULL terminator)
        mov     [.len_tab+4],16+2       ; quad number - max. 16 digits
        mov     [.len_tab+8],11+2       ; octal number - max. 11 digits
        mov     [.len_tab+10],9+2       ; decimal number - max. 9 digits
        mov     [.len_tab+16],8+2       ; hexadecimal number - max. 8 digits
        movzx   ebx,byte [.flags+1]     ; load radix into ebx
        movzx   eax,byte[.len_tab+ebx]
        mov     [.max_len],eax          ; store max. number of digits
        mov     eax,[.strng]
        or      eax,eax
        jnz     .string_exists
        stdcall StrNew
        mov     [.strng],eax
  .string_exists:
        test    eax,0xffff0000
        jnz     @f                      ; don't resize if [str] isn't a handle
        mov     ebx,eax
        mov     eax,[.max_len]
        add     eax,[.index]
        mov     edx,eax
        stdcall StrLen,ebx
        cmp     eax,edx
        ja      @f                      ; don't resize string if it has enough place for converted number

        stdcall StrSetLength,ebx, edx

  @@:   ; determine which conversion func to use
        mov     eax,[.flags]
        mov     edx,eax
        and     eax,ntsFixedWidth
        jnz     .fixed_width
        mov     eax,edx
        and     eax,ntsUnsigned
        jnz     .unsigned
        mov     ebx,_NumToStr
        jmp     .got_func
  .unsigned:
        mov     ebx,_NumToStrU
        jmp     .got_func

  .fixed_width:
        movzx   esi, byte [.flags]         ; load fixed width into esi
        mov     eax, edx
        and     eax, ntsUnsigned
        jnz     .fixed_unsigned
        mov     ebx,NumToStrF
        jmp     .got_func
  .fixed_unsigned:
        mov     ebx,NumToStrUF
  .got_func:
        stdcall StrPtr, [.strng]
        add     eax,[.index]
        mov     edi,eax
        movzx   ecx,byte [.flags+1]       ; load radix into ecx
        mov     eax, [.num]
        call    ebx                     ; call low-level convertion routine
        mov     eax, [.flags]
        and     eax, ntsZeroTerminated
        jz      .ret
        mov     byte [edi], 0

  .ret:
        pop     edi esi edx ecx ebx
        mov     eax, [.strng]
        return
endp


;-------------------------------------------------
; function StrHash
;   Computes 32 bit hash value from the string.
;   The function is compatible with FASM hash
;   function if OrMask = 0.
;
; Arguments:
;   hString - handle/pointer of the string.
;   OrMask  - every byte from the string will be ORed
;             with this value (byte)
; Return:
;   eax - 32bit hash value.
;-------------------------------------------------
proc StrHashOld, .hString, .OrMask
begin
        push    esi ebx ecx

        stdcall StrPtr, [.hString]
        mov     esi, eax

        xor     ebx, ebx
        xor     eax, eax
.hashloop:
        rol     eax, 12
        mov     ecx, eax
        shr     eax, 8
        and     ecx, 1111b
        or      eax, ecx
        movzx   ecx, byte [esi+ebx]
        jecxz   .endloop
        or      cl, byte [.OrMask]
        add     eax, ecx
        inc     ebx
        jmp     .hashloop

.endloop:
        and     eax,0FFFFFFh
        shl     ebx,24
        or      eax,ebx
        pop     ecx ebx esi
        return
endp


proc StrHash, .hString, .OrMask
begin
        push    esi edi ebx ecx edx

        stdcall StrPtr, [.hString]
        mov     esi, eax

        xor     ebx, ebx
        mov     eax,2166136261          ; FNV offset basis
        xor     ecx, ecx
        mov     edi, 16777619                ; FNV prime
.hashloop:
        mov     cl, [esi+ebx]
        jecxz   .endstring
        inc     bl
        or      cl, byte [.OrMask]
        xor     al,cl                   ; FNV-1a hashing
        mul     edi
        jmp     .hashloop

.endstring:
        mov     edx,eax
        and     eax,0FFFFFFh            ; xor-fold to 24 bits
        shr     edx,24
        xor     eax,edx
        shl     ebx,24                  ; the length of the string
        or      eax,ebx                 ; store length in high 8 bits
        pop     edx ecx ebx edi esi
        return
endp



;-------------------------------------------------------
; function StrToNum
;   Converts specified string into a number
;
; Arguments:
;   hString - handle/pointer of the string containing
;     number to convert. It doesn't have to be ended by
;     NULL, any other character will stop conversion.
;     Number to convert must be decimal.
;
; Return:
;   eax - converted number
;
; Note: in case of failture (first char of given pointer
;   isn't a number) function returns -1.
;-------------------------------------------------------
proc StrToNum, .hString
        begin
        push    ebx edx esi
        xor     ebx,ebx         ; ebx will store our number
        stdcall StrPtr, [.hString]
        mov     esi,eax
        xor     eax,eax
        mov     al,[esi]
        cmp     al,'0'
        jb      .error
        cmp     al,'9'
        jbe     .digit
        jmp     .error
     .digit:
        sub     al,'0'
        add     ebx,eax
        inc     esi
        mov     al,[esi]
        cmp     al,'0'
        jb      .finish
        cmp     al,'9'
        ja      .finish
        mov     edx,ebx         ; multiply ebx by 10
        shl     ebx,3
        add     ebx,edx
        add     ebx,edx
        jmp     .digit
     .finish:
        mov     eax,ebx
        pop     esi edx ebx
        return

     .error:
        xor     eax,eax
        dec     eax
        pop     esi edx ebx
        return
endp

;-------------------------------------------------------
; function StrCharCat
;   Addes specified char to the end of a string
;
; Arguments:
;   hString - string to append
;   char - char to add
;-------------------------------------------------------
proc StrCharCat, .hString, .char
begin
        push    eax ebx ecx
        mov     ebx, [.hString]
        stdcall StrLen, ebx
        mov     ecx, eax
        inc     eax
        stdcall StrSetLength, ebx, eax
;        stdcall StrPtr, ebx                    ; StrSetLength returns a pointer to the string
        add     ecx, eax
        mov     eax, [.char]
        mov     [ecx], al
        inc     ecx
        mov     byte [ecx], 0
        pop     ecx ebx eax
        return
endp

;------------------------------------------------------------
; function StrInsertChar
;   Inserts specified char into given position ot the string
;
; Arguments:
;   hString - string to append
;   char    - char to add
;   pos     - position where to add the char
;-------------------------------------------------------------
proc StrInsertChar, .hString, .char, .pos
        begin
        push    eax ebx ecx
        mov     ebx, [.hString]
        stdcall StrLen, ebx
        cmp     eax, [.pos]
        jb      .finish
        je      .append
        mov     ecx,eax
        inc     eax
        stdcall StrSetLength, ebx, eax
        stdcall StrPtr, ebx
        add     ecx, eax
        mov     ebx, eax
        add     ebx, [.pos]
        mov     byte [ecx+1], 0     ; add NULL-terminator in the end of our string
  .shift:
        mov     al, [ecx-1]
        mov     [ecx], al
        dec     ecx
        cmp     ecx, ebx
        jne     .shift
        mov     eax, [.char]
        mov     [ebx], al
  .finish:
        pop     ecx ebx eax
        return
  .append:
        stdcall StrCharCat, ebx, [.char]
        jmp     .finish
endp





proc StrURLEncode, .hstr
.res dd ?
begin
        push    ebx ecx edx esi edi
        stdcall StrPtr, [.hstr]
        mov     esi, eax

        stdcall StrLen, esi
        mov     ecx, eax
        lea     edx, [2*eax+eax]        ; the encoded string can be max 3x long as original string.

        stdcall StrNew
        mov     [.res], eax
        jecxz   .finish

        stdcall StrSetLength, eax, edx
        mov     edi, eax
        xor     edx, edx
        xor     ebx, ebx

.encode:
        lodsb
        cmp     al, $80
        jae     .store          ; it is a hack, but I hope save enough.

        mov     dl, al
        mov     bl, al
        shr     edx, 5
        and     ebx, $1f
        bt      dword [URLCharTable+4*edx], ebx
        jnc     .store

        mov     ah, al
        mov     al, '%'
        stosb
        mov     al, ah
        shr     al, 4
        cmp     al, $0a
        sbb     al, $69
        das
        stosb
        mov     al, ah
        and     al, $0f
        cmp     al, $0a
        sbb     al, $69
        das

.store:
        stosb
        loop    .encode
.end:
        xor     al, al
        stosb
.finish:
        mov     eax, [.res]
        pop     edi esi edx ecx ebx
        return
endp

; Contains 1 where the character must be % encoded and 0 where it is save to pass it directly
URLCharTable db 11111111b       ;
             db 11111111b       ;
             db 11111111b       ;
             db 11111111b       ; 0..31 -control chars | encoded
             db 11111111b       ; $27 - $20: '&%$#"!   | encoded
             db 11111111b       ; $2f - $28: /.-,+*)(  | encoded
             db 00000000b       ; $37 - $30: 76543210  | not encoded
             db 11111100b       ; $3f - $38: ?>=<;:98  | partially
             db 00000001b       ; $47 - $40: GFEDCBA@  | partially
             db 00000000b       ; $4f - $48: ONMLKJIH  | not encoded
             db 00000000b       ; $57 - $50: WVUTSRQP  | not encoded
             db 11111000b       ; $5f - $58: _^]\[ZYX  | partially
             db 00000001b       ; $67 - $60: gfedcba`  | partially
             db 00000000b       ; $6f - $68: onmlkjih  | not encoded
             db 00000000b       ; $77 - $70: wvutsrqp  | not encoded
             db 11111000b       ; $7f - $78:  ~}|{zyx  | partially
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/drafts/strlibnew.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; ____________________________________________________________________
;|                                                                    |
;| This file is part of the project:                                  |
;|                                                                    |
;| ..::FreshLib::.. - portable, assembler library and GUI toolkit.    |
;|____________________________________________________________________|
;|                                                                    |
;|                          This file                                 |
;|                          _________                                 |
;|   Author:                                                          |
;|                                                                    |
;|   Title: StrLib.asm - OS independent string manipulation library.  |
;|                                                                    |
;|   OS:                                                              |
;|                                                                    |
;|   Notes and changes:                                               |
;|     Uses memory.asm library for memory functions.                  |
;|                                                                    |
;|                                                                    |
;|____________________________________________________________________|


STR_MINSTRLEN = 16      ; 16 bytes minimum string length

; NumToStr flags
ntsSigned = $00000
ntsUnsigned = $10000
ntsZeroTerminated = $20000
ntsFixedWidth     = $40000

ntsBin  = $0200
ntsQuad = $0400
ntsOct  = $0800
ntsDec  = $0a00
ntsHex  = $1000

struc TString {
  .capacity dd ?        ; length of allocated buffer.
  .len      dd ?        ; length of the string.
  label .data byte
}
virtual at -(sizeof.TString)
  TString TString
  sizeof.TString = $-TString
end virtual


struc string [value] {
common
local ..len, ..capacity, ..pad1, ..pad2
      virtual
        align 4
        ..pad1 = $ - $$
      end virtual
      db  ..pad1 dup 0

      dd  ..capacity
      dd  ..len
label . byte
forward
        db  value
common
  ..len = $ - .
      virtual
        align 4
        ..pad2 = $ - $$
      end virtual
      db  ..pad2 dup 0
  ..capacity = $ - .
      dd  0
}


; String format:
;   Let esi points to StrLib string. Then:
;   dword [esi-8] contains allocated memory size for the string.
;   dword [esi-4] contains length of the string in bytes.
;   [esi] .. [esi+length] contains the string itself.
;   at the end of the string, always have at least one dword zero, so it is safe to
;   scan the string by dwords.


; < Library functions >


;______________________________________________________________________________________
;
;  Creates new empty string and returns pointer to it.
;  Arguments:
;    NONE
;  RETURNS:
;    CF=0 -> no error; ebx = pointer to the new created string.
;    CF=1 -> memory allocation error. ebx=0
;______________________________________________________________________________________
proc StrNew
begin
        stdcall GetMem, STR_MINSTRLEN+sizeof.TString+4
        jc      .finish

        lea     eax, [eax+sizeof.TString]
        mov     [eax+TString.capacity], STR_MINSTRLEN

.finish:
        return
endp


;__________________________________________________________________________
;
; Delete string.
; Arguments:
;   .pString - string created with StrNew, or other StrLib procedure.
; Returns:
;   Nothing
;__________________________________________________________________________
proc StrDel, .pString
begin
        push    [.pString]
        sub     dword [esp], sizeof.TString
        call    FreeMem
        return
endp



;__________________________________________________________________________
;
; Duplicates given string, and returns a pointer to new one
; Arguments:
;   .pString - pointer to the string, allocated with StrLib
; Returns:
;   CF=0; eax - pointer to the duplicated string.
;   CF=1; eax - NULL
;__________________________________________________________________________
proc StrDup, .pString
begin
        stdcall StrNew
        jc      .exit

        stdcall StrCopy, eax, [.pString]
        jnc     .exit

        stdcall StrDel, eax
        xor     eax, eax
        stc
.exit:
        return
endp



proc StrDupAsciiZ, .pAsciiZ
begin
        stdcall StrNew
        jc      .exit

        stdcall StrCopyAsciiZ, eax, [.pAsciiZ]
        jnc     .exit

        stdcall StrDel, eax
        xor     eax, eax
        stc
.exit:
        return
endp



;__________________________________________________________________________
;
; proc StrSearchLen, .pString
; Searches to the end of ASCIIZ string and returns the length of the string.
;
; Arguments:
;  pString - pointer to the string.
; Returns:
;  ecx - length of the string in bytes.
;__________________________________________________________________________
proc StrSearchLen, .pString
begin
        mov     ecx, [.pString]
.scan:
        cmp     byte [ecx], 0
        lea     ecx, [ecx+1]
        jne     .scan

        stc
        sbb     ecx, [.pString]
        return
endp


;__________________________________________________________________________
; proc StrSearchLenFast, .pString
; The same as StrSearchLen, but works on dwords and is much faster.
; The string must ends with at least one aligned dword of NULL.
; This is the case with every string from StrLib, but not always with
; system provided strings.
;
; Arguments:
;  pString - pointer to the string.
; Returns:
;  ecx - length of the string in bytes.
;__________________________________________________________________________
proc StrSearchLenFast, .pString
begin
        mov     ecx, [.pString]
.scan:
        cmp     dword [ecx], 0
        lea     ecx, [ecx+4]
        jne     .scan

        lea     ecx, [ecx-4]

; so search back
.byteloop:
        lea     ecx, [ecx-1]
        cmp     byte [ecx], 0
        je      .byteloop

        lea     ecx, [ecx+1]
        sub     ecx, [.pString]
        return
endp





;___________________________________________________________________________
;
; Ensures that the string can take [.capacity] bytes.
; If the function resize the string, the new size is multiple of 4.
;
; Arguments:
;   .pString - string pointer.
;   .capacity - desired string capacity.
; Returns:
;   eax - pointer to the string (can be different than passed in .pString)
;   CF=1 if error allocation. In this case eax still contains pointer, but
;   the capacity is not changed.
;___________________________________________________________________________
proc StrSetCapacity, .pString, .capacity
begin
        push    ecx

        mov     ecx, [.capacity]

        add     ecx, 3 + sizeof.TString + 4
        and     cl, $fc
        cmp     ecx, STR_MINSTRLEN + sizeof.TString + 4
        jae     @f
        mov     ecx, STR_MINSTRLEN + sizeof.TString + 4
@@:
        sub     [.pString], sizeof.TString

        stdcall ResizeMem, [.pString], ecx
        jc      .finish

.sizeok:
        lea     ecx, [ecx-(sizeof.TString+4)]
        mov     [eax], ecx

.finish:
        lea     eax, [eax+sizeof.TString]
        pop     ecx
        return
endp




;_______________________________________________________________________________________
;  Copies source to destination string.
;  Arguments:
;     source - source string. for StrCopyAsciiZ - can be any zero terminated string.
;              for StrCopy, must be strlib string.
;     dest -  destination string. Always strlib string.
;  Returns:
;     eax - pointer to destination string.
;     CF=1 -> error with memory allocation. source is not copied and destination is
;             not changed.
;_______________________________________________________________________________________
proc StrCopyAsciiZ, .dest, .source
begin
        push    ecx esi edi

        mov     esi, [.source]
        stdcall StrSearchLen, esi
        jmp     StrCopy.docopy
virtual
  call StrCopy
end virtual
endp



proc StrCopy, .dest, .source
begin
        push    ecx esi edi

        mov     esi, [.source]
        mov     ecx, [esi+TString.len]

.docopy:
        stdcall StrSetCapacity, [.dest], ecx
        jc      .finish

        mov     edi, eax
        mov     [eax+TString.len], ecx
        push    ecx
        shr     ecx, 2
        rep movsd
        pop     ecx
        and     ecx, 3
        rep movsb

        mov     dword [edi], ecx
        add     edi, 3
        and     edi, $fffffffc
        mov     dword [edi], ecx
        clc

.finish:
        pop     edi esi ecx
        return
endp




proc StrCopyPart, .dest, .source, .pos
begin
        push    ecx esi edi

        mov     eax, [.dest]
        mov     esi, [.source]
        mov     ecx, [esi+TString.len]
        cmp     [.pos], ecx
        jae     .finish

        sub     ecx, [.pos]
        add     esi, [.pos]

        stdcall StrSetCapacity, [.dest], ecx
        jc      .finish

        mov     edi, eax
        mov     [eax+TString.len], ecx

        push    ecx
        shr     ecx, 2
        rep movsd
        pop     ecx
        and     ecx, 3
        rep movsb

        mov     dword [edi], ecx
        add     edi, 3
        and     edi, $fffffffc
        mov     dword [edi], ecx
        clc

.finish:
        pop     edi esi ecx
        return
endp


;__________________________________________________________________________________
; Splits the string on two strings, at position [.pos]
; Arguments:
;   .pString - pointer to string to be splitted.
;   .pos     - position where to split the string.
; Returns:
;   eax - pointer to the new created string with second part of the string.
;         the original string does not reallocate memory and it's capacity
;         and the pointer will remains the same.
;__________________________________________________________________________________

proc StrSplit, .pString, .pos
begin
        push    ecx

        stdcall StrNew

        mov     ecx, [.pString]
        mov     ecx, [ecx+TString.len]
        cmp     [.pos], ecx
        jae     .ready

        stdcall StrCopyPart, eax, [.pString], [.pos]

        mov     ecx, [.pString]
        push    [.pos]
        pop     [ecx+TString.len]  ; new length of the string.

        add     ecx, [ecx+TString.len]

        mov     dword [ecx], 0
        add     ecx, 3
        and     cl, $fc
        mov     dword [ecx], 0

.ready:
        pop     ecx
        return
endp








;_______________________________________________________________________________________
; Compares two strings - case sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;_______________________________________________________________________________________
proc StrCompCase, .str1, .str2
begin
        push    eax ecx esi edi

        mov     esi, [.str1]
        mov     edi, [.str2]

        cmp     esi, 0
        je      .noteq

        cmp     edi, 0
        je      .noteq

        mov     ecx, [esi+TString.len]
        cmp     ecx, [edi+TString.len]
        jne     .noteq

        repe cmpsb
        jne     .noteq

        stc
        pop     edi esi ecx eax
        return

.noteq:
        clc
        pop     edi esi ecx eax
        return
endp


;_______________________________________________________________________________________
; Compares two strings - case NOT sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;_______________________________________________________________________________________
proc StrCompNoCase, .str1, .str2
begin
        push    eax esi edi
        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax

.cmploop:
        mov     al, [esi]
        lea     esi, [esi+1]
        mov     ah, [edi]
        lea     edi, [edi+1]

        test    al,al
        jz      .eos
        test    ah,ah
        jz      .noteq

        or      eax, $2020
        cmp     al, ah
        je      .cmploop

.noteq:
        clc
        pop     edi esi eax
        return

.eos:
        test    ah,ah
        jnz     .noteq

        stc
        pop     edi esi eax
        return
endp





;__________________________________________________________________________________
; StrCat appends one string to another
; Arguments:
;   dest - destination string (handle only)
;   source - source string
; Returs:
;   eax - pointer to destination string.
;   CF - error flag.
;__________________________________________________________________________________
proc StrCat, .dest, .source
begin
        push    ecx esi edi

        mov     eax, [.dest]
        mov     esi, [.source]
        mov     edi, eax

        mov     ecx, [esi+TString.len]
        add     ecx, [edi+TString.len]
        cmp     ecx, [edi+TString.capacity]
        jbe     .sizeok

        stdcall StrSetCapacity, edi, ecx
        jc      .finish
        mov     edi, eax

.sizeok:
        xchg    [edi+TString.len], ecx
        add     edi, ecx

        mov     ecx, [esi+TString.len]
        push    ecx
        shr     ecx, 2

        rep movsd
        pop     ecx
        and     ecx, 3
        rep movsb

        mov     dword [edi], 0

        clc

.finish:
        pop     edi esi ecx
        return
endp


;__________________________________________________________________________________
; StrCharPos returns a pointer to the first occurence of a given char
;   in specified string
; Arguments:
;   Char - char to look for
;   hString -  string to search
; Returns:
;   ebx - offset of the char in the string.
;   CF=1 if the char is found.
;   CF=0 if the char is not found. EBX is not changed in this case.
;__________________________________________________________________________________
proc StrPosChar, .pString, .char
begin
        push    eax ecx ebx

        mov     ebx, [.pString]
        mov     ecx, [esi+TString.len]

        mov     al, byte [.char]

.search:
        cmp     [ebx], al
        je      .found
        lea     ebx, [ebx+1]
        dec     ecx
        jnz     .search

        clc
        pop     ebx ecx eax
        return

.found:
        sub     ebx, [.pString]
        lea     esp, [esp+4]
        stc
        pop     ecx eax
        return
endp


;__________________________________________________________________________________
; StrPos returns the offset of the first occurence of a pattern string
;   in another string
; Arguments:
;   hPattern - 'pattern' string
;   hString -  string to search
; Returns: a pointer to the pattern string in source , or NULL if pattern string
; doesn't occur in the string to search
;__________________________________________________________________________________
proc StrPos, .pString, .pPatern
begin
        push    esi edi eax ecx ebx

        mov     esi, [.pString]
        mov     edi, [.pPatern]

        mov     ecx, [esi+TString.len]
        mov     ebx, [edi+TString.len]
        test    ebx, ebx
        jz      .found

        cmp     ebx, ecx
        ja      .notfound       ; the parern is longer than string.

        sub     ecx, ebx
        dec     esi
        lea     ecx, [ecx+2]

.outer:
        dec     ecx
        jz      .notfound

        mov     ebx, [edi+TString.len]
        lea     esi, [esi+1]

.inner:
        mov     al, [esi+ebx-1]
        cmp     al, [edi+ebx-1]
        jne     .outer

        dec     ebx
        jnz     .inner

.found:
        sub     esi, [.pString]
        mov     [esp], esi
        stc
        pop     ebx ecx eax edi esi
        return

.notfound:
        clc
        pop     ebx ecx eax edi esi
        return
endp




;__________________________________________________________________________________
; StrInsert inserts one string into another at specified pos
; Arguments:
;   dest - destination where the source will be inserted.
;   source -  string to insert
;   pos    - where to insert.
; Returns:
;   eax - pointer to destination string.
;__________________________________________________________________________________
proc StrInsert, .dest, .source, .pos
begin
        stdcall StrSplit, [.dest], [.pos]
        push    eax eax
        stdcall StrCat, [.dest], [.source]
        stdcall StrCat, eax ; source from the stack.
        stdcall StrDel; from the stack.
        return
endp



;__________________________________________________________________________________
; Converts strings to Lower Case
; First parameter = String to Convert to lower case
; corrupts eax
;__________________________________________________________________________________
proc StrLCase, .ptrString
begin
        push    eax edi
        mov     edi, [.ptrString]
        mov     eax, [edi+TString.len]
        dec     edi
.loop:
        inc     edi
        dec     eax
        js      .endstring

        cmp     byte [edi], 'A'
        jb      .loop
        cmp     byte [edi], 'Z'
        ja      .loop

        or      byte [edi], 20h
        jmp     .loop

.endstring:
        pop     edi eax
        return
endp


;__________________________________________________________________________________
; Converts strings to Upper Case
; First parameter = String to Convert to upper case
; corrupts eax
;__________________________________________________________________________________
proc StrUCase, .ptrString
begin
        push    eax edi
        mov     edi, [.ptrString]
        mov     eax, [edi+TString.len]
        dec     edi
.loop:
        inc     edi
        dec     eax
        js      .endstring

        cmp     byte [edi], 'a'
        jb      .loop
        cmp     byte [edi], 'z'
        ja      .loop

        and     byte [edi], ~20h
        jmp     .loop

.endstring:
        pop     edi eax
        return
endp




;__________________________________________________________________________________
; _NumToStr converts the number in eax to the string in any radix approx. [2..26]
; Arguments:
;   edi - pointer to the string buffer
;   ecx - radix
;   eax - number to convert.
; There is no parameter check, so be careful.
; returns: edi points to the end of a converted number
;__________________________________________________________________________________
proc _NumToStr
begin
    test  eax, eax
    jns   _NumToStrU
    neg   eax
    mov   byte [edi],"-"
    inc   edi
endp


proc _NumToStrU
begin
    cmp   eax,ecx
    jb    .lessA

    xor   edx,edx
    div   ecx
    push  edx
    call  _NumToStrU
    pop   eax

.lessA:
    cmp   al, 10
    sbb   al, 69h
    das
    stosb
    return
endp

;_____________________________________________________
; NumToStrF:
;   Converts signed integer value to string.
; NumToStrUF:
;   Converts unsigned integer value to string.
;
; edi - pointer to string buffer
; eax - Number to convert
; ecx - radix from 2 to 26
; esi - length of the number in chars
;
; returns: edi - pointer to the end of converted num
;
; Note: Don't use 1 as radix.
;_____________________________________________________
proc NumToStrF
begin
        test    eax,eax
        jns     NumToStrUF
        neg     eax
        mov     byte [edi],'-'
        push    esi
        dec     esi
        add     edi,esi
        push    edi
        jmp     NumToStrUF.loopc
endp

proc NumToStrUF
        begin
        push    esi
        add     edi, esi
        push    edi
        dec     edi
.loopc:
        xor     edx,edx
        div     ecx
        xchg    al,dl
        cmp     al,$0a
        sbb     al,$69
        das
        mov     [edi],al
        dec     edi
        xchg    al,dl
        dec     esi
        jnz     .loopc
        pop     edi
        pop     esi
        return
endp


;___________________________________________________________
; NumToStr - converts number to any radix.
; num - number to convert
; str - handle of the string. If NULL - creates new string.
; index - Offset in string where to put converted number.
; flags:
;   byte 0 - number of digits if ntsFixedWidth is set.
;   byte 1 - contains radix for the convertion.
;   byte 2,3 - flags.
; Returns:
;   eax - handle of the string (new one or passed in [str])
;   edx - pointer to the string.
;___________________________________________________________
proc NumToStr, .num, .strng, .index, .flags
.max_len dd ?
.len_tab rb 20      ; table that holds maximum number of digits in given system
begin
        push    ebx ecx edx esi edi

        mov     [.len_tab+2],32+2       ; binary number - max. 32 digits (+2 bytes for '-' character and NULL terminator)
        mov     [.len_tab+4],16+2       ; quad number - max. 16 digits
        mov     [.len_tab+8],11+2       ; octal number - max. 11 digits
        mov     [.len_tab+10],9+2       ; decimal number - max. 9 digits
        mov     [.len_tab+16],8+2       ; hexadecimal number - max. 8 digits
        movzx   ebx,byte [.flags+1]     ; load radix into ebx
        movzx   eax,byte[.len_tab+ebx]
        mov     [.max_len],eax          ; store max. number of digits
        mov     eax,[.strng]
        or      eax,eax
        jnz     .string_exists
        stdcall StrNew
        mov     [.strng],eax

  .string_exists:
        test    eax,0xffff0000
        jnz     @f                      ; don't resize if [str] isn't a handle
        mov     ebx,eax
        mov     eax,[.max_len]
        add     eax,[.index]
        mov     edx,eax
        stdcall StrSearchLen, ebx
        cmp     eax,edx
        ja      @f                      ; don't resize string if it has enough place for converted number

        stdcall StrSetLength,ebx, edx

  @@:   ; determine which conversion func to use
        mov     eax,[.flags]
        mov     edx,eax
        and     eax,ntsFixedWidth
        jnz     .fixed_width
        mov     eax,edx
        and     eax,ntsUnsigned
        jnz     .unsigned
        mov     ebx,_NumToStr
        jmp     .got_func
  .unsigned:
        mov     ebx,_NumToStrU
        jmp     .got_func

  .fixed_width:
        movzx   esi, byte [.flags]         ; load fixed width into esi
        mov     eax, edx
        and     eax, ntsUnsigned
        jnz     .fixed_unsigned
        mov     ebx,NumToStrF
        jmp     .got_func
  .fixed_unsigned:
        mov     ebx,NumToStrUF
  .got_func:
        stdcall StrPtr, [.strng]
        add     eax,[.index]
        mov     edi,eax
        movzx   ecx,byte [.flags+1]       ; load radix into ecx
        mov     eax, [.num]
        call    ebx                     ; call low-level convertion routine
        mov     eax, [.flags]
        and     eax, ntsZeroTerminated
        jz      .ret
        mov     byte [edi], 0

  .ret:
        pop     edi esi edx ecx ebx
        mov     eax, [.strng]
        return
endp



;-------------------------------------------------------
; function StrToNum
;   Converts specified string into a number
;
; Arguments:
;   hString - handle/pointer of the string containing
;     number to convert. It doesn't have to be ended by
;     NULL, any other character will stop conversion.
;     Number to convert must be decimal.
;
; Return:
;   eax - converted number
;
; Note: in case of failture (first char of given pointer
;   isn't a number) function returns -1.
;-------------------------------------------------------
proc StrToNum, .hString
begin
        push    ebx edx esi
        xor     ebx,ebx         ; ebx will store our number
        stdcall StrPtr, [.hString]
        mov     esi,eax
        xor     eax,eax
        mov     al,[esi]
        cmp     al,'0'
        jb      .error
        cmp     al,'9'
        jbe     .digit
        jmp     .error
     .digit:
        sub     al,'0'
        add     ebx,eax
        inc     esi
        mov     al,[esi]
        cmp     al,'0'
        jb      .finish
        cmp     al,'9'
        ja      .finish
        mov     edx,ebx         ; multiply ebx by 10
        shl     ebx,3
        add     ebx,edx
        add     ebx,edx
        jmp     .digit
     .finish:
        mov     eax,ebx
        pop     esi edx ebx
        return

     .error:
        xor     eax,eax
        dec     eax
        pop     esi edx ebx
        return
endp


;-------------------------------------------------------
; function StrCharCat
;   Addes up to 4 chars to the end of a string.
;
; Arguments:
;   ptrString - string to append
;   char - char(s) to add
; Returns
;   eax: pointer to the string.
;-------------------------------------------------------
proc StrCatChar, .ptrString, .char
begin
        push    ebx ecx

        mov     eax, [.ptrString]
        mov     ecx, [eax+TString.len]
        lea     ebx, [ecx+4]
        cmp     ebx, [eax+TString.capacity]
        jbe     .sizeok

        stdcall StrSetCapacity, eax, ebx

        pushd   [.char]
        popd    [eax+ecx]
        xor     ebx, ebx
        mov     [eax+ecx+4], ebx
        dec     ecx
.len:
        inc     ecx
        cmp     [eax+ecx], bl
        jne     .len

        mov     [eax+TString.len], ecx
        pop     ecx ebx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/drafts/tests/MainForm.frm.

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
;<ff
Window frmMain, 3, 0, 'TForm', 'Tiny GUI application using TForm', $16080000, $0, 0, 339, 199, 320, 240, MainFormWinProc;
Window NONE, 0, 0, 'BUTTON', 'Button', $50000000, $0, 0, 96, 40, 64, 25, 0;
Window NONE, 0, 0, 'STATIC', 'Label', $50001200, $0, 101, 136, 88, 80, 16, 0;
Window NONE, 0, 0, 'STATIC', 'Result:', $50000000, $0, 0, 136, 72, 88, 16, 0;
Window NONE, 0, 0, 'STATIC', 'Time [ms]', $50000000, $0, 0, 16, 72, 88, 16, 0;
Window NONE, 2, 0, 'STATIC', 'Label', $50001200, $0, 100, 16, 88, 80, 16, 0;
;ff>
uglobal
  pointer dd ?
endg



proc StrProc1, .ptr

begin
        push    edi ecx

        xor     eax, eax
        or      ecx, -1
        mov     edi, [.ptr]

        repnz scasb

        not     ecx
        dec     ecx
        mov     eax, ecx

        pop     ecx edi
        return
endp



proc StrProc2, .ptr
begin
        mov     eax, [.ptr]

.loop:
        cmp     byte [eax], 0
        lea     eax, [eax+1]
        jne     .loop

        stc
        sbb     eax, [.ptr]
        return
endp




proc StrProc3, .ptr
begin
        push    ebx ecx edx esi edi

        mov     edi, $7f7f7f7f
        mov     ecx, $80808080

        mov     esi, [.ptr]

.scan:
        mov     eax, [esi]
        mov     edx, [esi+4]

        and     eax, edi
        and     edx, edi

        add     eax, edi
        add     edx, edi

        or      eax, [esi]
        or      edx, [esi+4]

        and     eax, ecx
        and     edx, ecx

        and     eax, edx
        add     esi, 8

        cmp     eax, ecx
        je      .scan

.found:
        lea     eax, [esi-9]

; so search by bytes
.byteloop:
        lea     eax, [eax+1]
        cmp     byte [eax], 0
        jne     .byteloop

        sub     eax, [.ptr]

        pop     edi esi edx ecx ebx
        return
endp





proc StrProc4, .pString
begin
        mov     eax, [.pString]
.scan:
        cmp     dword [eax], 0
        lea     eax, [eax+4]
        jne     .scan

        lea     eax, [eax-4]

; so search back
.byteloop:
        lea     eax, [eax-1]
        cmp     byte [eax], 0
        je      .byteloop

        lea     eax, [eax+1]
        sub     eax, [.pString]
        return
endp




proc StrProc5, .ptr
begin
        push    edx esi

        mov     esi, [.ptr]
.scan:
        mov     eax, [esi]
        mov     edx, [esi+4]

        and     eax, $7f7f7f7f
        and     edx, $7f7f7f7f

        add     eax, $7f7f7f7f
        add     edx, $7f7f7f7f

        or      eax, [esi]
        or      edx, [esi+4]

        and     eax, $80808080
        and     edx, $80808080

        and     eax, edx
        add     esi, 8

        cmp     eax, $80808080
        je      .scan

        lea     eax, [esi-9]

; so search by bytes
.byteloop:
        lea     eax, [eax+1]
        cmp     byte [eax], 0
        jne     .byteloop

        sub     eax, [.ptr]

        pop     esi edx
        return
endp


proc StrProc6, .ptr
begin
        push    ecx edx esi edi

        mov     eax, [.ptr]
.scan:
        mov     ecx, [eax]
        mov     edx, [eax+4]

        lea     eax, [eax+8]

        lea     esi, [ecx-$01010101]
        lea     edi, [edx-$01010101]

        not     ecx
        not     edx

        and     esi, ecx
        and     edi, edx

        and     esi, $80808080
        and     edi, $80808080

        or      esi, edi
        jz      .scan

        sub     eax, 9

; byte 0 was found: so search by bytes.
.byteloop:
        lea     eax, [eax+1]
        cmp     byte [eax], 0
        jne     .byteloop

        sub     eax, [.ptr]

        pop     edi esi edx ecx
        return
endp



proc StrProc7, .ptr
begin
        push    ebx ecx

        mov     eax, [.ptr]

.scan:
        mov     ebx, [eax]
        lea     eax, [eax+4]

        lea     ecx, [ebx-$01010101]
        not     ebx
        and     ecx, ebx
        and     ecx, $80808080
        jz      .scan

        lea     eax, [eax-5]

; so search by bytes
.byteloop:
        inc     eax
        cmp     byte [eax], 0
        jne     .byteloop

        sub     eax, [.ptr]

        pop     ecx ebx
        return
endp












winproc MainFormWinProc
begin


ondefault
        stc
        return




onmessage WM_COMMAND

        invoke  GetProcessHeap
        invoke  HeapAlloc, eax, HEAP_ZERO_MEMORY, 1000000

        mov     [pointer], eax

        mov     edi, eax
        mov     ecx, 985000 / 4
        or      eax, -1

        rep stosd
        mov     ecx, 29
        rep stosb


        invoke  GetTickCount
        push    eax

        mov     ecx, 1000

.loop1:
        stdcall StrProc7, [pointer]
        loop    .loop1

        pop     ebx
        push    eax

        invoke  GetTickCount
        sub     eax, ebx

        stdcall SetNumber, [.hwnd], 100, eax

        pop     eax
        stdcall SetNumber, [.hwnd], 101, eax

        invoke  GetProcessHeap
        invoke  HeapFree, eax, 0, [pointer]

        clc
        return


endwp





proc SetNumber, .hwnd, .id, .number
begin
        pushad

        stdcall NumToStr, [.number], 0, 0, ntsDec or ntsUnsigned or ntsZeroTerminated
        push    eax
        stdcall StrPtr, eax
        invoke  SendDlgItemMessage, [.hwnd], [.id], WM_SETTEXT, 0, eax
        stdcall StrDel ; from the stack

        popad
        return
endp



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































































































































































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/drafts/tests/README.TXT.

1
2
3
4
5
6
7
8
9
10
11
Atom 270 1.6GHz (eeepc 901HA)

Proc1 - [repnz scasb]           -       2380ms
Proc2 - [cmp byte [eax],0]      -       3000ms
Proc3 - [$7f/$80 qword regs]    -       1078ms
Proc4 - [cmp dword[eax],0]      -        828ms
Proc5 - [$7f/$80 qword const]   -       1080ms
Proc6 - [$01/$80 qword const]   -       1000ms
Proc7 - [$01/$80 dword const]   -       1297ms

Proc2 is interesting.
<
<
<
<
<
<
<
<
<
<
<






















Deleted freshlib/_trash/SurplusSources/drafts/tests/TinyGUI.asm.

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
format PE GUI 4.0
entry Start

include '%finc%\win32\win32a.inc'
include '%finc%\libs\strlib.inc'

include "%finc%\libs\msgutils.inc"
include "%finc%\libs\tform.inc"
include "%finc%\libs\parents.inc"
include "%finc%\libs\templates.inc"

include "%finc%\libs\msgutils.asm"
include "%finc%\libs\tform.asm"
include "%finc%\libs\parents.asm"
include "%finc%\libs\templates.asm"

include '%finc%\libs\strlib.asm'


include "MainForm.frm"

uglobal
  hInstance dd ?
  hHeap     dd ?
  hMainForm dd ?
endg

Start:
        invoke  GetModuleHandle,0
        mov     [hInstance],eax
        invoke  GetProcessHeap
        mov     [hHeap], eax

        InitializeAll

        stdcall CreateForm, frmMain, NULL
        xor     eax, eax
        test    ebx, ebx
        jz      .terminate

        mov     [hMainForm], ebx

.run:
        call    ProcessMessages
        jc      .terminate

        invoke  WaitMessage
        jmp     .run

.terminate:
        push    eax
        FinalizeAll
        invoke  ExitProcess ; exit code from the stack.

data import
  ImportLib kernel32, user32, gdi32,         \
            comctl32, comdlg32, shell32,     \
            ole32, advapi32
end data

IncludeAllGlobals
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































Deleted freshlib/_trash/SurplusSources/drafts/tests/TinyGUI.fpr.

cannot compute difference between binary files

Deleted freshlib/_trash/SurplusSources/macroses.inc.

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
;*************************************************************
;* macroses.inc
;*
;* This file contains some common data structures and
;* constants. It not contains any data or
;* code.
;*
;* You must include somewhere in the begining of the program.
;*
;* You can use this work for any purpos, only don't forget to
;* write somewhere in docs: "Based on work of John Found" or
;* something similar. :)
;*
;* '2003 John Found
;*************************************************************

macro icon group, [label, icon_file, index] {
  common
    local count

    count = 0
  forward
    local data,size,position

    load size dword from icon_file:$0e + $10 * index  ; size of icon
    load position dword from icon_file:$12 + $10 * index  ; position

    label dd RVA data,size, 0, 0

    data file icon_file:position,size

    count = count + 1

  common
    local header

    align 4
    group dd RVA header,6+count*14,0,0
    header dw 0,1,count

  forward

    file icon_file: 6+index*16, 12
    dw label#.resid

  common
    align 4

}



macro cursor [group,_label,cursor_file] {
  forward
    local _header, _data,_size,_position,_hotX, _hotY, _xsize, _ysize

    load _xsize     byte  from cursor_file:$06
    load _ysize     byte  from cursor_file:$07
    load _hotX	    word  from cursor_file:$0a
    load _hotY	    word  from cursor_file:$0c
    load _size	    dword from cursor_file:$0e
    load _position  dword from cursor_file:$12

    align 4

    group   dd	  RVA _header, $14, 0, 0

    _header dw	  0, 2, 1
	    dw	  _xsize, _ysize
	    dw	  $1			 ; Planes ???
	    dw	  $00			  ; Bit count ???
	    dd	  _size+4		     ; Resource len

    filter_id = RVA _label

	    dw	  _label#.resid

    _label dd RVA _data, _size+4, 0, 0

    _data dw _hotX, _hotY
	    file    cursor_file:_position,_size
}








struc TInitCommonControlsEx Flg {
  .dwSize: dd .size	    ; size of this structure
  .dwICC:  dd Flg	    ; flags indicating which classes to be initialized
  .size = $ - .dwSize
}


struc TMenuItemInfo {
  .cbSize	 dd  .size
  .fMask	 dd  ?
  .fType	 dd  ?
  .fState	 dd  ?
  .wID		 dd  ?
  .hSubMenu	 dd  ?
  .hBmpChecked	 dd  ?
  .hBmpUnchecked dd  ?
  .dwItemData	 dd  ?
  .dwTypeData	 dd  ?
  .cch		 dd  ?
  .size 	 =   $ - .cbSize
}


virtual at 0
  TMenuItemInfo TMenuItemInfo
end virtual



struc  TMeasureItemStruct {
  .CtlType    dd ?
  .CtlID      dd ?
  .itemID     dd ?
  .itemWidth  dd ?
  .itemHeight dd ?
  .itemData   dd ?

  .size = $ - .CtlType
}

virtual at 0
  TMeasureItemStruct TMeasureItemStruct
end virtual


struc	TDrawItemStruct {
  .CtlType     dd ?
  .CtlID       dd ?
  .itemID      dd ?
  .itemAction  dd ?
  .itemState   dd ?
  .hwndItem    dd ?
  .hDC	       dd ?
  .rectItem    RECT
  .itemData    dd ?

  .size = $ - .CtlType
}

virtual at 0
  TDrawItemStruct TDrawItemStruct
end virtual




struc TLogBrush Color {
  .lbStyle    dd    BS_SOLID
  .lbColor    dd    Color
  .lbHatch    dd    ?
}


struc TWindowClass AStyle, AWinProc, ABackground, AClassName
 {
   .style	  dd AStyle
   .lpfnWndProc   dd AWinProc
   .cbClsExtra	  dd 0
   .cbWndExtra	  dd 0
   .hInstance	  dd ?
   .hIcon	  dd ?
   .hCursor	  dd ?
   .hbrBackground dd ABackground
   .lpszMenuName  dd 0

   if AClassName eqtype ''
     .lpszClassName dd .ClassName
     .ClassName   db AClassName,0
   else
     .lpszClassName dd AClassName
     .ClassName = AClassName
   end if
 }


struc TLogBrush Color {
  .lbStyle    dd    BS_SOLID
  .lbColor    dd    Color
  .lbHatch    dd    ?
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































































































































































































































































Deleted freshlib/_trash/SurplusSources/qsort.asm.

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
QuickSortLib:

;****************************************************
; Quick sort of the array in the memory.
;
;  ptrArray       - pointer to the memory array.
;  ElementSize    - size of one array element in bytes.
;  iBegin         - index of the first element
;  iEnd           - index of the last element
;  ptrCompareProc - pointer to procedure that compares two elements.
;
; ptrCompareProc have interface:
;  proc CompareSomething, ptrElement1, ptrElement2
;    returns: c=1 if elements are not properly sorted.
;             c=0 if elements are sorted, i.e.
;                 element1 should be before element2
;****************************************************


proc QSort, ptrArray, ElementSize, iBegin, iEnd, ptrCompareProc
begin
        push    esi edi ebx
        mov     esi, [ptrArray]
        mov     edi, [ptrCompareProc]
        mov     ebx, [ElementSize]

        stdcall DoQSort, [iBegin], [iEnd]
        pop     ebx edi esi
        return
endp

;*****************************************************
; Procedure for internal call from QSort procedure.
;*****************************************************
proc DoQSort, Left, Right
begin
        push    ecx

        mov     ecx, [Left]     ; i variable
        mov     eax, ecx
        mov     edx, [Right]    ; j variable
        add     eax, edx
        sar     eax, 1
        imul    eax, ebx
        imul    ecx, ebx
        imul    edx, ebx
        add     eax, esi
        add     ecx, esi
        add     edx, esi

.repeat:
        sub     ecx, ebx
        add     edx, ebx

.whylei:
        add     ecx, ebx
        stdcall edi, ecx, eax
        jnc     .whylei

.whylej:
        sub     edx, ebx
        stdcall edi, eax, edx
        jnc     .whylej

        cmp     edx, ecx
        jl      .next

        call    SwapElements

        push    edx
        cmp     eax, ecx
        je      @f
        mov     [esp], ecx
        cmp     eax, edx
        je      @f

        mov     [esp], eax
@@:
        pop     eax

        add     ecx, ebx
        sub     edx, ebx

.next:
        cmp     ecx, edx
        jle     .repeat

        mov     eax, edx
        sub     eax, esi
        cdq
        idiv    ebx

        cmp     [Left], eax
        jge     .leftok

        stdcall DoQSort, [Left], eax

.leftok:
        mov     eax, ecx
        sub     eax, esi
        cdq
        idiv    ebx

        cmp     eax, [Right]
        jge     .rightok

        stdcall DoQSort, eax, [Right]

.rightok:
        pop     ecx
        return
endp



;********************************************
; Swaps two elements of the array with
; pointers in:
;   Element1 - ecx
;   Element2 - edx
;   ElementSize - ebx
;********************************************
proc SwapElements
begin
        push    esi eax

        xor     esi, esi
.loop:
        mov     al, [ecx+esi]
        xchg    al, [edx+esi]
        mov     [ecx+esi], al

        inc     esi
        cmp     esi, ebx
        jne     .loop

        pop     eax esi
        return
endp




proc CompareIntAscending, ptrElement1, ptrElement2
begin
        push    eax esi edi

        mov     esi, [ptrElement1]
        mov     edi, [ptrElement2]

        mov     eax, [esi]
        cmp     eax, [edi]
        jl      .qfalse

        stc
        pop     edi esi eax
        return


.qfalse:
        clc
        pop     edi esi eax
        return
endp



DispSize 'QSort lib', $ - QuickSortLib
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































Deleted freshlib/_trash/readme.txt.

1
2
3
4
5
6
7
8
9
10
So, this is very early version of "FreshLib", that
is highly portable library for Fresh and FASM
development.

Even now, you can create simple applications, portable
between Win32 and Linux simply with one-click change in
project options.

The test project, that uses FreshLib is "TestFreshLib.fpr"
You can compile and run it as Windows or as Linux application.
<
<
<
<
<
<
<
<
<
<




















Deleted freshlib/compiler/Linux/executable.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Executable file formating macro library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

TargetOS equ Linux

macro _BinaryType type {
  if type eq GUI
    format ELF executable 3
    entry start
  end if

  if type eq console
    format ELF executable 3
    entry start
  end if

  if type eq DLL
    format ELF executable  ; is it correct???
  end if

  segment readable writeable executable
}


macro _AllDataSection {
segment readable writeable
IncludeAllGlobals
}

macro _AllDataEmbeded {
IncludeAllGlobals
}


macro _AllImportSection {
segment interpreter readable
\include '%lib%/imports/allimports.asm'
}

macro _AllImportEmbeded {
segment interpreter readable
\include '%lib%/imports/allimports.asm'
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































Deleted freshlib/compiler/Win32/executable.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Executable file formating macro library.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

TargetOS equ Win32

macro _BinaryType type {
  if type eq GUI
    format PE GUI 4.0
    entry start
  end if

  if type eq console
    format PE Console 4.0
    entry start
  end if

  if type eq DLL
    format PE GUI 4.0 DLL
    entry EntryPoint
  end if

  section '.code' code readable writeable executable
}


macro _AllDataSection {
  section '.data' data readable writeable
  IncludeAllGlobals
}


macro _AllDataEmbeded {
  IncludeAllGlobals
}


macro _AllImportSection {
  section '.idata' import readable
  \include '%lib%/imports/allimports.asm'
}


macro _AllImportEmbeded {
  data import
  \include '%lib%/imports/allimports.asm'
  end data
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































Deleted freshlib/compiler/executable.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Executable file formating macro library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Includes OS dependent versions of the library.
;_________________________________________________________________________________________

include '%TargetOS%/executable.inc'

macro module name {
  ___StartLibAddress = $
  ___LibraryName equ name
}

macro endmodule {
  DispSize ___LibraryName, $-___StartLibAddress
  restore ___LibraryName
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































Deleted freshlib/data/Linux/utf8.asm.

Deleted freshlib/data/ToBeRemoved/StrLibOS.asm.

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
;*******************************************************************************
; Get the text of the [Control] using WM_GETTEXT and put it to the string with
; handle (only) in [string].
;
; if [string] = NULL creates new string and returns the handle.
; if [string] <> NULL just copyes the text.
;*******************************************************************************
proc GetControlText, .Control, .string
.len dd ?
begin
        push    ebx ecx edx

        mov     eax, [.string]
        test    eax,eax
        jnz     @f
        stdcall StrNew
@@:
        mov     ebx, eax

        invoke  SendMessage, [.Control], WM_GETTEXTLENGTH, 0, 0
        mov     [.len], eax
        stdcall StrSetCapacity, ebx, eax
        jc      .error

        push    eax
        add     [.len], 1
        invoke  SendMessage, [.Control], WM_GETTEXT, [.len], eax
        pop     ecx
        mov     [ecx+string.len], eax
        mov     eax, ebx
        clc

.error:
        pop     edx ecx ebx
        return
endp





;*******************************************************************************
; Sets the text in control using WM_SETTEXT from string with handle or pointer
; in [string].
;*******************************************************************************
proc SetControlText, .Control, .string
begin
        push    eax ecx edx
        stdcall StrPtr, [.string]
        invoke  SendMessage, [.Control], WM_SETTEXT, 0, eax
        pop     edx ecx eax
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































Deleted freshlib/data/Win32/utf8.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Library for converting UTF8 to and from WideChar
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


;-----------------------------------------------------------
; Returns:
;    eax - pointer to the widechar string.
;    ecx - length of the widechar string in characters.
;-----------------------------------------------------------
proc utf8ToWideChar, .hString
begin
        push    edx edi

        stdcall StrLen, [.hString]
        mov     ecx, eax

        mov     edx, eax
        shl     edx, 2
        stdcall GetMem, edx
        mov     edi, eax

        stdcall StrPtr, [.hString]

        sar     edx, 1
        invoke  MultiByteToWideChar, CP_UTF8, 0, eax, ecx, edi, edx
        mov     ecx, eax
        mov     eax, edi

        pop     edi edx
        return
endp




proc WideCharToUtf8, .ptrWideChar
begin
        push    ebx ecx edx edi
        invoke  WideCharToMultiByte, CP_UTF8, 0, [.ptrWideChar], -1, 0, 0, 0, 0
        test    eax, eax
        jz      .error

        mov     ebx, eax
        stdcall GetMem, ebx
        mov     edi, eax

        invoke  WideCharToMultiByte, CP_UTF8, 0, [.ptrWideChar], -1, edi, ebx, 0, 0
        stdcall StrDup, edi

        push    eax
        stdcall FreeMem, edi
        pop     eax

        clc
.finish:
        pop     edi edx ecx ebx
        return

.error:
        stc
        jmp     .finish
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































Deleted freshlib/data/all.asm.

1
2
3
4
5
include 'arrays.asm'
include 'strlib.asm'
include 'uconfig.asm'
include 'memstream.asm'
include 'markdown.asm'
<
<
<
<
<










Deleted freshlib/data/arrays.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: OS independent dynamic arrays library.
;
;  Target OS: Any
;
;  Dependencies: memory.asm
;
;  Notes:
;_________________________________________________________________________________________

module "Arrays library"

struct TArray
  .count     dd ?           ; Count of elements in dynamic array
  .capacity  dd ?           ; Capacity of the array allocated memory.
  .itemsize  dd ?           ; Size of one element in dynamic array. Aligned on dword.
  .lparam    dd ?           ; User defined value.
  label .array dword
ends


; ____________________________________________________________________
;|                                                                    |
;| Creates dynamic array.                                             |
;|                                                                    |
;| Arguments:                                                         |
;|                                                                    |
;|   .ItemSize: size in bytes of one array element.                   |
;|              This size will be aligned to dword.                   |
;|                                                                    |
;| Return:                                                            |
;|   if CF=1 the memory can't be allocated.                           |
;|   if CF=0 eax contains pointer to the created array.               |
;|____________________________________________________________________|

proc CreateArray, .ItemSize
begin
        push    ecx edx
        mov     ecx, [.ItemSize]
        add     ecx, 3
        and     cl, $fc
        mov     edx, ecx

        imul    ecx, cInitialCapacity
        add     ecx, sizeof.TArray
        stdcall GetMem, ecx
.retaddr:
        jc      .finish

        mov     [eax+TArray.itemsize], edx
        mov     [eax+TArray.capacity], cInitialCapacity
        clc

.finish:
        pop     edx ecx
        return
endp



;____________________________________________________________________
;
;  proc AddArrayItems - adds new item at the end of TArray
;                      dynamic array.
;  Arguments:
;
;    .ptrArray - pointer to dword variable containing pointer
;               to TArray structure.
;    .count - count of the elements to be added.
;
;  Returns:
;    CF=1 if error: edx - pointer to the original array.
;
;    CF=0 if OK:    eax - pointer to new created element.
;                   edx - pointer to the array.
;
;  Notes:
;    The procedure returns in edx pointer to the TArray. This pointer
;    can differs from .ptrArray argument, if the memory was
;    reallocated. The user should save the pointer for future access
;    to the array. It is safe to save the pointer before check of CF
;    for error, because the procedure returns original pointer in case
;    of memory allocation error.
;____________________________________________________________________

proc AddArrayItems, .ptrArray, .count
begin
        push    ebx ecx

        mov     edx, [.ptrArray]
        test    edx, edx
        jnz     @f

        stc
        pop     ecx ebx
        return

@@:
        mov     eax, [edx+TArray.count]
        mov     ecx, [edx+TArray.capacity]
        add     eax, [.count]
        cmp     ecx, eax
        jae     .memallocated

; enlarge the array. Strategy here is not clear.
        mov     ecx, eax
        call    dword [ResizeIt]
        jc      .finish

        mov     ebx, ecx
        imul    ecx, [edx+TArray.itemsize]
        add     ecx, sizeof.TArray

        stdcall ResizeMem, edx, ecx
.readdr:
        jc      .finish

        mov     edx, eax
        mov     [edx+TArray.capacity], ebx

.memallocated:
        mov     eax, [edx+TArray.count]
        mov     ecx, [.count]
        add     [edx+TArray.count], ecx

        imul    eax, [edx+TArray.itemsize]
        lea     eax, [edx+eax+TArray.array]
        clc

.finish:
        pop     ecx ebx
        return
endp


;____________________________________________________________________
;
;  proc InsertArrayItems - inserts new item in the array.
;
;  Arguments:
;
;    .ptrArray - pointer to TArray structure.
;    .iElement - on what index to be inserted the new elements.
;    .count    - how many elements to be inserted.
;
;  Returns:
;    CF=1 if error: edx - pointer to the original array; new elements are
;                         not inserted.
;
;    CF=0 if OK:    eax - pointer to the first of the new inserted elements.
;                   edx - pointer to the array.
;
;  Notes:
;    If .iElement is larger or equal to [TArray.count] the elements are
;    appended at the end of the array. Otherwise, all elements are moved
;    to make room for the new elements. If the capacity of the array is
;    not enough to hold the new elements, the array is resized.
;
;    The procedure returns in edx pointer to the TArray. This pointer
;    can differs from .ptrArray argument, if the memory was
;    reallocated. The user should save the pointer for future access
;    to the array. It is safe to save the pointer before check of CF
;    for error, because the procedure returns original pointer in case
;    of memory allocation error.
;____________________________________________________________________

proc InsertArrayItems, .ptrArray, .iElement, .count
begin
        stdcall AddArrayItems, [.ptrArray], [.count]
        jc      .end1

        push    ecx

        mov     ecx, [.iElement]
        add     ecx, [.count]
        cmp     ecx, [edx+TArray.count]
        jae     .end2

        push    esi edi

        imul    ecx, [edx+TArray.itemsize]
        lea     ecx, [edx+ecx+TArray.array]

        lea     esi, [eax-4]                    ; the last element.
        mov     edi, [edx+TArray.count]
        imul    edi, [edx+TArray.itemsize]
        lea     edi, [edx+edi+TArray.array]     ; end of the array.

        mov     eax, ecx
        sub     eax, [edx+TArray.itemsize]

        sub     ecx, edi
        neg     ecx
        shr     ecx, 2

        sub     edi, 4

        std

; scroll the data.
        rep movsd

; clear the new items.
        mov     ecx, [edx+TArray.itemsize]
        imul    ecx, [.count]
        shr     ecx, 2
        xor     eax, eax
        rep stosd

        lea     eax, [edi+4]
        cld

        pop     edi esi

.end2:
        pop     ecx
.end1:
        return
endp


;**************************************************************
;  proc DeleteArrayItems - deletes the items with the specified
;                          index and specified count from TArray
;                          dynamic array.
;  If the capacity of the array is bigger than the recomended
;  for the new count, then the array is resized.
;  The recomended size is calculated using ResizeIt procedure
;  from memory library.
;
;  Arguments:
;    .ptrArray - pointer to TArray structure.
;    .iElement - index of the element to be deleted.
;    .count    - how many elements to be deleted.
;
;  Returns: edx - pointer to the TArray. In the most cases
;                 this pointer will not be changed, but this
;                 also depends on the current OS memory
;                 allocation API, so it is safer to store
;                 the pointer for future use instead of
;                 passed to the procedure.
;
;  Notes:
;           This function can't fail, because delete is
;           always possible in already allocated array.
;           in some cases shrinking resize possibly can fail
;           but this will not affect the data in the array.
;
;           if [.iElement]+[.count] is bigger that the [TArray.count]
;           of the array, only the elements to the end of the array
;           will be deleted.
;
;*******************************************************
proc DeleteArrayItems, .ptrArray, .iElement, .count
begin
        push    edi esi ecx ebx eax

        mov     edx, [.ptrArray]
        test    edx, edx
        jz      .exit

        mov     ecx, [.iElement]
        mov     eax, [edx+TArray.count]

        test    ecx, ecx
        js      .exit

        cmp     ecx, eax
        jae     .exit                   ; index greater or equal to the count...

        add     ecx, [.count]
        cmp     ecx, eax
        jae     .movedone               ; if there is no more elements after the last deleted element, don't move

        mov     eax, [edx+TArray.itemsize]

        imul    ecx, eax
        lea     esi, [edx+ecx+TArray.array]     ; the first after deleted

        mov     ecx, [.iElement]
        imul    ecx, eax                        ; offset of the deleted element.
        lea     edi, [edx+ecx+TArray.array]     ; destination address.

        mov     ecx, [edx+TArray.count]
        imul    ecx, eax
        lea     ecx, [ecx+edx+TArray.array]
        sub     ecx, esi                        ; bytes to be moved. It should be dword aligned count.

        shr     ecx, 2
        rep movsd                               ; move the data.

.movedone:
        mov     ecx, [edx+TArray.count]
        mov     eax, [.iElement]
        sub     ecx, [.count]
        cmp     ecx, eax
        ja      @f
        mov     ecx, eax
@@:
        mov     [edx+TArray.count], ecx

        call    [ResizeIt]
        jc      .exit                           ; the array is OK, but the resize failed.

        cmp     ecx, [edx+TArray.capacity]
        jae     .exit                           ; the array have smaller capacity than recomended, so don't resize.

        mov     eax, ecx
        imul    eax, [edx+TArray.itemsize]
        add     eax, sizeof.TArray
        stdcall ResizeMem, edx, eax
        jc      .exit                           ; the resize failed, but the array is ok.

        mov     edx, eax
        mov     [edx+TArray.capacity], ecx      ; set new capacity.

.exit:
        pop     eax ebx ecx esi edi
        return
endp



;**************************************************************
;  proc VacuumArray - deletes the reserved memory from the array.
;
;  Arguments:
;    .ptrArray - pointer to TArray structure.
;
;  Returns: edx - pointer to the TArray. In the most cases
;                 this pointer will not be changed, but this
;                 also depends on the current OS memory
;                 allocation API, so it is safer to store
;                 the pointer for future use instead of
;                 passed to the procedure.
;           CF=1 - there is a error on vacuuming. This is not
;                  exactly error, because this case indicates
;                  simply some memory manager unabiliry to reallocate
;                  memory. Although the array will not be changed.
;
; This procedure removes all reserved space in the array.
; Vacuum can save a lot of memory space, but takes time and
; also will make future inserts of new elements
; slower at least for the first add/insert.
;
; it is wise to vacuum the array after it is filled with
; most/all of the needed elements.
;
proc VacuumArray, .ptrArray
begin
        push    eax ecx

        mov     edx, [.ptrArray]
        mov     ecx, [edx+TArray.count]
        mov     eax, [edx+TArray.itemsize]
        add     ecx, 1
        imul    eax, ecx
        add     eax, sizeof.TArray

        stdcall ResizeMem, edx, eax
        jc      .exit

        mov     edx, eax
        mov     [eax+TArray.capacity], ecx

.exit:
        pop     ecx eax
        return

endp





;____________________________________________________________________
;
; proc ListIndexOf, .ptrArray, .item - searches dynamic list for
;                                    the given item.
;
; List is a special case of dynamic array, where the size of the
; elements is dword (4 bytes).
;
; Arguments:
;   .ptrList - pointer to TArray dynamic array.
;   .item    - value of the element.
; Returns:
;   CF = 0 if the element was found. eax contains index of
;          the element.
;   CF = 1 the element is not found.
;____________________________________________________________________

proc ListIndexOf, .ptrList, .Item
begin
        push    edi ecx

        mov     edi, [.ptrList]

        cmp     [edi+TArray.itemsize], 4
        jne     .notfound

        mov     ecx, [edi+TArray.count]
        jecxz   .notfound

        lea     edi, [edi+4*ecx+TArray.array-4] ; from the end
        mov     eax, [.Item]
        std
        repnz scasd
        cld
        jz      .found

.notfound:
        stc
        pop     ecx edi
        return

.found:
        clc
        mov     eax, ecx
        pop     ecx edi
        return
endp


;--------------------------------------------
; Frees all elements of the list calling
; [FreeProc] on every element.
; (proc FreeProc, ptrItem)
; Frees the array of items
;--------------------------------------------
proc ListFree, .ptrList, .FreeProc
begin
        push    edi ebx

        mov     edi, [.ptrList]
        mov     ebx, [edi+TArray.count]

        cmp     [.FreeProc], 0
        je      .endwhile

.freeloop:
        dec     ebx
        js      .endwhile

        stdcall [.FreeProc], [edi+4*ebx+TArray.array]
        jmp     .freeloop

.endwhile:
        stdcall FreeMem, edi

.finish:
        pop     ebx edi
        return
endp


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/data/markdown.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
module "markdown parser"

struct TMarkdownResults
  .hContent     dd ?
  .hIndex       dd ?
  .hKeywords    dd ?
  .hDescription dd ?
ends



fblkQuote       = 1
fblkTable       = 2


fstateHeader    = $01
fstatePara      = $02
fstateWhite     = $04
fstateBold      = $08
fstateLink      = $10
fstateUnderline = $20
fstateStrikeout = $40
fstateItalic    = $80

fstateTextNow  = $200         ; don't use the second byte for any other flags.
fstateTextPrev = $100

fstateInlineSource    =  $10000
fstateBlockSource     =  $20000
fstateImage           =  $40000
fstateInlineImage     =  $80000
fstateTable           = $100000


; Translates some markdown text to HTML
; Arguments:
;     .markdown - pointer or handler of the markdown text.
;     .procFixLink - [proc .ptrLink] procedure that process the link address and returns
;                    handle to the processed link address. if [.procFixLink]=NULL, the links
;                    are inserted as they are in the HTML.
;     .fBacklinks - flag, that defines whether to insert after the headers back links to the
;                   table of contents item.
; Returns:
;     eax - handler of the HTML formated text.
;     edx - handler of the page index.
;     ebx - handler of the detected keywords.
;     ecx - handler of the detected page description.

proc TranslateMarkdown, .markdown, .procFixLink, .fBacklinks, .pResult

.result      dd ?
.index       dd ?
.keywords    dd ?
.description dd ?

  ; first and second pass local variables
  .IdString        rb  256
  .IdLen           dd  ?

  .cntH2           dd  ?
  .cntH3           dd  ?
  .cntH4           dd  ?
  .cntH5           dd  ?
  .cntH6           dd  ?

.pHashTable dd ?
.pHTML      dd ?
.limit      dd ?

  .blocks rb 1024
  .pblock dd ?

begin
        pushad

        stdcall GetMem, 4*65536
        mov     [.pHashTable], eax
        stdcall GetMem, 16384
        mov     [.pHTML], eax
        add     eax, 8192
        mov     [.limit], eax

        stdcall StrNew
        mov     [.result], eax

        stdcall StrNew
        mov     [.index], eax

        stdcall StrNew
        mov     [.keywords], eax

        stdcall StrNew
        mov     [.description], eax

        stdcall StrPtr, [.markdown]
        mov     esi, eax

        call    .FirstPass

        stdcall StrPtr, [.markdown]
        mov     esi, eax
        call    .SecondPass

        stdcall FreeMem, [.pHTML]
        stdcall FreeMem, [.pHashTable]

        mov     edi, [.pResult]

        mov     eax, [.result]
        mov     edx, [.index]
        mov     ebx, [.keywords]
        mov     ecx, [.description]

        mov     [edi+TMarkdownResults.hContent], eax
        mov     [edi+TMarkdownResults.hIndex], edx
        mov     [edi+TMarkdownResults.hKeywords], ebx
        mov     [edi+TMarkdownResults.hDescription], ecx

        popad
        return

;.... start of .FirstPass ..........................................

.FirstPass:
        mov     edi, [.pHTML]
        mov     [.cntH2], 0
        mov     [.cntH3], 0
        mov     [.cntH4], 0
        mov     [.cntH5], 0
        mov     [.cntH6], 0

.line_start:
        cmp     edi, [.limit]
        jb      @f

        mov     dword [edi], 0
        stdcall StrCat, [.index], [.pHTML]
        mov     edi, [.pHTML]

@@:
        cmp     byte [esi], '#'
        je      .header

        cmp     byte [esi], '['
        je      .link

.skip_to_eol:
        mov     al, [esi]
        lea     esi, [esi+1]
        cmp     al, $0d
        je      .line_start
        cmp     al, $0a
        je      .line_start
        test    al, al
        jnz     .skip_to_eol

.end_of_file:
        mov     dword [edi], 0
        stdcall StrCat, [.index], [.pHTML]

        retn

; ----- return from .FirstPass -------------------

; create table of contents item.
.header:
        xor     ecx, ecx

.scan_level:
        inc     ecx
.scan_space:
        lea     esi, [esi+1]
        mov     al, [esi]
        cmp     al, '#'
        je      .scan_level
        cmp     al, ' '
        je      .scan_space
        cmp     al, $09
        je      .scan_space

        cmp     al, $0d
        je      .line_start
        cmp     al, $0a
        je      .line_start

        cmp     ecx, 6
        jbe     @f
        mov     ecx, 6
@@:
        call    .BuildID

        mov     dword [edi], '<a i'
        lea     edi, [edi+4]
        mov     dword [edi], 'd="B'
        lea     edi, [edi+4]

        call    .InsertID

        mov     dword [edi], '" hr'
        mov     dword [edi+4], 'ef="'
        mov     word  [edi+8], '#H'
        lea     edi, [edi+10]

        call    .InsertID

        mov     dword [edi],    '" st'
        mov     dword [edi+4],  'yle='
        mov     dword [edi+8],  '"pad'
        mov     dword [edi+12], 'ding'
        mov     dword [edi+16], '-lef'
        mov     word [edi+20],  't:'
        lea     edi, [edi+22]

        push    ecx
        mov     eax, ecx
        mov     ecx, 10
        sub     eax, 2
        jns     @f
        xor     eax, eax
@@:
        call    _NumToStrU
        pop     ecx

        mov     dword [edi], 'em">'
        lea     edi, [edi+4]

        cmp     ecx, 1
        je      @f
        call    .InsertID
@@:
; copy the header text

.copy_loop:
        mov     al, [esi]
        lea     esi, [esi+1]
        cmp     al, $0d
        je      .end_header
        cmp     al, $0a
        je      .end_header
        test    al, al
        jz      .end_header

        mov     [edi], al
        lea     edi, [edi+1]
        jmp     .copy_loop

.end_header:
        dec     esi
        mov     dword [edi],   '</a>'
        mov     dword [edi+4], '<br '
        mov     word [edi+8], '/>'
        lea     edi, [edi+10]
        jmp     .line_start

;link processing
.link:
        mov     edx, $811C9DC5   ; 2166136261 ; FNV offset basis
        mov     ecx, esi

.label_loop:
        mov     al, [esi]
        lea     esi, [esi+1]

        cmp     al, $20
        je      .label_loop
        cmp     al, $09
        je      .label_loop

        cmp     al, $0d
        je      .line_start
        cmp     al, $0a
        je      .line_start

        test    al, al
        jz      .end_of_file

        xor     dl, al
        imul    edx, $01000193                  ;   16777619              ; FNV prime
        cmp     al, ']'
        jne     .label_loop

; fold the hash to 16 bit value...
        mov     ebx, edx
        shr     ebx, 16
        xor     ebx, edx
        and     ebx, $ffff
        mov     edx, ebx

; search free slot
.search_slot:
        mov     eax, [.pHashTable]
        xchg    ecx, [eax+4*ebx]
        test    ecx, ecx
        jz      .skip_to_eol

; conflict...
; compare the labels on ecx (the old content of the slot) with [HashTable+4*ebx] (the new pointer)
        push    edi ecx

        mov     edi, [eax+4*ebx]

.first:
        mov     al, [ecx]
        lea     ecx, [ecx+1]

        cmp     al, $20
        je      .first
        cmp     al, $09
        je      .first

.second:
        mov     ah, [edi]
        lea     edi, [edi+1]
        cmp     ah, $20
        je      .second
        cmp     ah, $09
        je      .second

        cmp     al, ah
        jne     .add_not_equal

        cmp     ah, ']'
        jne     .first

        pop     ecx edi
        jmp     .skip_to_eol

; save it to the next slot
.add_not_equal:
        pop     ecx edi

        inc     ebx
        and     ebx, $ffff
        cmp     ebx, edx
        jne     .search_slot

        int3    ; full hash table -> to be implemented error processing

;---- End of .FirstPass --------------------------------


;.... Start of .SecondPass .............................

locals
  ; .SecondPass only local variables
  .state       dd ?
  .last_header dd ?
  .linkID_end  dd ?
endl

.SecondPass:
        mov     edi, [.pHTML]

        xor     eax, eax
        mov     [.state], eax
        mov     [.cntH2], eax
        mov     [.cntH3], eax
        mov     [.cntH4], eax
        mov     [.cntH5], eax
        mov     [.cntH6], eax
        mov     [.pblock], eax


.line_start2:
        shr     byte [.state+1], 1   ; fstateTextPrev = fstateTextNow; fStateTextNow = 0

        cmp     edi, [.limit]
        jb      @f
        mov     dword [edi], 0
        stdcall StrCat, [.result], [.pHTML]
        mov     edi, [.pHTML]
@@:

        test    [.state], fstateBlockSource
        jnz     .copy_source

        cmp     byte [esi], '['
        je      .link_definition

        cmp     byte [esi], '#'
        je      .header2

        cmp     byte [esi], ';'
        je      .block_element

        cmp     dword [esi], '----'
        je      .horiz_rule


.scan_line2:
        mov     al, [esi]
        lea     esi, [esi+1]

        cmp     al, ' '
        je      .white_space
        cmp     al, $09         ; tab
        je      .white_space

        cmp     al, $0d
        je      .end_of_line
        cmp     al, $0a
        je      .end_of_line
        test    al, al
        jz      .end_of_line

; it is not white space character...
        test    [.state], fstateTextPrev or fstateTextNow or fstateHeader
        jz      .start_para

.process_char:
        or      [.state], fstateTextNow

        test    [.state], fstateInlineSource
        jnz     .inline_source

        cmp     al, '*'
        je      .process_bold

        cmp     al, '_'
        je      .process_underline

        cmp     al, '-'
        je      .process_strikeout

        cmp     al, '/'
        je      .process_italic

        cmp     al, '['
        je      .is_link_begin

        cmp     al, ']'
        je      .is_link_end

.inline_source:
        cmp     al, '`'
        je      .process_inline_code


.normal_char:
        and     [.state], not fstateWhite

.markup_ok:

        call    .store_char
        jmp     .scan_line2


; stores the char from al in [edi], and
; replaces the invalid HTML characters
; with their &name; representation.

.store_char:
        cmp     al, 'A'
        jb      @f

        mov     [edi], al
        lea     edi, [edi+1]
        retn

@@:
        cmp     al, '<'
        je      .char_less_then
        cmp     al, '>'
        je      .char_greater_then
        cmp     al, '"'
        je      .char_quote
        cmp     al, '&'
        je      .char_amp
        cmp     al, "'"
        je      .char_apos

        mov     [edi], al
        lea     edi, [edi+1]
        retn

.char_less_then:
        mov     dword [edi], '&lt;'
        lea     edi, [edi+4]
        retn

.char_greater_then:
        mov     dword [edi], '&gt;'
        lea     edi, [edi+4]
        retn

.char_quote:
        mov     dword [edi], '&quo'
        mov     word [edi+4], 't;'
        lea     edi, [edi+6]
        retn

.char_apos:
        mov     dword [edi], '&apo'
        mov     word [edi+4], 's;'
        lea     edi, [edi+6]
        retn

.char_amp:
        mov     dword [edi], '&amp'
        mov     byte [edi+1], ';'
        lea     edi, [edi+5]
        retn


.start_para:
        test    [.state], fstateTable
        jz      .not_td_open

        mov     dword [edi], '<td>'
        lea     edi, [edi+4]

        cmp     al, '('         ; col, row span
        jne     .td_ok

        dec     edi

        mov     dword [edi], ' col'
        mov     dword [edi+4], 'span'
        mov     word  [edi+8], '="'
        lea     edi, [edi+10]

.copy_span:
        mov     al, [esi]
        lea     esi, [esi+1]
        cmp     al, ','
        je      .row_span
        cmp     al, ')'
        je      .end_span

        call    .store_char
        jmp     .copy_span

.row_span:
        mov     dword [edi],    '" ro'
        mov     dword [edi+4],  'wspa'
        mov     dword [edi+8],  'n="'
        lea     edi, [edi+11]
        jmp     .copy_span

.end_span:
        mov     word [edi], '">'
        lea     edi, [edi+2]

        mov     al, [esi]
        lea     esi, [esi+1]

.td_ok:
        or      [.state], fstatePara
        jmp     .process_char

.not_td_open:
        mov     word [edi], '<p'
        lea     edi, [edi+2]
        or      [.state], fstatePara

; is it bullet list?

        cmp     al, '*'
        jne     .close_p_tag

        cmp     byte [esi], ' '
        jne     .close_p_tag

        mov     dword [edi], ' cla'
        mov     dword [edi+4], 'ss="'
        mov     dword [edi+8], 'uli"'
        lea     edi, [edi+12]

        inc     esi
        mov     al, [esi]
        inc     esi

.close_p_tag:
        mov     byte [edi], '>'
        lea     edi, [edi+1]
        jmp     .process_char

.process_inline_code:
        mov     ecx, fstateInlineSource
        mov     ebx, 'code'
        jmp     .ProcessTag

.process_bold:
        mov     ecx, fstateBold
        mov     ebx, 'b'
        jmp     .ProcessTag


.process_italic:
        mov     ecx, fstateItalic
        mov     ebx, 'i'
        jmp     .ProcessTag

.process_underline:
        mov     ecx, fstateUnderline
        mov     ebx, 'u'
        jmp     .ProcessTag

.process_strikeout:
        mov     ecx, fstateStrikeout
        mov     ebx, 's'

; ecx = state mask
; ebx = html tag
.ProcessTag:
        mov     dl, al

        test    [.state], ecx
        jz      .start_tag

; close tag
        not     ecx
        and     [.state], ecx

        mov     word [edi], '</'
        lea     edi, [edi+2]
        jmp     .finish_tag

.start_tag:
        test    [.state], fstateWhite
        jz      .normal_char
        cmp     byte [esi], $20
        je      .normal_char
        cmp     byte [esi], $09
        je      .normal_char
        cmp     byte [esi], $0d
        je      .normal_char
        cmp     byte [esi], $0a
        je      .normal_char

        or      [.state], ecx

; open tag
        mov     byte [edi], '<'
        lea     edi, [edi+1]

.finish_tag:
        mov     [edi], ebx

.taglen:
        lea     edi, [edi+1]
        shr     ebx, 8
        jnz     .taglen

        mov     byte [edi], '>'
        lea     edi, [edi+1]

        jmp     .scan_line2


.white_space:
        test    [.state], fstateWhite
        jnz     .scan_line2

        or      [.state], fstateWhite
        mov     [edi], al
        lea     edi, [edi+1]
        jmp     .scan_line2

; end of line and end of file processing
.end_of_line:
        test    al, al
        jz      @f

        xor     al, $0d xor $0a
        cmp     [esi], al
        jne     @f
        inc     esi
@@:
        or      [.state], fstateWhite

        test    [.state], fstateTextNow
        jnz     .para_ok

        call    .close_paragraph

.para_ok:
        test    [.state], fstateHeader
        jz      .crlf

; insert back link
        cmp     [.fBacklinks], 0
        je      .backlink_ok

        mov     dword [edi],    '<a c'
        mov     dword [edi+4],  'lass'
        mov     dword [edi+8],  '="ba'
        mov     dword [edi+12], 'ck" '
        lea     edi, [edi+16]

        mov     dword [edi],   'href'
        mov     dword [edi+4], '="#B'
        lea     edi, [edi+8]

        call    .InsertID

        mov     word  [edi], '">'
        mov     dword [edi+2], '</a>'
        lea     edi, [edi+6]

.backlink_ok:
        mov     byte [edi], '<'
        lea     edi, [edi+1]

        mov     ecx, [.last_header]
        add     ecx, '/h0>'
        mov     [edi], ecx
        lea     edi, [edi+4]

        and     [.state], not (fstateHeader or fstateTextNow)   ; For the paragraph flow, the header loops like empty line.

.crlf:
        test    [.state], fstateTextPrev or fstateTextNow
        jz     @f
        mov     word [edi], $0a0d
        lea     edi, [edi+2]
@@:
        test    al, al
        jnz     .line_start2

.finish:
        mov     dword [edi], 0
        stdcall StrCat, [.result], [.pHTML]
        retn


.is_link_begin:
        test    [.state], fstateWhite
        jz      .normal_char

.searchID:
        dec     esi

;.SearchLink:
        push    edi
        push    esi

; first compute the hash for the link label
        mov     edx, $811C9DC5                  ; 2166136261              ; FNV offset basis

.hashloop:
        mov     al, [esi]
        lea     esi, [esi+1]

        cmp     al, $20
        je      .hashloop
        cmp     al, $09
        je      .hashloop

        cmp     al, $0d
        je      .not_a_link
        cmp     al, $0a
        je      .not_a_link
        test    al, al
        je      .not_a_link

        xor     dl, al
        imul    edx, $01000193                  ;   16777619              ; FNV prime
        cmp     al, ']'
        jne     .hashloop

; fold the hash to 16 bit value...
        mov     [.linkID_end], esi

        mov     ebx, edx
        shr     ebx, 16
        xor     ebx, edx
        dec     ebx

.hash_table_loop:
        lea     ebx, [ebx+1]
        and     ebx, $ffff

        mov     eax, [.pHashTable]
        mov     edi, [eax+4*ebx]
        mov     esi, [esp]

        test    edi, edi
        jnz     .cmp_labels

.inline_link:                   ; the linkID was not found in the hash table. So, it should be inline link address.
        lea     edi, [esi+1]    ; the address of the link is in esi
        mov     esi, [.linkID_end] ; the address of the end of the linkID.
        jmp     .create_link

.not_a_link:
        pop     esi edi
        mov     al, [esi]
        lea     esi, [esi+1]
        jmp     .normal_char    ; the link address was not found, so it is not link at all.

.cmp_labels:
        mov     al, [esi]
        lea     esi, [esi+1]

        cmp     al, ' '
        je      .cmp_labels
        cmp     al, $09
        je      .cmp_labels

.target:
        mov     ah, [edi]
        lea     edi, [edi+1]

        cmp     ah, ' '
        je      .target
        cmp     ah, $09
        je      .target

        cmp     al, ah
        jne     .hash_table_loop      ; it is not the same label - try again.

        cmp     ah, ']'
        jne     .cmp_labels

; the labels are equal, so search the address.

.create_link:
        or      [.state], fstateLink
        mov     edx, [esp]              ; the start of the linkID.
        cmp     byte [esi], '['         ; is the link has separate ID and text?
        jne     @f
        mov     [esp], esi              ; replace the source address.
@@:
        inc     edx
        cmp     byte [edx], '#'       ; is it internal link?
        je      .internal_link_address

        cmp     byte [edx], '?'       ; is it inline image?
        jne     .maybe_block_image

        xor     [.state], fstateInlineImage or fstateLink
        jmp     .firstnw

.maybe_block_image:
        cmp     byte [edx], '!'       ; is it an image?
        jne     .firstnw
        xor     [.state], fstateImage or fstateLink

.firstnw:
        mov     al, [edi]
        lea     edi, [edi+1]
        cmp     al, ' '
        je      .firstnw
        cmp     al, $09
        je      .firstnw

        dec     edi
        mov     edx, edi

.internal_link_address:
        pop     esi edi

        test    [.state], fstateLink
        jnz     .it_is_link

; it is image.
        mov     dword [edi],    '<img'
        mov     dword [edi+4],  ' cla'
        mov     dword [edi+8],  'ss="'

        test    [.state], fstateImage
        jnz     .block_image

        mov     dword [edi+12], 'ico"'
        jmp     .img_tag_end

.block_image:
        mov     dword [edi+12], 'txt"'

.img_tag_end:
        mov     dword [edi+16], ' src'
        mov     word [edi+20],  '="'
        lea     edi, [edi+22]
        jmp     .link_tag_ok

; yes the link was found.
.it_is_link:
        mov     dword [edi],   '<a h'
        mov     dword [edi+4], 'ref='
        mov     byte [edi+8], '"'
        lea     edi, [edi+9]

.link_tag_ok:
        push    ecx esi
        mov     esi, edx

        cmp     byte [esi], '?'
        je      .skip_img_char

        cmp     byte [esi], '!'
        jne     .copy_link_pre

.skip_img_char:
        inc     esi

.copy_link_pre:
        cmp     [.procFixLink], 0
        je      .copy_link_loop

        stdcall [.procFixLink], esi, edi
        mov     edi, eax
        mov     esi, edx

.copy_link_loop:
        mov     al, [esi]
        lea     esi, [esi+1]

        cmp     al, $0d
        je      .end_link
        cmp     al, $0a
        je      .end_link
        cmp     al, ']'
        je      .end_link
        test    al, al
        jz      .end_link

        mov     [edi], al
        lea     edi, [edi+1]
        jmp     .copy_link_loop

.end_link:
        pop     esi ecx

        test    [.state], fstateImage or fstateInlineImage
        jnz     .finalize_image

        mov     word [edi], '">'
        lea     edi, [edi+2]

.go_link_text:
        and     [.state], not fstateWhite
        inc     esi
        jmp     .scan_line2

.finalize_image:
        mov     dword [edi],   '" al'
        mov     dword [edi+4], 't="'
        lea     edi, [edi+7]
        and     [.state], not fstateWhite
        jmp     .go_link_text

;....................................................................

.is_link_end:
        test    [.state], fstateLink
        jnz     .close_link_tag

        test    [.state], fstateImage or fstateInlineImage
        jz      .normal_char

; close the image tag
        mov     dword [edi], '" />'
        lea     edi, [edi+4]

        and     [.state], not (fstateImage or fstateInlineImage)
        jmp     .scan_line2

.close_link_tag:
        mov     dword [edi], '</a>'
        lea     edi, [edi+4]

        and     [.state], not fstateLink
        jmp     .scan_line2

;....................................................................
; Processing of block source code
.copy_source:

.source_line:

        cmp     edi, [.limit]
        jb      @f
        mov     dword [edi], 0
        stdcall StrCat, [.result], [.pHTML]
        mov     edi, [.pHTML]
@@:

        cmp     dword [esi], ';end'
        je      .end_source_block

.copy_source_line:
        mov     al, [esi]
        lea     esi, [esi+1]

        call    .store_char

        test    al, al
        jz      .end_source_block2

        cmp     al, $0d
        je      .end_source_line
        cmp     al, $0a
        jne     .copy_source_line

.end_source_line:
        xor     al, $0d xor $0a
        cmp     [esi], al
        jne     .source_line

        inc     esi
        mov     [edi], al
        lea     edi, [edi+1]
        jmp     .source_line

.end_source_block2:
        dec     esi

.end_source_block:
        mov     dword [edi],   '</di'
        mov     dword [edi+4], ($0a0d shl 16) + 'v>'
        lea     edi, [edi+8]

        and     [.state], not fstateBlockSource
        jmp     .skip2

;....................................................................

.close_paragraph:
        test    [.state], fstatePara
        jz      .close_para_ok

        test    [.state], fstateTable
        jnz     .close_td

        mov     dword [edi], '</p>'
        lea     edi, [edi+4]
        jmp     .close_para_ok

.close_td:
        mov     dword [edi], '</td'
        mov     dword [edi+4], '>'+($0a0d shl 8)
        lea     edi, [edi+7]

.close_para_ok:
        and     [.state], not fstatePara
        retn

;....................................................................
; horizontal rule element

.horiz_rule:
        call    .close_paragraph

        mov     dword [edi], '<hr '
        mov     dword [edi+4], '/>'+($0a0d shl 16)
        lea     edi, [edi+8]
        jmp     .skip2

;....................................................................
; Processing of the block elements.

.block_element:
        cmp     dword [esi], ';end'
        je      .end_block

        cmp     dword [esi], ';beg'
        jne     .not_code
        cmp     word [esi+4], 'in'
        jne     .not_code

; code block
        call    .close_paragraph

        mov     dword [edi],    '<div'
        mov     dword [edi+4],  ' cla'
        mov     dword [edi+8],  'ss="'
        mov     dword [edi+12], 'code'
        mov     word  [edi+16], '">'
        lea     edi, [edi+18]
        or      [.state], fstateBlockSource
        jmp     .skip2


.not_code:
        cmp     dword [esi], ';tab'
        jne     .not_table
        cmp     word [esi+4], 'le'
        jne     .not_table

; table block;
        call    .close_paragraph

        mov     al, fblkTable
        call    .PushBlock

        mov     dword [edi], '<tab'
        mov     dword [edi+4], 'le c'
        mov     dword [edi+8], 'lass'
        mov     dword [edi+12],'="tx'
        mov     dword [edi+16], 't"><'
        mov     dword [edi+20], 'tr>'+($0d shl 24)
        mov     byte  [edi+24], $0a
        lea     edi,  [edi+25]

        or      [.state], fstateTable
        jmp     .skip2


.not_table:
        cmp     dword [esi], ';---'
        jne     .not_row

.table_row:
        call    .close_paragraph

        mov     dword [edi],   '</tr'
        mov     dword [edi+4], '><tr'
        mov     byte  [edi+8], '>'
        lea     edi, [edi+9]
        jmp     .skip2


.not_row:
        cmp     dword [esi], ';quo'
        jne     .not_quote
        cmp     word [esi+4], 'te'
        jne     .not_quote

; block quote
        call    .close_paragraph

        mov     al, fblkQuote
        call    .PushBlock

        mov     dword [edi],   '<div'
        mov     dword [edi+4], ' cla'
        mov     dword [edi+8], 'ss="'
        mov     dword [edi+12],'bq">'
        lea     edi, [edi+16]

        jmp     .skip2


.not_quote:
        cmp     dword [esi], ';key'
        jne     .not_keywords
        cmp     dword [esi+4], 'word'
        jne     .not_keywords
        cmp     byte [esi+8], 's'
        jne     .not_keywords

        add     esi, 9
        mov     ecx, [.keywords]
        jmp     .append_line_to_string

.not_keywords:
        cmp     dword [esi], ';des'
        jne     .not_desc
        cmp     dword [esi+4], 'crip'
        jne     .not_desc
        cmp     dword [esi+8], 'tion'
        jne     .not_desc

        add     esi, 12
        mov     ecx, [.description]

.append_line_to_string:


        push    esi     ; first argument of

        nop

.seek_eoa:
        mov     al, [esi]
        lea     esi, [esi+1]

        test    al, al
        jz      .end_of_appended

        cmp     al, $0d
        je      .end_of_appended

        cmp     al, $0a
        jne     .seek_eoa

.end_of_appended:
        dec     esi
        mov     byte [esi], 0

        stdcall StrCat, ecx ; start address from the stack
        mov     [esi], al   ; restore the text
        jmp     .skip2


.not_desc:
        jmp     .skip2          ; ";" at the begining without keyword is comment. The line is ignored.


.end_block:
        call    .close_paragraph

.do_end_block:
        call    .PopBlock

        cmp     eax, fblkQuote
        je      .end_quote
        cmp     eax, fblkTable
        je      .end_table

        jmp     .skip2

.end_quote:
        mov     dword [edi], '</di'
        mov     word  [edi+4], 'v>'
        lea     edi, [edi+6]
        jmp     .skip2

.end_table:

        mov     dword [edi], '</tr'
        mov     dword [edi+4], '>'+($0a0d shl 8)
        mov     dword [edi+7], '</ta'
        mov     dword [edi+11],'ble>'
        mov     word  [edi+15], $0a0d
        lea     edi, [edi+17]
        and     [.state], not fstateTable
        jmp     .skip2

;....................................................................
.PushBlock:
        push    ecx
        mov     ecx, [.pblock]
        mov     [.blocks+ecx], al
        inc     ecx
        cmp     ecx, 1024
        jb      @f
        dec     ecx
@@:
        mov     [.pblock], ecx
        pop     ecx
        retn

.PopBlock:
        mov     eax, [.pblock]
        dec     eax
        jns     @f
        xor     eax, eax
        mov     [.pblock], eax
        retn
@@:
        mov     [.pblock], eax
        movzx   eax, [.blocks+eax]
        retn

;....................................................................
; processing link definitions in the second pass.
.link_definition:

        mov     al, [esi+1]
        cmp     al, '#'
        je      .define_anchor

        cmp     al, '^'
        jne     .skip2


;.define_footnote:

        jmp     .skip2                  ; any other variant should be
                                        ; stripped from the text.

.define_anchor:
        add     esi, 2
        mov     dword [edi], '<p>'
        lea     edi, [edi+3]
        or      [.state], fstatePara or fstateTextNow

        mov     dword [edi],    '<a c'
        mov     dword [edi+4],  'lass'
        mov     dword [edi+8],  '="a"'
        mov     dword [edi+12], ' id='
        mov     byte [edi+16],  '"'
        lea     edi, [edi+17]

        push    esi
        call    .copy_id

        mov     dword [edi],   '" hr'
        mov     dword [edi+4], 'ef="'
        mov     byte [edi+8], '#'
        lea     edi, [edi+9]

        pop     esi
        call    .copy_id

        mov     word [edi], '">'
        lea     edi, [edi+2]

        mov     dword [edi], '</a>'
        lea     edi, [edi+4]

        mov     al, [esi]
        jmp     .normal_char

.copy_id:
        mov     al, [esi]
        lea     esi, [esi+1]
        cmp     al, ']'
        je      .cpid_ok
        cmp     al, $0d
        je      .cpid_ok
        cmp     al, $0a
        je      .cpid_ok
        test    al, al
        jz      .cpid_ok

        mov     [edi], al
        lea     edi, [edi+1]
        jmp     .copy_id

.cpid_ok:
        retn

;....................................................................

; processing header items and building of the table of contents.

.header2:
        xor     ecx, ecx

.scan_level2:
        inc     ecx
.scan_space2:
        lea     esi, [esi+1]
        mov     al, [esi]
        cmp     al, '#'
        je      .scan_level2
        cmp     al, ' '
        je      .scan_space2
        cmp     al, $09
        je      .scan_space2

        cmp     al, $0d
        je      .end_of_line
        cmp     al, $0a
        je      .end_of_line

        cmp     ecx, 6
        jbe     @f
        mov     ecx, 6
@@:

; create ID
        call    .BuildID

        shl     ecx, 16
        mov     [.last_header], ecx

        add     ecx, '<h0 '
        mov     [edi], ecx
        mov     dword [edi+4], 'id="'
        mov     byte [edi+8], 'H'
        lea     edi, [edi+9]

; insert the id here.

        call    .InsertID

        mov     word [edi], '">'
        lea     edi, [edi+2]

        cmp     [.last_header], 1 shl 16
        je      @f
        call    .InsertID
        mov     dword [edi], '&nbs'
        mov     word [edi+4], 'p;'
        lea     edi, [edi+6]
@@:
        or      [.state], fstateHeader
        jmp     .scan_line2

.skip2:
        mov     al, [esi]
        lea     esi, [esi+1]

        test    al, al
        jz      .finish
        cmp     al, $0d
        je      .skip_eol
        cmp     al, $0a
        jne     .skip2

.skip_eol:
        xor     al, $0d xor $0a
        cmp     [esi], al
        jne     .line_start2
        inc     esi
        jmp     .line_start2

;----- End of .SecondPass ------------------------------


; ecx - level of the header 1..6
.BuildID:
        push    eax ebx ecx edx edi

        lea     edi, [.IdString]
        cmp     ecx, 1
        jbe     .main

        sub     ecx, 2
        push    ecx

        inc     [.cntH2+4*ecx]

.zero:
        inc     ecx
        cmp     ecx, 5
        je      .end_zero
        mov     [.cntH2+4*ecx], 0
        jmp     .zero

.end_zero:
        xor     ebx, ebx
        mov     ecx, 10

.loop_numbers:
        mov     eax, [.cntH2+4*ebx]
        call    _NumToStrU
        mov     al, '.'
        stosb
        inc     ebx
        cmp     ebx, [esp]
        jbe     .loop_numbers

        pop     ecx
        jmp     .finID

.main:
        mov     eax, 'main'
        stosd

.finID:
        lea     eax, [.IdString]
        sub     edi, eax
        mov     [.IdLen], edi

        pop     edi edx ecx ebx eax
        retn

.InsertID:
        push    ecx esi

        lea     esi, [.IdString]
        mov     ecx, [.IdLen]

        rep movsb

        pop     esi ecx
        retn
endp









endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/data/memstream.asm.

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
struct TMemoryStream
  .size    dd   ?
  .offset  dd   ?
  label .data byte
ends


;------------------------------------------------------------
; Returns: ebx - base addr
;          edi - offset to put data.
;------------------------------------------------------------
proc GetStreamRoom, .ptrVarStream, .room
begin
        push    esi ecx

        mov     esi, [.ptrVarStream]
        mov     ebx, [esi]              ; pointer to the array

        mov     edi, [ebx+TMemoryStream.offset]
        mov     eax, [ebx+TMemoryStream.size]
        sub     eax, edi
        cmp     eax, [.room]      ; check for enough room
        jge     .sizeok

        mov     ecx, [ebx+TMemoryStream.size]
        call    [ResizeIt]
        push    ecx

        stdcall ResizeMem, ebx, ecx
        mov     ebx, eax
        mov     [esi], eax  ; new pointer
        jc      .exit

        mov     [ebx+TMemoryStream.size], ecx   ; new size.

.sizeok:
        mov     eax, [.room]
        add     [ebx+TMemoryStream.offset], eax

.exit:
        pop     ecx esi
        return
endp




proc SetStreamOfs, .ptrVarStream, .offset
begin
        push    esi edi ebx

        mov     edi, [.ptrVarStream]
        mov     eax, [edi]
        mov     ebx, [.offset]
        mov     esi, [eax+TMemoryStream.size]

        cmp     ebx, esi
        jl      .sizeok

        lea     esi, [ebx+$1000]        ; new size
        stdcall ResizeMem, eax, esi
        mov     [edi], eax

.sizeok:
        mov     [eax+TMemoryStream.size], esi
        mov     [eax+TMemoryStream.offset], ebx
        pop     ebx edi esi
        return
endp





proc CreateMemoryStream, .ptrVarStream, .initsize
begin
        push    ebx esi

        mov     ebx, [.initsize]
        mov     esi, [.ptrVarStream]
        add     ebx, sizeof.TMemoryStream

        stdcall GetMem, ebx
        mov     [esi], eax
        mov     [eax+TMemoryStream.size], ebx
        mov     [eax+TMemoryStream.offset], TMemoryStream.data

        pop     esi ebx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































Deleted freshlib/data/strlib.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: OS independent string manipulation library.
;
;  Target OS: Any
;
;  Dependencies: memory.asm; arrays.asm
;
;  Notes:
;
;_________________________________________________________________________________________

module "String library"

STR_MINSTRLEN = 127      ; must be N*8-1
STR_SEARCH_ONE_ATEMPT = 100

struc string {
  .capacity dd ?
  .len      dd ?
  label .data byte
}

virtual at -(sizeof.string)
  string string
  sizeof.string = $-string
end virtual


; NumToStr flags
ntsSigned       = $00000
ntsUnsigned     = $10000
ntsFixedWidth   = $20000


ntsBin  = $0200
ntsQuad = $0400
ntsOct  = $0800
ntsDec  = $0a00
ntsHex  = $1000


; Global variable, storing parameters of dynamic strings list.
uglobal
  if used InitStrings
    ptrStrTable       dd  ?      ; StrLib strings arrray. Contains pointers to the memory allocated for strings.
  end if
endg



; < OS independent library functions >

;************************************************************************************
; Allocates memory for string table and allocates memory for strings.
; Start it before any work with strings. (Or better use InitializeAll macro)
; Returns 0 if failed to allocate needed memory.
;************************************************************************************
if used ptrStrTable
initialize InitStrings
begin
        StrLib = 1

        stdcall CreateArray, 4
        jc      .finish

        mov     [ptrStrTable], eax
        mov     [eax+TArray.lparam], 0     ; lParam is the last allocated handle number

.finish:
        return
endp
end if

;**************************************************************************************
; Frees all memory used for strings library
; Call it before exit of the program or use FinalizeAll macro.
;**************************************************************************************
if used InitStrings
finalize FreeStrings
begin
        mov     esi, [ptrStrTable]
        mov     ecx, [esi+TArray.count]
        xor     ebx,ebx

.freeloop:
        dec     ecx
        js      .endloop

        cmp     [esi+TArray.array+4*ecx], ebx
        je      .freeloop

        stdcall FreeMem, [esi+TArray.array+4*ecx]
        jmp     .freeloop

.endloop:
        stdcall FreeMem, esi
        mov     [ptrStrTable], ebx

        return
endp
end if



;**************************************************************************************
;  Returns:
;    CF=0 no error; eax = pointer in memory of the hString
;    CF=1 on error - hString is handle, but is not in the table.*
;**************************************************************************************
proc StrPtr, .hString
begin
        mov     eax, [.hString]

        xor     eax, $c0000000
        test    eax, $c0000000
        jnz     .pointer

        push    ebx

        mov     ebx, [ptrStrTable]
        cmp     eax, [ebx+TArray.count]
        jae     .notfound

        mov     eax, [ebx+TArray.array+4*eax]
        test    eax, eax
        jz      .notfound

        add     eax, sizeof.string
        pop     ebx
        clc
        return

.pointer:
        xor     eax, $c0000000
        clc
        return

.notfound:
        stc
        pop     ebx
        return
endp

;**************************************************************************************
;  Creates new empty string and returns handle
;  Return: handle of the new created string.
;**************************************************************************************
proc StrNew
begin
        push    ecx edx esi

; Search for first empty place.
        mov     edx, [ptrStrTable]
        mov     ecx, STR_SEARCH_ONE_ATEMPT       ; search only limited count of items
        cmp     ecx, [edx+TArray.count]
        jb      @f
        mov     ecx, [edx+TArray.count]
@@:
;        cmp     [flagStringFastAdd], 0
;        jne     .notfound

        mov     esi,[edx+TArray.lparam]
        xor     eax,eax

.search:
        dec     ecx
        js      .notfound

        inc     esi
        cmp     esi, [edx+TArray.count]
        jne     @f
        xor     esi,esi
@@:
        cmp     [edx+TArray.array+4*esi], eax
        je      .found
        jmp     .search

.notfound:
        mov     [edx+TArray.lparam], esi        ; store the place where the search ends this time.
        mov     esi, [edx+TArray.count]
        stdcall AddArrayItems, edx, 1
        mov     [ptrStrTable], edx

.found:
        mov     [edx+TArray.lparam], esi
        stdcall GetMem, STR_MINSTRLEN + sizeof.string + 1
        mov     [edx+TArray.array+4*esi], eax
        mov     [eax+sizeof.string+string.capacity], STR_MINSTRLEN

        mov     eax, esi
        or      eax, $c0000000

        pop     esi edx ecx
        return
endp


;**************************************************************************
; Deletes the string if it is possible.
;**************************************************************************
proc StrDel, .hString
begin
        push    eax ecx esi

        mov     esi, [ptrStrTable]
        mov     ecx, [.hString]
        jecxz   .finish

        xor     ecx, $c0000000
        test    ecx, $c0000000
        jnz     .pointer

        cmp     ecx, [esi+TArray.count]
        jae     .finish

.free:
        stdcall FreeMem, [esi+TArray.array+4*ecx]
        mov     [esi+TArray.array+4*ecx], 0

.finish:
        pop     esi ecx eax
        return

.pointer:
        xor     ecx, $c0000000

; search the pointer in the table.
        lea     eax, [ecx-sizeof.string]
        mov     ecx, [esi+TArray.count]

.search:
        dec     ecx
        js      .finish
        cmp     [esi+TArray.array+4*ecx], eax
        jne     .search
        jmp     .free
endp


;**************************************************************************
; Duplicates given string, and returns a handle to new one
;**************************************************************************
proc StrDup, .hSource
begin
        stdcall StrNew
        stdcall StrCopy, eax, [.hSource]
        return
endp


;**************************************************************************
; Arguments:
;  hString - handle or pointer to the string (static or dynamic)
; Returns:
;   CF=0; eax = length of the string in bytes.
;   CF=1; eax = 0 in case, the handle of the string can't be found in the
;               string table or the pointer is NULL.
;
; If pointer is passed the the procedure, it should be dword aligned and
; all bytes of the string including zero terminator to be accessed on
; qword boundary. Although, the zero terminator can be single byte zero.
;
; The performance of the procedure is high for pointers and
; instant for handles (the StrLib created string doesn't need any
; search, because the length is precomputed)
;**************************************************************************

proc StrLen, .hString    ; proc StrLen [hString]
begin
        push    esi

        mov     esi, [ptrStrTable]
        mov     eax, [.hString]

        xor     eax, $c0000000
        test    eax, $c0000000
        jnz     .pointer

        cmp     eax, [esi+TArray.count]
        jae     .error

        mov     eax, [esi+TArray.array+4*eax]
        test    eax, eax
        jz      .error

        mov     eax, [eax+sizeof.string+string.len]
        clc
        pop     esi
        return

.error:
        xor     eax, eax
        stc
        pop     esi
        return

.pointer:
        push    ecx edx edi

        xor     eax, $c0000000

; align on dword
.byte1:
        test    eax, 3
        jz      .scan

        cmp     byte [eax], 0
        je      .found

        inc     eax
        jmp     .byte1

.scan:
        mov     ecx, [eax]
        mov     edx, [eax+4]

        lea     eax, [eax+8]

        lea     esi, [ecx-$01010101]
        lea     edi, [edx-$01010101]

        not     ecx
        not     edx

        and     esi, ecx
        and     edi, edx

        and     esi, $80808080
        and     edi, $80808080

        or      esi, edi
        jz      .scan

        sub     eax, 9

; byte 0 was found: so search by bytes.
.byteloop:
        lea     eax, [eax+1]
        cmp     byte [eax], 0
        jne     .byteloop

.found:
        sub     eax, [.hString]
        clc
        pop     edi edx ecx esi
        return
endp





; This procedure calculates the length of zero terminated string and "fixes" [string.len] field.
; StrFixLen should be call when the content of the string is created by call to external to StrLib
; procedures - for example Win32 API functions.
;
proc StrFixLen, .hstring
begin
        push    eax ecx
        stdcall StrPtr, [.hstring]
        mov     ecx, eax
        stdcall StrLen, eax
        mov     [ecx+string.len], eax
        pop     ecx eax
        return
endp




;***************************************************************************
; If the hString is larger than length - do nothing
; If the hString is smaller than length -> set the length of string to length
; returns pointer to the new (old) string
;
; Arguments:
;   hString - string handle. /not pointer!/
;   capacity - new string length.
; Returns:
;   eax: pointer to the string.
;   CF: error flag. If 1 the pointer to the string is returned, but
;       the capacity is not changed.
;***************************************************************************
proc StrSetCapacity, .hString, .capacity
begin
        push    ebx ecx esi

        mov     eax, [.hString]

        xor     eax, $c0000000
        test    eax, $c0000000
        jnz     .pointer

        mov     esi, eax

        mov     ebx, [ptrStrTable]
        cmp     esi, [ebx+TArray.count]
        jae     .pointer

        mov     eax, [ebx+TArray.array+4*esi]   ; pointer to the string.
        mov     ecx, [.capacity]
        cmp     ecx, STR_MINSTRLEN
        jge     @f
        mov     ecx, STR_MINSTRLEN
@@:
        cmp     [eax+sizeof.string+string.capacity], ecx
        jae     .sizeok

        shl     ecx, 1
        add     ecx, sizeof.string+4+7
        and     cl,  $f8                ; align the size to 8 bytes

        stdcall ResizeMem, eax, ecx
        jc      .error

        lea     ecx, [ecx-(sizeof.string+4)]
        mov     [ebx+TArray.array+4*esi], eax
        mov     [eax+sizeof.string+string.capacity], ecx

.sizeok:
        add     eax, sizeof.string
        pop     esi ecx ebx
        return

.error:
        int3
        add     eax, sizeof.string
        stc
        pop     esi ecx ebx
        return

.pointer:
        xor     eax, $c0000000
        stc
        pop     esi ecx ebx
        return
endp


;***************************************************************************************
;  Copies source to destination string.
;  Arguments:
;     dest - destination string (handle only)
;     source -  source string (handle or pointer)
;  Returns: nothing
;***************************************************************************************
proc StrCopy, .dest, .source
begin
        push    esi edi eax ecx

        stdcall StrLen, [.source]
        mov     ecx, eax

        stdcall StrSetCapacity, [.dest], ecx
        mov     edi, eax
        jc      .error

        stdcall StrPtr, [.source]
        mov     esi, eax

        mov     [edi+string.len], ecx

        inc     ecx
        mov     eax, ecx
        shr     ecx, 2
        rep movsd
        mov     ecx, eax
        and     ecx, 3
        rep movsb
        clc

.finish:
        pop     ecx eax edi esi
        return

.error:
        int3
        jmp     .finish

endp




;***************************************************************************************
; Compares two strings for greater, equal or less.
; Returns eax = 0 if the strings are equal.
;         eax = 1 if .str1 is grater than .str2
;         eax = -1 if .str1 is less than .str2
;
; As long as this function uses StrLen, it will be very fast on handles and relatively
; slow on pointers.
;***************************************************************************************
proc StrCompSort, .str1, .str2
begin
        push    ebx ecx esi edi

        mov     eax, [.str1]
        mov     ecx, [.str2]

        cmp     eax, ecx
        je      .equal

        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax


.cmp_loop:
        stdcall DecodeUtf8, [esi]
        add     esi, edx
        mov     ecx, eax

        stdcall DecodeUtf8, [edi]
        add     edi, edx

        test    ecx, ecx
        jz      .endstr
        test    eax, eax
        jz      .endstr

        cmp     ecx, eax
        je      .cmp_loop

        ja      .greater
        jmp     .less

.endstr:
        cmp     ecx, eax
        ja      .greater
        jb      .less

.equal:
        xor     eax, eax

.finish:
        pop     edi esi ecx ebx
        return

.greater:
        mov     eax, 1
        jmp     .finish

.less:
        mov     eax, -1
        jmp     .finish
endp



;***************************************************************************************
; Compares two strings - case sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;
; As long as this function uses StrLen, it will be very fast on handles and relatively
; slow on pointers.
;***************************************************************************************
proc StrCompCase, .str1, .str2
begin
        push    eax ecx esi edi

        mov     eax, [.str1]
        mov     ecx, [.str2]

        cmp     eax, ecx
        je      .equal

        test    eax, eax
        jz      .noteq

        test    ecx, ecx
        jz      .noteq

        stdcall StrLen, eax
        push    eax
        stdcall StrLen, ecx

        pop     ecx
        cmp     eax, ecx
        jne     .noteq

        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax

        mov     eax, ecx
        shr     ecx, 2
        repe cmpsd
        jne     .noteq
        mov     ecx, eax
        and     ecx, 3
        repe cmpsb
        jne     .noteq

.equal:
        stc
        pop     edi esi ecx eax
        return

.noteq:
        clc
        pop     edi esi ecx eax
        return
endp


;***************************************************************************************
; Compares two strings - case NOT sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;
; relatively slow, especially on equal strings, passed as pointers - this is the worst
; case. The nontrivial best case is "strings with different lengths passed as handles."
;***************************************************************************************
proc StrCompNoCase, .str1, .str2
begin
        push    eax ebx ecx edx esi edi

        mov     eax, [.str1]
        mov     ecx, [.str2]

        cmp     eax, ecx
        je      .equal

        test    eax, eax
        jz      .noteq

        test    ecx, ecx
        jz      .noteq

        stdcall StrLen, eax
        push    eax
        stdcall StrLen, ecx

        pop     ecx
        cmp     eax, ecx
        jne     .noteq

        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax


        mov     ebx, ecx
        shr     ecx, 2
        and     ebx, 3

.dword:
        dec     ecx
        js      .byte

        mov     eax, [esi]
        mov     edx, [edi]

        and     eax, $40404040
        and     edx, $40404040
        shr     eax, 1
        shr     edx, 1
        or      eax, [esi]
        or      edx, [edi]

        lea     esi, [esi+4]
        lea     edi, [edi+4]

        cmp     eax, edx
        jne     .noteq
        jmp     .dword

.byte:
        dec     ebx
        js      .equal

        mov     al, [esi]
        mov     ah, [edi]

        and     eax, $ffff
        mov     edx, eax
        and     eax, $4040
        shr     eax, 1
        or      eax, edx

        inc     esi
        inc     edi

        cmp     al, ah
        je      .byte

.noteq:
        clc
        pop     edi esi edx ecx ebx eax
        return

.equal:
        stc
        pop     edi esi edx ecx ebx eax
        return

endp



;**********************************************************
;  Creates string and assigns it to variable. If variable
;  already contains string handle, the old string will be
;  used.
;  Arguments:
;    [ptrHString] - variable containing string handle.
;    ptrSource - pointer to the source for string.
;**********************************************************
proc SetString, .ptrHString, .ptrSource
begin
        push    eax esi
        mov     esi, [.ptrHString]

        mov     eax, [esi]
        test    eax, eax
        jnz     @f
        stdcall StrNew
@@:
        mov     [esi], eax
        stdcall StrPtr, eax
        mov     dword [eax], 0
        mov     [eax+string.len], 0

        cmp     [.ptrSource], 0
        je      .finish

        stdcall StrCopy, [esi], [.ptrSource]

.finish:
        pop     esi eax
        return
endp


;**********************************************************************************
; StrCat appends one string to another
; Arguments:
;   dest - destination string (handle only)
;   source - source string
;**********************************************************************************
proc StrCat, .dest, .source
begin
        push    eax ebx ecx esi edi

        stdcall StrLen, [.dest]
        mov     ebx,eax                 ; store dest length in ebx

        stdcall StrLen, [.source]
        mov     esi, eax
        lea     ecx, [eax+ebx]

        stdcall StrSetCapacity, [.dest], ecx

        mov     [eax+string.len], ecx
        lea     edi, [eax+ebx]

        stdcall StrPtr, [.source]
        lea     ecx, [esi+1]
        mov     esi, eax

        mov     ebx, ecx
        shr     ecx, 2
        rep movsd
        mov     ecx, ebx
        and     ecx, 3
        rep movsb

        pop     edi esi ecx ebx eax
        return
endp


;**********************************************************************************
; StrCharPos returns a pointer to the first occurence of a given char
;   in specified string
; Arguments:
;   Char - char to look for
;   hString -  string to search
; Returns: a pointer to the char in source, or NULL if char doesn't occur
;   in given string
;**********************************************************************************
proc StrCharPos, .hString, .char
begin
        push    esi

        stdcall StrPtr, [.hString]
        mov     esi,eax

        mov     ah, byte [.char]
;        xchg    al,ah

.search:
        mov     al,[esi]
        inc     esi
        or      al,al
        jz      .not_found
        cmp     al,ah
        jne     .search

        mov     eax, esi
        dec     eax
        pop     esi
        return

.not_found:
        xor     eax,eax
        pop     esi
        return
endp


;**********************************************************************************
; StrPos returns a pointer to the first occurence of a pattern string
;   in another string
; Arguments:
;   hPattern - 'pattern' string
;   hString -  string to search
; Returns: a pointer to the pattern string in source , or NULL if pattern string
; doesn't occur in the string to search
;**********************************************************************************
proc StrPos, .hString, .hPattern
begin
        push    ebx ecx edx esi edi     ; esp = esp -20
        mov     esi,[.hPattern]         ; mov esi,[hPattern]
        mov     edi,[.hString]          ; mov edi,[hString]
        stdcall StrLen, edi
        mov     ebx,eax                 ; now ebx holds lenght of the string to search
        stdcall StrLen, esi
        mov     edx,eax                 ; now edx holds length of the pattern string

        cmp     edx, ebx
        ja      .not_found              ; if the pattern is longer than the string

        stdcall StrPtr, esi
        mov     esi,eax                 ; put pointer to the pattern str in esi
        stdcall StrPtr,edi
        mov     edi,eax                 ; put pointer to the search str in edi
        lodsb                           ; load first character of the pattern
        mov     ecx,ebx                 ;
        mov     ebx,edx                 ; put str_len(pattern)-1 in ebx
        dec     ebx                     ;
        sub     ecx, ebx                ; there is no need to search to the end, but only to len(string)-len(pattern)-1

.search:
        repne   scasb
        jne     .not_found
;        cmp     ecx,ebx
;        jb      .not_found
        push    edi esi ecx
        or      ebx,ebx                 ; ebx==0 means that we were searching for one
        jz      .got_it                 ; character. We found it, so we stop.
        mov     ecx,ebx
        repe    cmpsb
        jne     .not_match

.got_it:
        pop     ecx esi edi
        dec     edi
        mov     eax,edi

.ret:
        pop     edi esi edx ecx ebx
        return

.not_match:
        pop     ecx esi edi
        jmp     .search

.not_found:
        xor     eax,eax
        jmp     .ret
endp





proc StrCopyPart, .dest, .source, .pos, .len
begin
        push    eax ecx esi edi

        stdcall StrPtr, [.source]
        mov     esi, eax
        stdcall StrLen, [.source]
        mov     ecx, eax

        mov     eax, [.pos]
        cmp     eax, ecx
        jae     .cleardest      ;

        sub     ecx, [.pos]
        mov     eax, [.len]

; ecx = min(ecx, eax)
        sub     eax, ecx
        sbb     edi, edi
        and     edi, eax
        add     ecx, edi

        add     esi, [.pos]

        stdcall StrSetCapacity, [.dest], ecx
        jc      .finish

        mov     edi, eax
        mov     [edi+string.len], ecx

        push    ecx
        shr     ecx, 2
        rep movsd
        pop     ecx
        and     ecx, 3
        rep movsb

        lea     ecx, [edi+3]
        and     cl, $fc
        sub     ecx, edi
        xor     eax, eax
        rep stosb

.finish:
        pop     edi esi ecx eax
        return

.cleardest:
        stdcall StrSetCapacity, [.dest], STR_MINSTRLEN
        mov     [eax+string.len], 0
        mov     dword [eax], 0
        jmp     .finish
endp




;**********************************************************************************
; StrExtract copies the part of [string] from [index] with lenght in [len]
; Returns handle to new created string.
;**********************************************************************************
proc StrExtract, .string, .pos, .len
begin
        stdcall StrNew
        stdcall StrCopyPart, eax, [.string], [.pos], [.len]
        return
endp




;__________________________________________________________________________________
; Splits the string on two strings, at position [.pos]
; Arguments:
;   .pString - pointer to string to be splitted.
;   .pos     - position where to split the string.
; Returns:
;   eax - handle to the new created string with second part of the string.
;         the original string does not reallocate memory and it's capacity
;         and the pointer will remains the same.
;__________________________________________________________________________________

proc StrSplit, .hString, .pos
begin
        push    ecx edi

        stdcall StrExtract, [.hString], [.pos], -1
        push    eax

        stdcall StrLen, eax
        mov     ecx, eax
        stdcall StrPtr, [.hString]

        sub     [eax+string.len], ecx   ; new length of the source string.
        add     eax, [eax+string.len]
        mov     edi, eax

        lea     ecx, [eax+3]
        and     cl, $fc
        sub     ecx, eax
        xor     eax, eax
        cld
        rep stosb

        pop     eax
        pop     edi ecx
        return
endp





;__________________________________________________________________________________
; StrInsert inserts one string into another at specified pos
; Arguments:
;   dest - destination where the source will be inserted.
;   source -  string to insert
;   pos    - where to insert.
; Returns:
;   nothing.
;__________________________________________________________________________________
proc StrInsert, .dest, .source, .pos
begin
        push    eax

        stdcall StrSplit, [.dest], [.pos]
        push    eax eax

        stdcall StrCat, [.dest], [.source]
        stdcall StrCat, [.dest] ; source from the stack.
        stdcall StrDel; from the stack.

        pop     eax
        return
endp


; TODO:
; String case functions are giving weird results in linux, so
; here are two functons I wrote some time ago.
; I have tested the following functions in win32 and worked well
; Perhaps it is time to fully support UTF encoded strings.
; These functions here are faster (20-25%), but the results are
; exactly the same as the strlib ones.
;                                    pelaillo

; -----------------------------------------------
; str_ucase:
;         Author: pelaillo
;           Date: Jan. 16, 2002
;    Converts also accented characters: ÑÚ <--> ñú
; -----------------------------------------------

proc StrUCase2, .hString
begin
        push    eax edx edi

        stdcall StrPtr, [.hString]
        mov     edi, eax
.str_ucase:
                mov     eax, [edi]
                mov     edx, eax
                and     edx, 40404040h
                ror     edx, 1
                xor     edx, -1
                and     eax, edx
                mov     [edi], eax
                add     edi, 4
                lea     edx, [eax-01010101h]
                xor     eax, edx
                and     eax, 80808080h
                jz      .str_ucase
                and     eax, edx
                jz      .str_ucase

        pop     edi edx eax
        return
endp

; -----------------------------------------------
; str_lcase:
;         Author: pelaillo
;           Date: Jan. 16, 2002
;    Converts also accented characters: ÑÚ <--> ñú
; -----------------------------------------------

proc StrLCase2, .hString
begin
        push    eax edx edi

        stdcall StrPtr, [.hString]
        mov     edi, eax
.str_lcase:
        mov     eax, [edi]
        mov     edx, eax
        and     edx, 40404040h
        ror     edx, 1
        or      eax, edx
        mov     [edi], eax
        add     edi, 4
        lea     edx, [eax-01010101h]
        xor     eax, edx
        and     eax, 80808080h
        jz      .str_lcase
        and     eax, edx
        jz      .str_lcase

        pop     edi edx eax
        return
endp


;**********************************************************************************
; Converts strings to Lower Case
;**********************************************************************************
proc StrLCase, .hString
begin
        push    eax ebx ecx edx edi

        stdcall StrPtr, [.hString]
        mov     edi, eax

        stdcall StrLen, [.hString]
        mov     ecx, eax
        mov     ebx, edi

        and     ebx, 3
        sub     ecx, ebx
        jbe     .byte2          ; the string is small enough, so process it by bytes.

.byte1:
        test    edi, 3
        jz      .ddword

        mov     al, [edi]
        and     al, $40
        shr     al, 1
        or      byte [edi], al

        inc     edi
        jmp     .byte1

.ddword:
        mov     ebx, ecx
        and     ebx, 3
        shr     ecx, 2
        jecxz   .byte

.qword:
        mov     eax, [edi]
        mov     edx, [edi+4]

        and     eax, $40404040
        and     edx, $40404040

        shr     eax, 1
        shr     edx, 1

        or      [edi], eax
        or      [edi+4], edx

        add     edi, 8
        dec     ecx
        jnz     .qword

.byte:
        dec     ebx
        js      .finish

        mov     al, [edi]
        and     al, $40
        shr     al, 1
        or      byte [edi], al

        inc     edi
        jmp     .byte

.byte2:
        mov     ebx, ecx
        jmp     .byte

.finish:
        pop     edi edx ecx ebx eax
        return
endp


;**********************************************************************************
; Converts strings to Upper Case
; First parameter = String to Convert to upper case
;**********************************************************************************
proc StrUCase, .hString
begin
        push    eax ebx ecx edx edi

        stdcall StrPtr, [.hString]
        mov     edi, eax

        stdcall StrLen, [.hString]
        mov     ecx, eax
        mov     ebx, edi

        and     ebx, 3
        sub     ecx, ebx
        jbe     .byte2          ; the string is small enough, so process it by bytes.

.byte1:
        test    edi, 3
        jz      .ddword

        mov     al, [edi]
        and     al, $40
        shr     al, 1
        not     al
        and     byte [edi], al

        inc     edi
        jmp     .byte1

.ddword:
        mov     ebx, ecx
        and     ebx, 3
        shr     ecx, 2
        jecxz   .byte

.qword:
        mov     eax, [edi]
        mov     edx, [edi+4]

        and     eax, $40404040
        and     edx, $40404040

        shr     eax, 1
        shr     edx, 1

        not     eax
        not     edx

        and     [edi], eax
        and     [edi+4], edx

        add     edi, 8
        dec     ecx
        jnz     .qword

.byte:
        dec     ebx
        js      .finish

        mov     al, [edi]
        and     al, $40
        shr     al, 1
        not     al
        and     byte [edi], al

        inc     edi
        jmp     .byte

.byte2:
        mov     ebx, ecx
        jmp     .byte

.finish:
        pop     edi edx ecx ebx eax
        return
endp




;**********************************************************************************
; _NumToStr converts the number in eax to the string in any radix approx. [2..26]
; Arguments:
;   [edi] - pointer to the string buffer
;   ecx - radix
;   eax - number to convert.
; There is no parameter check, so be careful.
; returns: edi points to the end of a converted number
;**********************************************************************************
proc _NumToStr
begin
    test  eax,eax
    jns   _NumToStrU
    neg   eax
    mov   byte [edi],"-"
    inc   edi
endp

proc _NumToStrU
begin
    cmp   eax,ecx
    jb    .lessA
    xor   edx,edx
    div   ecx
    push  edx
    call  _NumToStrU
    pop   eax
.lessA:
    cmp   al, 10
    sbb   al, 69h
    das
    stosb
    return
endp



;*****************************************************
; NumToStrF:
;   Converts signed integer value to string.
; NumToStrUF:
;   Converts unsigned integer value to string.
;
; edi - pointer to string buffer
; eax - Number to convert
; ecx - radix from 2 to $ff
; esi - length of the number in chars
;
; returns: edi - pointer to the end of converted num
;
; Note: Don't use 1 as radix.
;*****************************************************
proc _NumToStrF
begin
        test    eax,eax
        jns     _NumToStrUF
        neg     eax
        mov     byte [edi],'-'
        push    esi
        dec     esi
        add     edi, esi
        push    edi
        jmp     _NumToStrUF.loopc
endp

proc _NumToStrUF
begin
        push    esi
        add     edi, esi
        push    edi
        dec     edi
.loopc:
        xor     edx,edx
        div     ecx
        xchg    al,dl
        cmp     al,$0a
        sbb     al,$69
        das
        mov     [edi],al
        dec     edi
        xchg    al,dl
        dec     esi
        jnz     .loopc
        pop     edi
        pop     esi
        return
endp


;***********************************************************
; NumToStr - converts number to any radix.
; num - number to convert
; str - handle of the string. If NULL - creates new string.
; index - Offset in string where to put converted number.
; flags:
;   byte 0 - number of digits if ntsFixedWidth is set.
;   byte 1 - contains radix for the convertion.
;   byte 2,3 - flags.
; Returns:
;   eax - handle of the string.
;***********************************************************
proc NumToStr, .num, .flags
begin
        push    ebx ecx edx esi edi

        stdcall StrNew
        push    eax

        stdcall StrSetCapacity, eax, 40
        mov     edi, eax
        push    eax             ; pointer for the length.

; determine which conversion func to use
        movzx   eax, byte [.flags+2]    ; signed/fixed
        and     eax, (ntsUnsigned or ntsFixedWidth) shr 16
        mov     ebx, [.NumToStrFunc+4*eax]

        movzx   ecx, byte [.flags+1]       ; load radix into ecx
        movzx   esi, byte [.flags]
        mov     eax, [.num]
        call    ebx                     ; call low-level convertion routine
        mov     dword [edi], 0

        pop     eax
        sub     edi, eax
        mov     [eax+string.len], edi

        pop     eax
        pop     edi esi edx ecx ebx
        return

.NumToStrFunc dd _NumToStr, _NumToStrU, _NumToStrF, _NumToStrUF

endp




;-------------------------------------------------------
; function StrToNum
;   Converts specified string into a number
;
; Arguments:
;   hString - handle/pointer of the string containing
;     number to convert. It doesn't have to be ended by
;     NULL, any other character will stop conversion.
;     Number to convert must be decimal.
;
; Return:
;   eax - converted number
;   edx - offset to the byte where convertion ended.
;
; Note: in case of failture (first char of given pointer
;   isn't a number) function returns -1.
;-------------------------------------------------------
proc StrToNum, .hString
begin
        push    ebx esi edi
        xor     ebx,ebx         ; ebx will store our number

        stdcall StrPtr, [.hString]
        mov     edi, eax
        mov     esi,eax
        xor     eax,eax
        mov     al,[esi]
        cmp     al,'0'
        jb      .error
        cmp     al,'9'
        jbe     .digit
        jmp     .error
     .digit:
        sub     al,'0'
        add     ebx,eax
        inc     esi
        mov     al,[esi]
        cmp     al,'0'
        jb      .finish
        cmp     al,'9'
        ja      .finish
        mov     edx,ebx         ; multiply ebx by 10
        shl     ebx,3
        add     ebx,edx
        add     ebx,edx
        jmp     .digit
     .finish:

        mov     eax, ebx
        mov     edx, esi
        sub     edx, edi
        clc
        pop     edi esi ebx
        return

     .error:
        mov     eax, -1
        stc
        pop     edi esi ebx
        return
endp






proc StrToNumEx, .hstring
.sign dd ?
begin
        push    ebx edx esi edi

        stdcall StrLen, [.hstring]
        mov     edx, eax
        test    eax, eax
        jz      .invalid_number

        stdcall StrPtr, [.hstring]
        mov     esi, eax
        lea     edi, [eax+edx]

; sign?
        mov     [.sign], 0
        cmp     byte [esi], '-'
        jne     .radix

        mov     [.sign], -1
        inc     esi

; determine what is the radix.
.radix:
        cmp     byte [esi], '$'
        je      .hex
        cmp     word [esi], '0x'
        jne     .postfix
        inc     esi
.hex:
        inc     esi
        mov     edx, 16
        jmp     .decode

.postfix:
; search for 'h' or 'b' or 'o'
        mov     al, [edi-1]
        or      al, $40

        mov     edx, 16
        cmp     al, 'h'
        je      .postok

        mov     edx, 8
        cmp     al, 'o'
        je      .postok

        mov     edx, 2
        cmp     al, 'b'
        je      .postok

        mov     edx, 10
        inc     edi

.postok:
        dec     edi

; here, edx contains the radix, esi - begin of the number; edi - end of the number.
.decode:
        xor     ebx, ebx
        cmp     esi, edi
        jae     .invalid_number

.decode_loop:
        lodsb

        cmp     al, '0'
        jb      .invalid_number
        cmp     al, '9'
        jbe     .digit

        or      al, $40
        cmp     al, 'z'         ; common
        ja      .invalid_number
        cmp     al, 'a'
        jb      .invalid_number

        sub     al, 'a'-'0'-10

.digit:
        sub     al, '0'
        movzx   eax, al

        cmp     eax, edx
        jae     .invalid_number

        imul    ebx, edx
        add     ebx, eax

        cmp     esi, edi
        jne     .decode_loop

; set the sign:
        xor     ebx, [.sign]
        sub     ebx, [.sign]

        clc
        mov     eax, ebx
        pop     edi esi edx ebx
        return

.invalid_number:
        xor     eax, eax
        stc
        pop     edi esi edx ebx
        return
endp








;-------------------------------------------------------
; function StrCharCat
;   Appends up to 4 chard at the end of the string.
;
; Arguments:
;   hString - string to append
;   char - char(s) to add
; Returns:
;   nothing
;-------------------------------------------------------
proc StrCharCat, .hString, .char
begin
        push    eax ecx

        stdcall StrLen, [.hString]
        mov     ecx, eax
        add     eax, 8

        stdcall StrSetCapacity, [.hString], eax
        jnc     @f
        int3
@@:

        pushd   [.char]
        popd    [eax+ecx]
        mov     dword [eax+ecx+4], 0
        dec     ecx
.goend:
        inc     ecx
        cmp     byte [eax+ecx], 0
        jne     .goend

        mov     [eax+string.len], ecx

        pop     ecx eax
        return
endp


;------------------------------------------------------------
; function StrInsertChar
;   Inserts up to 4 chars into the given position of the string
;
; Arguments:
;   hString - string to append
;   char    - char to add
;   pos     - position where to add the char
;-------------------------------------------------------------
proc StrCharInsert, .hString, .char, .pos
.str rd 4
begin
        push    eax
        push    [.char]
        pop     [.str]
        mov     [.str+4], 0
        mov     [.str+8], 0

        lea     eax, [.str]
        stdcall StrInsert, [.hString], eax, [.pos]
        pop     eax
        return
endp



;_______________________________________________________________________
; proc StrClipSpacesR
;   Removes the spaces from the right of the string.
; Arguments:
;   hString - string to be processed
; Returns:
;   CF=1 - invalid string handle.
;_______________________________________________________________________
proc StrClipSpacesR, .hString
begin
        push    eax ecx

        stdcall StrPtr, [.hString]
        jc      .finish

        mov     ecx, [eax+string.len]
        jecxz   .exit
.loop:
        cmp     byte [eax+ecx-1], ' '
        jne     .exit
        dec     ecx
        jnz     .loop
.exit:
        mov     [eax+string.len], ecx
        mov     dword [eax+ecx], 0

.finish:
        pop     ecx eax
        return
endp


;_______________________________________________________________________
; proc StrClipSpacesL
;   Removes the spaces from the left of the string.
; Arguments:
;   hString - string to be processed
; Returns:
;   CF=1 - invalid string handle.
;_______________________________________________________________________
proc StrClipSpacesL, .hString
begin
        push    esi edi eax ecx

        stdcall StrPtr, [.hString]
        jc      .finish

        mov     ecx, [eax+string.len]
        mov     esi, eax
        mov     edi, eax

.loop:
        jecxz   .copy
        cmp     byte [esi], ' '
        jne     .copy

        inc     esi
        dec     ecx
        jmp     .loop

.copy:
        mov     [edi+string.len], ecx
        jecxz   .finish
        cmp     esi, edi
        je      .finish
        rep movsb

.finish:
        pop     ecx eax edi esi
        return
endp



;_______________________________________________________________________
; proc StrCleanDupSpaces
;   Removes duplicating spaces from the string.
; Arguments:
;   hString - string to be processed
; Returns:
;   CF=1 - invalid string handle.
;_______________________________________________________________________
proc StrCleanDupSpaces, .hString
begin
        push    esi edi eax ecx edx

        stdcall StrPtr, [.hString]
        jc      .finish

        mov     ecx, [eax+string.len]
        lea     edx, [eax+string.len]
        mov     esi, eax
        mov     edi, eax

        jecxz   .endcopy

.loop:
        lodsb
        cmp     al, ' '
        jne     .store
        cmp     byte [esi], ' '
        jne     .store
; skip
        dec     dword [edx]
        jmp     .next

.store:
        stosb

.next:
        dec     ecx
        jnz     .loop

.endcopy:
        xor     eax, eax
        stosd

.finish:
        pop     edx ecx eax edi esi
        return
endp






;_______________________________________________________________________
;
; proc StrHash
;   Computes 32 bit hash value from the string.
;   This procedure implements the hash algoritm: FNV-1b
;
; Arguments:
;   .hString - handle of string.
;
; Return:
;   eax - 32bit hash value.
;
; Changes:
;   eax
;_______________________________________________________________________
proc StrHash, .hString
begin
        stdcall StrLen, [.hString]
        push    eax
        stdcall StrPtr, [.hString]
        push    eax
        call    DataHash
        return
endp


proc DataHash, .ptrData, .len
begin
        push    ecx edx esi

        mov     esi, [.ptrData]
        mov     ecx, [.len]
        mov     eax, $811C9DC5                  ; 2166136261              ; FNV offset basis
        inc     ecx

.hashloop:
        dec     ecx
        jz      .exit
        movzx   edx, byte [esi]
        xor     eax, edx
        inc     esi
        imul    eax, $01000193                  ;   16777619              ; FNV prime
        jmp     .hashloop

.exit:
        pop     esi edx ecx
        return
endp



proc StrURLEncode, .hstr
.res dd ?
begin
        push    ebx ecx edx esi edi
        stdcall StrPtr, [.hstr]
        mov     esi, eax

        stdcall StrLen, esi
        mov     ecx, eax
        lea     edx, [2*eax+eax]        ; the encoded string can be max 3x long as original string.

        stdcall StrNew
        mov     [.res], eax
        jecxz   .finish

        stdcall StrSetCapacity, eax, edx
        mov     edi, eax
        xor     edx, edx
        xor     ebx, ebx

        push    eax
.encode:
        lodsb
        cmp     al, $80
        jae     .store          ; it is a hack, but I hope save enough.

        mov     dl, al
        mov     bl, al
        shr     edx, 5
        and     ebx, $1f
        bt      dword [.URLCharTable+4*edx], ebx
        jnc     .store

        mov     ah, al
        mov     al, '%'
        stosb
        mov     al, ah
        shr     al, 4
        cmp     al, $0a
        sbb     al, $69
        das
        stosb
        mov     al, ah
        and     al, $0f
        cmp     al, $0a
        sbb     al, $69
        das

.store:
        stosb
        loop    .encode

        xor     al, al
        mov     [edi], al

        pop     eax
        sub     edi, eax
        mov     [eax+string.len], edi

.finish:
        mov     eax, [.res]
        pop     edi esi edx ecx ebx
        return

; Contains 1 where the character must be % encoded and 0 where it is save to pass it directly
.URLCharTable db 11111111b       ;
              db 11111111b       ;
              db 11111111b       ;
              db 11111111b       ; 0..31 -control chars | encoded
              db 11111111b       ; $27 - $20: '&%$#"!   | encoded
              db 11111111b       ; $2f - $28: /.-,+*)(  | encoded
              db 00000000b       ; $37 - $30: 76543210  | not encoded
              db 11111100b       ; $3f - $38: ?>=<;:98  | partially
              db 00000001b       ; $47 - $40: GFEDCBA@  | partially
              db 00000000b       ; $4f - $48: ONMLKJIH  | not encoded
              db 00000000b       ; $57 - $50: WVUTSRQP  | not encoded
              db 11111000b       ; $5f - $58: _^]\[ZYX  | partially
              db 00000001b       ; $67 - $60: gfedcba`  | partially
              db 00000000b       ; $6f - $68: onmlkjih  | not encoded
              db 00000000b       ; $77 - $70: wvutsrqp  | not encoded
              db 11111000b       ; $7f - $78:  ~}|{zyx  | partially
endp



proc StrURLDecode, .hstring
begin
        pushad

        stdcall StrLen, [.hstring]
        mov     ecx, eax
        jecxz   .finish

        stdcall StrPtr, [.hstring]
        mov     esi, eax
        mov     edi, eax
        mov     ebx, eax

.loop:
        lodsb

        test    al, al
        jz      .end_of_string

        cmp     al, '+'
        je      .space

        cmp     al, '%'
        jne     .store

        lodsb
        cmp     al, '9'
        jbe     @f
        add     al, $09
@@:
        shl     al, 4
        mov     ah, al

        lodsb
        cmp     al, '9'
        jbe     @f
        add     al, $09
@@:
        and     al, $0f
        or      al, ah
        jmp     .store

.space:
        mov     al, ' '

.store:
        stosb
        loop    .loop

.end_of_string:
        mov     ecx, edi
        sub     ecx, ebx
        xor     eax, eax
        stosd

        mov     [ebx+string.len], ecx

.finish:
        popad
        return

endp


; UTF-8 support functions.
; Some of the above functions also need some revision in order to support
; utf-8 strings properly.


;  Bug - on [.len]=-1 sometimes in Linux returns error on normal strings.

proc StrLenUtf8, .hString, .len
.maxptr dd ?
begin
        push    esi ecx edx

        stdcall StrPtr, [.hString]
        mov     esi, eax
        mov     eax, [.len]
        cmp     eax, -1
        je      @f
        add     eax, esi
@@:
        mov     [.maxptr], eax
        xor     ecx, ecx

.loop:
        cmp     esi, [.maxptr]
        jae     .endofstring

        mov     eax, [esi]
        stdcall DecodeUtf8, eax
        jc      .error

        test    eax, eax
        jz      .endofstring

        add     esi, edx
        inc     ecx
        jmp     .loop

.endofstring:
        mov     eax, ecx
        pop     edx ecx esi
        clc
        return

.error:
        pop     edx ecx esi
        return
endp



proc StrOffsUtf8, .hString, .pos
begin
        push    edx esi

        stdcall StrPtr, [.hString]
        mov     esi, eax

.loop:
        dec     [.pos]
        js      .finish

        stdcall DecodeUtf8, [esi]
        jc      .error

        test    eax, eax
        jz      .finish

        add     esi, edx
        jmp     .loop

.finish:
        clc
        mov     eax, esi
        pop     esi edx
        return

.error:
        xor     eax, eax
        pop     esi edx
        return
endp



; decodes 4 bytes in [.chars] to UNICODE dword value.
; returns:
;   CF=0 - no error
;     eax - unicode value.
;     edx - byte count of the char. [1..4]
;   CF=1 - invalid utf-8 char;
;     eax = edx = 0  the character can not be decoded.
;     edx <> 0 -> eax = the overlong encoded character. edx = byte count of the char.
;
;  Note: When CF=1 and [.chars] are overlong encoded char.
;        eax contains the proper value and edx contains the proper length.
;        But it is still invalid character, according to the standards.
proc DecodeUtf8, .chars
begin
        push    ebx ecx

        xor     ecx, ecx

.loop1:
        shl     byte [.chars], 1
        jnc     .countok
        inc     ecx
        jmp     .loop1

.countok:
        jecxz   .ascii

        cmp     ecx, 1
        je      .error          ; internal byte
        cmp     ecx, 4
        ja      .error          ; more than 4 bytes

        mov     edx, 1
        xor     ebx, ebx
        movzx   eax, byte [.chars]
        shr     eax, cl
        shr     eax, 1

.loop2:
        mov     bl, byte [.chars+edx]
        and     bl, $c0
        cmp     bl, $80
        jne     .error
        mov     bl, byte [.chars+edx]
        and     bl, $3f
        shl     eax, 6
        or      eax, ebx
        inc     edx
        cmp     edx, ecx
        jne     .loop2

        and     eax, $1fffff
        cmp     eax, $10ffff
        ja      .error

        cmp     eax, [._minimal+4*edx-8]
        jb      .overlong   ; overlong coding.

        clc
        pop     ecx ebx
        return

.ascii:
        movzx   eax, byte [.chars]
        shr     eax, 1
        mov     edx, 1
        pop     ecx ebx
        clc
        return

.error:
        xor     eax, eax
        xor     edx, edx
.overlong:
        stc
        pop     ecx ebx
        return

._minimal dd $80, $800, $10000

endp



proc ScanForwardUtf8
begin
        push    eax

        mov     al, [esi]
        test    al, al
        jns     .finish

        and     al, 11000000b
        cmp     al, 11000000b
        je      .finish

; inc forward
.loopf:
        inc     esi
        mov     al, [esi]
        and     al, 11000000b
        cmp     al, 10000000b
        je      .loopf

.finish:
        pop     eax
        return
endp



proc ScanBackUtf8
begin
        push    eax

        mov     al, [esi]
        test    al, al
        jns     .finish

        and     al, 11000000b
        cmp     al, 11000000b
        je      .finish

; inc back
.loopf:
        dec     esi
        mov     al, [esi]
        and     al, 11000000b
        cmp     al, 10000000b
        je      .loopf

.finish:
        pop     eax
        return
endp



proc ExpandTabs, .hstring, .tabstop
.start dd ?
.count dd ?
.correction dd ?
begin
        pushad

        mov     [.count], 0
        mov     [.correction], 0

        stdcall StrLen, [.hstring]
        mov     ecx, eax
        stdcall StrPtr, [.hstring]
        mov     [.start], eax
        mov     esi, eax
        add     ecx, eax
        xor     ebx, ebx

        jecxz   .end_scan

.scan_loop:
        stdcall DecodeUtf8, [esi]
        cmp     eax, $09
        jne     .next

        mov     byte [esi], $20

        push    edx
        mov     eax, ebx
        cdq
        div     [.tabstop]
        imul    eax, [.tabstop]
        pop     edx
        add     eax, [.tabstop]
        sub     eax, ebx
        dec     eax
        jz      .next

        add     ebx, eax
        add     [.correction], eax
        push    eax             ; space count

        mov     eax, esi
        sub     eax, [.start]
        push    eax             ; offset

        inc     [.count]

.next:
        inc     ebx
        add     esi, edx
        cmp     esi, ecx
        jb      .scan_loop

.end_scan:
        cmp     [.count], 0
        je      .finish

.expand:
        pop     ebx             ; offset
        pop     eax             ; count

.ins_spc:
        stdcall StrCharInsert, [.hstring], ' ', ebx
        dec     eax
        jnz     .ins_spc

.next_tab:
        dec     [.count]
        jnz     .expand

.finish:
        popad
        mov     eax, [.correction]
        return
endp



proc StrIP2Num, .hString
begin
        push    ebx edx esi

        xor     ebx, ebx
        stdcall StrPtr, [.hString]
        mov     esi, eax

; string to IP
.iploop:
        stdcall StrToNum, esi
        cmp     eax, $100
        jae     .invalid_ip

        cmp     ebx, $1000000
        jae     .invalid_ip

        shl     ebx, 8
        or      bl, al

        cmp     byte [esi+edx], 0
        je      .end_of_ip

        cmp     byte [esi+edx], '.'
        jne     .invalid_ip

        lea     esi, [esi+edx+1]
        jmp     .iploop

.invalid_ip:
        stc
        mov     eax, ebx
        pop     esi ebx
        return

.end_of_ip:
        clc
        mov     eax, ebx
        pop     esi edx ebx
        return
endp



proc StrEncodeHTML, .hString
begin
        push    esi edi

        stdcall StrNew
        mov     edi, eax

        stdcall StrPtr, [.hString]
        mov     esi, eax

.loop:
        movzx   eax, byte [esi]
        inc     esi

        test    eax, eax
        jz      .end_of_string

        cmp     al, '<'
        je      .char_less_then
        cmp     al, '>'
        je      .char_greater_then
        cmp     al, '"'
        je      .char_quote
        cmp     al, '&'
        je      .char_amp
        cmp     al, "'"
        je      .char_apos

.store:
        stdcall StrCharCat, edi, eax
        jmp     .loop

.end_of_string:
        mov     eax, edi
        pop     edi esi
        return

.char_less_then:
        mov     eax, '&lt;'
        jmp     .store

.char_greater_then:
        mov     eax, '&gt;'
        jmp     .store

.char_quote:
        stdcall StrCharCat, edi, '&quo'
        mov     eax, 't;'
        jmp     .store

.char_apos:
        stdcall StrCharCat, edi, '&apo'
        mov     eax, 's;'
        jmp     .store

.char_amp:
        stdcall StrCharCat, edi, '&amp'
        mov     eax, ';'
        jmp     .store
endp





proc DateTimeToStr, .pDateTime, .format
begin
        push    ebx esi

        mov     esi, [.pDateTime]

; date
        stdcall NumToStr, [esi+TDateTime.date], ntsUnsigned or ntsFixedWidth or ntsDec + 2
        mov     ebx, eax
        stdcall StrCharCat, ebx, '.'
        stdcall NumToStr, [esi+TDateTime.month], ntsUnsigned or ntsFixedWidth or ntsDec + 2
        stdcall StrCat, ebx, eax
        stdcall StrDel, eax
        stdcall StrCharCat, ebx, '.'
        stdcall NumToStr, [esi+TDateTime.year], ntsSigned or ntsFixedWidth or ntsDec + 4
        stdcall StrCat, ebx, eax
        stdcall StrDel, eax
        stdcall StrCharCat, ebx, '  '

; time
        stdcall NumToStr, [esi+TDateTime.hour], ntsUnsigned or ntsFixedWidth or ntsDec + 2
        stdcall StrCat, ebx, eax
        stdcall StrDel, eax
        stdcall StrCharCat, ebx, ':'
        stdcall NumToStr, [esi+TDateTime.minute], ntsUnsigned or ntsFixedWidth or ntsDec + 2
        stdcall StrCat, ebx, eax
        stdcall StrDel, eax
        stdcall StrCharCat, ebx, ':'
        stdcall NumToStr, [esi+TDateTime.second], ntsUnsigned or ntsFixedWidth or ntsDec + 2
        stdcall StrCat, ebx, eax
        stdcall StrDel, eax

        mov     eax, ebx
        pop     esi ebx
        return
endp




include '%TargetOS%/utf8.asm'



endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/data/uConfig.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: OS independent micro configuration files library.
;
;  Target OS: Any
;
;  Dependencies: memory.asm; strlib.asm; arrays.asm; files.asm
;
;  Notes:
;
;_________________________________________________________________________________________
module "uConfig library"


; Structure of the file of uConfig:
;
; offset  | size  |   description
; --------+-------+-----------------------------------------------------------------------
;   0     |  4    |   Signature
;   4     |  4    |   $0a1a0a0d (CR, LF, EOF, 00)
;   8     |  4    |   Hash of the whole file including file length of the next field
;   12    |  4    |   Chunk data length (N)
;   16    |  N    |   Data chunks
; --------+-------+-----------------------------------------------------------------------
;
; Every data chunk have following structure:
;
; offset  | size  |   description
; --------+-------+-----------------------------------------------------------------------
;    0    |  4    |  Key name 4xASCII chars.
;    4    |  4    |  Length of the data in bytes (K)
;    8    |  4    |  Data type. Constant of cdtXXXXX (see definitions below)
;   12    |  K    |  Chunk data.
; --------+-------+-----------------------------------------------------------------------
;


cdtNULL     = 0
cdtInteger  = 1   ; 32bit integer value.
cdtString   = 2   ; utf-8 string.
cdtBlob     = 3   ; arbitraty sized array of bytes.
cdtConfig   = 4

cdtMaxAlowed = cdtConfig

struct TConfigHeader
  .signature dd ?
  .filler    dd ?
  .hash      dd ?
  .length    dd ?
  .chunks:
ends


struct TChunkHeader
  .KeyName dd ?
  .length  dd ?         ; length of the data without the size of the header and checksum.
  .type    dd ?
ends


struct TConfigRecord
  .KeyName  dd ?
  .DataSize dd ?
  .Type     dd ?
  .Data     dd ?
ends


; loads the file representation from the memory and expands it to the database tree structure.
; returns pointer to TArray of TConfigRecord structures.
proc LoadConfigDB, .ptrSource, .signature
begin
        push    ecx edx esi

        mov     esi, [.ptrSource]
        test    esi, esi
        jnz     .process_source

        stdcall CreateArray, sizeof.TConfigRecord
        jmp     .db_ok

.process_source:
; check 8 bytes signature
        mov     edx, [esi+TConfigHeader.signature]

        cmp     [.signature], -1
        je      .signatureok

        cmp     edx, [.signature]
        jne     .error_bad_signature

.signatureok:
        mov     [.signature], edx

        cmp     dword [esi+TConfigHeader.filler], $001a0a0d
        jne     .error_bad_signature

        mov     ecx, [esi+TConfigHeader.length]
        lea     esi, [esi+TConfigHeader.length]
        add     ecx, 4                                  ;(the length itself)
        stdcall DataHash, esi, ecx
        cmp     eax, [esi-4]
        jne     .error_bad_hash

        add     esi, 4
        sub     ecx, 4
        stdcall __DoRecurseConfigSource, esi, ecx

.db_ok:
        pushd   [.signature]
        popd    [eax+TArray.lparam]     ; store the signature to the .lparam field of the root TArray
        clc

.finish:
        pop     esi edx ecx
        return

.error_bad_signature:
        mov     eax, -1
        stc
        jmp     .finish

.error_bad_hash:
        mov     eax, -2
        stc
        jmp     .finish
endp



proc __DoRecurseConfigSource, .ptrSource, .length
.array  dd ?
begin
        pushad

        stdcall CreateArray, sizeof.TConfigRecord
        mov     [.array], eax

        mov     esi, [.ptrSource]
        mov     ecx, [.length]

.chunk_loop:
        cmp     ecx, sizeof.TConfigRecord
        jb      .finish

        stdcall AddArrayItems, [.array], 1
        mov     [.array], edx
        mov     edi, eax

        mov     eax, [esi+TChunkHeader.KeyName]
        mov     edx, [esi+TChunkHeader.length]
        mov     [edi+TConfigRecord.KeyName], eax
        mov     [edi+TConfigRecord.DataSize], edx

        mov     eax, [esi+TChunkHeader.type]
        mov     [edi+TConfigRecord.Type], eax

        add     esi, sizeof.TChunkHeader
        sub     ecx, sizeof.TChunkHeader

        and     eax, $7
        movzx   eax, [.type_handlers+eax]
        add     eax, .type_handlers
        call    eax
        mov     [edi+TConfigRecord.Data], eax

.next_chunk:
        mov     eax, [edi+TConfigRecord.DataSize]
        add     eax, 3
        and     al, $fc

        add     esi, eax
        sub     ecx, eax
        jmp     .chunk_loop

.finish:
        popad
        mov     eax, [.array]
        return

.type_handlers db .handle_null   - .type_handlers
               db .handle_int    - .type_handlers
               db .handle_string - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_config - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers

.handle_config:
        stdcall __DoRecurseConfigSource, esi, edx
.handle_null:
        retn

.handle_int:
        mov     eax, [esi]
        retn

.handle_string:
        stdcall StrNew
        stdcall StrCopyPart, eax, esi, 0, edx
        retn

.handle_blob:
        stdcall   GetMem, edx
        push      esi edi ecx
        mov       edi, eax
        mov       ecx, edx
        rep movsb
        pop       ecx edi esi
        retn
endp


; creates memory image (TArray) of the file of the config database.

proc SaveConfigFile, .ptrRoot, .signature
begin
        push    edx ecx

        stdcall CreateArray, 4
        mov     edx, eax

        mov     ecx, [.ptrRoot]
        stdcall AddArrayItems, edx, sizeof.TConfigHeader/4
        pushd   [.signature] $001a0a0d
        popd    [eax+TConfigHeader.filler] [eax+TConfigHeader.signature]

        stdcall __DoSaveParamArray, edx, [.ptrRoot]
        push    edx

        mov     ecx, [edx+TArray.count]
        shl     ecx, 2
        lea     edx, [edx+TArray.array+TConfigHeader.length]
        sub     ecx, sizeof.TConfigHeader
        mov     [edx], ecx
        add     ecx, 4 ; .length field
        stdcall DataHash, edx, ecx
        mov     [edx-4], eax            ; -4 if the offset to TConfigHeader.hash relative to TConfigHeader.length

        pop     eax
        pop     ecx edx
        return
endp



proc __DoSaveParamArray, .stream, .array
.count dd ?
begin
        pushad

        mov     ebx, [.array]
        mov     ecx, [ebx+TArray.count]
        lea     ebx, [ebx+TArray.array-sizeof.TConfigRecord]
        mov     [.count], ecx

.loop:
        add     ebx, sizeof.TConfigRecord
        dec     [.count]
        js      .end_save

        stdcall AddArrayItems, [.stream], 3
        mov     [.stream], edx

        pushd   [ebx+TConfigRecord.KeyName] [ebx+TConfigRecord.DataSize] [ebx+TConfigRecord.Type]
        popd    [eax+TChunkHeader.type] [eax+TChunkHeader.length] [eax+TChunkHeader.KeyName]

        movzx   eax, byte [ebx+TConfigRecord.Type]
        and     al, $07
        movzx   eax, [.type_handlers+eax]
        add     eax, .type_handlers
        call    eax
        jc      .loop

; align to dword
        mov     ecx, [ebx+TConfigRecord.DataSize]
        add     ecx, 3
        and     cl, $fc
        shr     ecx, 2
        stdcall AddArrayItems, [.stream], ecx
        mov     [.stream], edx
        mov     edi, eax

        rep movsd
        jmp     .loop

.end_save:
        popad
        mov     edx, [.stream]
        return

.type_handlers db .handle_null   - .type_handlers
               db .handle_int    - .type_handlers
               db .handle_string - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_config - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers

.handle_int:
        lea     esi, [ebx+TConfigRecord.Data]
        clc
        retn

.handle_string:
        stdcall StrPtr, [ebx+TConfigRecord.Data]
        mov     esi, eax
        clc
        retn

.handle_blob:
        mov     esi, [ebx+TConfigRecord.Data]
        clc
        retn

.handle_config:
        mov     eax, [.stream]
        mov     eax, [eax+TArray.count]
        push    eax
        stdcall __DoSaveParamArray, [.stream], [ebx+TConfigRecord.Data]
        mov     [.stream], edx

        pop     eax     ; old size
        mov     ecx, [edx+TArray.count]
        sub     ecx, eax
        lea     edx, [edx+TArray.array+4*eax-sizeof.TChunkHeader]
        shl     ecx, 2
        mov     [edx+TChunkHeader.length], ecx

.handle_null:
        stc
        retn
endp



proc FreeConfigDB, .ptrRoot
.dummy TConfigRecord
begin
        push    eax

        cmp     [.ptrRoot], 0
        je      .exit

        mov     [.dummy.Type], cdtConfig
        mov     eax, [.ptrRoot]
        mov     [.dummy.Data], eax

        lea     eax, [.dummy]
        stdcall __FreeConfigRecord, eax

.exit:
        pop     eax
        return
endp



; searches the tree for the given path and returns a pointer to the variable, containing pointer to TArray of the directory.
proc __GetParamArray, .ptrVarRoot, .pDirectory, .create
begin
        push    ebx edx esi

        mov     esi, [.pDirectory]
        mov     ebx, [.ptrVarRoot]

        test    esi, esi
        jz      .found

.loop:
        cmp     dword [esi], 0
        je      .found

        stdcall __ScanParamArray, [ebx], [esi]
        jc      .err_not_found
        cmp     [eax+TConfigRecord.Type], cdtConfig
        jne     .err_not_directory

.next:
        lea     ebx, [eax+TConfigRecord.Data]
        add     esi, 4
        jmp     .loop

.found:
        mov      eax, ebx
        clc
        pop     esi edx ebx
        return

.err_not_found:
        cmp     [.create], 0
        je      .no_create

        stdcall AddArrayItems, [ebx], 1
        mov     [ebx], edx
        mov     edx, eax
        pushd   [esi]
        popd    [edx+TConfigRecord.KeyName]
        mov     [edx+TConfigRecord.Type], cdtConfig
        stdcall CreateArray, sizeof.TConfigRecord
        mov     [edx+TConfigRecord.Data], eax
        mov     eax, edx
        jmp     .next

.no_create:
        xor     eax, eax
.error:
        stc
        pop     esi edx ebx
        return

.err_not_directory:
        xor     eax, eax
        dec     eax
        jmp     .error
endp




; returns:
;   CF=0 and eax = pointer to TConfigRecord
;            ecx = index of the record in the array.
;   CF=1 and eax = 0 - the key was not found.
proc __ScanParamArray, .ptrArray, .name
begin
        push    ecx esi
        mov     esi, [.ptrArray]
        test    esi, esi
        jz      .not_found

        mov     ecx, [esi+TArray.count]
        lea     esi, [esi+TArray.array]
        jecxz   .not_found

        xor     edx, edx
.loop:
        mov     eax, [esi+TConfigRecord.KeyName]
        cmp     eax, [.name]
        je      .found

        add     esi, sizeof.TConfigRecord
        inc     edx
        loop    .loop

.not_found:
        xor     eax, eax
        stc
        pop     esi ecx
        return

.found:
        mov     eax, esi
        clc
        pop     esi ecx
        return
endp


; returns
;   eax - poiner to the TConfigRecord or NULL if missing
proc GetConfigParam, .ptrConfig, .pDirectory, .name
begin
        push    edx
        lea     eax, [.ptrConfig]
        stdcall __GetParamArray, eax, [.pDirectory], 0
        stdcall __ScanParamArray, [eax], [.name]
        pop     edx
        return
endp


proc GetConfigParam.AsString, .ptrConfig, .pDirectory, .name
begin
        push    edx

        stdcall GetConfigParam, [.ptrConfig], [.pDirectory], [.name]
        jc      .finish

        movzx   edx, byte [eax+TConfigRecord.Type]
        and     dl, $07
        movzx   edx, [.type_handlers+edx]
        add     edx, .type_handlers
        call    edx

.finish:
        pop     edx
        return

.type_handlers db .handle_null   - .type_handlers
               db .handle_int    - .type_handlers
               db .handle_string - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_config - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers

.handle_null:
        stdcall StrDup, .txtNULL
        retn

.handle_int:
        stdcall NumToStr, [eax+TConfigRecord.Data], ntsSigned or ntsDec
        retn

.handle_string:
        stdcall StrDup, [eax+TConfigRecord.Data]
        retn

.handle_config:
        stdcall StrDup, .txtDir
        retn

.handle_blob:
        stdcall StrDup, .txtBlob
        retn

.txtNULL db 'NULL', 0
.txtDir  db 'SDIR', 0
.txtBlob db 'BLOB', 0

endp



proc __FreeConfigRecord, .ptrRecord
begin
        pushad

        mov     esi, [.ptrRecord]
        movzx   eax, byte [esi+TConfigRecord.Type]

        and     al, $07
        mov     al, [.type_handlers+eax]
        add     eax, .type_handlers
        call    eax

        xor     eax, eax
        mov     [esi+TConfigRecord.Type], eax
        mov     [esi+TConfigRecord.Data], eax
        mov     [esi+TConfigRecord.DataSize], eax
        popad
        return

.type_handlers db .handle_null   - .type_handlers
               db .handle_int    - .type_handlers
               db .handle_string - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_config - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers

.handle_config:
        mov     eax, [esi+TConfigRecord.Data]
        mov     ecx, [eax+TArray.count]
        lea     eax, [eax+TArray.array]
        jecxz   .handle_blob

.loop:
        stdcall __FreeConfigRecord, eax
        add     eax, sizeof.TConfigRecord
        loop    .loop

.handle_blob:
        stdcall FreeMem, [esi+TConfigRecord.Data]
        retn

.handle_string:
        stdcall StrDel, [esi+TConfigRecord.Data]
.handle_null:
.handle_int:
        retn
endp





proc DelCongigParam, .ptrVarConfig, .pDirectory, .name
begin
        pushad

        stdcall __GetParamArray, [.ptrVarConfig], [.pDirectory], 0
        jc      .deleted
        mov     esi, eax

        stdcall __ScanParamArray, [esi], [.name]
        jc      .deleted

        stdcall __FreeConfigRecord, eax
        stdcall DeleteArrayItems, [esi], edx, 1
        mov     [esi], edx

.deleted:
        popad
        return
endp


; set the value of the given config parameter.
; if the parameter exists, the value will be changed.
; if the parameter does not exists, it will be created.
proc SetConfigParam, .ptrVarConfig, .pDirectory, .name, .type, .value, .size
begin
        push    eax ecx edx esi edi

        stdcall __GetParamArray, [.ptrVarConfig], [.pDirectory], 1
        jc      .missing_directory

        mov     esi, eax

        stdcall __ScanParamArray, [esi], [.name]
        jnc     .record_ok

        stdcall AddArrayItems, [esi], 1
        mov     [esi], edx
        push    [.name]
        pop     [eax+TConfigRecord.KeyName]

.record_ok:
        mov     esi, eax

        stdcall __FreeConfigRecord, esi

        movzx   ecx, byte [.type]
        and     cl, $7
        mov     [esi+TConfigRecord.Type], ecx
        movzx   ecx, [.type_handlers+ecx]
        add     ecx, .type_handlers

        call    ecx
        clc
.finish:
        pop     edi esi edx ecx eax
        return

.missing_directory:
        stc
        jmp     .finish

.type_handlers db .handle_null   - .type_handlers
               db .handle_int    - .type_handlers
               db .handle_string - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_config - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers
               db .handle_blob   - .type_handlers

.handle_int:
        mov     [esi+TConfigRecord.DataSize], 4
        push    [.value]
        pop     [esi+TConfigRecord.Data]

.handle_null:
        retn

.handle_string:
        stdcall StrDup, [.value]
        mov     [esi+TConfigRecord.Data], eax
        stdcall StrLen, eax
        mov     [esi+TConfigRecord.DataSize], eax
        retn

.handle_config:
        stdcall CreateArray, sizeof.TConfigRecord
        mov     [esi+TConfigRecord.Data], eax
        mov     [esi+TConfigRecord.DataSize], 4
        retn

.handle_blob:
        mov     ecx, [.size]
        stdcall GetMem, ecx
        mov     [esi+TConfigRecord.Data], eax
        mov     [esi+TConfigRecord.DataSize], ecx

        push    esi
        mov     edi, eax
        mov     esi, [.value]
        rep movsb
        pop     esi
        retn
endp




endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Linux/XftCompat.inc.

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
; 
;  * $Id: XftCompat.h,v 1.4 2005/07/03 07:00:57 daniels Exp $
;  *
;  * Copyright © 2001 Keith Packard
;  *
;  * Permission to use, copy, modify, distribute, and sell this software and its
;  * documentation for any purpose is hereby granted without fee, provided that
;  * the above copyright notice appear in all copies and that both that
;  * copyright notice and this permission notice appear in supporting
;  * documentation, and that the name of Keith Packard not be used in
;  * advertising or publicity pertaining to distribution of the software without
;  * specific, written prior permission.  Keith Packard makes no
;  * representations about the suitability of this software for any purpose.  It
;  * is provided "as is" without express or implied warranty.
;  *
;  * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
;  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
;  * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
;  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
;  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
;  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
;  * PERFORMANCE OF THIS SOFTWARE.
;  

if ~defined  _XFTCOMPAT_H_ | defined @f
@@:
_XFTCOMPAT_H_	=	1
include	"X11/Xfuncproto.h"  


; 
;  * Compatibility definitions -- map Fc names to Xft names
;  

XftChar8	equ	 FcChar8	   
XftChar16	equ	 FcChar16   
XftChar32	equ	 FcChar32   

XFT_FAMILY	equ	FC_FAMILY
XFT_STYLE	equ	FC_STYLE
XFT_SLANT	equ	FC_SLANT
XFT_WEIGHT	equ	FC_WEIGHT
XFT_SIZE	equ	FC_SIZE
XFT_PIXEL_SIZE	equ	FC_PIXEL_SIZE
XFT_SPACING	equ	FC_SPACING
XFT_FOUNDRY	equ	FC_FOUNDRY
XFT_ANTIALIAS	equ	FC_ANTIALIAS
XFT_FILE	equ	FC_FILE
XFT_INDEX	equ	FC_INDEX
XFT_RASTERIZER	equ	FC_RASTERIZER
XFT_OUTLINE	equ	FC_OUTLINE
XFT_SCALABLE	equ	FC_SCALABLE
XFT_RGBA	equ	FC_RGBA

;  defaults from resources 
XFT_SCALE	equ	FC_SCALE
XFT_MINSPACE	equ	FC_MINSPACE
XFT_DPI	equ	FC_DPI

;  specific to FreeType rasterizer 
XFT_CHAR_WIDTH	equ	FC_CHAR_WIDTH
XFT_CHAR_HEIGHT	equ	FC_CHAR_HEIGHT
XFT_MATRIX	equ	FC_MATRIX

XFT_WEIGHT_LIGHT	equ	FC_WEIGHT_LIGHT
XFT_WEIGHT_MEDIUM	equ	FC_WEIGHT_MEDIUM
XFT_WEIGHT_DEMIBOLD	equ	FC_WEIGHT_DEMIBOLD
XFT_WEIGHT_BOLD	equ	FC_WEIGHT_BOLD
XFT_WEIGHT_BLACK	equ	FC_WEIGHT_BLACK

XFT_SLANT_ROMAN	equ	FC_SLANT_ROMAN
XFT_SLANT_ITALIC	equ	FC_SLANT_ITALIC
XFT_SLANT_OBLIQUE	equ	FC_SLANT_OBLIQUE

XFT_PROPORTIONAL	equ	FC_PROPORTIONAL
XFT_MONO	equ	FC_MONO
XFT_CHARCELL	equ	FC_CHARCELL

XFT_RGBA_UNKNOWN	equ	FC_RGBA_UNKNOWN
XFT_RGBA_RGB	equ	FC_RGBA_RGB
XFT_RGBA_BGR	equ	FC_RGBA_BGR
XFT_RGBA_VRGB	equ	FC_RGBA_VRGB
XFT_RGBA_VBGR	equ	FC_RGBA_VBGR
XFT_RGBA_NONE	equ	FC_RGBA_NONE

; 
;  * Old constants
;  
XFT_ENCODING	equ	"encoding"

XftType	equ	 FcType

XftMatrix	equ	 FcMatrix


XftResult	equ	 FcResult   

XftResultMatch	equ	FcResultMatch
XftResultNoMatch	equ	FcResultNoMatch
XftResultTypeMismatch	equ	FcResultTypeMismatch
XftResultNoId	equ	FcResultNoId

XftValue	equ	 FcValue	
XftPattern	equ	 FcPattern
XftFontSet	equ	 FcFontSet
XftObjectSet	equ	 FcObjectSet

XftGlyphExists	equ	XftCharExists

XftObjectSetCreate	equ	FcObjectSetCreate
XftObjectSetAdd	equ	FcObjectSetAdd
XftObjectSetDestroy	equ	FcObjectSetDestroy
XftObjectSetVaBuild	equ	FcObjectSetVaBuild
XftObjectSetBuild	equ	FcObjectSetBuild

XftFontSetMatch	equ	FcFontSetMatch
XftFontSetDestroy	equ	FcFontSetDestroy

XftMatrixEqual	equ	FcMatrixEqual
XftMatrixMultiply	equ	FcMatrixMultiply
XftMatrixRotate	equ	FcMatrixRotate
XftMatrixScale	equ	FcMatrixScale
XftMatrixShear	equ	FcMatrixShear

XftPatternCreate	equ	FcPatternCreate
XftPatternDuplicate	equ	FcPatternDuplicate
XftValueDestroy	equ	FcValueDestroy
XftValueListDestroy	equ	FcValueListDestroy
XftPatternDestroy	equ	FcPatternDestroy
XftPatternFind	equ	FcPatternFind
XftPatternAdd	equ	FcPatternAdd
XftPatternGet	equ	FcPatternGet
XftPatternDel	equ	FcPatternDel
XftPatternAddInteger	equ	FcPatternAddInteger
XftPatternAddDouble	equ	FcPatternAddDouble
XftPatternAddMatrix	equ	FcPatternAddMatrix
XftPatternAddBool	equ	FcPatternAddBool
XftPatternGetInteger	equ	FcPatternGetInteger
XftPatternGetDouble	equ	FcPatternGetDouble
XftPatternGetMatrix	equ	FcPatternGetMatrix
XftPatternGetBool	equ	FcPatternGetBool
XftPatternVaBuild	equ	FcPatternVaBuild
XftPatternBuild	equ	FcPatternBuild

XftUtf8ToUcs	=	4
		FcUtf8ToUcs4
XftUtf	=	8
Len		FcUtf8Len

XftTypeVoid	equ	FcTypeVoid
XftTypeInteger	equ	FcTypeInteger
XftTypeDouble	equ	FcTypeDouble
XftTypeString	equ	FcTypeString
XftTypeBool	equ	FcTypeBool
XftTypeMatrix	equ	FcTypeMatrix





end if
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































































































Deleted freshlib/equates/Linux/Xrender.inc.

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
; 
;  *
;  * Copyright © 2000 SuSE, Inc.
;  *
;  * Permission to use, copy, modify, distribute, and sell this software and its
;  * documentation for any purpose is hereby granted without fee, provided that
;  * the above copyright notice appear in all copies and that both that
;  * copyright notice and this permission notice appear in supporting
;  * documentation, and that the name of SuSE not be used in advertising or
;  * publicity pertaining to distribution of the software without specific,
;  * written prior permission.  SuSE makes no representations about the
;  * suitability of this software for any purpose.  It is provided "as is"
;  * without express or implied warranty.
;  *
;  * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
;  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
;  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
;  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
;  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
;  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
;  *
;  * Author:  Keith Packard, SuSE, Inc.
;  

if ~defined  _XRENDER_H_ | defined @f
@@:
_XRENDER_H_	=	1

include	"X11/Xlib.h"  

include	"X11/Xfuncproto.h"  

include	"X11/Xosdefs.h"  

include	"X11/Xutil.h"  


include	"X11/extensions/render.h"  


struct
{

	.red:		rw 1
	.redMask:		rw 1
	.green:		rw 1
	.greenMask:		rw 1
	.blue:		rw 1
	.blueMask:		rw 1
	.alpha:		rw 1
	.alphaMask:		rw 1

}


struct
{

    PictFormat		id;
	.type:		rd 1
	.depth:		rd 1
    XRenderDirectFormat	direct;
    Colormap		colormap;

}



struc	_XRenderPictureAttributes
{

	.repeat:		rd 1
    Picture		alpha_map;
	.alpha_x_origin:		rd 1
	.alpha_y_origin:		rd 1
	.clip_x_origin:		rd 1
	.clip_y_origin:		rd 1
    Pixmap		clip_mask;
    Bool		graphics_exposures;
	.subwindow_mode:		rd 1
	.poly_edge:		rd 1
	.poly_mode:		rd 1
    Atom		dither;
    Bool		component_alpha;

	_XRenderPictureAttributes_size	=	$ - .
}


struct
{

	.red:		rw 1
	.green:		rw 1
	.blue:		rw 1
	.alpha:		rw 1

}


struc	_XGlyphInfo
{

	.width:		rw 1
	.height:		rw 1
	.x:		rw 1
	.y:		rw 1
	.xOff:		rw 1
	.yOff:		rw 1

	_XGlyphInfo_size	=	$ - .
}


struc	_XGlyphElt8
{

    GlyphSet		    glyphset;
	.chars:		rd 1
	.nchars:		rd 1
	.xOff:		rd 1
	.yOff:		rd 1

	_XGlyphElt8_size	=	$ - .
}


struc	_XGlyphElt16
{

    GlyphSet		    glyphset;
	.chars:		rd 1
	.nchars:		rd 1
	.xOff:		rd 1
	.yOff:		rd 1

	_XGlyphElt16_size	=	$ - .
}


struc	_XGlyphElt32
{

    GlyphSet		    glyphset;
	.chars:		rd 1
	.nchars:		rd 1
	.xOff:		rd 1
	.yOff:		rd 1

	_XGlyphElt32_size	=	$ - .
}


XDouble	equ	 double

struc	_XPointDouble
{

	.x:		rq 1
	.y:		rq 1

	_XPointDouble_size	=	$ - .
}



XFixed	equ	 int

struc	_XPointFixed
{

    XFixed  x;
    XFixed  y;

	_XPointFixed_size	=	$ - .
}


struc	_XLineFixed
{

    XPointFixed p1;
    XPointFixed p2;

	_XLineFixed_size	=	$ - .
}


struc	_XTriangle
{

    XPointFixed p1;
    XPointFixed p2;
    XPointFixed p3;

	_XTriangle_size	=	$ - .
}


struc	_XCircle
{

    XFixed x;
    XFixed y;
    XFixed radius;

	_XCircle_size	=	$ - .
}


struc	_XTrapezoid
{

    XFixed  top;
    XFixed  bottom;
    XLineFixed left;
    XLineFixed right;

	_XTrapezoid_size	=	$ - .
}


struc	_XTransform
{

    XFixed  matrix[3][3];

	_XTransform_size	=	$ - .
}


struc	_XFilters
{

	.nfilter:		rd 1
	.filter:		rd 1
	.nalias:		rd 1
	.alias:		rd 1

	_XFilters_size	=	$ - .
}


struc	_XIndexValue
{

	.pixel:		rd 1
	.red:		rw 1
	.green:		rw 1
	.blue:		rw 1
	.alpha:		rw 1

	_XIndexValue_size	=	$ - .
}


struc	_XAnimCursor
{

    Cursor	    cursor;
	.delay:		rd 1

	_XAnimCursor_size	=	$ - .
}


struc	_XSpanFix
{

    XFixed left;
    XFixed right;
    XFixed y;

	_XSpanFix_size	=	$ - .
}


struc	_XTrap
{

    XSpanFix top;
    XSpanFix bottom;

	_XTrap_size	=	$ - .
}


struc	_XLinearGradient
{

    XPointFixed p1;
    XPointFixed p2;

	_XLinearGradient_size	=	$ - .
}


struc	_XRadialGradient
{

    XCircle inner;
    XCircle outer;

	_XRadialGradient_size	=	$ - .
}


struc	_XConicalGradient
{

    XPointFixed center;
    XFixed angle;  ;  in degrees 

	_XConicalGradient_size	=	$ - .
}










PictStandardARGB32	=	0

PictStandardRGB24	=	1

PictStandardA8	=	2

PictStandardA4	=	3

PictStandardA1	=	4

PictStandardNUM	=	5








































end if
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Linux/_XLib.inc.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: XLib specific constants and structures.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


; X Protocol
 X_PROTOCOL              =       11
 X_PROTOCOL_REVISION     =       0

;X Constants

None            =       0
ParentRelative  =       1
CopyFromParent  =       0
PointerWindow   =       0
InputFocus      =       1
PointerRoot     =       1
AnyPropertyType =       0
AnyKey          =       0
AnyButton       =       0
AllTemporary    =       0
CurrentTime     =       0
NoSymbol        =       0

;Event Masks

NoEventMask              =       0h
KeyPressMask             =       1h
KeyReleaseMask           =       2h
ButtonPressMask          =       4h
ButtonReleaseMask        =       8h
EnterWindowMask          =      10h
LeaveWindowMask          =      20h
PointerMotionMask        =      40h
PointerMotionHintMask    =      80h
Button1MotionMask        =     100h
Button2MotionMask        =     200h
Button3MotionMask        =     400h
Button4MotionMask        =     800h
Button5MotionMask        =    1000h
ButtonMotionMask         =    2000h
KeymapStateMask          =    4000h
ExposureMask             =    8000h
VisibilityChangeMask     =   10000h
StructureNotifyMask      =   20000h
ResizeRedirectMask       =   40000h
SubstructureNotifyMask   =   80000h
SubstructureRedirectMask =  100000h
FocusChangeMask          =  200000h
PropertyChangeMask       =  400000h
ColormapChangeMask       =  800000h
OwnerGrabButtonMask      = 1000000h

AllEventsMask            = 1fbff7fh   ;1ffffffh




;Event           Names

KeyPress                =       2
KeyRelease              =       3
ButtonPress             =       4
ButtonRelease           =       5
MotionNotify            =       6
EnterNotify             =       7
LeaveNotify             =       8
FocusIn                 =       9
FocusOut                =       10
KeymapNotify            =       11
Expose                  =       12
GraphicsExpose          =       13
NoExpose                =       14
VisibilityNotify        =       15
CreateNotify            =       16
DestroyNotify           =       17
UnmapNotify             =       18
MapNotify               =       19
MapRequest              =       20
ReparentNotify          =       21
ConfigureNotify         =       22
ConfigureRequest        =       23
GravityNotify           =       24
ResizeRequest           =       25
CirculateNotify         =       26
CirculateRequest        =       27
PropertyNotify          =       28
SelectionClear          =       29
SelectionRequest        =       30
SelectionNotify         =       31
ColormapNotify          =       32
ClientMessage           =       33
MappingNotify           =       34
LASTEvent               =       35

;Key             Masks

ShiftMask       =       1h
LockMask        =       2h
ControlMask     =       4h
Mod1Mask        =       8h
Mod2Mask        =       10h
Mod3Mask        =       20h
Mod4Mask        =       40h
Mod5Mask        =       80h

;Modifier                Names

ShiftMapIndex   =       0
LockMapIndex    =       1
ControlMapIndex =       2
Mod1MapIndex    =       3
Mod2MapIndex    =       4
Mod3MapIndex    =       5
Mod4MapIndex    =       6
Mod5MapIndex    =       7

;Button          Masks

Button1Mask     =       100h
Button2Mask     =       200h
Button3Mask     =       400h
Button4Mask     =       800h
Button5Mask     =       1000h
AnyModifier     =       10000h

;Button          Names

Button1         =       1
Button2         =       2
Button3         =       3
Button4         =       4
Button5         =       5

;Notify          Modes
NotifyNormal    =       0
NotifyGrab      =       1
NotifyUngrab    =       2
NotifyWhileGrabbed      =       3
NotifyHint      =       1

;Notify          Detail

NotifyAncestor  =       0
NotifyVirtual   =       1
NotifyInferior  =       2
NotifyNonlinear =       3
NotifyNonlinearVirtual  =       4
NotifyPointer   =       5
NotifyPointerRoot       =       6
NotifyDetailNone        =       7

;Visibility              Notify

VisibilityUnobscured    =       0
VisibilityPartiallyObscured     =       1
VisibilityFullyObscured =       2

;Circulation             request

PlaceOnTop      =       0
PlaceOnBottom   =       1

;Protocol                Families

FamilyInternet  =       0
FamilyDECnet    =       1
FamilyChaos     =       2
FamilyInternet6 =       6

;Unspecific              authentication  families

FamilyServerInterpreted =       5

;Property       Notification

PropertyNewValue        =       0
PropertyDelete  =       1

;Color           Map     notification

ColormapUninstalled     =       0
ColormapInstalled       =       1

;Grab            Modes
GrabModeSync    =       0
GrabModeAsync   =       1

;Grab            reply   status
GrabSuccess     =       0
AlreadyGrabbed  =       1
GrabInvalidTime =       2
GrabNotViewable =       3
GrabFrozen      =       4

;AllowEvents             modes
AsyncPointer    =       0
SyncPointer     =       1
ReplayPointer   =       2
AsyncKeyboard   =       3
SyncKeyboard    =       4
ReplayKeyboard  =       5
AsyncBoth       =       6
SyncBoth        =       7

;InputFocus              specific

RevertToNone    =       None
RevertToPointerRoot     =       PointerRoot
RevertToParent  =       2

;Error           Codes
Success                 =       0
BadRequest              =       1
BadValue                =       2
BadWindow               =       3
BadPixmap               =       4
BadAtom                 =       5
BadCursor               =       6
BadFont                 =       7
BadMatch                =       8
BadDrawable             =       9
BadAccess               =       10
BadAlloc                =       11
BadColor                =       12
BadGC                   =       13
BadIDChoice             =       14
BadName                 =       15
BadLength               =       16
BadImplementation       =       17
FirstExtensionError     =       128
LastExtensionError      =       255

;Window          Classes

InputOutput     =       1
InputOnly       =       2

;Window          Attributes
CWBackPixmap    =       1h
CWBackPixel     =       2h
CWBorderPixmap  =       4h
CWBorderPixel   =       8h
CWBitGravity    =       10h
CWWinGravity    =       20h
CWBackingStore  =       40h
CWBackingPlanes =       80h
CWBackingPixel  =       100h
CWOverrideRedirect =    200h
CWSaveUnder     =       400h
CWEventMask     =       800h
CWDontPropagate =       1000h
CWColormap      =       2000h
CWCursor        =       4000h

;ConfigureWindow         Structure
CWX             =       1h
CWY             =       2h
CWWidth         =       4h
CWHeight        =       8h
CWBorderWidth   =       10h
CWSibling       =       20h
CWStackMode     =       40h

;Bit             Gravity
ForgetGravity           =       0
NorthWestGravity        =       1
NorthGravity            =       2
NorthEastGravity        =       3
WestGravity             =       4
CenterGravity           =       5
EastGravity             =       6
SouthWestGravity        =       7
SouthGravity            =       8
SouthEastGravity        =       9
StaticGravity           =       10

;Window          Gravity
UnmapGravity    =       0

;CreateWindow            backing-store   hint
NotUseful       =       0
WhenMapped      =       1
Always  =       2

;GetWindowAttributes             reply
IsUnmapped      =       0
IsUnviewable    =       1
IsViewable      =       2

;Used            in      ChangeSaveSet
SetModeInsert   =       0
SetModeDelete   =       1

;Used            in      ChangeCloseDownMode
DestroyAll      =       0
RetainPermanent =       1
RetainTemporary =       2

;Window          stacking        method  (in     configureWindow)
Above   =       0
Below   =       1
TopIf   =       2
BottomIf        =       3
Opposite        =       4

;Circulation             direction
RaiseLowest     =       0
LowerHighest    =       1

;Property                modes
PropModeReplace =       0
PropModePrepend =       1
PropModeAppend  =       2

;Graphics Functions
GXclear         =       0
GXand           =       1
GXandReverse    =       2
GXcopy          =       3
GXandInverted   =       4
GXnoop          =       5
GXxor           =       6
GXor            =       7
GXnor           =       8
GXequiv         =       9
GXinvert        =       10
GXorReverse     =       11
GXcopyInverted  =       12
GXorInverted    =       13
GXnand          =       14
GXset           =       15

;LineStyle
LineSolid       =       0
LineOnOffDash   =       1
LineDoubleDash  =       2

;capStyle
CapNotLast      =       0
CapButt         =       1
CapRound        =       2
CapProjecting   =       3

;joinStyle
JoinMiter       =       0
JoinRound       =       1
JoinBevel       =       2

;fillStyle
FillSolid       =       0
FillTiled       =       1
FillStippled    =       2
FillOpaqueStippled      =       3

;fillRule

EvenOddRule     =       0
WindingRule     =       1

;subwindow               mode

ClipByChildren  =       0
IncludeInferiors        =       1

;SetClipRectangles               ordering

Unsorted        =       0
YSorted =       1
YXSorted        =       2
YXBanded        =       3

;CoordinateMode          for     drawing routines

CoordModeOrigin =       0
CoordModePrevious       =       1

;Polygon         shapes

Complex =       0
Nonconvex       =       1
Convex  =       2

;Arc             modes   for     PolyFillArc

ArcChord        =       0
ArcPieSlice     =       1

;GC              components

GCFunction      =       1h
GCPlaneMask     =       2h
GCForeground    =       4h
GCBackground    =       8h
GCLineWidth     =       10h
GCLineStyle     =       20h
GCCapStyle      =       40h
GCJoinStyle     =       80h
GCFillStyle     =       100h
GCFillRule      =       200h
GCTile  =       400h
GCStipple       =       800h
GCTileStipXOrigin       =       1000h
GCTileStipYOrigin       =       2000h
GCFont  =       4000h
GCSubwindowMode =       8000h
GCGraphicsExposures     =       10000h
GCClipXOrigin   =       20000h
GCClipYOrigin   =       40000h
GCClipMask      =       80000h
GCDashOffset    =       100000h
GCDashList      =       200000h
GCArcMode       =       400000h

GCLastBit       =       22

GCAll = (1 shl (GCLastBit+1)) -1

struct XGCValues
  .function    dd ?                     ;  logical operation
  .plane_mask  dd ?                     ;  plane mask
  .foreground  dd ?                     ;  foreground pixel
  .background  dd ?                     ;  background pixel
  .line_width  dd ?                     ;  line width (in pixels)
  .line_style  dd ?                     ;  LineSolid, LineOnOffDash, LineDoubleDash
  .cap_style   dd ?                     ;  CapNotLast, CapButt, CapRound, CapProjecting
  .join_style  dd ?                     ;  JoinMiter, JoinRound, JoinBevel
  .fill_style  dd ?                     ;  FillSolid, FillTiled, FillStippled FillOpaqueStippled
  .fill_rule   dd ?                     ;  EvenOddRule, WindingRule
  .arc_mode    dd ?                     ;  ArcChord, ArcPieSlice
  .tile        dd ?                     ;  tile pixmap for tiling operations
  .stipple     dd ?                     ;  stipple 1 plane pixmap for stippling
  .ts_x_origin dd ?                     ;  offset for tile or stipple operations
  .ts_y_origin dd ?
  .font        dd ?                     ;  default text font for text operations
  .subwindow_mode dd ?                  ;  ClipByChildren, IncludeInferiors
  .fraphics_exposures dd ?              ;  boolean, should exposures be generated
  .clip_x_origin dd ?                   ;  origin for clipping
  .clip_y_origin dd ?
  .clip_mask   dd ?                     ;  bitmap clipping; other calls for rects
  .dash_offset dd ?                     ;  patterned/dashed line information
  .dashes      dd ?
ends


;used            in      QueryFont       --      draw    direction

FontLeftToRight =       0
FontRightToLeft =       1

FontChange      =       255

;ImageFormat             --      PutImage,       GetImage

XYBitmap        =       0
XYPixmap        =       1
ZPixmap =       2

;For             CreateColormap

AllocNone       =       0
AllocAll        =       1


;Flags           used    in      StoreNamedColor,        StoreColors

DoRed   =       1h
DoGreen =       2h
DoBlue  =       4h

;QueryBestSize           Class

CursorShape     =       0
TileShape       =       1
StippleShape    =       2

;Keyboard                pointer stuff

AutoRepeatModeOff       =       0
AutoRepeatModeOn        =       1
AutoRepeatModeDefault   =       2

LedModeOff      =       0
LedModeOn       =       1

;masks           for     ChangeKeyboardControl

KBKeyClickPercent       =       1h
KBBellPercent   =       2h
KBBellPitch     =       4h
KBBellDuration  =       8h
KBLed   =       10h
KBLedMode       =       20h
KBKey   =       40h
KBAutoRepeatMode        =       80h

MappingSuccess  =       0
MappingBusy     =       1
MappingFailed   =       2

MappingModifier =       0
MappingKeyboard =       1
MappingPointer  =       2

;Screensaver             stuff

DontPreferBlanking      =       0
PreferBlanking  =       1
DefaultBlanking =       2

DisableScreenSaver      =       0
DisableScreenInterval   =       0

DontAllowExposures      =       0
AllowExposures  =       1
DefaultExposures        =       2

;for             ForceScreenSaver

ScreenSaverReset        =       0
ScreenSaverActive       =       1

;for             ChangeHosts

HostInsert      =       0
HostDelete      =       1

;for             ChangeAccessControl

EnableAccess    =       1
DisableAccess   =       0

;display         classes

StaticGray      =       0
GrayScale       =       1
StaticColor     =       2
PseudoColor     =       3
TrueColor       =       4
DirectColor     =       5


;Byte            order           used    in      imageByteOrder  and     bitmapBitOrder

LSBFirst        =       0
MSBFirst        =       1

;Keyboard and Pointer Event Structures

struct   XButtonEvent
  .type         rd    1
  .serial       rd    1
  .send_event   rd    1
  .display      rd    1
  .window       rd    1
  .root         rd    1
  .subwindow    rd    1
  .time         rd    1
  .x            rd    1
  .y            rd    1
  .x_root       rd    1
  .y_root       rd    1
  .state        rd    1
  .button       rd    1
  .same_screen  rd    1
ends


virtual at 0
XButtonPressedEvent  XButtonEvent
end virtual

virtual at 0
XButtonReleasedEvent XButtonEvent
end virtual

struct   XKeyEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .root                           rd    1
        .subwindow                      rd    1
        .time                           rd    1
        .x                              rd    1
        .y                              rd    1
        .x_root                         rd    1
        .y_root                         rd    1
        .state                          rd    1
        .keycode                        rd    1
        .same_screen                    rd    1
ends


virtual at 0
XKeyPressedEvent   XKeyEvent
end virtual

virtual at 0
XKeyReleasedEvent  XKeyEvent
end virtual


struct   XMotionEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .root                           rd    1
        .subwindow                      rd    1
        .time                           rd    1
        .x                              rd    1
        .y                              rd    1
        .x_root                         rd    1
        .y_root                         rd    1
        .state                          rd    1
        .is_hint                        rb    1
        .same_screen                    rd    1
ends


virtual at 0
XPointerMovedEvent  XMotionEvent
end virtual

;Window Entry/Exit Events

struct   XCrossingEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .root                           rd    1
        .subwindow                      rd    1
        .time                           rd    1
        .x                              rd    1
        .y                              rd    1
        .x_root                         rd    1
        .y_root                         rd    1
        .mode                           rd    1
        .detail                         rd    1
        .same_screen                    rd    1
        .focus                          rd    1
        .state                          rd    1
ends

virtual at 0
XEnterWindowEvent  XCrossingEvent
end virtual

virtual at 0
XLeaveWindowEvent  XCrossingEvent
end virtual

;       Input           Focus   Events

struct   XFocusChangeEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .mode                           rd    1
        .detail                         rd    1
ends



virtual at 0
XFocusInEvent  XFocusChangeEvent
end virtual

virtual at 0
XFocusOutEvent  XFocusChangeEvent
end virtual

;       Keymap          Notification    Events

struct   XKeymapEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .key_vector                     rb    32
ends

;       Exposure/Update         Events

struct   XExposeEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .height                         rd    1
        .count                          rd    1
ends


struct   XGraphicsExposeEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .drawable                       rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .height                         rd    1
        .count                          rd    1
        .major_code                     rd    1
        .minor_code                     rd    1
ends


struct   XNoExposeEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .drawable                       rd    1
        .major_code                     rd    1
        .minor_code                     rd    1
ends


;       CirculateNotify         Events

struct   XCirculateEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .place                          rd    1
ends


struct   XCirculateRequestEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .parent                         rd    1
        .window                         rd    1
        .place                          rd    1
ends

;       Configuration           Change  Events

struct   XConfigureEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .height                         rd    1
        .border_width                   rd    1
        .above                          rd    1
        .override_redirect              rd    1
ends

struct   XConfigureRequestEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .parent                         rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .height                         rd    1
        .border_width                   rd    1
        .above                          rd    1
        .detail                         rd    1
        .value_mask                     rd    1
ends

struct   XPropertyEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .atom                           rd    1
        .time                           rd    1
        .state                          rd    1
ends

struct   XResizeEvent
        .type                           rd    1
        .serial                         rd    1
        .display                        rd    1
        .window                         rd    1
        .width                          rd    1
        .height                         rd    1
ends

struct   XColormapEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .colormap                       rd    1
        .new                            rd    1
        .state                          rd    1
ends

;       Creation/Destruction            Notifications

struct   XCreateWindowEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .parent                         rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
        .width                          rd    1
        .heigth                         rd    1
        .border_width                   rd    1
        .override_redirect              rd    1
ends


struct   XDestroyWindowEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
ends

;       Parent          Movement        Events

struct   XGravityEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .x                              rd    1
        .y                              rd    1
ends

;       Mapping         Events

struct   XMapEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .override_redirect              rd    1
ends

struct   XMappingEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .request                        rd    1
        .first_keycode                  rd    1
        .count                          rd    1
ends


struct   XMapRequestEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .parent                         rd    1
        .window                         rd    1
ends

;       Parent          Change  Events

struct   XReparentEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .parent                         rd    1
        .x                              rd    1
        .y                              rd    1
        .override_redirect              rd    1
ends

struct   XSelectionClearEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .selection                      rd    1
        .time                           rd    1
ends

struct   XSelectionRequestEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .owner                          rd    1
        .requestor                      rd    1
        .selection                      rd    1
        .target                         rd    1
        .property                       rd    1
        .time                           rd    1
ends

struct   XSelectionEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .requestor                      rd    1
        .selection                      rd    1
        .target                         rd    1
        .property                       rd    1
        .time                           rd    1
ends

;       Hidden          Window  Events

struct   XUnmapEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .event                          rd    1
        .window                         rd    1
        .from_configure                 rd    1
ends

struct   XVisibilityEvent
        .type                           rd    1
        .serial                         rd    1
        .send_event                     rd    1
        .display                        rd    1
        .window                         rd    1
        .state                          rd    1
ends

;       Client          Messages        (XSendEvent)

struct   XClientMessageEvent
  .type                           rd    1
  .serial                         rd    1
  .send_event                     rd    1
  .display                        rd    1
  .window                         rd    1
  .message_type                   rd    1
  .format                         rd    1
  .data                           rb    20
ends


struct   XErrorEvent
  .type         dd    ?
  .display      dd    ?
  .resourceid   dd    ?
  .serial       dd    ?
  .error_code   db    ?
  .request_code db    ?
  .minor_code   db    ?
ends



struct XAnyEvent
  .type         rd    1
  .serial       rd    1
  .send_event   rd    1
  .display      rd    1
  .window       rd    1
ends


struct XEvent
  .xany XAnyEvent
  .pad  rb 24*4 - sizeof.XAnyEvent

  virtual at .xany
  . XAnyEvent
  end virtual


  virtual at .xany
  .xkey XKeyEvent
  end virtual

  virtual at .xany
  .xbutton XButtonEvent
  end virtual

  virtual at .xany
  .xmotion XMotionEvent
  end virtual

  virtual at .xany
  .xcrossing XCrossingEvent
  end virtual

  virtual at .xany
  .xfocus XFocusChangeEvent
  end virtual

  virtual at .xany
  .xexpose XExposeEvent
  end virtual

  virtual at .xany
  .xgraphicsexpose XGraphicsExposeEvent
  end virtual

  virtual at .xany
  .xnoexpose XNoExposeEvent
  end virtual

  virtual at .xany
  .xvisibility XVisibilityEvent
  end virtual

  virtual at .xany
  .xcreatewindow XCreateWindowEvent
  end virtual

  virtual at .xany
  .xdestroywindow XDestroyWindowEvent
  end virtual

  virtual at .xany
  .xunmap XUnmapEvent
  end virtual

  virtual at .xany
  .xmap XMapEvent
  end virtual

  virtual at .xany
  .xmaprequest XMapRequestEvent
  end virtual

  virtual at .xany
  .xreparent XReparentEvent
  end virtual

  virtual at .xany
  .xconfigure XConfigureEvent
  end virtual

  virtual at .xany
  .xgravity XGravityEvent
  end virtual

  virtual at .xany
  .xresizerequest XResizeEvent
  end virtual

  virtual at .xany
  .xconfigurerequest XConfigureRequestEvent
  end virtual

  virtual at .xany
  .xcirculate XCirculateEvent
  end virtual

  virtual at .xany
  .xcirculaterequest XCirculateRequestEvent
  end virtual

  virtual at .xany
  .xproperty XPropertyEvent
  end virtual

  virtual at .xany
  .xselectionclear XSelectionClearEvent
  end virtual

  virtual at .xany
  .xselectionrequest XSelectionRequestEvent
  end virtual

  virtual at .xany
  .xselection XSelectionEvent
  end virtual

  virtual at .xany
  .xcolormap XColormapEvent
  end virtual

  virtual at .xany
  .xclient XClientMessageEvent
  end virtual

  virtual at .xany
  .xmapping XMappingEvent
  end virtual

  virtual at .xany
  .xerror XErrorEvent
  end virtual

  virtual at .xany
  .xkeymap XKeymapEvent
  end virtual
ends


;       Misc.           Structures

struct   XKeyboardControl
        .key_click_percent              rd    1
        .bell_percent                   rd    1
        .bell_pitch                     rd    1
        .bell_duration                  rd    1
        .led                            rd    1
        .led_mode                       rd    1
        .key                            rd    1
        .auto_repeat_mode               rd    1
ends



struct   XModifierKeymap
        .max_keypermod                  rd    1
        .modifiermap                    rd    1
ends




struct XWindowAttributes
  .x                     dd  ?     ; location of window
  .y                     dd  ?     ;
  .width                 dd  ?     ; width and height of window
  .height                dd  ?     ;
  .border_width          dd  ?     ; border width of window
  .depth                 dd  ?     ; depth of window
  .pVisual               dd  ?     ; the associated visual structure
  .root                  dd  ?     ; root of screen containing window
  .class                 dd  ?     ; InputOutput, InputOnly

  .bit_gravity           dd  ?     ; one of the bit gravity values
  .win_gravity           dd  ?     ; one of the window gravity values
  .backing_store         dd  ?     ; NotUseful, WhenMapped, Always
  .backing_planes        dd  ?     ; planes to be preserved if possible
  .backing_pixel         dd  ?     ; value to be used when restoring planes
  .save_under            dd  ?     ; boolean, should bits under be saved?
  .colormap              dd  ?     ; color map to be associated with window
  .map_installed         dd  ?     ; boolean, is color map currently installed
  .map_state             dd  ?     ; IsUnmapped, IsUnviewable, IsViewable
  .all_event_masks       dd  ?    ; set of events all people have interest in
  .your_event_mask       dd  ?          ; my event mask
  .do_not_propagate_mask dd  ?    ; set of events that should not propagate
  .override_redirect     dd  ?    ; boolean value for override-redirect
  .pScreen               dd  ?  ; back pointer to correct screen
ends


struct XSetWindowAttributes
  .background_pixmap    dd  ?           ; background, None, or ParentRelative
  .background_pixel     dd  ?           ; background pixel
  .border_pixmap        dd  ?           ; border of the window or CopyFromParent
  .border_pixel         dd  ?           ; border pixel value
  .bit_gravity          dd  ?           ; one of bit gravity values
  .win_gravity          dd  ?           ; one of the window gravity values
  .backing_store        dd  ?           ; NotUseful, WhenMapped, Always
  .backing_planes       dd  ?           ; planes to be preserved if possible
  .backing_pixel        dd  ?           ; value to use in restoring planes
  .save_under           dd  ?           ; should bits under be saved? (popups)
  .event_mask           dd  ?           ; set of events that should be saved
  .do_not_propagate_mask dd ?           ; set of events that should not propagate
  .override_redirect    dd  ?           ; boolean value for override_redirect
  .colormap             dd  ?           ; color map to be associated with window
  .cursor               dd  ?           ; cursor to be displayed (or None)
ends



struct XCharStruct
  .lbearing   dw ?       ; origin to left edge of raster
  .rbearing   dw ?       ; origin to right edge of raster
  .width      dw ?       ; advance to next char's origin
  .ascent     dw ?       ; baseline to top edge of raster
  .descent    dw ?       ; baseline to bottom edge of raster
  .attributes dw ?       ; per char flags (not predefined)
ends


struct XFontStruct
  .ext_data          dd   ?       ; hook for extension to hang data
  .fid               dd   ?       ; Font id for this font
  .direction         dd   ?       ; hint about the direction font is painted
  .min_char_or_byte2 dd   ?       ; first character
  .max_char_or_byte2 dd   ?       ; last character
  .min_byte1         dd   ?       ; first row that exists
  .max_byte1         dd   ?       ; last row that exists
  .all_chars_exist   dd   ?       ; flag if all characters have nonzero size
  .default_char      dd   ?       ; char to print for undefined character
  .n_properties      dd   ?       ; how many properties there are
  .properties        dd   ?       ; pointer to array of additional properties
  .min_bounds        XCharStruct  ; minimum bounds over all existing char
  .max_bounds        XCharStruct  ; maximum bounds over all existing char
  .per_char          dd   ?       ; first_char to last_char information
  .ascent            dd   ?       ; logical extent above baseline for spacing
  .descent           dd   ?       ; logical decent below baseline for spacing
ends


struct XWindowChanges
  .x            dd ?
  .y            dd ?
  .width        dd ?
  .height       dd ?
  .border_width dd ?
  .sibling      dd ?
  .stack_mode   dd ?
ends


struct XImage
  .width        dd ?                         ; size of image
  .height       dd ?
  .xoffset      dd ?                         ; number of pixels offset in X direction
  .format       dd ?                         ; XYBitmap, XYPixmap, ZPixmap
  .pData        dd ?                         ; pointer to image data
  .byte_order   dd ?                         ; data byte order, LSBFirst=0, MSBFirst=1
  .bitmap_unit  dd ?                         ; quantity of scan line 8, 16, 32
  .bitmap_bit_order dd ?                     ; LSBFirst, MSBFirst
  .bitmap_pad   dd ?                         ; 8, 16, 32 either XY or ZPixmap
  .depth        dd ?                         ; depth of image
  .bytes_per_line dd ?                       ; accelerator to next line
  .bits_per_pixel dd ?                       ; bits per pixel (ZPixmap)
  .red_mask       dd ?                       ; bits in z arrangment
  .green_mask     dd ?                       ; bits in z arrangment
  .blue_mask      dd ?                       ; bits in z arrangment
  .ptrObData      dd ?                       ; hook for object routines to hang on

  .funcCreateImage dd ?                      ; image manipulation routines
  .funcDestroyImage dd ?                     ;
  .funcGetPixel     dd ?
  .funcPutPixel     dd ?
  .funcSubImage     dd ?
  .funcAddPixel     dd ?
ends


struct XWMHints
  .flags dd ?
  .input dd ?
  .initial_state dd ?
  .icon_pixmap   dd ?
  .icon_window   dd ?
  .icon_x        dd ?
  .icon_y        dd ?
  .icon_mask     dd ?
  .window_group  dd ?
ends


InputHint       =       1
StateHint       =       2
IconPixmapHint  =       4
IconWindowHint  =       8
IconPositionHint=       16
IconMaskHint    =       32
WindowGroupHint =       64
UrgencyHint     =       128
AllHints = InputHint or StateHint or IconPixmapHint or IconWindowHint or IconPositionHint or IconMaskHint or WindowGroupHint or UrgencyHint


WithdrawnState  = 0
NormalState = 1
IconicState = 3


; RequestCodes
Xrequests = 0
.CreateWindow            =1
.ChangeWindowAttributes  =2
.GetWindowAttributes     =3
.DestroyWindow           =4
.DestroySubwindows       =5
.ChangeSaveSet           =6
.ReparentWindow          =7
.MapWindow               =8
.MapSubwindows           =9
.UnmapWindow             =10
.UnmapSubwindows         =11
.ConfigureWindow         =12
.CirculateWindow         =13
.GetGeometry             =14
.QueryTree               =15
.InternAtom              =16
.GetAtomName             =17
.ChangeProperty          =18
.DeleteProperty          =19
.GetProperty             =20
.ListProperties          =21
.SetSelectionOwner       =22
.GetSelectionOwner       =23
.ConvertSelection        =24
.SendEvent               =25
.GrabPointer             =26
.UngrabPointer           =27
.GrabButton              =28
.UngrabButton            =29
.ChangeActivePointerGrab =30
.GrabKeyboard            =31
.UngrabKeyboard          =32
.GrabKey                 =33
.UngrabKey               =34
.AllowEvents             =35
.GrabServer              =36
.UngrabServer            =37
.QueryPointer            =38
.GetMotionEvents         =39
.TranslateCoords         =40
.WarpPointer             =41
.SetInputFocus           =42
.GetInputFocus           =43
.QueryKeymap             =44
.OpenFont                =45
.CloseFont               =46
.QueryFont               =47
.QueryTextExtents        =48
.ListFonts               =49
.ListFontsWithInfo       =50
.SetFontPath             =51
.GetFontPath             =52
.CreatePixmap            =53
.FreePixmap              =54
.CreateGC                =55
.ChangeGC                =56
.CopyGC                  =57
.SetDashes               =58
.SetClipRectangles       =59
.FreeGC                  =60
.ClearArea               =61
.CopyArea                =62
.CopyPlane               =63
.PolyPoint               =64
.PolyLine                =65
.PolySegment             =66
.PolyRectangle           =67
.PolyArc                 =68
.FillPoly                =69
.PolyFillRectangle       =70
.PolyFillArc             =71
.PutImage                =72
.GetImage                =73
.PolyText8               =74
.PolyText16              =75
.ImageText8              =76
.ImageText16             =77
.CreateColormap          =78
.FreeColormap            =79
.CopyColormapAndFree     =80
.InstallColormap         =81
.UninstallColormap       =82
.ListInstalledColormaps  =83
.AllocColor              =84
.AllocNamedColor         =85
.AllocColorCells         =86
.AllocColorPlanes        =87
.FreeColors              =88
.StoreColors             =89
.StoreNamedColor         =90
.QueryColors             =91
.LookupColor             =92
.CreateCursor            =93
.CreateGlyphCursor       =94
.FreeCursor              =95
.RecolorCursor           =96
.QueryBestSize           =97
.QueryExtension          =98
.ListExtensions          =99
.ChangeKeyboardMapping   =100
.GetKeyboardMapping      =101
.ChangeKeyboardControl   =102
.GetKeyboardControl      =103
.Bell                    =104
.ChangePointerControl    =105
.GetPointerControl       =106
.SetScreenSaver          =107
.GetScreenSaver          =108
.ChangeHosts             =109
.ListHosts               =110
.SetAccessControl        =111
.SetCloseDownMode        =112
.KillClient              =113
.RotateProperties        =114
.ForceScreenSaver        =115
.SetPointerMapping       =116
.GetPointerMapping       =117
.SetModifierMapping      =118
.GetModifierMapping      =119
.NoOperation             =127


; Predefined atoms from the X server.

XA_PRIMARY      = 1
XA_SECONDARY    = 2
XA_ARC          = 3
XA_ATOM         = 4
XA_BITMAP       = 5
XA_CARDINAL     = 6
XA_COLORMAP     = 7
XA_CURSOR       = 8
XA_CUT_BUFFER0  = 9
XA_CUT_BUFFER1  = 10
XA_CUT_BUFFER2  = 11
XA_CUT_BUFFER3  = 12
XA_CUT_BUFFER4  = 13
XA_CUT_BUFFER5  = 14
XA_CUT_BUFFER6  = 15
XA_CUT_BUFFER7  = 16
XA_DRAWABLE     = 17
XA_FONT         = 18
XA_INTEGER      = 19
XA_PIXMAP       = 20
XA_POINT        = 21
XA_RECTANGLE    = 22
XA_RESOURCE_MANAGER = 23
XA_RGB_COLOR_MAP = 24
XA_RGB_BEST_MAP  = 25
XA_RGB_BLUE_MAP = 26
XA_RGB_DEFAULT_MAP = 27
XA_RGB_GRAY_MAP = 28
XA_RGB_GREEN_MAP = 29
XA_RGB_RED_MAP  = 30
XA_STRING       = 31
XA_VISUALID     = 32
XA_WINDOW       = 33
XA_WM_COMMAND   = 34
XA_WM_HINTS     = 35
XA_WM_CLIENT_MACHINE = 36
XA_WM_ICON_NAME = 37
XA_WM_ICON_SIZE = 38
XA_WM_NAME      = 39
XA_WM_NORMAL_HINTS = 40
XA_WM_SIZE_HINTS = 41
XA_WM_ZOOM_HINTS = 42
XA_MIN_SPACE     = 43
XA_NORM_SPACE    = 44
XA_MAX_SPACE     = 45
XA_END_SPACE     = 46
XA_SUPERSCRIPT_X = 47
XA_SUPERSCRIPT_Y = 48
XA_SUBSCRIPT_X   = 49
XA_SUBSCRIPT_Y   = 50
XA_UNDERLINE_POSITION = 51
XA_UNDERLINE_THICKNESS = 52
XA_STRIKEOUT_ASCENT = 53
XA_STRIKEOUT_DESCENT = 54
XA_ITALIC_ANGLE  = 55
XA_X_HEIGHT      = 56
XA_QUAD_WIDTH    = 57
XA_WEIGHT        = 58
XA_POINT_SIZE    = 59
XA_RESOLUTION    = 60
XA_COPYRIGHT     = 61
XA_NOTICE        = 62
XA_FONT_NAME     = 63
XA_FAMILY_NAME   = 64
XA_FULL_NAME     = 65
XA_CAP_HEIGHT    = 66
XA_WM_CLASS      = 67
XA_WM_TRANSIENT_FOR = 68

XA_LAST_PREDEFINED = 68
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Linux/_geometry.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Different geometry structures.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


struct RECT
  .left   dd ?
  .top    dd ?
  .right  dd ?
  .bottom dd ?
ends

struct POINT
  .x  dd ?
  .y  dd ?
ends

struct XRectangle
  .x       dw  ?
  .y       dw  ?
  .width   dw  ?
  .height  dw  ?
ends
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































Deleted freshlib/equates/Linux/_linux.inc.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Common Linux equates.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

; Error numbers from the kernel

EPERM       =     1      ; Operation not permitted
ENOENT      =     2      ; No such file or directory
ESRCH       =     3      ; No such process
EINTR       =     4      ; Interrupted system call
EIO         =     5      ; I/O error
ENXIO       =     6      ; No such device or address
E2BIG       =     7      ; Argument list too long
ENOEXEC     =     8      ; Exec format error
EBADF       =     9      ; Bad file number
ECHILD      =    10      ; No child processes
EAGAIN      =    11      ; Try again
ENOMEM      =    12      ; Out of memory
EACCES      =    13      ; Permission denied
EFAULT      =    14      ; Bad address
ENOTBLK     =    15      ; Block device required
EBUSY       =    16      ; Device or resource busy
EEXIST      =    17      ; File exists
EXDEV       =    18      ; Cross-device link
ENODEV      =    19      ; No such device
ENOTDIR     =    20      ; Not a directory
EISDIR      =    21      ; Is a directory
EINVAL      =    22      ; Invalid argument
ENFILE      =    23      ; File table overflow
EMFILE      =    24      ; Too many open files
ENOTTY      =    25      ; Not a typewriter
ETXTBSY     =    26      ; Text file busy
EFBIG       =    27      ; File too large
ENOSPC      =    28      ; No space left on device
ESPIPE      =    29      ; Illegal seek
EROFS       =    30      ; Read-only file system
EMLINK      =    31      ; Too many links
EPIPE       =    32      ; Broken pipe
EDOM        =    33      ; Math argument out of domain of func
ERANGE      =    34      ; Math result not representable

EDEADLK       =  35      ; Resource deadlock would occur
ENAMETOOLONG  =  36      ; File name too long
ENOLCK        =  37      ; No record locks available
ENOSYS        =  38      ; Function not implemented
ENOTEMPTY     =  39      ; Directory not empty
ELOOP         =  40      ; Too many symbolic links encountered
EWOULDBLOCK   =  EAGAIN  ; Operation would block
ENOMSG        =  42      ; No message of desired type
EIDRM         =  43      ; Identifier removed
ECHRNG        =  44      ; Channel number out of range
EL2NSYNC      =  45      ; Level 2 not synchronized
EL3HLT        =  46      ; Level 3 halted
EL3RST        =  47      ; Level 3 reset
ELNRNG        =  48      ; Link number out of range
EUNATCH       =  49      ; Protocol driver not attached
ENOCSI        =  50      ; No CSI structure available
EL2HLT        =  51      ; Level 2 halted
EBADE         =  52      ; Invalid exchange
EBADR         =  53      ; Invalid request descriptor
EXFULL        =  54      ; Exchange full
ENOANO        =  55      ; No anode
EBADRQC       =  56      ; Invalid request code
EBADSLT       =  57      ; Invalid slot

EDEADLOCK     =  EDEADLK

EBFONT        =  59      ; Bad font file format
ENOSTR        =  60      ; Device not a stream
ENODATA       =  61      ; No data available
ETIME         =  62      ; Timer expired
ENOSR         =  63      ; Out of streams resources
ENONET        =  64      ; Machine is not on the network
ENOPKG        =  65      ; Package not installed
EREMOTE       =  66      ; Object is remote
ENOLINK       =  67      ; Link has been severed
EADV          =  68      ; Advertise error
ESRMNT        =  69      ; Srmount error
ECOMM         =  70      ; Communication error on send
EPROTO        =  71      ; Protocol error
EMULTIHOP     =  72      ; Multihop attempted
EDOTDOT       =  73      ; RFS specific error
EBADMSG       =  74      ; Not a data message
EOVERFLOW     =  75      ; Value too large for defined data type
ENOTUNIQ      =  76      ; Name not unique on network
EBADFD        =  77      ; File descriptor in bad state
EREMCHG       =  78      ; Remote address changed
ELIBACC       =  79      ; Can not access a needed shared library
ELIBBAD       =  80      ; Accessing a corrupted shared library
ELIBSCN       =  81      ; .lib section in a.out corrupted
ELIBMAX       =  82      ; Attempting to link in too many shared libraries
ELIBEXEC      =  83      ; Cannot exec a shared library directly
EILSEQ        =  84      ; Illegal byte sequence
ERESTART      =  85      ; Interrupted system call should be restarted
ESTRPIPE      =  86      ; Streams pipe error
EUSERS        =  87      ; Too many users
ENOTSOCK      =  88      ; Socket operation on non-socket
EDESTADDRREQ  =  89      ; Destination address required
EMSGSIZE      =  90      ; Message too long
EPROTOTYPE    =  91      ; Protocol wrong type for socket
ENOPROTOOPT   =  92      ; Protocol not available
EPROTONOSUPPORT =93      ; Protocol not supported
ESOCKTNOSUPPORT =94      ; Socket type not supported
EOPNOTSUPP      =95      ; Operation not supported on transport endpoint
EPFNOSUPPORT  =  96      ; Protocol family not supported
EAFNOSUPPORT  =  97      ; Address family not supported by protocol
EADDRINUSE    =  98      ; Address already in use
EADDRNOTAVAIL =  99      ; Cannot assign requested address
ENETDOWN      =  100     ; Network is down
ENETUNREACH   =  101     ; Network is unreachable
ENETRESET     =  102     ; Network dropped connection because of reset
ECONNABORTED  =  103     ; Software caused connection abort
ECONNRESET    =  104     ; Connection reset by peer
ENOBUFS       =  105     ; No buffer space available
EISCONN       =  106     ; Transport endpoint is already connected
ENOTCONN      =  107     ; Transport endpoint is not connected
ESHUTDOWN     =  108     ; Cannot send after transport endpoint shutdown
ETOOMANYREFS  =  109     ; Too many references: cannot splice
ETIMEDOUT     =  110     ; Connection timed out
ECONNREFUSED  =  111     ; Connection refused
EHOSTDOWN     =  112     ; Host is down
EHOSTUNREACH  =  113     ; No route to host
EALREADY      =  114     ; Operation already in progress
EINPROGRESS   =  115     ; Operation now in progress
ESTALE        =  116     ; Stale NFS file handle
EUCLEAN       =  117     ; Structure needs cleaning
ENOTNAM       =  118     ; Not a XENIX named type file
ENAVAIL       =  119     ; No XENIX semaphores available
EISNAM        =  120     ; Is a named type file
EREMOTEIO     =  121     ; Remote I/O error
EDQUOT        =  122     ; Quota exceeded

ENOMEDIUM     =  123     ; No medium found
EMEDIUMTYPE   =  124     ; Wrong medium type
ECANCELED     =  125     ; Operation Canceled
ENOKEY        =  126     ; Required key not available
EKEYEXPIRED   =  127     ; Key has expired
EKEYREVOKED   =  128     ; Key has been revoked
EKEYREJECTED  =  129     ; Key was rejected by service

; for robust mutexes
EOWNERDEAD     = 130     ; Owner died
ENOTRECOVERABLE= 131     ; State not recoverable





; System functions ( int $80 )

;         Name              EAX

sys_restart_syscall      =  $00
sys_exit                 =  $01
sys_fork                 =  $02
sys_read                 =  $03
sys_write                =  $04
sys_open                 =  $05
sys_close                =  $06
sys_waitpid              =  $07
sys_creat                =  $08
sys_link                 =  $09
sys_unlink               =  $0a
sys_execve               =  $0b
sys_chdir                =  $0c
sys_time                 =  $0d
sys_mknod                =  $0e
sys_chmod                =  $0f
sys_lchown16             =  $10
sys_stat                 =  $12
sys_lseek                =  $13
sys_getpid               =  $14
sys_mount                =  $15
sys_oldumount            =  $16
sys_setuid16             =  $17
sys_getuid16             =  $18
sys_stime                =  $19
sys_ptrace               =  $1a
sys_alarm                =  $1b
sys_fstat                =  $1c
sys_pause                =  $1d
sys_utime                =  $1e
sys_access               =  $21
sys_nice                 =  $22
sys_sync                 =  $24
sys_kill                 =  $25
sys_rename               =  $26
sys_mkdir                =  $27
sys_rmdir                =  $28
sys_dup                  =  $29
sys_pipe                 =  $2a
sys_times                =  $2b
sys_brk                  =  $2d
sys_setgid16             =  $2e
sys_getgid16             =  $2f
sys_signal               =  $30
sys_geteuid16            =  $31
sys_getegid16            =  $32
sys_acct                 =  $33
sys_umount               =  $34
sys_ioctl                =  $36
sys_fcntl                =  $37
sys_setpgid              =  $39
sys_olduname             =  $3b
sys_umask                =  $3c
sys_chroot               =  $3d
sys_ustat                =  $3e
sys_dup2                 =  $3f
sys_getppid              =  $40
sys_getpgrp              =  $41
sys_setsid               =  $42
sys_sigaction            =  $43
sys_sgetmask             =  $44
sys_ssetmask             =  $45
sys_setreuid16           =  $46
sys_setregid16           =  $47
sys_sigsuspend           =  $48
sys_sigpending           =  $49
sys_sethostname          =  $4a
sys_setrlimit            =  $4b
sys_old_getrlimit        =  $4c
sys_getrusage            =  $4d
sys_gettimeofday         =  $4e
sys_settimeofday         =  $4f
sys_getgroups16          =  $50
sys_setgroups16          =  $51
sys_old_select           =  $52
sys_symlink              =  $53
sys_lstat                =  $54
sys_readlink             =  $55
sys_uselib               =  $56
sys_swapon               =  $57
sys_reboot               =  $58
sys_old_readdir          =  $59
sys_old_mmap             =  $5a
sys_munmap               =  $5b
sys_truncate             =  $5c
sys_ftruncate            =  $5d
sys_fchmod               =  $5e
sys_fchown16             =  $5f
sys_getpriority          =  $60
sys_setpriority          =  $61
sys_statfs               =  $63
sys_fstatfs              =  $64
sys_ioperm               =  $65
sys_socketcall           =  $66
sys_syslog               =  $67
sys_setitimer            =  $68
sys_getitimer            =  $69
sys_newstat              =  $6a
sys_newlstat             =  $6b
sys_newfstat             =  $6c
sys_uname                =  $6d
sys_iopl                 =  $6e
sys_vhangup              =  $6f
sys_vm86old              =  $71
sys_wait4                =  $72
sys_swapoff              =  $73
sys_sysinfo              =  $74
sys_ipc                  =  $75
sys_fsync                =  $76
sys_sigreturn            =  $77
sys_clone                =  $78
sys_setdomainname        =  $79
sys_newuname             =  $7a
sys_modify_ldt           =  $7b
sys_adjtimex             =  $7c
sys_mprotect             =  $7d
sys_sigprocmask          =  $7e
sys_init_module          =  $80
sys_delete_module        =  $81
sys_quotactl             =  $83
sys_getpgid              =  $84
sys_fchdir               =  $85
sys_bdflush              =  $86
sys_sysfs                =  $87
sys_personality          =  $88
sys_setfsuid16           =  $8a
sys_setfsgid16           =  $8b
sys_llseek               =  $8c
sys_getdents             =  $8d
sys_select               =  $8e
sys_flock                =  $8f
sys_msync                =  $90
sys_readv                =  $91
sys_writev               =  $92
sys_getsid               =  $93
sys_fdatasync            =  $94
sys_sysctl               =  $95
sys_mlock                =  $96
sys_munlock              =  $97
sys_mlockall             =  $98
sys_munlockall           =  $99
sys_sched_setparam       =  $9a
sys_sched_getparam       =  $9b
sys_sched_setscheduler   =  $9c
sys_sched_getscheduler   =  $9d
sys_sched_yield          =  $9e
sys_sched_get_priority_m =  $9f
sys_sched_get_priority_m =  $a0
sys_sched_rr_get_interva =  $a1
sys_nanosleep            =  $a2
sys_mremap               =  $a3
sys_setresuid16          =  $a4
sys_getresuid16          =  $a5
sys_vm86                 =  $a6
sys_poll                 =  $a8
sys_nfsservctl           =  $a9
sys_setresgid16          =  $aa
sys_getresgid16          =  $ab
sys_prctl                =  $ac
sys_rt_sigreturn         =  $ad
sys_rt_sigaction         =  $ae
sys_rt_sigprocmask       =  $af
sys_rt_sigpending        =  $b0
sys_rt_sigtimedwait      =  $b1
sys_rt_sigqueueinfo      =  $b2
sys_rt_sigsuspend        =  $b3
sys_pread64              =  $b4
sys_pwrite64             =  $b5
sys_chown16              =  $b6
sys_getcwd               =  $b7
sys_capget               =  $b8
sys_capset               =  $b9
sys_sigaltstack          =  $ba
sys_sendfile             =  $bb
sys_vfork                =  $be
sys_getrlimit            =  $bf
sys_mmap_pgoff           =  $c0
sys_truncate64           =  $c1
sys_ftruncate64          =  $c2
sys_stat64               =  $c3
sys_lstat64              =  $c4
sys_fstat64              =  $c5
sys_lchown               =  $c6
sys_getuid               =  $c7
sys_getgid               =  $c8
sys_geteuid              =  $c9
sys_getegid              =  $ca
sys_setreuid             =  $cb
sys_setregid             =  $cc
sys_getgroups            =  $cd
sys_setgroups            =  $ce
sys_fchown               =  $cf
sys_setresuid            =  $d0
sys_getresuid            =  $d1
sys_setresgid            =  $d2
sys_getresgid            =  $d3
sys_chown                =  $d4
sys_setuid               =  $d5
sys_setgid               =  $d6
sys_setfsuid             =  $d7
sys_setfsgid             =  $d8
sys_pivot_root           =  $d9
sys_mincore              =  $da
sys_madvise              =  $db
sys_getdents64           =  $dc
sys_fcntl64              =  $dd
sys_gettid               =  $e0
sys_readahead            =  $e1
sys_setxattr             =  $e2
sys_lsetxattr            =  $e3
sys_fsetxattr            =  $e4
sys_getxattr             =  $e5
sys_lgetxattr            =  $e6
sys_fgetxattr            =  $e7
sys_listxattr            =  $e8
sys_llistxattr           =  $e9
sys_flistxattr           =  $ea
sys_removexattr          =  $eb
sys_lremovexattr         =  $ec
sys_fremovexattr         =  $ed
sys_tkill                =  $ee
sys_sendfile64           =  $ef
sys_futex                =  $f0
sys_sched_setaffinity    =  $f1
sys_sched_getaffinity    =  $f2
sys_set_thread_area      =  $f3
sys_get_thread_area      =  $f4
sys_io_setup             =  $f5
sys_io_destroy           =  $f6
sys_io_getevents         =  $f7
sys_io_submit            =  $f8
sys_io_cancel            =  $f9
sys_fadvise64            =  $fa
sys_exit_group           =  $fc
sys_lookup_dcookie       =  $fd
sys_epoll_create         =  $fe
sys_epoll_ctl            =  $ff
sys_epoll_wait           =  $100
sys_remap_file_pages     =  $101
sys_set_tid_address      =  $102
sys_timer_create         =  $103
sys_timer_settime        =  $104
sys_timer_gettime        =  $105
sys_timer_getoverrun     =  $106
sys_timer_delete         =  $107
sys_clock_settime        =  $108
sys_clock_gettime        =  $109
sys_clock_getres         =  $10a
sys_clock_nanosleep      =  $10b
sys_statfs64             =  $10c
sys_fstatfs64            =  $10d
sys_tgkill               =  $10e
sys_utimes               =  $10f
sys_fadvise64_64         =  $110
sys_mbind                =  $112
sys_get_mempolicy        =  $113
sys_set_mempolicy        =  $114
sys_mq_open              =  $115
sys_mq_unlink            =  $116
sys_mq_timedsend         =  $117
sys_mq_timedreceive      =  $118
sys_mq_notify            =  $119
sys_mq_getsetattr        =  $11a
sys_kexec_load           =  $11b
sys_waitid               =  $11c
sys_add_key              =  $11e
sys_request_key          =  $11f
sys_keyctl               =  $120
sys_ioprio_set           =  $121
sys_ioprio_get           =  $122
sys_inotify_init         =  $123
sys_inotify_add_watch    =  $124
sys_inotify_rm_watch     =  $125
sys_migrate_pages        =  $126
sys_openat               =  $127
sys_mkdirat              =  $128
sys_mknodat              =  $129
sys_fchownat             =  $12a
sys_futimesat            =  $12b
sys_fstatat64            =  $12c
sys_unlinkat             =  $12d
sys_renameat             =  $12e
sys_linkat               =  $12f
sys_symlinkat            =  $130
sys_readlinkat           =  $131
sys_fchmodat             =  $132
sys_faccessat            =  $133
sys_pselect6             =  $134
sys_ppoll                =  $135
sys_unshare              =  $136
sys_set_robust_list      =  $137
sys_get_robust_list      =  $138
sys_splice               =  $139
sys_sync_file_range      =  $13a
sys_tee                  =  $13b
sys_vmsplice             =  $13c
sys_move_pages           =  $13d
sys_getcpu               =  $13e
sys_epoll_pwait          =  $13f
sys_utimensat            =  $140
sys_signalfd             =  $141
sys_timerfd_create       =  $142
sys_eventfd              =  $143
sys_fallocate            =  $144
sys_timerfd_settime      =  $145
sys_timerfd_gettime      =  $146
sys_signalfd4            =  $147
sys_eventfd2             =  $148
sys_epoll_create1        =  $149
sys_dup3                 =  $14a
sys_pipe2                =  $14b
sys_inotify_init1        =  $14c
sys_preadv               =  $14d
sys_pwritev              =  $14e
sys_rt_tgsigqueueinfo    =  $14f
sys_perf_event_open      =  $150
sys_recvmmsg             =  $151


; Signal values
; default action is: "Term" - terminate; "Core" - terminate with core dump; "Ign" - ignore; "Stop" - stop the process; "Cont" - continue the process.

macro signal name, value {
  name = value
  .mask = 1 shl value
}

signal SIGHUP   ,  1    ; Term    Hangup detected on controlling terminal or death of controlling process
signal SIGINT   ,  2    ; Term    Interrupt from keyboard
signal SIGQUIT  ,  3    ; Core    Quit from keyboard
signal SIGILL   ,  4    ; Core    Illegal Instruction
signal SIGTRAP  ,  5    ; Core    Trace/breakpoint trap
signal SIGABRT  ,  6    ; Core    Abort signal from abort(3)
signal SIGIOT   ,  6    ; Core    IOT trap. A synonym for SIGABRT
signal SIGBUS   ,  7    ; Core    Bus error (bad memory access)
signal SIGFPE   ,  8    ; Core    Floating point exception
signal SIGKILL  ,  9    ; Term    Kill signal
signal SIGUSR1  , 10    ; Term    User-defined signal 1
signal SIGSEGV  , 11    ; Core    Invalid memory reference
signal SIGUSR2  , 12    ; Term    User-defined signal 2
signal SIGPIPE  , 13    ; Term    Broken pipe: write to pipe with no readers
signal SIGALRM  , 14    ; Term    Timer signal from alarm(2)
signal SIGTERM  , 15    ; Term    Termination signal
signal SIGSTKFLT, 16    ; Term    Stack fault on coprocessor (unused)
signal SIGCHLD  , 17    ; Ign     Child stopped or terminated
signal SIGCONT  , 18    ; Cont    Continue if stopped
signal SIGSTOP  , 19    ; Stop    Stop process
signal SIGTSTP  , 20    ; Stop    Stop typed at tty
signal SIGTTIN  , 21    ; Stop    tty input for background process
signal SIGTTOU  , 22    ; Stop    tty output for background process
signal SIGURG   , 23    ; Ign     Urgent condition on socket (4.2BSD)
signal SIGXCPU  , 24    ; Core    CPU time limit exceeded (4.2BSD)
signal SIGXFSZ  , 25    ; Core    File size limit exceeded (4.2BSD)
signal SIGVTALRM, 26    ; Term    Virtual alarm clock (4.2BSD)
signal SIGPROF  , 27    ; Term    Profiling timer expired
signal SIGWINCH , 28    ; Ign     Window resize signal (4.3BSD, Sun)
signal SIGIO    , 29    ; Term    I/O now possible (4.2BSD)
signal SIGPWR   , 30    ; Term    Power failure (System V)
signal SIGSYS   , 31    ; Core    Bad argument to routine (SVr4)
signal SIGUNUSED, 31    ; Core    Synonymous with SIGSYS

SIGRTMIN = 34
SIGRTMAX = 64

; signal flags

SA_ONSTACK    =  $00000001      ;  Call the signal handler on an alternate signal stack provided by
                                ;  sigaltstack(2).  If an alternate stack is not available, the
                                ;  default stack will be used.  This flag is only meaningful when
                                ;  establishing a signal handler.



SA_RESETHAND  =  $00000004      ;  Restore the signal action to the default state once the signal
                                ;  handler has been called.  This flag is only meaningful when
                                ;  establishing a signal handler.  SA_ONESHOT is an obsolete,
                                ;  nonstandard synonym for this flag.


SA_NOCLDSTOP  =  $00000008      ; If signum is SIGCHLD, do not receive notification when child
                                ; processes stop (i.e., when they receive one of SIGSTOP, SIGTSTP,
                                ; SIGTTIN or SIGTTOU) or resume (i.e., they receive SIGCONT) (see
                                ; wait(2)).  This flag is only meaningful when establishing a handler
                                ; for SIGCHLD.


SA_SIGINFO    =  $00000010      ;  The signal handler takes 3 arguments, not one.  In this case,
                                ;  sa_sigaction should be set instead of sa_handler.  This flag is
                                ;  only meaningful when establishing a signal handler.


SA_NODEFER    =  $00000020      ; Do not prevent the signal from being received from within its own
                                ; signal handler.  This flag is only meaningful when establishing a
                                ; signal handler.  SA_NOMASK is an obsolete, nonstandard synonym for
                                ; this flag.


SA_RESTART    =  $00000040      ;  Provide behavior compatible with BSD signal semantics by making
                                ;  certain system calls restartable across signals.  This flag is only
                                ;  meaningful when establishing a signal handler.  See signal(7) for a
                                ;  discussion of system call restarting.


SA_NOCLDWAIT  =  $00000080      ; If signum is SIGCHLD, do not transform children into zombies when
                                ; they terminate.  See also waitpid(2).  This flag is only meaningful
                                ; when establishing a handler for SIGCHLD, or when setting that
                                ; signal's disposition to SIG_DFL.
                                ;
                                ; If the SA_NOCLDWAIT flag is set when establishing a handler for
                                ; SIGCHLD, POSIX.1 leaves it unspecified whether a SIGCHLD signal is
                                ; generated when a child process terminates.  On Linux, a SIGCHLD
                                ; signal is generated in this case; on some other implementations, it
                                ; is not.


SA_NOMASK     =  SA_NODEFER
SA_ONESHOT    =  SA_RESETHAND
SA_INTERRUPT  =  $20000000      ; dummy -- ignored
SA_RESTORER   =  $04000000      ; obsolete -- ignored

; Signals hanlers constants

SIG_DFL = 0     ; default signal handling
SIG_IGN = 1     ; ignore signal
SIG_ERR = -1    ; error return from signal


; Interval timers structures

ITIMER_REAL    = 0
ITIMER_VIRTUAL = 1
ITIMER_PROF    = 2


struct lnx_sigaction
  .sa_handler   dd ?      ; SIG_DFL, SIG_IGN or ptr proc Handler, .signal
  .sa_sigaction dd ?      ; ptr proc SigAction, .signal, .ptrSignalInfo, .ptr
  .sa_mask      dd ?      ; mask of the signals
  .sa_flags     dd ?      ;
  .sa_restorer  dd ?      ; obsolete, don't use
ends



struct lnx_timeval
  .tv_sec  dd ?
  .tv_usec dd ?
ends

struct lnx_timezone
  .tz_minuteswest dd ?
  .tz_dsttime     dd ?
ends



struct lnx_itimerval
  .it_interval lnx_timeval
  .it_value    lnx_timeval
ends


; structures and equates for timer_xxxx POSIX functions


CLOCK_REALTIME            =  0 ; Identifier for system-wide realtime clock.
CLOCK_MONOTONIC           =  1 ; Monotonic system-wide clock.
CLOCK_PROCESS_CPUTIME_ID  =  2 ; High-resolution timer from the CPU.
CLOCK_THREAD_CPUTIME_ID   =  3 ; Thread-specific CPU-time clock.

SIGEV_SIGNAL = 0     ; Notify via signal.
SIGEV_NONE   = 1     ; Other notification: meaningless.
SIGEV_THREAD = 2     ; Deliver via thread creation.
SIGEV_THREAD_ID = 4  ; Send signal to specific thread.


struct lnx_sigevent
  .notify           dd ?
  .signo            dd ?
  .value            dd ?
  .ptr_notify_proc  dd ?
  .ptr_notify_attr  dd ?
  .notify_thread_id dd ?
ends

struct lnx_timespec
  .tv_sec  dd ?   ; time in seconds
  .tv_nsec dd ?   ; time is nano seconds
ends


struct lnx_itimerspec
  .it_interval lnx_timespec
  .it_value    lnx_timespec
ends


; sys_clone function flags

CLONE_VM                =  $00000100      ; set if VM shared between processes
CLONE_FS                =  $00000200      ; set if fs info shared between processes
CLONE_FILES             =  $00000400      ; set if open files shared between processes
CLONE_SIGHAND           =  $00000800      ; set if signal handlers and blocked signals shared
CLONE_PTRACE            =  $00002000      ; set if we want to let tracing continue on the child too
CLONE_VFORK             =  $00004000      ; set if the parent wants the child to wake it up on mm_release
CLONE_PARENT            =  $00008000      ; set if we want to have the same parent as the cloner
CLONE_THREAD            =  $00010000      ; Same thread group?
CLONE_NEWNS             =  $00020000      ; New namespace group?
CLONE_SYSVSEM           =  $00040000      ; share system V SEM_UNDO semantics
CLONE_SETTLS            =  $00080000      ; create a new TLS for the child
CLONE_PARENT_SETTID     =  $00100000      ; set the TID in the parent
CLONE_CHILD_CLEARTID    =  $00200000      ; clear the TID in the child
CLONE_DETACHED          =  $00400000      ; Unused, ignored
CLONE_UNTRACED          =  $00800000      ; set if the tracing process can't force CLONE_PTRACE on this clone
CLONE_CHILD_SETTID      =  $01000000      ; set the TID in the child
CLONE_STOPPED           =  $02000000      ; Start in stopped state
CLONE_NEWUTS            =  $04000000      ; New utsname group?
CLONE_NEWIPC            =  $08000000      ; New ipcs
CLONE_NEWUSER           =  $10000000      ; New user namespace
CLONE_NEWPID            =  $20000000      ; New pid namespace
CLONE_NEWNET            =  $40000000      ; New network namespace
CLONE_IO                =  $80000000      ; Clone io context


; Memory constants

; Protections are chosen from these bits, OR'd together.  The
;   implementation does not necessarily support PROT_EXEC or PROT_WRITE
;   without PROT_READ.  The only guarantees are that no writing will be
;   allowed without PROT_WRITE and no access will be allowed for PROT_NONE.

PROT_READ       =  $1             ; Page can be read.
PROT_WRITE      =  $2             ; Page can be written.
PROT_EXEC       =  $4             ; Page can be executed.
PROT_NONE       =  $0             ; Page can not be accessed.
PROT_GROWSDOWN  =  $01000000      ; Extend change to start of
                                        ; growsdown vma (mprotect only).
PROT_GROWSUP    =  $02000000      ; Extend change to start of
                                        ; growsup vma (mprotect only).

; Sharing types (must choose one and only one of these).
MAP_SHARED      =  $01            ; Share changes.
MAP_PRIVATE     =  $02            ; Changes are private.
MAP_TYPE        =  $0f            ; Mask for type of mapping.


; Other flags.
MAP_FIXED       =  $10            ; Interpret addr exactly.
MAP_ANONYMOUS   =  $20            ; Don't use a file.
MAP_32BIT       =  $40            ; Only give out 32-bit addresses.


; These are Linux-specific.
MAP_GROWSDOWN  =  $00100          ; Stack-like segment.
MAP_DENYWRITE  =  $00800          ; ETXTBSY
MAP_EXECUTABLE =  $01000          ; Mark it as an executable.
MAP_LOCKED     =  $02000          ; Lock the mapping.
MAP_NORESERVE  =  $04000          ; Don't check for reservations.
MAP_POPULATE   =  $08000          ; Populate (prefault) pagetables.
MAP_NONBLOCK   =  $10000          ; Do not block on IO.
MAP_STACK      =  $20000          ; Allocation is for a stack.


; Flags to `msync'.
MS_ASYNC       = 1                ; Sync memory asynchronously.
MS_SYNC        = 4                ; Synchronous memory sync.
MS_INVALIDATE  = 2                ; Invalidate the caches.


; Flags for `mlockall'.
MCL_CURRENT    = 1                ; Lock all currently mapped pages.
MCL_FUTURE     = 2                ; Lock all additions to address space.

; Flags for `mremap'.
MREMAP_MAYMOVE = 1
MREMAP_FIXED   = 2

; Advice to `madvise'.
MADV_NORMAL     = 0      ; No further special treatment.
MADV_RANDOM     = 1      ; Expect random page references.
MADV_SEQUENTIAL = 2      ; Expect sequential page references.
MADV_WILLNEED   = 3      ; Will need these pages.
MADV_DONTNEED   = 4      ; Don't need these pages.
MADV_REMOVE     = 9      ; Remove these pages and resources.
MADV_DONTFORK   = 10     ; Do not inherit across fork.
MADV_DOFORK     = 11     ; Do inherit across fork.


; The POSIX people had to invent similar names for the same things.
POSIX_MADV_NORMAL      = 0 ; No further special treatment.
POSIX_MADV_RANDOM      = 1 ; Expect random page references.
POSIX_MADV_SEQUENTIAL  = 2 ; Expect sequential page references.
POSIX_MADV_WILLNEED    = 3 ; Will need these pages.
POSIX_MADV_DONTNEED    = 4 ; Don't need these pages.



; sys_futex constants


FUTEX_WAIT             = 0
FUTEX_WAKE             = 1
FUTEX_FD               = 2
FUTEX_REQUEUE          = 3
FUTEX_CMP_REQUEUE      = 4
FUTEX_WAKE_OP          = 5
FUTEX_LOCK_PI          = 6
FUTEX_UNLOCK_PI        = 7
FUTEX_TRYLOCK_PI       = 8
FUTEX_WAIT_BITSET      = 9
FUTEX_WAKE_BITSET      = 10


; sys_fstat and similar structures

struct STAT
  .st_dev     dw  ?     ; ID of device containing file
  .pad1       dw  ?
  .st_ino     dd  ?     ; inode number
  .st_mode    dw  ?     ; protection
  .st_nlink   dw  ?     ; number of hard links
  .st_uid     dw  ?     ; user ID of owner
  .st_gid     dw  ?     ; group ID of owner
  .st_rdev    dw  ?     ; device ID (if special file)
  .pad2       dw  ?
  .st_size    dd  ?     ; total size, in bytes
  .st_blksize dd  ?     ; block size
  .st_blocks  dd  ?

  .st_atime   dd  ?     ; time of last access
  .unused1    dd  ?

  .st_mtime   dd  ?     ; time of last modification
  .unused2    dd  ?

  .st_ctime   dd  ?     ; time of last status change
  .unused3    dd  ?
  .unused4    dd  ?
  .unused5    dd  ?
ends


; sys_getdents

; it is variable length structure.
struct linux_dirent
  .d_ino dd ?
  .d_off dd ?
  .d_reclen dw ?
  label .d_name byte
ends

; file types for the above structure.
; this value is written at the last byte of the structure. (linux_dirent.d_reclen-1)

DT_UNKNOWN   =   0
DT_FIFO      =   1
DT_CHR       =   2
DT_DIR       =   4
DT_BLK       =   6
DT_REG       =   8      ; regular file
DT_LNK       =   10
DT_SOCK      =   12
DT_WHT       =   14

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Linux/_xft.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: XFT library constants and structures.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________



struct XRenderColor
  .red   dw ?
  .green dw ?
  .blue  dw ?
  .alpha dw ?
ends


XFT_MAJOR       =       2
XFT_MINOR       =       1
XFT_REVISION    =       8
XftVersion      equ     XFT_VERSION

XFT_CORE                equ     "core"
XFT_RENDER              equ     "render"
XFT_XLFD                equ     "xlfd"
XFT_MAX_GLYPH_MEMORY    equ     "maxglyphmemory"
XFT_MAX_UNREF_FONTS     equ     "maxunreffonts"


FcTypeVoid      = 0
FcTypeInteger   = 1
FcTypeDouble    = 2
FcTypeString    = 3
FcTypeBool      = 4
FcTypeMatrix    = 5
FcTypeCharSet   = 6
FcTypeFTFace    = 7
FcTypeLangSet   = 8

XftTypeVoid      =  FcTypeVoid
XftTypeInteger   =  FcTypeInteger
XftTypeDouble    =  FcTypeDouble
XftTypeString    =  FcTypeString
XftTypeBool      =  FcTypeBool
XftTypeMatrix    =  FcTypeMatrix
XftTypeCharSet   =  FcTypeCharSet
XftTypeFTFace    =  FcTypeFTFace
XftTypeLangSet   =  FcTypeLangSet

FC_SLANT_ROMAN   = 0
FC_SLANT_ITALIC  = 100
FC_SLANT_OBLIQUE = 110

XFT_SLANT_ROMAN   =  FC_SLANT_ROMAN
XFT_SLANT_ITALIC  =  FC_SLANT_ITALIC
XFT_SLANT_OBLIQUE =  FC_SLANT_OBLIQUE

FC_PROPORTIONAL         =  0
FC_DUAL                 =  90
FC_MONO                 =  100
FC_CHARCELL             =  110

XFT_PROPORTIONAL         =  FC_PROPORTIONAL
XFT_DUAL                 =  FC_DUAL
XFT_MONO                 =  FC_MONO
XFT_CHARCELL             =  FC_CHARCELL


struct   _XftFont
  .ascent                dd ?
  .descent               dd ?
  .height                dd ?
  .max_advance_width     dd ?
  .charset               dd ?
  .pattern               dd ?
ends


struct  _XftColor
  .pixel  dd ?
  .color  XRenderColor
ends


struct _XftCharSpec
  .ucs4  dd ?
  .x:    dw ?
  .y:    dw ?
ends


struct   _XftCharFontSpec
  .font  dd ?
  .ucs4  dd ?
  .x     dw ?
  .y     dw ?
ends


struct _XftGlyphSpec
  .glyph  dd ?
  .x      dw ?
  .y      dw ?
ends


struct _XftGlyphFontSpec
  .font   dd ?
  .glyph  dd ?
  .x      dw ?
  .y      dw ?
ends


struct _XGlyphInfo
  .width  dw ?
  .height dw ?
  .x      dw ?
  .y      dw ?
  .xOff   dw ?
  .yOff   dw ?
ends
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































Deleted freshlib/equates/Linux/allequates.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Combined include of all Linux equates.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

; Linux programming constants
include '_geometry.inc'
include '_linux.inc'
include '_XLib.inc'
include '_xft.inc'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































Deleted freshlib/equates/Win32/_COMCTL32.INC.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: COMCTL32.DLL structures and constants
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

struct PROPSHEETPAGE
  .dwSize      dd ?
  .dwFlags     dd ?
  .hInstance   dd ?
  .pszTemplate dd ?
  .pszIcon     dd ?
  .pszTitle    dd ?
  .pfnDlgProc  dd ?
  .lParam      dd ?
  .pfnCallback dd ?
  .pcRefParent dd ?
ends

struct PROPSHEETHEADER
  .dwSize     dd ?
  .dwFlags    dd ?
  .hwndParent dd ?
  .hInstance  dd ?
  .pszIcon    dd ?
  .pszCaption dd ?
  .nPages     dd ?
  .pStartPage dd ?
ends

struct IMAGEINFO
  .hbmImage dd ?
  .hbmMask  dd ?
  .Unused1  dd ?
  .Unused2  dd ?
  .rcImage  dd ?
ends

struct HDITEM
  .mask       dd ?
  .cxy        dd ?
  .pszText    dd ?
  .hbm        dd ?
  .cchTextMax dd ?
  .fmt        dd ?
  .lParam     dd ?
ends

struct HDLAYOUT
  .prc   dd ?
  .pwpos dd ?
ends

struct HDHITTESTINFO
  .pt    POINT
  .flags dd ?
  .iItem dd ?
ends

struct HDNOTIFY
  .hdr     NMHDR
  .iItem   dd ?
  .iButton dd ?
  .pitem   dd ?
ends

struct TBBUTTON
  .iBitmap   dd ?
  .idCommand dd ?
  .fsState   db ?
  .fsStyle   db ?
             dw ?
  .dwData    dd ?
  .iString   dd ?
ends

struct COLORMAP
  .from dd ?
  .to   dd ?
ends

struct TBADDBITMAP
  .hInst dd ?
  .nID   dd ?
ends

struct TBSAVEPARAMS
  .hkr          dd ?
  .pszSubKey    dd ?
  .pszValueName dd ?
ends

struct TBREPLACEBITMAP
  .hInstOld dd ?
  .nIDOld   dd ?
  .hInstNew dd ?
  .nIDNew   dd ?
  .nButtons dd ?
ends

struct NMTOOLBAR
  .hdr      NMHDR
  .iItem    dd ?
  .tbButton TBBUTTON
  .cchText  dd ?
  .pszText  dd ?
ends

struct REBARINFO
  .cbSize dd ?
  .fMask  dd ?
  .himl   dd ?
ends

struct REBARBANDINFO
  .cbSize      dd ?
  .fMask       dd ?
  .fStyle      dd ?
  .clrFore     dd ?
  .clrBack     dd ?
  .lpText      dd ?
  .cch         dd ?
  .iImage      dd ?
  .hwndChild   dd ?
  .cxMinChild  dd ?
  .cyMinChild  dd ?
  .cx          dd ?
  .hbmBack     dd ?
  .wID         dd ?
ends

struct TOOLINFO
  .cbSize   dd ?
  .uFlags   dd ?
  .hwnd     dd ?
  .uId      dd ?
  .Rect     RECT
  .hInst    dd ?
  .lpszText dd ?
ends

struct TTHITTESTINFO
  .hwnd dd ?
  .pt   POINT
  .ti   TOOLINFO
ends

struct TOOLTOPTEXT
  .hdr      NMHDR
  .lpszText dd ?
  .szText   rb 80
  .hinst    dd ?
  .uFlags   dd ?
ends

struct UDACCEL
  .nSec dd ?
  .nInc dd ?
ends

struct NMUPDOWN
  .hdr    NMHDR
  .iPos   dd ?
  .iDelta dd ?
ends

struct LVITEM
  .mask       dd ?
  .iItem      dd ?
  .iSubItem   dd ?
  .state      dd ?
  .stateMask  dd ?
  .pszText    dd ?
  .cchTextMax dd ?
  .iImage     dd ?
  .lParam     dd ?
  .iIndent    dd ?
ends

struct LVFINDINFO
  .flags       dd ?
  .psz         dd ?
  .lParam      dd ?
  .pt          POINT
  .vkDirection dd ?
ends

struct LVHITTESTINFO
  .pt    POINT
  .flags dd ?
  .iItem dd ?
ends

struct LVCOLUMN
  .mask       dd ?
  .fmt        dd ?
  .cx         dd ?
  .pszText    dd ?
  .cchTextMax dd ?
  .iSubItem   dd ?
ends

struct NMLISTVIEW
  .hdr       NMHDR
  .iItem     dd ?
  .iSubItem  dd ?
  .uNewState dd ?
  .uOldState dd ?
  .uChanged  dd ?
  .ptAction  POINT
  .lParam    dd ?
ends

struct NMCACHEHINT
  .hdr   NMHDR
  .iFrom dd ?
  .iTo   dd ?
ends

struct NMFINDITEM
  .hdr    NMHDR
  .iStart dd ?
  .lvfi   LVFINDINFO
ends

struct LVDISPINFO
  .hdr  NMHDR
  .item LVITEM
ends

struct LVKEYDOWN
  .hdr   NMHDR
  .wVKey dw ?
  .flags dd ?
ends

struct TVITEM
  .mask           dd ?
  .hItem          dd ?
  .state          dd ?
  .stateMask      dd ?
  .pszText        dd ?
  .cchTextMax     dd ?
  .iImage         dd ?
  .iSelectedImage dd ?
  .cChildren      dd ?
  .lParam         dd ?
ends

struct TVINSERTSTRUCT
  .hParent      dd ?
  .hInsertAfter dd ?
  .item         TVITEM
ends

struct TVHITTESTINFO
  .pt    POINT
  .flags dd ?
  .hItem dd ?
ends

struct TVSORTCB
  .hParent     dd ?
  .lpfnCompare dd ?
  .lParam      dd ?
ends

struct NMTREEVIEW
  .hdr     NMHDR
  .action  dd ?
  .itemOld TVITEM
  .itemNew TVITEM
  .ptDrag  POINT
ends

struct TVDISPINFO
  .hdr  NMHDR
  .item TVITEM
ends

struct TVKEYDOWN
  .hdr   NMHDR
  .wVKey dw ?
  .flags dd ?
ends

struct TCITEMHEADER
  .mask        dd ?
  .lpReserved1 dd ?
  .lpReserved2 dd ?
  .pszText     dd ?
  .cchTextMax  dd ?
  .iImage      dd ?
ends

struct TCITEM
  .mask        dd ?
  .lpReserved1 dd ?
  .lpReserved2 dd ?
  .pszText     dd ?
  .cchTextMax  dd ?
  .iImage      dd ?
  .lParam      dd ?
ends

struct TCHITTESTINFO
  .pt    POINT
  .flags dd ?
ends

struct TCKEYDOWN
  .hdr   NMHDR
  .wVKey dw ?
  .flags dd ?
ends

struct MCHITTESTINFO
  .cbSize dd ?
  .pt     POINT
  .uHit   dd ?
  .st     SYSTEMTIME
ends

struct NMSELCHANGE
  .nmhdr      NMHDR
  .stSelStart SYSTEMTIME
  .stSelEnd   SYSTEMTIME
ends

struct NMDAYSTATE
  .nmhdr       NMHDR
  .stStart     SYSTEMTIME
  .cDayState   dd ?
  .prgDayState dd ?
ends

struct NMDATETIMECHANGE
  .nmhdr   NMHDR
  .dwFlags dd ?
  .st      SYSTEMTIME
ends

struct NMDATETIMESTRING
  .nmhdr         NMHDR
  .pszUserString dd ?
  .st            SYSTEMTIME
  .dwFlags       dd ?
ends

struct NMDATETIMEWMKEYDOWN
  .nmhdr     NMHDR
  .nVirtKey  dd ?
  .pszFormat dd ?
  .st        SYSTEMTIME
ends

struct NMDATETIMEFORMAT
  .nmhdr      NMHDR
  .pszFormat  dd ?
  .st         SYSTEMTIME
  .pszDisplay dd ?
  .szDisplay  rb 64
ends

struct NMDATETIMEFORMATQUERY
  .nmhdr     NMHDR
  .pszFormat dd ?
  .szMax     SIZE
ends

struct NMCUSTOMDRAW
  .hdr         NMHDR
  .dwDrawStage dd ?
  .hdc         dd ?
  .rc          RECT
  .dwItemSpec  dd ?
  .uItemState  dd ?
  .lItemlParam dd ?
ends

struct NMLVCUSTOMDRAW
  .nmcd        NMCUSTOMDRAW
  .clrText     dd ?
  .clrTextBk   dd ?
  .iSubItem    dd ?
  .dwItemType  dd ?
  .clrFace     dd ?
  .iIconEffect dd ?
  .iIconPhase  dd ?
  .iPartId     dd ?
  .iStateId    dd ?
  .rcText      RECT
  .uAlign      dd ?
ends

struct INITCOMMONCONTROLSEX
  .dwSize dd ?
  .dwICC  dd ?
ends

; Common control window classes

HOTKEY_CLASS       equ 'msctls_hotkey32'
PROGRESS_CLASS     equ 'msctls_progress32'
STATUS_CLASS       equ 'msctls_statusbar32'
TRACKBAR_CLASS     equ 'msctls_trackbar32'
UPDOWN_CLASS       equ 'msctls_updown32'
TOOLTIPS_CLASS     equ 'tooltips_class32'
ANIMATE_CLASS      equ 'SysAnimate32'
HEADER_CLASS       equ 'SysHeader32'
LISTVIEW_CLASS     equ 'SysListView32'
TREEVIEW_CLASS     equ 'SysTreeView32'
TABCONTROL_CLASS   equ 'SysTabControl32'
MONTHCAL_CLASS     equ 'SysMonthCal32'
DATETIMEPICK_CLASS equ 'SysDateTimePick32'
TOOLBAR_CLASS      equ 'ToolbarWindow32'
REBAR_CLASS        equ 'ReBarWindow32'

; Ranges for control message IDs

LVM_FIRST = 1000h
TV_FIRST  = 1100h
HDM_FIRST = 1200h
TCM_FIRST = 1300h
MCM_FIRST = 1000h
DTM_FIRST = 1000h
CCM_FIRST = 2000h

; Ranges for control notification IDs

NM_FIRST   = 0
LVN_FIRST  = -100
PSN_FIRST  = -200
HDN_FIRST  = -300
TVN_FIRST  = -400
TTN_FIRST  = -520
TCN_FIRST  = -550
CDN_FIRST  = -601
TBN_FIRST  = -700
UDN_FIRST  = -721
MCN_FIRST  = -750
DTN_FIRST  = -760
CBEN_FIRST = -800
RBN_FIRST  = -831

; Generic notifications

NM_OUTOFMEMORY = NM_FIRST - 1
NM_CLICK       = NM_FIRST - 2
NM_DBLCLK      = NM_FIRST - 3
NM_RETURN      = NM_FIRST - 4
NM_RCLICK      = NM_FIRST - 5
NM_RDBLCLK     = NM_FIRST - 6
NM_SETFOCUS    = NM_FIRST - 7
NM_KILLFOCUS   = NM_FIRST - 8
NM_CUSTOMDRAW  = NM_FIRST - 12

; Common control styles

CCS_TOP           = 01h
CCS_NOMOVEY       = 02h
CCS_BOTTOM        = 03h
CCS_NORESIZE      = 04h
CCS_NOPARENTALIGN = 08h
CCS_ADJUSTABLE    = 20h
CCS_NODIVIDER     = 40h
CCS_VERT          = 80h
CCS_LEFT          = CCS_VERT or CCS_TOP
CCS_RIGHT         = CCS_VERT or CCS_BOTTOM
CCS_NOMOVEX       = CCS_VERT or CCS_NOMOVEY

; Owner-drawn control types

ODT_HEADER   = 100
ODT_TAB      = 101
ODT_LISTVIEW = 102

; InitCommonControlsEx classes

ICC_ANIMATE_CLASS      = 0080h
ICC_BAR_CLASSES        = 0004h
ICC_COOL_CLASSES       = 0400h
ICC_DATE_CLASSES       = 0100h
ICC_HOTKEY_CLASS       = 0040h
ICC_INTERNET_CLASSES   = 0800h
ICC_LISTVIEW_CLASSES   = 0001h
ICC_PAGESCROLLER_CLASS = 1000h
ICC_PROGRESS_CLASS     = 0020h
ICC_TAB_CLASSES        = 0008h
ICC_TREEVIEW_CLASSES   = 0002h
ICC_UPDOWN_CLASS       = 0010h
ICC_USEREX_CLASSES     = 0200h
ICC_WIN95_CLASSES      = 00FFh

; Shared messages

CCM_SETCOLORSCHEME   = CCM_FIRST + 2
CCM_GETCOLORSCHEME   = CCM_FIRST + 3
CCM_GETDROPTARGET    = CCM_FIRST + 4
CCM_SETUNICODEFORMAT = CCM_FIRST + 5
CCM_GETUNICODEFORMAT = CCM_FIRST + 6

; Property sheet page flags

PSP_DEFAULT      = 0000h
PSP_DLGINDIRECT  = 0001h
PSP_USEHICON     = 0002h
PSP_USEICONID    = 0004h
PSP_USETITLE     = 0008h
PSP_HASHELP      = 0020h
PSP_USEREFPARENT = 0040h
PSP_USECALLBACK  = 0080h

; Property sheet page actions

PSPCB_RELEASE = 1
PSPCB_CREATE  = 2

; Property sheet header flags

PSH_DEFAULT       = 0000h
PSH_PROPTITLE     = 0001h
PSH_USEHICON      = 0002h
PSH_USEICONID     = 0004h
PSH_PROPSHEETPAGE = 0008h
PSH_MULTILINETABS = 0010h
PSH_WIZARD        = 0020h
PSH_USEPSTARTPAGE = 0040h
PSH_NOAPPLYNOW    = 0080h
PSH_USECALLBACK   = 0100h
PSH_HASHELP       = 0200h
PSH_MODELESS      = 0400h

; Property sheet actions

PSCB_INITIALIZED  = 1

; Property sheet notifications

PSN_SETACTIVE   = PSN_FIRST - 0
PSN_KILLACTIVE  = PSN_FIRST - 1
PSN_APPLY       = PSN_FIRST - 2
PSN_RESET       = PSN_FIRST - 3
PSN_HELP        = PSN_FIRST - 5
PSN_WIZBACK     = PSN_FIRST - 6
PSN_WIZNEXT     = PSN_FIRST - 7
PSN_WIZFINISH   = PSN_FIRST - 8
PSN_QUERYCANCEL = PSN_FIRST - 9

; Property sheet return values

PSNRET_NOERROR              = 0
PSNRET_INVALID              = 1
PSNRET_INVALID_NOCHANGEPAGE = 2

; Property sheet messages

PSM_SETCURSEL       = WM_USER + 101
PSM_REMOVEPAGE      = WM_USER + 102
PSM_ADDPAGE         = WM_USER + 103
PSM_CHANGED         = WM_USER + 104
PSM_RESTARTWINDOWS  = WM_USER + 105
PSM_REBOOTSYSTEM    = WM_USER + 106
PSM_CANCELTOCLOSE   = WM_USER + 107
PSM_QUERYSIBLINGS   = WM_USER + 108
PSM_UNCHANGED       = WM_USER + 109
PSM_APPLY           = WM_USER + 110
PSM_SETTITLE        = WM_USER + 111
PSM_SETTITLEW       = WM_USER + 120
PSM_SETWIZBUTTONS   = WM_USER + 112
PSM_PRESSBUTTON     = WM_USER + 113
PSM_SETCURSELID     = WM_USER + 114
PSM_SETFINISHTEXT   = WM_USER + 115
PSM_SETFINISHTEXTW  = WM_USER + 121
PSM_GETTABCONTROL   = WM_USER + 116
PSM_ISDIALOGMESSAGE = WM_USER + 117

; Property sheet buttons

PSBTN_BACK            = 0
PSBTN_NEXT            = 1
PSBTN_FINISH          = 2
PSBTN_OK              = 3
PSBTN_APPLYNOW        = 4
PSBTN_CANCEL          = 5
PSBTN_HELP            = 6
PSWIZB_BACK           = 1
PSWIZB_NEXT           = 2
PSWIZB_FINISH         = 4
PSWIZB_DISABLEDFINISH = 8
ID_PSRESTARTWINDOWS   = 2
ID_PSREBOOTSYSTEM     = ID_PSRESTARTWINDOWS or 1

; Property sheet sizes

PROP_SM_CXDLG  = 212
PROP_SM_CYDLG  = 188
PROP_MED_CXDLG = 227
PROP_MED_CYDLG = 215
PROP_LG_CXDLG  = 252
PROP_LG_CYDLG  = 218
WIZ_CXDLG      = 276
WIZ_CYDLG      = 140
WIZ_CXBMP      = 80
WIZ_BODYX      = 92
WIZ_BODYCX     = 184

; Image list types

ILC_MASK     = 001h
ILC_COLOR    = 0FEh
ILC_COLORDDB = 0FEh
ILC_COLOR4   = 004h
ILC_COLOR8   = 008h
ILC_COLOR16  = 010h
ILC_COLOR24  = 018h
ILC_COLOR32  = 020h
ILC_PALETTE  = 800h

; Image list color values

CLR_NONE    = 0FFFFFFFFh
CLR_DEFAULT = 0FF000000h
CLR_HILIGHT = CLR_DEFAULT

; Image list drawing styles

ILD_NORMAL      = 0000h
ILD_TRANSPARENT = 0001h
ILD_MASK        = 0010h
ILD_IMAGE       = 0020h
ILD_BLEND25     = 0002h
ILD_BLEND50     = 0004h
ILD_OVERLAYMASK = 0F00h
ILD_SELECTED    = ILD_BLEND50
ILD_FOCUS       = ILD_BLEND25
ILD_BLEND       = ILD_BLEND50

; Header control styles

HDS_HORZ     = 00h
HDS_BUTTONS  = 02h
HDS_HOTTRACK = 04h
HDS_HIDDEN   = 08h
HDS_DRAGDROP = 40h
HDS_FULLDRAG = 80h

; Header control structure flags

HDI_WIDTH  = 01h
HDI_HEIGHT = HDI_WIDTH
HDI_TEXT   = 02h
HDI_FORMAT = 04h
HDI_LPARAM = 08h
HDI_BITMAP = 10h

; Header control flags

HDF_LEFT        = 0000h
HDF_RIGHT       = 0001h
HDF_CENTER      = 0002h
HDF_JUSTIFYMASK = 0003h
HDF_RTLREADING  = 0004h
HDF_BITMAP      = 2000h
HDF_STRING      = 4000h
HDF_OWNERDRAW   = 8000h

; Header control messages

HDM_GETITEMCOUNT = HDM_FIRST + 0
HDM_INSERTITEMA  = HDM_FIRST + 1
HDM_DELETEITEM   = HDM_FIRST + 2
HDM_GETITEMA     = HDM_FIRST + 3
HDM_SETITEMA     = HDM_FIRST + 4
HDM_LAYOUT       = HDM_FIRST + 5
HDM_HITTEST      = HDM_FIRST + 6
HDM_INSERTITEMW  = HDM_FIRST + 10
HDM_GETITEMW     = HDM_FIRST + 11
HDM_SETITEMW     = HDM_FIRST + 12
HDM_INSERTITEM   = HDM_INSERTITEMA
HDM_GETITEM      = HDM_GETITEMA
HDM_SETITEM      = HDM_SETITEMA

; Hit test result flags

HHT_NOWHERE   = 001h
HHT_ONHEADER  = 002h
HHT_ONDIVIDER = 004h
HHT_ONDIVOPEN = 008h
HHT_ABOVE     = 100h
HHT_BELOW     = 200h
HHT_TORIGHT   = 400h
HHT_TOLEFT    = 800h

; Header control notifications

HDN_ITEMCHANGINGA    = HDN_FIRST - 0
HDN_ITEMCHANGEDA     = HDN_FIRST - 1
HDN_ITEMCLICKA       = HDN_FIRST - 2
HDN_ITEMDBLCLICKA    = HDN_FIRST - 3
HDN_DIVIDERDBLCLICKA = HDN_FIRST - 5
HDN_BEGINTRACKA      = HDN_FIRST - 6
HDN_ENDTRACKA        = HDN_FIRST - 7
HDN_TRACKA           = HDN_FIRST - 8
HDN_ITEMCHANGINGW    = HDN_FIRST - 20
HDN_ITEMCHANGEDW     = HDN_FIRST - 21
HDN_ITEMCLICKW       = HDN_FIRST - 22
HDN_ITEMDBLCLICKW    = HDN_FIRST - 23
HDN_DIVIDERDBLCLICKW = HDN_FIRST - 25
HDN_BEGINTRACKW      = HDN_FIRST - 26
HDN_ENDTRACKW        = HDN_FIRST - 27
HDN_TRACKW           = HDN_FIRST - 28
HDN_ITEMCHANGING     = HDN_ITEMCHANGINGA
HDN_ITEMCHANGED      = HDN_ITEMCHANGEDA
HDN_ITEMCLICK        = HDN_ITEMCLICKA
HDN_ITEMDBLCLICK     = HDN_ITEMDBLCLICKA
HDN_DIVIDERDBLCLICK  = HDN_DIVIDERDBLCLICKA
HDN_BEGINTRACK       = HDN_BEGINTRACKA
HDN_ENDTRACK         = HDN_ENDTRACKA
HDN_TRACK            = HDN_TRACKA

; Toolbar bitmap flags

CMB_MASKED = 2

; Toolbar button states

TBSTATE_CHECKED       = 01h
TBSTATE_PRESSED       = 02h
TBSTATE_ENABLED       = 04h
TBSTATE_HIDDEN        = 08h
TBSTATE_INDETERMINATE = 10h
TBSTATE_WRAP          = 20h
TBSTATE_ELLIPSES      = 40h

; Toolbar button styles

TBSTYLE_BUTTON      = 0000h
TBSTYLE_SEP         = 0001h
TBSTYLE_CHECK       = 0002h
TBSTYLE_GROUP       = 0004h
TBSTYLE_CHECKGROUP  = TBSTYLE_GROUP or TBSTYLE_CHECK
TBSTYLE_DROPDOWN    = 0008h
TBSTYLE_AUTOSIZE    = 0010h     ; automatically calculate width of the button
TBSTYLE_NOPREFIX    = 0020h     ; if this button should not have accel prefix

TBSTYLE_TOOLTIPS    = 0100h
TBSTYLE_WRAPABLE    = 0200h
TBSTYLE_ALTDRAG     = 0400h
TBSTYLE_FLAT        = 0800h
TBSTYLE_LIST        = 1000h
TBSTYLE_CUSTOMERASE = 2000h
TBSTYLE_TRANSPARENT = 8000h

; Toolbar button extended styles

TBSTYLE_EX_DRAWDDARROWS = 0001h

; Toolbar messages

TB_ENABLEBUTTON          = WM_USER + 1
TB_CHECKBUTTON           = WM_USER + 2
TB_PRESSBUTTON           = WM_USER + 3
TB_HIDEBUTTON            = WM_USER + 4
TB_INDETERMINATE         = WM_USER + 5
TB_ISBUTTONENABLED       = WM_USER + 9
TB_ISBUTTONCHECKED       = WM_USER + 10
TB_ISBUTTONPRESSED       = WM_USER + 11
TB_ISBUTTONHIDDEN        = WM_USER + 12
TB_ISBUTTONINDETERMINATE = WM_USER + 13
TB_SETSTATE              = WM_USER + 17
TB_GETSTATE              = WM_USER + 18
TB_ADDBITMAP             = WM_USER + 19
TB_ADDBUTTONS            = WM_USER + 20
TB_INSERTBUTTON          = WM_USER + 21
TB_DELETEBUTTON          = WM_USER + 22
TB_GETBUTTON             = WM_USER + 23
TB_BUTTONCOUNT           = WM_USER + 24
TB_COMMANDTOINDEX        = WM_USER + 25
TB_SAVERESTOREA          = WM_USER + 26
TB_ADDSTRINGA            = WM_USER + 28
TB_CUSTOMIZE             = WM_USER + 27
TB_GETITEMRECT           = WM_USER + 29
TB_BUTTONSTRUCTSIZE      = WM_USER + 30
TB_SETBUTTONSIZE         = WM_USER + 31
TB_SETBITMAPSIZE         = WM_USER + 32
TB_AUTOSIZE              = WM_USER + 33
TB_GETTOOLTIPS           = WM_USER + 35
TB_SETTOOLTIPS           = WM_USER + 36
TB_SETPARENT             = WM_USER + 37
TB_SETROWS               = WM_USER + 39
TB_GETROWS               = WM_USER + 40
TB_GETBITMAPFLAGS        = WM_USER + 41
TB_SETCMDID              = WM_USER + 42
TB_CHANGEBITMAP          = WM_USER + 43
TB_GETBITMAP             = WM_USER + 44
TB_GETBUTTONTEXTA        = WM_USER + 45
TB_REPLACEBITMAP         = WM_USER + 46
TB_SETINDENT             = WM_USER + 47
TB_SETIMAGELIST          = WM_USER + 48
TB_GETIMAGELIST          = WM_USER + 49
TB_LOADIMAGES            = WM_USER + 50
TB_GETRECT               = WM_USER + 51
TB_SETHOTIMAGELIST       = WM_USER + 52
TB_GETHOTIMAGELIST       = WM_USER + 53
TB_SETDISABLEDIMAGELIST  = WM_USER + 54
TB_GETDISABLEDIMAGELIST  = WM_USER + 55
TB_SETSTYLE              = WM_USER + 56
TB_GETSTYLE              = WM_USER + 57
TB_GETBUTTONSIZE         = WM_USER + 58
TB_SETBUTTONWIDTH        = WM_USER + 59
TB_SETMAXTEXTROWS        = WM_USER + 60
TB_GETTEXTROWS           = WM_USER + 61
TB_GETBUTTONTEXTW        = WM_USER + 75
TB_SAVERESTOREW          = WM_USER + 76
TB_ADDSTRINGW            = WM_USER + 77
TB_SETEXTENDEDSTYLE      = WM_USER + 84
TB_GETEXTENDEDSTYLE      = WM_USER + 85
TB_GETBUTTONTEXT         = TB_GETBUTTONTEXTA
TB_SAVERESTORE           = TB_SAVERESTOREA
TB_ADDSTRING             = TB_ADDSTRINGA

; System-defined button bitmaps

HINST_COMMCTRL       = -1
IDB_STD_SMALL_COLOR  = 0
IDB_STD_LARGE_COLOR  = 1
IDB_VIEW_SMALL_COLOR = 4
IDB_VIEW_LARGE_COLOR = 5
IDB_HIST_SMALL_COLOR = 8
IDB_HIST_LARGE_COLOR = 9

; Icon indexes for standard bitmap

STD_CUT        = 0
STD_COPY       = 1
STD_PASTE      = 2
STD_UNDO       = 3
STD_REDOW      = 4
STD_DELETE     = 5
STD_FILENEW    = 6
STD_FILEOPEN   = 7
STD_FILESAVE   = 8
STD_PRINTPRE   = 9
STD_PROPERTIES = 10
STD_HELP       = 11
STD_FIND       = 12
STD_REPLACE    = 13
STD_PRINT      = 14

; Icon indexes for standard view bitmap

VIEW_LARGEICONS    = 0
VIEW_SMALLICONS    = 1
VIEW_LIST          = 2
VIEW_DETAILS       = 3
VIEW_SORTNAME      = 4
VIEW_SORTSIZE      = 5
VIEW_SORTDATE      = 6
VIEW_SORTTYPE      = 7
VIEW_PARENTFOLDER  = 8
VIEW_NETCONNECT    = 9
VIEW_NETDISCONNECT = 10
VIEW_NEWFOLDER     = 11

; Icon indexes for history bitmap

HIST_BACK           = 0
HIST_FORWARD        = 1
HIST_FAVORITES      = 2
HIST_ADDTOFAVORITES = 3
HIST_VIEWTREE       = 4

; Toolbar bitmap flags

TBBF_LARGE = 1

; Toolbar notifications

TBN_GETBUTTONINFOA = TBN_FIRST - 0
TBN_BEGINDRAG      = TBN_FIRST - 1
TBN_ENDDRAG        = TBN_FIRST - 2
TBN_BEGINADJUST    = TBN_FIRST - 3
TBN_ENDADJUST      = TBN_FIRST - 4
TBN_RESET          = TBN_FIRST - 5
TBN_QUERYINSERT    = TBN_FIRST - 6
TBN_QUERYDELETE    = TBN_FIRST - 7
TBN_TOOLBARCHANGE  = TBN_FIRST - 8
TBN_CUSTHELP       = TBN_FIRST - 9
TBN_DROPDOWN       = TBN_FIRST - 10
TBN_CLOSEUP        = TBN_FIRST - 11
TBN_GETBUTTONINFOW = TBN_FIRST - 20
TBN_GETBUTTONINFO  = TBN_GETBUTTONINFOA

; ReBar styles

RBS_TOOLTIPS        = 100h
RBS_VARHEIGHT       = 200h
RBS_BANDBORDERS     = 400h
RBS_FIXEDORDER      = 800h
RBS_REGISTERDROP    = 1000h
RBS_AUTOSIZE        = 2000h
RBS_VERTICALGRIPPER = 4000h
RBS_DBLCLKTOGGLE    = 8000h

; ReBar band info structure flags

RBBIM_STYLE      = 001h
RBBIM_COLORS     = 002h
RBBIM_TEXT       = 004h
RBBIM_IMAGE      = 008h
RBBIM_CHILD      = 010h
RBBIM_CHILDSIZE  = 020h
RBBIM_SIZE       = 040h
RBBIM_BACKGROUND = 080h
RBBIM_ID         = 100h
RBBIM_IDEALSIZE  = 200h
RBBIM_LPARAM     = 400h
RBBIM_HEADERSIZE = 800h

; ReBar band styles

RBBS_BREAK          = 001h
RBBS_FIXEDSIZE      = 002h
RBBS_CHILDEDGE      = 004h
RBBS_HIDDEN         = 008h
RBBS_NOVERT         = 010h
RBBS_FIXEDBMP       = 020h
RBBS_VARIABLEHEIGHT = 040h
RBBS_GRIPPERALWAYS  = 080h
RBBS_NOGRIPPER      = 100h

; ReBar messages

RB_INSERTBANDA      = WM_USER + 1
RB_DELETEBAND       = WM_USER + 2
RB_GETBARINFO       = WM_USER + 3
RB_SETBARINFO       = WM_USER + 4
RB_GETBANDINFO      = WM_USER + 5
RB_SETBANDINFOA     = WM_USER + 6
RB_SETPARENT        = WM_USER + 7
RB_INSERTBANDW      = WM_USER + 10
RB_SETBANDINFOW     = WM_USER + 11
RB_GETBANDCOUNT     = WM_USER + 12
RB_GETROWCOUNT      = WM_USER + 13
RB_GETROWHEIGHT     = WM_USER + 14
RB_IDTOINDEX        = WM_USER + 16
RB_GETTOOLTIPS      = WM_USER + 17
RB_SETTOOLTIPS      = WM_USER + 18
RB_SETBKCOLOR       = WM_USER + 19
RB_GETBKCOLOR       = WM_USER + 20
RB_SETTEXTCOLOR     = WM_USER + 21
RB_GETTEXTCOLOR     = WM_USER + 22
RB_SIZETORECT       = WM_USER + 23
RB_BEGINDRAG        = WM_USER + 24
RB_ENDDRAG          = WM_USER + 25
RB_DRAGMOVE         = WM_USER + 26
RB_GETBARHEIGHT     = WM_USER + 27
RB_GETBANDINFOW     = WM_USER + 28
RB_GETBANDINFOA     = WM_USER + 29
RB_MINIMIZEBAND     = WM_USER + 30
RB_MAXIMIZEBAND     = WM_USER + 31
RB_GETDROPTARGET    = CCM_GETDROPTARGET
RB_GETBANDBORDERS   = WM_USER + 34
RB_SHOWBAND         = WM_USER + 35
RB_SETPALETTE       = WM_USER + 37
RB_GETPALETTE       = WM_USER + 38
RB_MOVEBAND         = WM_USER + 39
RB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT
RB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT
RB_INSERTBAND       = RB_INSERTBANDA
RB_SETBANDINFO      = RB_SETBANDINFOA

; ReBar notifications

RBN_HEIGHTCHANGE  = RBN_FIRST - 0
RBN_GETOBJECT     = RBN_FIRST - 1
RBN_LAYOUTCHANGED = RBN_FIRST - 2
RBN_AUTOSIZE      = RBN_FIRST - 3
RBN_BEGINDRAG     = RBN_FIRST - 4
RBN_ENDDRAG       = RBN_FIRST - 5
RBN_DELETINGBAND  = RBN_FIRST - 6
RBN_DELETEDBAND   = RBN_FIRST - 7
RBN_CHILDSIZE     = RBN_FIRST - 8

; Tooltip styles

TTS_ALWAYSTIP = 1
TTS_NOPREFIX  = 2

; Tooltip flags

TTF_IDISHWND   = 01h
TTF_CENTERTIP  = 02h
TTF_RTLREADING = 04h
TTF_SUBCLASS   = 10h

; Tooltip durations

TTDT_AUTOMATIC = 0
TTDT_RESHOW    = 1
TTDT_AUTOPOP   = 2
TTDT_INITIAL   = 3

; Tooltip messages

TTM_ACTIVATE        = WM_USER + 1
TTM_SETDELAYTIME    = WM_USER + 3
TTM_ADDTOOLA        = WM_USER + 4
TTM_DELTOOLA        = WM_USER + 5
TTM_NEWTOOLRECTA    = WM_USER + 6
TTM_RELAYEVENT      = WM_USER + 7
TTM_GETTOOLINFOA    = WM_USER + 8
TTM_SETTOOLINFOA    = WM_USER + 9
TTM_HITTESTA        = WM_USER + 10
TTM_GETTEXTA        = WM_USER + 11
TTM_UPDATETIPTEXTA  = WM_USER + 12
TTM_GETTOOLCOUNT    = WM_USER + 13
TTM_ENUMTOOLSA      = WM_USER + 14
TTM_GETCURRENTTOOLA = WM_USER + 15
TTM_WINDOWFROMPOINT = WM_USER + 16
TTM_ADDTOOLW        = WM_USER + 50
TTM_DELTOOLW        = WM_USER + 51
TTM_NEWTOOLRECTW    = WM_USER + 52
TTM_GETTOOLINFOW    = WM_USER + 53
TTM_SETTOOLINFOW    = WM_USER + 54
TTM_HITTESTW        = WM_USER + 55
TTM_GETTEXTW        = WM_USER + 56
TTM_UPDATETIPTEXTW  = WM_USER + 57
TTM_ENUMTOOLSW      = WM_USER + 58
TTM_GETCURRENTTOOLW = WM_USER + 59
TTM_ADDTOOL         = TTM_ADDTOOLA
TTM_DELTOOL         = TTM_DELTOOLA
TTM_NEWTOOLRECT     = TTM_NEWTOOLRECTA
TTM_GETTOOLINFO     = TTM_GETTOOLINFOA
TTM_SETTOOLINFO     = TTM_SETTOOLINFOA
TTM_HITTEST         = TTM_HITTESTA
TTM_GETTEXT         = TTM_GETTEXTA
TTM_UPDATETIPTEXT   = TTM_UPDATETIPTEXTA
TTM_ENUMTOOLS       = TTM_ENUMTOOLSA
TTM_GETCURRENTTOOL  = TTM_GETCURRENTTOOLA

; Tooltip notifications

TTN_NEEDTEXTA = TTN_FIRST - 0
TTN_SHOW      = TTN_FIRST - 1
TTN_POP       = TTN_FIRST - 2
TTN_NEEDTEXTW = TTN_FIRST - 10
TTN_NEEDTEXT  = TTN_NEEDTEXTA

; tooltip structures

struct TOOLTIPTEXT
  .hdr      NMHDR
  .lpszText dd ?
  .char     rb 80
  .hinst    dd ?
  .uFlags   dd ?
ends





; Status bar styles

SBARS_SIZEGRIP = 100h

; Status bar messages

SB_SETTEXTA       = WM_USER + 1
SB_GETTEXTA       = WM_USER + 2
SB_GETTEXTLENGTHA = WM_USER + 3
SB_SETPARTS       = WM_USER + 4
SB_GETPARTS       = WM_USER + 6
SB_GETBORDERS     = WM_USER + 7
SB_SETMINHEIGHT   = WM_USER + 8
SB_SIMPLE         = WM_USER + 9
SB_GETRECT        = WM_USER + 10
SB_SETTEXTW       = WM_USER + 11
SB_GETTEXTW       = WM_USER + 13
SB_GETTEXTLENGTHW = WM_USER + 12
SB_SETTEXT        = SB_SETTEXTA
SB_GETTEXT        = SB_GETTEXTA
SB_GETTEXTLENGTH  = SB_GETTEXTLENGTHA

; Status bar drawing types

SBT_OWNERDRAW  = 1000h
SBT_NOBORDERS  = 0100h
SBT_POPOUT     = 0200h
SBT_RTLREADING = 0400h

; Trackbar styles

TBS_AUTOTICKS      = 01h
TBS_VERT           = 02h
TBS_HORZ           = 00h
TBS_TOP            = 04h
TBS_BOTTOM         = 00h
TBS_LEFT           = 04h
TBS_RIGHT          = 00h
TBS_BOTH           = 08h
TBS_NOTICKS        = 10h
TBS_ENABLESELRANGE = 20h
TBS_FIXEDLENGTH    = 40h
TBS_NOTHUMB        = 80h

; Trackbar messages

TBM_GETPOS         = WM_USER + 0
TBM_GETRANGEMIN    = WM_USER + 1
TBM_GETRANGEMAX    = WM_USER + 2
TBM_GETTIC         = WM_USER + 3
TBM_SETTIC         = WM_USER + 4
TBM_SETPOS         = WM_USER + 5
TBM_SETRANGE       = WM_USER + 6
TBM_SETRANGEMIN    = WM_USER + 7
TBM_SETRANGEMAX    = WM_USER + 8
TBM_CLEARTICS      = WM_USER + 9
TBM_SETSEL         = WM_USER + 10
TBM_SETSELSTART    = WM_USER + 11
TBM_SETSELEND      = WM_USER + 12
TBM_GETPTICS       = WM_USER + 14
TBM_GETTICPOS      = WM_USER + 15
TBM_GETNUMTICS     = WM_USER + 16
TBM_GETSELSTART    = WM_USER + 17
TBM_GETSELEND      = WM_USER + 18
TBM_CLEARSEL       = WM_USER + 19
TBM_SETTICFREQ     = WM_USER + 20
TBM_SETPAGESIZE    = WM_USER + 21
TBM_GETPAGESIZE    = WM_USER + 22
TBM_SETLINESIZE    = WM_USER + 23
TBM_GETLINESIZE    = WM_USER + 24
TBM_GETTHUMBRECT   = WM_USER + 25
TBM_GETCHANNELRECT = WM_USER + 26
TBM_SETTHUMBLENGTH = WM_USER + 27
TBM_GETTHUMBLENGTH = WM_USER + 28

; Trackbar notifications

TB_LINEUP        = 0
TB_LINEDOWN      = 1
TB_PAGEUP        = 2
TB_PAGEDOWN      = 3
TB_THUMBPOSITION = 4
TB_THUMBTRACK    = 5
TB_TOP           = 6
TB_BOTTOM        = 7
TB_ENDTRACK      = 8

; Up-down control styles

UDS_WRAP        = 01h
UDS_SETBUDDYINT = 02h
UDS_ALIGNRIGHT  = 04h
UDS_ALIGNLEFT   = 08h
UDS_AUTOBUDDY   = 10h
UDS_ARROWKEYS   = 20h
UDS_HORZ        = 40h
UDS_NOTHOUSANDS = 80h

; Up-down control messages

UDM_SETRANGE = WM_USER + 101
UDM_GETRANGE = WM_USER + 102
UDM_SETPOS   = WM_USER + 103
UDM_GETPOS   = WM_USER + 104
UDM_SETBUDDY = WM_USER + 105
UDM_GETBUDDY = WM_USER + 106
UDM_SETACCEL = WM_USER + 107
UDM_GETACCEL = WM_USER + 108
UDM_SETBASE  = WM_USER + 109
UDM_GETBASE  = WM_USER + 110

; Up-down control notifications

UDN_DELTAPOS = UDN_FIRST - 1

; Progress bar messages

PBM_SETRANGE   = WM_USER + 1
PBM_SETPOS     = WM_USER + 2
PBM_DELTAPOS   = WM_USER + 3
PBM_SETSTEP    = WM_USER + 4
PBM_STEPIT     = WM_USER + 5
PBM_SETRANGE32 = WM_USER + 6
PBM_GETRANGE   = WM_USER + 7
PBM_GETPOS     = WM_USER + 8

; Progress bar styles

PBS_SMOOTH = 1
PBS_VERTICAL = 4


; Hot-key control messages

HKM_SETHOTKEY = WM_USER + 1
HKM_GETHOTKEY = WM_USER + 2
HKM_SETRULES  = WM_USER + 3

; Hot key flags

HOTKEYF_SHIFT   = 1
HOTKEYF_CONTROL = 2
HOTKEYF_ALT     = 4
HOTKEYF_EXT     = 8

; Key combination flags

HKCOMB_NONE = 01h
HKCOMB_S    = 02h
HKCOMB_C    = 04h
HKCOMB_A    = 08h
HKCOMB_SC   = 10h
HKCOMB_SA   = 20h
HKCOMB_CA   = 40h
HKCOMB_SCA  = 80h

; List view styles

LVS_ICON            = 0000h
LVS_REPORT          = 0001h
LVS_SMALLICON       = 0002h
LVS_LIST            = 0003h
LVS_TYPEMASK        = 0003h
LVS_SINGLESEL       = 0004h
LVS_SHOWSELALWAYS   = 0008h
LVS_SORTASCENDING   = 0010h
LVS_SORTDESCENDING  = 0020h
LVS_SHAREIMAGELISTS = 0040h
LVS_NOLABELWRAP     = 0080h
LVS_AUTOARRANGE     = 0100h
LVS_EDITLABELS      = 0200h
LVS_OWNERDATA       = 1000h
LVS_NOSCROLL        = 2000h
LVS_ALIGNTOP        = 0000h
LVS_ALIGNLEFT       = 0800h
LVS_OWNERDRAWFIXED  = 0400h
LVS_NOCOLUMNHEADER  = 4000h
LVS_NOSORTHEADER    = 8000h

; List view extended styles

LVS_EX_GRIDLINES        = 0001h
LVS_EX_SUBITEMIMAGES    = 0002h
LVS_EX_CHECKBOXES       = 0004h
LVS_EX_TRACKSELECT      = 0008h
LVS_EX_HEADERDRAGDROP   = 0010h
LVS_EX_FULLROWSELECT    = 0020h
LVS_EX_ONECLICKACTIVATE = 0040h
LVS_EX_TWOCLICKACTIVATE = 0080h
LVS_EX_FLATSB           = 0100h
LVS_EX_REGIONAL         = 0200h
LVS_EX_INFOTIP          = 0400h
LVS_EX_UNDERLINEHOT     = 0800h
LVS_EX_UNDERLINECOLD    = 1000h
LVS_EX_MULTIWORKAREAS   = 2000h
LVS_EX_LABELTIP         = 4000h
LVS_EX_BORDERSELECT     = 8000h

; List view messages

LVM_GETBKCOLOR               = LVM_FIRST + 0
LVM_SETBKCOLOR               = LVM_FIRST + 1
LVM_GETIMAGELIST             = LVM_FIRST + 2
LVM_SETIMAGELIST             = LVM_FIRST + 3
LVM_GETITEMCOUNT             = LVM_FIRST + 4
LVM_GETITEMA                 = LVM_FIRST + 5
LVM_SETITEMA                 = LVM_FIRST + 6
LVM_INSERTITEMA              = LVM_FIRST + 7
LVM_DELETEITEM               = LVM_FIRST + 8
LVM_DELETEALLITEMS           = LVM_FIRST + 9
LVM_GETCALLBACKMASK          = LVM_FIRST + 10
LVM_SETCALLBACKMASK          = LVM_FIRST + 11
LVM_GETNEXTITEM              = LVM_FIRST + 12
LVM_FINDITEMA                = LVM_FIRST + 13
LVM_GETITEMRECT              = LVM_FIRST + 14
LVM_SETITEMPOSITION          = LVM_FIRST + 15
LVM_GETITEMPOSITION          = LVM_FIRST + 16
LVM_GETSTRINGWIDTHA          = LVM_FIRST + 17
LVM_HITTEST                  = LVM_FIRST + 18
LVM_ENSUREVISIBLE            = LVM_FIRST + 19
LVM_SCROLL                   = LVM_FIRST + 20
LVM_REDRAWITEMS              = LVM_FIRST + 21
LVM_ARRANGE                  = LVM_FIRST + 22
LVM_EDITLABELA               = LVM_FIRST + 23
LVM_GETEDITCONTROL           = LVM_FIRST + 24
LVM_GETCOLUMNA               = LVM_FIRST + 25
LVM_SETCOLUMNA               = LVM_FIRST + 26
LVM_INSERTCOLUMNA            = LVM_FIRST + 27
LVM_DELETECOLUMN             = LVM_FIRST + 28
LVM_GETCOLUMNWIDTH           = LVM_FIRST + 29
LVM_SETCOLUMNWIDTH           = LVM_FIRST + 30
LVM_CREATEDRAGIMAGE          = LVM_FIRST + 33
LVM_GETVIEWRECT              = LVM_FIRST + 34
LVM_GETTEXTCOLOR             = LVM_FIRST + 35
LVM_SETTEXTCOLOR             = LVM_FIRST + 36
LVM_GETTEXTBKCOLOR           = LVM_FIRST + 37
LVM_SETTEXTBKCOLOR           = LVM_FIRST + 38
LVM_GETTOPINDEX              = LVM_FIRST + 39
LVM_GETCOUNTPERPAGE          = LVM_FIRST + 40
LVM_GETORIGIN                = LVM_FIRST + 41
LVM_UPDATE                   = LVM_FIRST + 42
LVM_SETITEMSTATE             = LVM_FIRST + 43
LVM_GETITEMSTATE             = LVM_FIRST + 44
LVM_GETITEMTEXTA             = LVM_FIRST + 45
LVM_SETITEMTEXTA             = LVM_FIRST + 46
LVM_SETITEMCOUNT             = LVM_FIRST + 47
LVM_SORTITEMS                = LVM_FIRST + 48
LVM_SETITEMPOSITION32        = LVM_FIRST + 49
LVM_GETSELECTEDCOUNT         = LVM_FIRST + 50
LVM_GETITEMSPACING           = LVM_FIRST + 51
LVM_GETISEARCHSTRINGA        = LVM_FIRST + 52
LVM_SETICONSPACING           = LVM_FIRST + 53
LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
LVM_GETSUBITEMRECT           = LVM_FIRST + 56
LVM_SUBITEMHITTEST           = LVM_FIRST + 57
LVM_SETCOLUMNORDERARRAY      = LVM_FIRST + 58
LVM_GETCOLUMNORDERARRAY      = LVM_FIRST + 59
LVM_SETHOTITEM               = LVM_FIRST + 60
LVM_GETHOTITEM               = LVM_FIRST + 61
LVM_SETHOTCURSOR             = LVM_FIRST + 62
LVM_GETHOTCURSOR             = LVM_FIRST + 63
LVM_APPROXIMATEVIEWRECT      = LVM_FIRST + 64
LVM_SETWORKAREA              = LVM_FIRST + 65
LVM_GETITEMW                 = LVM_FIRST + 75
LVM_SETITEMW                 = LVM_FIRST + 76
LVM_INSERTITEMW              = LVM_FIRST + 77
LVM_FINDITEMW                = LVM_FIRST + 83
LVM_GETSTRINGWIDTHW          = LVM_FIRST + 87
LVM_GETCOLUMNW               = LVM_FIRST + 95
LVM_SETCOLUMNW               = LVM_FIRST + 96
LVM_INSERTCOLUMNW            = LVM_FIRST + 97
LVM_GETITEMTEXTW             = LVM_FIRST + 115
LVM_SETITEMTEXTW             = LVM_FIRST + 116
LVM_GETISEARCHSTRINGW        = LVM_FIRST + 117
LVM_EDITLABELW               = LVM_FIRST + 118
LVM_GETITEM                  = LVM_GETITEMA
LVM_SETITEM                  = LVM_SETITEMA
LVM_INSERTITEM               = LVM_INSERTITEMA
LVM_FINDITEM                 = LVM_FINDITEMA
LVM_GETSTRINGWIDTH           = LVM_GETSTRINGWIDTHA
LVM_GETCOLUMN                = LVM_GETCOLUMNA
LVM_SETCOLUMN                = LVM_SETCOLUMNA
LVM_INSERTCOLUMN             = LVM_INSERTCOLUMNA
LVM_GETITEMTEXT              = LVM_GETITEMTEXTA
LVM_SETITEMTEXT              = LVM_SETITEMTEXTA
LVM_GETISEARCHSTRING         = LVM_GETISEARCHSTRINGA
LVM_EDITLABEL                = LVM_EDITLABELA

; List view image list types

LVSIL_NORMAL = 0
LVSIL_SMALL  = 1
LVSIL_STATE  = 2

; List view item structure flags

LVIF_TEXT       = 0001h
LVIF_IMAGE      = 0002h
LVIF_PARAM      = 0004h
LVIF_STATE      = 0008h
LVIF_INDENT     = 0010h
LVIF_DI_SETITEM = 1000h

; List view item states

LVIS_FOCUSED        = 00001h
LVIS_SELECTED       = 00002h
LVIS_CUT            = 00004h
LVIS_DROPHILITED    = 00008h
LVIS_OVERLAYMASK    = 00F00h
LVIS_STATEIMAGEMASK = 0F000h

; List view callback item values

LPSTR_TEXTCALLBACK = -1
I_IMAGECALLBACK    = -1
I_CHILDRENCALLBACK = -1

; List view next item relations

LVNI_ALL         = 000h
LVNI_FOCUSED     = 001h
LVNI_SELECTED    = 002h
LVNI_CUT         = 004h
LVNI_DROPHILITED = 008h
LVNI_ABOVE       = 100h
LVNI_BELOW       = 200h
LVNI_TOLEFT      = 400h
LVNI_TORIGHT     = 800h

; List view search types

LVFI_PARAM     = 01h
LVFI_STRING    = 02h
LVFI_PARTIAL   = 08h
LVFI_WRAP      = 20h
LVFI_NEARESTXY = 40h

; List view item rectangle types

LVIR_BOUNDS       = 0
LVIR_ICON         = 1
LVIR_LABEL        = 2
LVIR_SELECTBOUNDS = 3

; List view hit test flags

LVHT_NOWHERE        = 01h
LVHT_ONITEMICON     = 02h
LVHT_ONITEMLABEL    = 04h
LVHT_ONITEMSTATEICON= 08h
LVHT_ONITEM         = LVHT_ONITEMICON or LVHT_ONITEMLABEL or LVHT_ONITEMSTATEICON
LVHT_ABOVE          = 08h
LVHT_BELOW          = 10h
LVHT_TORIGHT        = 20h
LVHT_TOLEFT         = 40h

; List view alignment values

LVA_DEFAULT        = 000h
LVA_ALIGNLEFT      = 001h
LVA_ALIGNTOP       = 002h
LVA_ALIGNRIGHT     = 003h
LVA_ALIGNBOTTOM    = 004h
LVA_SNAPTOGRID     = 005h
LVA_SORTASCENDING  = 100h
LVA_SORTDESCENDING = 200h

; List view column structure flags

LVCF_FMT     = 1
LVCF_WIDTH   = 2
LVCF_TEXT    = 4
LVCF_SUBITEM = 8

; List view column alignment values

LVCFMT_LEFT        = 0
LVCFMT_RIGHT       = 1
LVCFMT_CENTER      = 2
LVCFMT_JUSTIFYMASK = 3

; List view column width values

LVSCW_AUTOSIZE           = -1
LVSCW_AUTOSIZE_USEHEADER = -2

; List view notifications

LVN_ITEMCHANGING    = LVN_FIRST - 0
LVN_ITEMCHANGED     = LVN_FIRST - 1
LVN_INSERTITEM      = LVN_FIRST - 2
LVN_DELETEITEM      = LVN_FIRST - 3
LVN_DELETEALLITEMS  = LVN_FIRST - 4
LVN_BEGINLABELEDITA = LVN_FIRST - 5
LVN_ENDLABELEDITA   = LVN_FIRST - 6
LVN_COLUMNCLICK     = LVN_FIRST - 8
LVN_BEGINDRAG       = LVN_FIRST - 9
LVN_BEGINRDRAG      = LVN_FIRST - 11
LVN_ODCACHEHINT     = LVN_FIRST - 13
LVN_ITEMACTIVATE    = LVN_FIRST - 14
LVN_GETDISPINFOA    = LVN_FIRST - 50
LVN_SETDISPINFOA    = LVN_FIRST - 51
LVN_ODFINDITEMA     = LVN_FIRST - 52
LVN_KEYDOWN         = LVN_FIRST - 55
LVN_BEGINLABELEDITW = LVN_FIRST - 75
LVN_ENDLABELEDITW   = LVN_FIRST - 76
LVN_GETDISPINFOW    = LVN_FIRST - 77
LVN_SETDISPINFOW    = LVN_FIRST - 78
LVN_ODFINDITEMW     = LVN_FIRST - 79
LVN_BEGINLABELEDIT  = LVN_BEGINLABELEDITA
LVN_ENDLABELEDIT    = LVN_ENDLABELEDITA
LVN_GETDISPINFO     = LVN_GETDISPINFOA
LVN_SETDISPINFO     = LVN_SETDISPINFOA
LVN_ODFINDITEM      = LVN_ODFINDITEMA

; Tree view styles

TVS_HASBUTTONS      = 01h
TVS_HASLINES        = 02h
TVS_LINESATROOT     = 04h
TVS_EDITLABELS      = 08h
TVS_DISABLEDRAGDROP = 10h
TVS_SHOWSELALWAYS   = 20h
TVS_RTLREADING      = 40h
TVS_NOTOOLTIPS      = 80h
TVS_CHECKBOXES      = 100h
TVS_TRACKSELECT     = 200h
TVS_SINGLEEXPAND    = 400h
TVS_INFOTIP         = 800h
TVS_FULLROWSELECT   = 1000h
TVS_NOSCROLL        = 2000h
TVS_NONEVENHEIGHT   = 4000h
TVS_NOHSCROLL       = 8000h

; Tree view item structure flags

TVIF_TEXT          = 0001h
TVIF_IMAGE         = 0002h
TVIF_PARAM         = 0004h
TVIF_STATE         = 0008h
TVIF_HANDLE        = 0010h
TVIF_SELECTEDIMAGE = 0020h
TVIF_CHILDREN      = 0040h
TVIF_DI_SETITEM    = 1000h

; Tree view item states

TVIS_FOCUSED        = 00001h
TVIS_SELECTED       = 00002h
TVIS_CUT            = 00004h
TVIS_DROPHILITED    = 00008h
TVIS_BOLD           = 00010h
TVIS_EXPANDED       = 00020h
TVIS_EXPANDEDONCE   = 00040h
TVIS_EXPANDPARTIAL  = 00080h
TVIS_OVERLAYMASK    = 00F00h
TVIS_STATEIMAGEMASK = 0F000h
TVIS_USERMASK       = 0F000h

; Tree view predefined item values

TVI_ROOT  = 0FFFF0000h
TVI_FIRST = 0FFFF0001h
TVI_LAST  = 0FFFF0002h
TVI_SORT  = 0FFFF0003h

; Tree view messages

TVM_INSERTITEMA       = TV_FIRST + 0
TVM_DELETEITEM        = TV_FIRST + 1
TVM_EXPAND            = TV_FIRST + 2
TVM_GETITEMRECT       = TV_FIRST + 4
TVM_GETCOUNT          = TV_FIRST + 5
TVM_GETINDENT         = TV_FIRST + 6
TVM_SETINDENT         = TV_FIRST + 7
TVM_GETIMAGELIST      = TV_FIRST + 8
TVM_SETIMAGELIST      = TV_FIRST + 9
TVM_GETNEXTITEM       = TV_FIRST + 10
TVM_SELECTITEM        = TV_FIRST + 11
TVM_GETITEMA          = TV_FIRST + 12
TVM_SETITEMA          = TV_FIRST + 13
TVM_EDITLABELA        = TV_FIRST + 14
TVM_GETEDITCONTROL    = TV_FIRST + 15
TVM_GETVISIBLECOUNT   = TV_FIRST + 16
TVM_HITTEST           = TV_FIRST + 17
TVM_CREATEDRAGIMAGE   = TV_FIRST + 18
TVM_SORTCHILDREN      = TV_FIRST + 19
TVM_ENSUREVISIBLE     = TV_FIRST + 20
TVM_SORTCHILDRENCB    = TV_FIRST + 21
TVM_ENDEDITLABELNOW   = TV_FIRST + 22
TVM_GETISEARCHSTRINGA = TV_FIRST + 23
TVM_INSERTITEMW       = TV_FIRST + 50
TVM_GETITEMW          = TV_FIRST + 62
TVM_SETITEMW          = TV_FIRST + 63
TVM_GETISEARCHSTRINGW = TV_FIRST + 64
TVM_EDITLABELW        = TV_FIRST + 65
TVM_INSERTITEM        = TVM_INSERTITEMA
TVM_GETITEM           = TVM_GETITEMA
TVM_SETITEM           = TVM_SETITEMA
TVM_GETISEARCHSTRING  = TVM_GETISEARCHSTRINGA
TVM_EDITLABEL         = TVM_EDITLABELA

; Tree view action flags

TVE_COLLAPSE      = 0001h
TVE_EXPAND        = 0002h
TVE_TOGGLE        = 0003h
TVE_EXPANDPARTIAL = 4000h
TVE_COLLAPSERESET = 8000h

; Tree view image list types

TVSIL_NORMAL = 0
TVSIL_STATE  = 2

; Tree view next item types

TVGN_ROOT            = 0
TVGN_NEXT            = 1
TVGN_PREVIOUS        = 2
TVGN_PARENT          = 3
TVGN_CHILD           = 4
TVGN_FIRSTVISIBLE    = 5
TVGN_NEXTVISIBLE     = 6
TVGN_PREVIOUSVISIBLE = 7
TVGN_DROPHILITE      = 8
TVGN_CARET           = 9

; Tree view hit test flags

TVHT_NOWHERE         = 001h
TVHT_ONITEMICON      = 002h
TVHT_ONITEMLABEL     = 004h
TVHT_ONITEMINDENT    = 008h
TVHT_ONITEMBUTTON    = 010h
TVHT_ONITEMRIGHT     = 020h
TVHT_ONITEMSTATEICON = 040h
TVHT_ONITEM          = TVHT_ONITEMICON or TVHT_ONITEMLABEL or TVHT_ONITEMSTATEICON
TVHT_ABOVE           = 100h
TVHT_BELOW           = 200h
TVHT_TORIGHT         = 400h
TVHT_TOLEFT          = 800h

; Tree view notifications

TVN_SELCHANGINGA    = TVN_FIRST - 1
TVN_SELCHANGEDA     = TVN_FIRST - 2
TVN_GETDISPINFOA    = TVN_FIRST - 3
TVN_SETDISPINFOA    = TVN_FIRST - 4
TVN_ITEMEXPANDINGA  = TVN_FIRST - 5
TVN_ITEMEXPANDEDA   = TVN_FIRST - 6
TVN_BEGINDRAGA      = TVN_FIRST - 7
TVN_BEGINRDRAGA     = TVN_FIRST - 8
TVN_DELETEITEMA     = TVN_FIRST - 9
TVN_BEGINLABELEDITA = TVN_FIRST - 10
TVN_ENDLABELEDITA   = TVN_FIRST - 11
TVN_KEYDOWN         = TVN_FIRST - 12
TVN_SELCHANGINGW    = TVN_FIRST - 50
TVN_SELCHANGEDW     = TVN_FIRST - 51
TVN_GETDISPINFOW    = TVN_FIRST - 52
TVN_SETDISPINFOW    = TVN_FIRST - 53
TVN_ITEMEXPANDINGW  = TVN_FIRST - 54
TVN_ITEMEXPANDEDW   = TVN_FIRST - 55
TVN_BEGINDRAGW      = TVN_FIRST - 56
TVN_BEGINRDRAGW     = TVN_FIRST - 57
TVN_DELETEITEMW     = TVN_FIRST - 58
TVN_BEGINLABELEDITW = TVN_FIRST - 59
TVN_ENDLABELEDITW   = TVN_FIRST - 60
TVN_SELCHANGING     = TVN_SELCHANGINGA
TVN_SELCHANGED      = TVN_SELCHANGEDA
TVN_GETDISPINFO     = TVN_GETDISPINFOA
TVN_SETDISPINFO     = TVN_SETDISPINFOA
TVN_ITEMEXPANDING   = TVN_ITEMEXPANDINGA
TVN_ITEMEXPANDED    = TVN_ITEMEXPANDEDA
TVN_BEGINDRAG       = TVN_BEGINDRAGA
TVN_BEGINRDRAG      = TVN_BEGINRDRAGA
TVN_DELETEITEM      = TVN_DELETEITEMA
TVN_BEGINLABELEDIT  = TVN_BEGINLABELEDITA
TVN_ENDLABELEDIT    = TVN_ENDLABELEDITA

; Tree view action flags

TVC_UNKNOWN    = 0
TVC_BYMOUSE    = 1
TVC_BYKEYBOARD = 2

; Tab control styles

TCS_SCROLLOPPOSITE    = 0001h
TCS_BOTTOM            = 0002h
TCS_RIGHT             = 0002h
TCS_FORCEICONLEFT     = 0010h
TCS_FORCELABELLEFT    = 0020h
TCS_HOTTRACK          = 0040h
TCS_VERTICAL          = 0080h
TCS_TABS              = 0000h
TCS_BUTTONS           = 0100h
TCS_SINGLELINE        = 0000h
TCS_MULTILINE         = 0200h
TCS_RIGHTJUSTIFY      = 0000h
TCS_FIXEDWIDTH        = 0400h
TCS_RAGGEDRIGHT       = 0800h
TCS_FOCUSONBUTTONDOWN = 1000h
TCS_OWNERDRAWFIXED    = 2000h
TCS_TOOLTIPS          = 4000h
TCS_FOCUSNEVER        = 8000h

; Tab control messages

TCM_GETIMAGELIST   = TCM_FIRST + 2
TCM_SETIMAGELIST   = TCM_FIRST + 3
TCM_GETITEMCOUNT   = TCM_FIRST + 4
TCM_GETITEMA       = TCM_FIRST + 5
TCM_SETITEMA       = TCM_FIRST + 6
TCM_INSERTITEMA    = TCM_FIRST + 7
TCM_DELETEITEM     = TCM_FIRST + 8
TCM_DELETEALLITEMS = TCM_FIRST + 9
TCM_GETITEMRECT    = TCM_FIRST + 10
TCM_GETCURSEL      = TCM_FIRST + 11
TCM_SETCURSEL      = TCM_FIRST + 12
TCM_HITTEST        = TCM_FIRST + 13
TCM_SETITEMEXTRA   = TCM_FIRST + 14
TCM_ADJUSTRECT     = TCM_FIRST + 40
TCM_SETITEMSIZE    = TCM_FIRST + 41
TCM_REMOVEIMAGE    = TCM_FIRST + 42
TCM_SETPADDING     = TCM_FIRST + 43
TCM_GETROWCOUNT    = TCM_FIRST + 44
TCM_GETTOOLTIPS    = TCM_FIRST + 45
TCM_SETTOOLTIPS    = TCM_FIRST + 46
TCM_GETCURFOCUS    = TCM_FIRST + 47
TCM_SETCURFOCUS    = TCM_FIRST + 48
TCM_GETITEMW       = TCM_FIRST + 60
TCM_SETITEMW       = TCM_FIRST + 61
TCM_INSERTITEMW    = TCM_FIRST + 62
TCM_GETITEM        = TCM_GETITEMA
TCM_SETITEM        = TCM_SETITEMA
TCM_INSERTITEM     = TCM_INSERTITEMA

; Tab control item structure flags

TCIF_TEXT       = 1
TCIF_IMAGE      = 2
TCIF_RTLREADING = 4
TCIF_PARAM      = 8

; Tab control hit test flags

TCHT_NOWHERE     = 1
TCHT_ONITEMICON  = 2
TCHT_ONITEMLABEL = 4
TCHT_ONITEM      = TCHT_ONITEMICON or TCHT_ONITEMLABEL

; Tab control notifications

TCN_KEYDOWN     = TCN_FIRST - 0
TCN_SELCHANGE   = TCN_FIRST - 1
TCN_SELCHANGING = TCN_FIRST - 2

; Animation control styles

ACS_CENTER      = 1
ACS_TRANSPARENT = 2
ACS_AUTOPLAY    = 4
ACS_TIMER       = 8

; Animation control messages

ACM_OPENA = WM_USER + 100
ACM_PLAY  = WM_USER + 101
ACM_STOP  = WM_USER + 102
ACM_OPENW = WM_USER + 103
ACM_OPEN  = ACM_OPENA

; Animation control notifications

ACN_START = 1
ACN_STOP  = 2

; Month calendar styles

MCS_DAYSTATE    = 1
MCS_MULTISELECT = 2
MCS_WEEKNUMBERS = 4
MCS_NOTODAY     = 8

; Month calendar messages

MCM_GETCURSEL         = MCM_FIRST + 1
MCM_SETCURSEL         = MCM_FIRST + 2
MCM_GETMAXSELCOUNT    = MCM_FIRST + 3
MCM_SETMAXSELCOUNT    = MCM_FIRST + 4
MCM_GETSELRANGE       = MCM_FIRST + 5
MCM_SETSELRANGE       = MCM_FIRST + 6
MCM_GETMONTHRANGE     = MCM_FIRST + 7
MCM_SETDAYSTATE       = MCM_FIRST + 8
MCM_GETMINREQRECT     = MCM_FIRST + 9
MCM_SETCOLOR          = MCM_FIRST + 10
MCM_GETCOLOR          = MCM_FIRST + 11
MCM_SETTODAY          = MCM_FIRST + 12
MCM_GETTODAY          = MCM_FIRST + 13
MCM_HITTEST           = MCM_FIRST + 14
MCM_SETFIRSTDAYOFWEEK = MCM_FIRST + 15
MCM_GETFIRSTDAYOFWEEK = MCM_FIRST + 16
MCM_GETRANGE          = MCM_FIRST + 17
MCM_SETRANGE          = MCM_FIRST + 18
MCM_GETMONTHDELTA     = MCM_FIRST + 19
MCM_SETMONTHDELTA     = MCM_FIRST + 20

; Month calendar hit test flags

MCHT_TITLE            = 0010000h
MCHT_CALENDAR         = 0020000h
MCHT_TODAYLINK        = 0030000h
MCHT_NEXT             = 1000000h
MCHT_PREV             = 2000000h
MCHT_NOWHERE          = 0000000h
MCHT_TITLEBK          = MCHT_TITLE
MCHT_TITLEMONTH       = MCHT_TITLE or 1
MCHT_TITLEYEAR        = MCHT_TITLE or 2
MCHT_TITLEBTNNEXT     = MCHT_TITLE or MCHT_NEXT or 3
MCHT_TITLEBTNPREV     = MCHT_TITLE or MCHT_PREV or 3
MCHT_CALENDARBK       = MCHT_CALENDAR
MCHT_CALENDARDATE     = MCHT_CALENDAR or 1
MCHT_CALENDARDATENEXT = MCHT_CALENDARDATE or MCHT_NEXT
MCHT_CALENDARDATEPREV = MCHT_CALENDARDATE or MCHT_PREV
MCHT_CALENDARDAY      = MCHT_CALENDAR or 2
MCHT_CALENDARWEEKNUM  = MCHT_CALENDAR or 3

; Month calendar color codes

MCSC_BACKGROUND   = 0
MCSC_TEXT         = 1
MCSC_TITLEBK      = 2
MCSC_TITLETEXT    = 3
MCSC_MONTHBK      = 4
MCSC_TRAILINGTEXT = 5

; Month calendar notifications

MCN_SELCHANGE   = MCN_FIRST + 1
MCN_GETDAYSTATE = MCN_FIRST + 3
MCN_SELECT      = MCN_FIRST + 4

; Date-time pick control messages

DTM_GETSYSTEMTIME = DTM_FIRST + 1
DTM_SETSYSTEMTIME = DTM_FIRST + 2
DTM_GETRANGE      = DTM_FIRST + 3
DTM_SETRANGE      = DTM_FIRST + 4
DTM_SETFORMATA    = DTM_FIRST + 5
DTM_SETMCCOLOR    = DTM_FIRST + 6
DTM_GETMCCOLOR    = DTM_FIRST + 7
DTM_GETMONTHCAL   = DTM_FIRST + 8
DTM_SETMCFONT     = DTM_FIRST + 9
DTM_GETMCFONT     = DTM_FIRST + 10
DTM_SETFORMATW    = DTM_FIRST + 50
DTM_SETFORMAT     = DTM_SETFORMATA

; Date-time pick control styles

DTS_UPDOWN          = 01h
DTS_SHOWNONE        = 02h
DTS_SHORTDATEFORMAT = 00h
DTS_LONGDATEFORMAT  = 04h
DTS_TIMEFORMAT      = 09h
DTS_APPCANPARSE     = 10h
DTS_RIGHTALIGN      = 20h

; Date-time pick control notifications

DTN_DATETIMECHANGE = DTN_FIRST + 1
DTN_USERSTRINGA    = DTN_FIRST + 2
DTN_WMKEYDOWNA     = DTN_FIRST + 3
DTN_FORMATA        = DTN_FIRST + 4
DTN_FORMATQUERYA   = DTN_FIRST + 5
DTN_DROPDOWN       = DTN_FIRST + 6
DTN_CLOSEUP        = DTN_FIRST + 7
DTN_USERSTRINGW    = DTN_FIRST + 15
DTN_WMKEYDOWNW     = DTN_FIRST + 16
DTN_FORMATW        = DTN_FIRST + 17
DTN_FORMATQUERYW   = DTN_FIRST + 18
DTN_USERSTRING     = DTN_USERSTRINGA
DTN_WMKEYDOWN      = DTN_WMKEYDOWNA
DTN_FORMAT         = DTN_FORMATA
DTN_FORMATQUERY    = DTN_FORMATQUERYA

; ImageList_LoadImage types

IMAGE_BITMAP      = 0
IMAGE_ICON        = 1
IMAGE_CURSOR      = 2
IMAGE_ENHMETAFILE = 3

; ImageList_LoadImage flags

LR_DEFAULTCOLOR     = 0000h
LR_MONOCHROME       = 0001h
LR_COLOR            = 0002h
LR_COPYRETURNORG    = 0004h
LR_COPYDELETEORG    = 0008h
LR_LOADFROMFILE     = 0010h
LR_LOADTRANSPARENT  = 0020h
LR_DEFAULTSIZE      = 0040h
LR_VGACOLOR         = 0080h
LR_LOADMAP3DCOLORS  = 1000h
LR_CREATEDIBSECTION = 2000h
LR_COPYFROMRESOURCE = 4000h
LR_SHARED           = 8000h

; IP control messages

IPM_CLEARADDRESS = WM_USER + 100
IPM_SETADDRESS   = WM_USER + 101
IPM_GETADDRESS   = WM_USER + 102
IPM_SETRANGE     = WM_USER + 103
IPM_SETFOCUS     = WM_USER + 104
IPM_ISBLANK      = WM_USER + 105
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Win32/_COMDLG32.INC.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: COMDLG32.DLL structures and constants
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________



struct OPENFILENAME
  .lStructSize       dd ?
  .hwndOwner         dd ?
  .hInstance         dd ?
  .lpstrFilter       dd ?
  .lpstrCustomFilter dd ?
  .nMaxCustFilter    dd ?
  .nFilterIndex      dd ?
  .lpstrFile         dd ?
  .nMaxFile          dd ?
  .lpstrFileTitle    dd ?
  .nMaxFileTitle     dd ?
  .lpstrInitialDir   dd ?
  .lpstrTitle        dd ?
  .Flags             dd ?
  .nFileOffset       dw ?
  .nFileExtension    dw ?
  .lpstrDefExt       dd ?
  .lCustData         dd ?
  .lpfnHook          dd ?
  .lpTemplateName    dd ?
ends

struct CHOOSECOLOR
  .lStructSize    dd ?
  .hwndOwner      dd ?
  .hInstance      dd ?
  .rgbResult      dd ?
  .lpCustColors   dd ?
  .Flags          dd ?
  .lCustData      dd ?
  .lpfnHook       dd ?
  .lpTemplateName dd ?
ends

struct FINDREPLACE
  .lStructSize      dd ?
  .hwndOwner        dd ?
  .hInstance        dd ?
  .Flags            dd ?
  .lpstrFindWhat    dd ?
  .lpstrReplaceWith dd ?
  .wFindWhatLen     dw ?
  .wReplaceWithLen  dw ?
  .lCustData        dd ?
  .lpfnHook         dd ?
  .lpTemplateName   dd ?
ends

struct CHOOSEFONT
  .lStructSize    dd ?
  .hwndOwner      dd ?
  .hDC            dd ?
  .lpLogFont      dd ?
  .iPointSize     dd ?
  .Flags          dd ?
  .rgbColors      dd ?
  .lCustData      dd ?
  .lpfnHook       dd ?
  .lpTemplateName dd ?
  .hInstance      dd ?
  .lpszStyle      dd ?
  .nFontType      dw ?
  .wReserved      dw ?
  .nSizeMin       dd ?
  .nSizeMax       dd ?
ends

struct PRINTDLG
  .lStructSize         dd ?
  .hwndOwner           dd ?
  .hDevMode            dd ?
  .hDevNames           dd ?
  .hDC                 dd ?
  .Flags               dd ?
  .nFromPage           dw ?
  .nToPage             dw ?
  .nMinPage            dw ?
  .nMaxPage            dw ?
  .nCopies             dw ?
  .hInstance           dd ?
  .lCustData           dd ?
  .lpfnPrintHook       dd ?
  .lpfnSetupHook       dd ?
  .lpPrintTemplateName dd ?
  .lpSetupTemplateName dd ?
  .hPrintTemplate      dd ?
  .hSetupTemplate      dd ?
ends

struct DEVNAMES
  .wDriverOffset dw ?
  .wDeviceOffset dw ?
  .wOutputOffset dw ?
  .wDefault      dw ?
ends

struct PAGESETUPDLG
  .lStructSize             dd ?
  .hwndOwner               dd ?
  .hDevMode                dd ?
  .hDevNames               dd ?
  .Flags                   dd ?
  .ptPaperSize             POINT
  .rtMinMargin             RECT
  .rtMargin                RECT
  .hInstance               dd ?
  .lCustData               dd ?
  .lpfnPageSetupHook       dd ?
  .lpfnPagePaintHook       dd ?
  .lpPageSetupTemplateName dd ?
  .hPageSetupTemplate      dd ?
ends

; OPENFILENAME flags

OFN_READONLY             = 000001h
OFN_OVERWRITEPROMPT      = 000002h
OFN_HIDEREADONLY         = 000004h
OFN_NOCHANGEDIR          = 000008h
OFN_SHOWHELP             = 000010h
OFN_ENABLEHOOK           = 000020h
OFN_ENABLETEMPLATE       = 000040h
OFN_ENABLETEMPLATEHANDLE = 000080h
OFN_NOVALIDATE           = 000100h
OFN_ALLOWMULTISELECT     = 000200h
OFN_EXTENSIONDIFFERENT   = 000400h
OFN_PATHMUSTEXIST        = 000800h
OFN_FILEMUSTEXIST        = 001000h
OFN_CREATEPROMPT         = 002000h
OFN_SHAREAWARE           = 004000h
OFN_NOREADONLYRETURN     = 008000h
OFN_NOTESTFILECREATE     = 010000h
OFN_NONETWORKBUTTON      = 020000h
OFN_NOLONGNAMES          = 040000h
OFN_EXPLORER             = 080000h
OFN_NODEREFERENCELINKS   = 100000h
OFN_LONGNAMES            = 200000h

; Common dialog notifications

CDN_FIRST          = -601
CDN_LAST           = -699
CDN_INITDONE       = CDN_FIRST - 0
CDN_SELCHANGE      = CDN_FIRST - 1
CDN_FOLDERCHANGE   = CDN_FIRST - 2
CDN_SHAREVIOLATION = CDN_FIRST - 3
CDN_HELP           = CDN_FIRST - 4
CDN_FILEOK         = CDN_FIRST - 5
CDN_TYPECHANGE     = CDN_FIRST - 6

; Common dialog messages

CDM_FIRST           = WM_USER + 100
CDM_LAST            = WM_USER + 200
CDM_GETSPEC         = CDM_FIRST + 0
CDM_GETFILEPATH     = CDM_FIRST + 1
CDM_GETFOLDERPATH   = CDM_FIRST + 2
CDM_GETFOLDERIDLIST = CDM_FIRST + 3
CDM_SETCONTROLTEXT  = CDM_FIRST + 4
CDM_HIDECONTROL     = CDM_FIRST + 5
CDM_SETDEFEXT       = CDM_FIRST + 6

; CHOOSECOLOR flags

CC_RGBINIT              = 001h
CC_FULLOPEN             = 002h
CC_PREVENTFULLOPEN      = 004h
CC_SHOWHELP             = 008h
CC_ENABLEHOOK           = 010h
CC_ENABLETEMPLATE       = 020h
CC_ENABLETEMPLATEHANDLE = 040h
CC_SOLIDCOLOR           = 080h
CC_ANYCOLOR             = 100h

; FINDREPLACE flags

FR_DOWN                 = 00001h
FR_WHOLEWORD            = 00002h
FR_MATCHCASE            = 00004h
FR_FINDNEXT             = 00008h
FR_REPLACE              = 00010h
FR_REPLACEALL           = 00020h
FR_DIALOGTERM           = 00040h
FR_SHOWHELP             = 00080h
FR_ENABLEHOOK           = 00100h
FR_ENABLETEMPLATE       = 00200h
FR_NOUPDOWN             = 00400h
FR_NOMATCHCASE          = 00800h
FR_NOWHOLEWORD          = 01000h
FR_ENABLETEMPLATEHANDLE = 02000h
FR_HIDEUPDOWN           = 04000h
FR_HIDEMATCHCASE        = 08000h
FR_HIDEWHOLEWORD        = 10000h

; CHOOSEFONT flags

CF_SCREENFONTS          = 0000001h
CF_PRINTERFONTS         = 0000002h
CF_BOTH                 = CF_SCREENFONTS or CF_PRINTERFONTS
CF_SHOWHELP             = 0000004h
CF_ENABLEHOOK           = 0000008h
CF_ENABLETEMPLATE       = 0000010h
CF_ENABLETEMPLATEHANDLE = 0000020h
CF_INITTOLOGFONTSTRUCT  = 0000040h
CF_USESTYLE             = 0000080h
CF_EFFECTS              = 0000100h
CF_APPLY                = 0000200h
CF_ANSIONLY             = 0000400h
CF_SCRIPTSONLY          = CF_ANSIONLY
CF_NOVECTORFONTS        = 0000800h
CF_NOOEMFONTS           = CF_NOVECTORFONTS
CF_NOSIMULATIONS        = 0001000h
CF_LIMITSIZE            = 0002000h
CF_FIXEDPITCHONLY       = 0004000h
CF_WYSIWYG              = 0008000h
CF_FORCEFONTEXIST       = 0010000h
CF_SCALABLEONLY         = 0020000h
CF_TTONLY               = 0040000h
CF_NOFACESEL            = 0080000h
CF_NOSTYLESEL           = 0100000h
CF_NOSIZESEL            = 0200000h
CF_SELECTSCRIPT         = 0400000h
CF_NOSCRIPTSEL          = 0800000h
CF_NOVERTFONTS          = 1000000h

; ChooseFont messages

WM_CHOOSEFONT_GETLOGFONT = WM_USER + 1
WM_CHOOSEFONT_SETLOGFONT = WM_USER + 101
WM_CHOOSEFONT_SETFLAGS   = WM_USER + 102

; PRINTDLG flags

PD_ALLPAGES                   = 000000h
PD_SELECTION                  = 000001h
PD_PAGENUMS                   = 000002h
PD_NOSELECTION                = 000004h
PD_NOPAGENUMS                 = 000008h
PD_COLLATE                    = 000010h
PD_PRINTTOFILE                = 000020h
PD_PRINTSETUP                 = 000040h
PD_NOWARNING                  = 000080h
PD_RETURNDC                   = 000100h
PD_RETURNIC                   = 000200h
PD_RETURNDEFAULT              = 000400h
PD_SHOWHELP                   = 000800h
PD_ENABLEPRINTHOOK            = 001000h
PD_ENABLESETUPHOOK            = 002000h
PD_ENABLEPRINTTEMPLATE        = 004000h
PD_ENABLESETUPTEMPLATE        = 008000h
PD_ENABLEPRINTTEMPLATEHANDLE  = 010000h
PD_ENABLESETUPTEMPLATEHANDLE  = 020000h
PD_USEDEVMODECOPIES           = 040000h
PD_USEDEVMODECOPIESANDCOLLATE = 040000h
PD_DISABLEPRINTTOFILE         = 080000h
PD_HIDEPRINTTOFILE            = 100000h
PD_NONETWORKBUTTON            = 200000h

; PAGESETUPDLG flags

PSD_DEFAULTMINMARGINS             = 000000h
PSD_INWININIINTLMEASURE           = 000000h
PSD_MINMARGINS                    = 000001h
PSD_MARGINS                       = 000002h
PSD_INTHOUSANDTHSOFINCHES         = 000004h
PSD_INHUNDREDTHSOFMILLIMETERS     = 000008h
PSD_DISABLEMARGINS                = 000010h
PSD_DISABLEPRINTER                = 000020h
PSD_NOWARNING                     = 000080h
PSD_DISABLEORIENTATION            = 000100h
PSD_RETURNDEFAULT                 = 000400h
PSD_DISABLEPAPER                  = 000200h
PSD_SHOWHELP                      = 000800h
PSD_ENABLEPAGESETUPHOOK           = 002000h
PSD_ENABLEPAGESETUPTEMPLATE       = 008000h
PSD_ENABLEPAGESETUPTEMPLATEHANDLE = 020000h
PSD_ENABLEPAGEPAINTHOOK           = 040000h
PSD_DISABLEPAGEPAINTING           = 080000h
PSD_NONETWORKBUTTON               = 200000h

; PageSetupDlg messages

WM_PSD_PAGESETUPDLG   = WM_USER
WM_PSD_FULLPAGERECT   = WM_USER + 1
WM_PSD_MINMARGINRECT  = WM_USER + 2
WM_PSD_MARGINRECT     = WM_USER + 3
WM_PSD_GREEKTEXTRECT  = WM_USER + 4
WM_PSD_ENVSTAMPRECT   = WM_USER + 5
WM_PSD_YAFULLPAGERECT = WM_USER + 6

; Common dialog error codes

CDERR_DIALOGFAILURE    = 0FFFFh
CDERR_GENERALCODES     = 00000h
CDERR_STRUCTSIZE       = 00001h
CDERR_INITIALIZATION   = 00002h
CDERR_NOTEMPLATE       = 00003h
CDERR_NOHINSTANCE      = 00004h
CDERR_LOADSTRFAILURE   = 00005h
CDERR_FINDRESFAILURE   = 00006h
CDERR_LOADRESFAILURE   = 00007h
CDERR_LOCKRESFAILURE   = 00008h
CDERR_MEMALLOCFAILURE  = 00009h
CDERR_MEMLOCKFAILURE   = 0000Ah
CDERR_NOHOOK           = 0000Bh
CDERR_REGISTERMSGFAIL  = 0000Ch
PDERR_PRINTERCODES     = 01000h
PDERR_SETUPFAILURE     = 01001h
PDERR_PARSEFAILURE     = 01002h
PDERR_RETDEFFAILURE    = 01003h
PDERR_LOADDRVFAILURE   = 01004h
PDERR_GETDEVMODEFAIL   = 01005h
PDERR_INITFAILURE      = 01006h
PDERR_NODEVICES        = 01007h
PDERR_NODEFAULTPRN     = 01008h
PDERR_DNDMMISMATCH     = 01009h
PDERR_CREATEICFAILURE  = 0100Ah
PDERR_PRINTERNOTFOUND  = 0100Bh
PDERR_DEFAULTDIFFERENT = 0100Ch
CFERR_CHOOSEFONTCODES  = 02000h
CFERR_NOFONTS          = 02001h
CFERR_MAXLESSTHANMIN   = 02002h
FNERR_FILENAMECODES    = 03000h
FNERR_SUBCLASSFAILURE  = 03001h
FNERR_INVALIDFILENAME  = 03002h
FNERR_BUFFERTOOSMALL   = 03003h
FRERR_FINDREPLACECODES = 04000h
FRERR_BUFFERLENGTHZERO = 04001h
CCERR_CHOOSECOLORCODES = 05000h
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Win32/_GDI32.INC.

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
489
490
491
492
493
494
495
496
497
498
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: GDI32.DLL structures and constants
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

struct SIZE
  .cx dd ?
  .cy dd ?
ends

struct BITMAP
  .bmType       dd ?
  .bmWidth      dd ?
  .bmHeight     dd ?
  .bmWidthBytes dd ?
  .bmPlanes     dw ?
  .bmBitsPixel  dw ?
  .bmBits       dd ?
ends

struct BITMAPCOREHEADER
  .bcSize     dd ?
  .bcWidth    dw ?
  .bcHeight   dw ?
  .bcPlanes   dw ?
  .bcBitCount dw ?
ends

struct BITMAPINFOHEADER
  .biSize          dd ?
  .biWidth         dd ?
  .biHeight        dd ?
  .biPlanes        dw ?
  .biBitCount      dw ?
  .biCompression   dd ?
  .biSizeImage     dd ?
  .biXPelsPerMeter dd ?
  .biYPelsPerMeter dd ?
  .biClrUsed       dd ?
  .biClrImportant  dd ?
ends

struct BITMAPFILEHEADER
  .bfType      dw ?
  .bfSize      dd ?
  .bfReserved1 dw ?
  .bfReserved2 dw ?
  .bfOffBits   dd ?
ends

struct TEXTMETRIC
  .tmHeight           dd ?
  .tmAscent           dd ?
  .tmDescent          dd ?
  .tmInternalLeading  dd ?
  .tmExternalLeading  dd ?
  .tmAveCharWidth     dd ?
  .tmMaxCharWidth     dd ?
  .tmWeight           dd ?
  .tmOverhang         dd ?
  .tmDigitizedAspectX dd ?
  .tmDigitizedAspectY dd ?
  .tmFirstChar        db ?
  .tmLastChar         db ?
  .tmDefaultChar      db ?
  .tmBreakChar        db ?
  .tmItalic           db ?
  .tmUnderlined       db ?
  .tmStruckOut        db ?
  .tmPitchAndFamily   db ?
  .tmCharSet          db ?
  .__align            rb 7
ends

struct LOGBRUSH
  .lbStyle dd ?
  .lbColor dd ?
  .lbHatch dd ?
ends

struct LOGPEN
  .lopnStyle dd ?
  .lopnWidth POINT
  .lopnColor dd ?
ends

struct EXTLOGPEN
  .elpPenStyle   dd ?
  .elpWidth      dd ?
  .elpBrushStyle dd ?
  .elpColor      dd ?
  .elpHatch      dd ?
  .elpNumEntries dd ?
  .elpStyleEntry dd ?
ends

struct LOGFONT
  .lfHeight         dd ?
  .lfWidth          dd ?
  .lfEscapement     dd ?
  .lfOrientation    dd ?
  .lfWeight         dd ?
  .lfItalic         db ?
  .lfUnderline      db ?
  .lfStrikeOut      db ?
  .lfCharSet        db ?
  .lfOutPrecision   db ?
  .lfClipPrecision  db ?
  .lfQuality        db ?
  .lfPitchAndFamily db ?
  .lfFaceName       rb 32
ends

struct ENUMLOGFONT
  .elfLogFont  LOGFONT
  .elfFullName rb 64
  .elfStyle    rb 32
ends

struct ENUMLOGFONTEX
  .elfLogFont  LOGFONT
  .elfFullName rb 64
  .elfStyle    rb 32
  .elfScript   rb 32
ends

struct PIXELFORMATDESCRIPTOR
  .nSize           dw ?
  .nVersion        dw ?
  .dwFlags         dd ?
  .iPixelType      db ?
  .cColorBits      db ?
  .cRedBits        db ?
  .cRedShift       db ?
  .cGreenBits      db ?
  .cGreenShift     db ?
  .cBlueBits       db ?
  .cBlueShift      db ?
  .cAlphaBits      db ?
  .cAlphaShift     db ?
  .cAccumBits      db ?
  .cAccumRedBits   db ?
  .cAccumGreenBits db ?
  .cAccumBlueBits  db ?
  .cAccumAlphaBits db ?
  .cDepthBits      db ?
  .cStencilBits    db ?
  .cAuxBuffers     db ?
  .iLayerType      db ?
  .bReserved       db ?
  .dwLayerMask     dd ?
  .dwVisibleMask   dd ?
  .dwDamageMask    dd ?
ends

; General constants

GDI_ERROR  = 0FFFFFFFFh
HGDI_ERROR = 0FFFFFFFFh

; Binary raster operations

R2_BLACK       = 1
R2_NOTMERGEPEN = 2
R2_MASKNOTPEN  = 3
R2_NOTCOPYPEN  = 4
R2_MASKPENNOT  = 5
R2_NOT         = 6
R2_XORPEN      = 7
R2_NOTMASKPEN  = 8
R2_MASKPEN     = 9
R2_NOTXORPEN   = 10
R2_NOP         = 11
R2_MERGENOTPEN = 12
R2_COPYPEN     = 13
R2_MERGEPENNOT = 14
R2_MERGEPEN    = 15
R2_WHITE       = 16

; Raster operations

SRCCOPY     = 00CC0020h
SRCPAINT    = 00EE0086h
SRCAND      = 008800C6h
SRCINVERT   = 00660046h
SRCERASE    = 00440328h
NOTSRCCOPY  = 00330008h
NOTSRCERASE = 001100A6h
MERGECOPY   = 00C000CAh
MERGEPAINT  = 00BB0226h
PATCOPY     = 00F00021h
PATPAINT    = 00FB0A09h
PATINVERT   = 005A0049h
DSTINVERT   = 00550009h
BLACKNESS   = 00000042h
WHITENESS   = 00FF0062h

; Region flags

ERROR         = 0
NULLREGION    = 1
SIMPLEREGION  = 2
COMPLEXREGION = 3

; CombineRgn styles

RGN_AND  = 1
RGN_OR   = 2
RGN_XOR  = 3
RGN_DIFF = 4
RGN_COPY = 5

; StretchBlt modes

BLACKONWHITE = 1
WHITEONBLACK = 2
COLORONCOLOR = 3
HALFTONE     = 4
STRETCH_ANDSCANS    = BLACKONWHITE
STRETCH_ORSCANS     = WHITEONBLACK
STRETCH_DELETESCANS = COLORONCOLOR
STRETCH_HALFTONE    = HALFTONE

; PolyFill modes

ALTERNATE = 1
WINDING   = 2

; Background modes

TRANSPARENT = 1
OPAQUE      = 2

; Point types

PT_CLOSEFIGURE = 1
PT_LINETO      = 2
PT_BEZIERTO    = 4
PT_MOVETO      = 6

; Mapping modes

MM_TEXT        = 1
MM_LOMETRIC    = 2
MM_HIMETRIC    = 3
MM_LOENGLISH   = 4
MM_HIENGLISH   = 5
MM_TWIPS       = 6
MM_ISOTROPIC   = 7
MM_ANISOTROPIC = 8

; Coordinate modes

ABSOLUTE = 1
RELATIVE = 2

; Stock logical objects

WHITE_BRUSH         = 0
LTGRAY_BRUSH        = 1
GRAY_BRUSH          = 2
DKGRAY_BRUSH        = 3
BLACK_BRUSH         = 4
NULL_BRUSH          = 5
HOLLOW_BRUSH        = NULL_BRUSH
WHITE_PEN           = 6
BLACK_PEN           = 7
NULL_PEN            = 8
OEM_FIXED_FONT      = 10
ANSI_FIXED_FONT     = 11
ANSI_VAR_FONT       = 12
SYSTEM_FONT         = 13
DEVICE_DEFAULT_FONT = 14
DEFAULT_PALETTE     = 15
SYSTEM_FIXED_FONT   = 16
DEFAULT_GUI_FONT    = 17

; Brush styles

BS_SOLID         = 0
BS_NULL          = 1
BS_HOLLOW        = BS_NULL
BS_HATCHED       = 2
BS_PATTERN       = 3
BS_INDEXED       = 4
BS_DIBPATTERN    = 5
BS_DIBPATTERNPT  = 6
BS_PATTERN8X8    = 7
BS_DIBPATTERN8X8 = 8
BS_MONOPATTERN   = 9

; Hatch styles

HS_HORIZONTAL = 0
HS_VERTICAL   = 1
HS_FDIAGONAL  = 2
HS_BDIAGONAL  = 3
HS_CROSS      = 4
HS_DIAGCROSS  = 5

; Pen styles

PS_SOLID         = 0
PS_DASH          = 1
PS_DOT           = 2
PS_DASHDOT       = 3
PS_DASHDOTDOT    = 4
PS_NULL          = 5
PS_INSIDEFRAME   = 6
PS_USERSTYLE     = 7
PS_ALTERNATE     = 8
PS_ENDCAP_ROUND  = 0
PS_ENDCAP_SQUARE = 100h
PS_ENDCAP_FLAT   = 200h
PS_JOIN_ROUND    = 0
PS_JOIN_BEVEL    = 1000h
PS_JOIN_MITER    = 2000h
PS_COSMETIC      = 0
PS_GEOMETRIC     = 010000h

; Arc directions

AD_COUNTERCLOCKWISE = 1
AD_CLOCKWISE        = 2

; Text alignment options

TA_NOUPDATECP = 0
TA_UPDATECP   = 1
TA_LEFT       = 0
TA_RIGHT      = 2
TA_CENTER     = 6
TA_TOP        = 0
TA_BOTTOM     = 8
TA_BASELINE   = 24
TA_RTLREADING = 100h
VTA_BASELINE  = TA_BASELINE
VTA_LEFT      = TA_BOTTOM
VTA_RIGHT     = TA_TOP
VTA_CENTER    = TA_CENTER
VTA_BOTTOM    = TA_RIGHT
VTA_TOP       = TA_LEFT

; ExtTextOut options

ETO_OPAQUE         = 0002h
ETO_CLIPPED        = 0004h
ETO_GLYPH_INDEX    = 0010h
ETO_RTLREADING     = 0080h
ETO_IGNORELANGUAGE = 1000h

; Bitmap compression types

BI_RGB       = 0
BI_RLE8      = 1
BI_RLE4      = 2
BI_BITFIELDS = 3

; tmPitchAndFamily flags

TMPF_FIXED_PITCH = 1
TMPF_VECTOR      = 2
TMPF_TRUETYPE    = 4
TMPF_DEVICE      = 8

; Font output precision values

OUT_DEFAULT_PRECIS        = 0
OUT_STRING_PRECIS         = 1
OUT_CHARACTER_PRECIS      = 2
OUT_STROKE_PRECIS         = 3
OUT_TT_PRECIS             = 4
OUT_DEVICE_PRECIS         = 5
OUT_RASTER_PRECIS         = 6
OUT_TT_ONLY_PRECIS        = 7
OUT_OUTLINE_PRECIS        = 8
OUT_SCREEN_OUTLINE_PRECIS = 9

; Font clipping precision values

CLIP_DEFAULT_PRECIS   = 0
CLIP_CHARACTER_PRECIS = 1
CLIP_STROKE_PRECIS    = 2
CLIP_LH_ANGLES        = 10h
CLIP_TT_ALWAYS        = 20h
CLIP_EMBEDDED         = 80h

; Font output quality values

DEFAULT_QUALITY        = 0
DRAFT_QUALITY          = 1
PROOF_QUALITY          = 2
NONANTIALIASED_QUALITY = 3
ANTIALIASED_QUALITY    = 4

; Font pitch values

DEFAULT_PITCH  = 0
FIXED_PITCH    = 1
VARIABLE_PITCH = 2
MONO_FONT      = 8

; Font families

FF_DONTCARE   = 00h
FF_ROMAN      = 10h
FF_SWISS      = 20h
FF_MODERN     = 30h
FF_SCRIPT     = 40h
FF_DECORATIVE = 50h

; Font weights

FW_DONTCARE   = 0
FW_THIN       = 100
FW_EXTRALIGHT = 200
FW_LIGHT      = 300
FW_NORMAL     = 400
FW_MEDIUM     = 500
FW_SEMIBOLD   = 600
FW_BOLD       = 700
FW_EXTRABOLD  = 800
FW_HEAVY      = 900
FW_ULTRALIGHT = FW_EXTRALIGHT
FW_REGULAR    = FW_NORMAL
FW_DEMIBOLD   = FW_SEMIBOLD
FW_ULTRABOLD  = FW_EXTRABOLD
FW_BLACK      = FW_HEAVY

; Character set values

ANSI_CHARSET        = 0
DEFAULT_CHARSET     = 1
SYMBOL_CHARSET      = 2
SHIFTJIS_CHARSET    = 128
HANGEUL_CHARSET     = 129
GB2312_CHARSET      = 134
CHINESEBIG5_CHARSET = 136
OEM_CHARSET         = 255
JOHAB_CHARSET       = 130
HEBREW_CHARSET      = 177
ARABIC_CHARSET      = 178
GREEK_CHARSET       = 161
TURKISH_CHARSET     = 162
VIETNAMESE_CHARSET  = 163
THAI_CHARSET        = 222
EASTEUROPE_CHARSET  = 238
RUSSIAN_CHARSET     = 204
MAC_CHARSET         = 77
BALTIC_CHARSET      = 186

; Pixel format constants

PFD_TYPE_RGBA             = 0
PFD_TYPE_COLORINDEX       = 1
PFD_MAIN_PLANE            = 0
PFD_OVERLAY_PLANE         = 1
PFD_UNDERLAY_PLANE        = -1
PFD_DOUBLEBUFFER          = 1
PFD_STEREO                = 2
PFD_DRAW_TO_WINDOW        = 4
PFD_DRAW_TO_BITMAP        = 8
PFD_SUPPORT_GDI           = 10h
PFD_SUPPORT_OPENGL        = 20h
PFD_GENERIC_FORMAT        = 40h
PFD_NEED_PALETTE          = 80h
PFD_NEED_SYSTEM_PALETTE   = 100h
PFD_SWAP_EXCHANGE         = 200h
PFD_SWAP_COPY             = 400h
PFD_SWAP_LAYER_BUFFERS    = 800h
PFD_GENERIC_ACCELERATED   = 1000h
PFD_DEPTH_DONTCARE        = 20000000h
PFD_DOUBLEBUFFER_DONTCARE = 40000000h
PFD_STEREO_DONTCARE       = 80000000h

DIB_RGB_COLORS = 0
DIB_PAL_COLORS = 1

; Object types for GetCurrentObject

OBJ_PEN     = 1
OBJ_BRUSH   = 2
OBJ_PAL     = 5
OBJ_FONT    = 6
OBJ_BITMAP  = 7

; Additional constants for GetObjectType
OBJ_DC      = $03
OBJ_MEMDC   = $0a
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Win32/_HTMLHELP.INC.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: HtmlHelp constants and structures.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

; Commands to pass to HtmlHelp()

HH_DISPLAY_TOPIC        = 0x0000
HH_HELP_FINDER          = 0x0000  ; WinHelp equivalent
HH_DISPLAY_TOC          = 0x0001
HH_DISPLAY_INDEX        = 0x0002
HH_DISPLAY_SEARCH       = 0x0003
HH_SET_WIN_TYPE         = 0x0004
HH_GET_WIN_TYPE         = 0x0005
HH_GET_WIN_HANDLE       = 0x0006
HH_ENUM_INFO_TYPE       = 0x0007  ; Get Info type name, call repeatedly to enumerate, -1 at end
HH_SET_INFO_TYPE        = 0x0008  ; Add Info type to filter.
HH_SYNC                 = 0x0009
HH_RESERVED1            = 0x000A
HH_RESERVED2            = 0x000B
HH_RESERVED3            = 0x000C
HH_KEYWORD_LOOKUP       = 0x000D
HH_DISPLAY_TEXT_POPUP   = 0x000E  ; display string resource id or text in a popup window
HH_HELP_CONTEXT         = 0x000F  ; display mapped numeric value in dwData
HH_TP_HELP_CONTEXTMENU  = 0x0010  ; text popup help, same as WinHelp HELP_CONTEXTMENU
HH_TP_HELP_WM_HELP      = 0x0011  ; text popup help, same as WinHelp HELP_WM_HELP
HH_CLOSE_ALL            = 0x0012  ; close all windows opened directly or indirectly by the caller
HH_ALINK_LOOKUP         = 0x0013  ; ALink version of HH_KEYWORD_LOOKUP
HH_GET_LAST_ERROR       = 0x0014  ; not currently implemented // See HHERROR.h
HH_ENUM_CATEGORY        = 0x0015  ; Get category name, call repeatedly to enumerate, -1 at end
HH_ENUM_CATEGORY_IT     = 0x0016  ; Get category info type members, call repeatedly to enumerate, -1 at end
HH_RESET_IT_FILTER      = 0x0017  ; Clear the info type filter of all info types.
HH_SET_INCLUSIVE_FILTER = 0x0018  ; set inclusive filtering method for untyped topics to be included in display
HH_SET_EXCLUSIVE_FILTER = 0x0019  ; set exclusive filtering method for untyped topics to be excluded from display
HH_INITIALIZE           = 0x001C  ; Initializes the help system.
HH_UNINITIALIZE         = 0x001D  ; Uninitializes the help system.
HH_PRETRANSLATEMESSAGE  = 0x00fd  ; Pumps messages. (NULL, NULL, MSG*).
HH_SET_GLOBAL_PROPERTY  = 0x00fc  ; Set a global property. (NULL, NULL, HH_GPROP)

HHWIN_PROP_TAB_AUTOHIDESHOW = 1 shl 0    ; Automatically hide/show tri-pane window
HHWIN_PROP_ONTOP            = 1 shl 1    ; Top-most window
HHWIN_PROP_NOTITLEBAR       = 1 shl 2    ; no title bar
HHWIN_PROP_NODEF_STYLES     = 1 shl 3    ; no default window styles (only HH_WINTYPE.dwStyles)
HHWIN_PROP_NODEF_EXSTYLES   = 1 shl 4    ; no default extended window styles (only HH_WINTYPE.dwExStyles)
HHWIN_PROP_TRI_PANE         = 1 shl 5    ; use a tri-pane window
HHWIN_PROP_NOTB_TEXT        = 1 shl 6    ; no text on toolbar buttons
HHWIN_PROP_POST_QUIT        = 1 shl 7    ; post WM_QUIT message when window closes
HHWIN_PROP_AUTO_SYNC        = 1 shl 8    ; automatically ssync contents and index
HHWIN_PROP_TRACKING         = 1 shl 9    ; send tracking notification messages
HHWIN_PROP_TAB_SEARCH       = 1 shl 10   ; include search tab in navigation pane
HHWIN_PROP_TAB_HISTORY      = 1 shl 11   ; include history tab in navigation pane
HHWIN_PROP_TAB_FAVORITES    = 1 shl 12   ; include favorites tab in navigation pane
HHWIN_PROP_CHANGE_TITLE     = 1 shl 13   ; Put current HTML title in title bar
HHWIN_PROP_NAV_ONLY_WIN     = 1 shl 14   ; Only display the navigation window
HHWIN_PROP_NO_TOOLBAR       = 1 shl 15   ; Don't display a toolbar
HHWIN_PROP_MENU             = 1 shl 16   ; Menu
HHWIN_PROP_TAB_ADVSEARCH    = 1 shl 17   ; Advanced FTS UI.
HHWIN_PROP_USER_POS         = 1 shl 18   ; After initial creation, user controls window size/position
HHWIN_PROP_TAB_CUSTOM1      = 1 shl 19   ; Use custom tab #1
HHWIN_PROP_TAB_CUSTOM2      = 1 shl 20   ; Use custom tab #2
HHWIN_PROP_TAB_CUSTOM3      = 1 shl 21   ; Use custom tab #3
HHWIN_PROP_TAB_CUSTOM4      = 1 shl 22   ; Use custom tab #4
HHWIN_PROP_TAB_CUSTOM5      = 1 shl 23   ; Use custom tab #5
HHWIN_PROP_TAB_CUSTOM6      = 1 shl 24   ; Use custom tab #6
HHWIN_PROP_TAB_CUSTOM7      = 1 shl 25   ; Use custom tab #7
HHWIN_PROP_TAB_CUSTOM8      = 1 shl 26   ; Use custom tab #8
HHWIN_PROP_TAB_CUSTOM9      = 1 shl 27   ; Use custom tab #9
HHWIN_TB_MARGIN             = 1 shl 28   ; the window type has a margin

HHWIN_PARAM_PROPERTIES      = 1 shl 1    ; valid fsWinProperties
HHWIN_PARAM_STYLES          = 1 shl 2    ; valid dwStyles
HHWIN_PARAM_EXSTYLES        = 1 shl 3    ; valid dwExStyles
HHWIN_PARAM_RECT            = 1 shl 4    ; valid rcWindowPos
HHWIN_PARAM_NAV_WIDTH       = 1 shl 5    ; valid iNavWidth
HHWIN_PARAM_SHOWSTATE       = 1 shl 6    ; valid nShowState
HHWIN_PARAM_INFOTYPES       = 1 shl 7    ; valid apInfoTypes
HHWIN_PARAM_TB_FLAGS        = 1 shl 8    ; valid fsToolBarFlags
HHWIN_PARAM_EXPANSION       = 1 shl 9    ; valid fNotExpanded
HHWIN_PARAM_TABPOS          = 1 shl 10   ; valid tabpos
HHWIN_PARAM_TABORDER        = 1 shl 11   ; valid taborder
HHWIN_PARAM_HISTORY_COUNT   = 1 shl 12   ; valid cHistory
HHWIN_PARAM_CUR_TAB         = 1 shl 13   ; valid curNavType

HHWIN_BUTTON_EXPAND         = 1 shl 1    ; Expand/contract button
HHWIN_BUTTON_BACK           = 1 shl 2    ; Back button
HHWIN_BUTTON_FORWARD        = 1 shl 3    ; Forward button
HHWIN_BUTTON_STOP           = 1 shl 4    ; Stop button
HHWIN_BUTTON_REFRESH        = 1 shl 5    ; Refresh button
HHWIN_BUTTON_HOME           = 1 shl 6    ; Home button
HHWIN_BUTTON_BROWSE_FWD     = 1 shl 7    ; not implemented
HHWIN_BUTTON_BROWSE_BCK     = 1 shl 8    ; not implemented
HHWIN_BUTTON_NOTES          = 1 shl 9    ; not implemented
HHWIN_BUTTON_CONTENTS       = 1 shl 10   ; not implemented
HHWIN_BUTTON_SYNC           = 1 shl 11   ; Sync button
HHWIN_BUTTON_OPTIONS        = 1 shl 12   ; Options button
HHWIN_BUTTON_PRINT          = 1 shl 13   ; Print button
HHWIN_BUTTON_INDEX          = 1 shl 14   ; not implemented
HHWIN_BUTTON_SEARCH         = 1 shl 15   ; not implemented
HHWIN_BUTTON_HISTORY        = 1 shl 16   ; not implemented
HHWIN_BUTTON_FAVORITES      = 1 shl 17   ; not implemented
HHWIN_BUTTON_JUMP1          = 1 shl 18
HHWIN_BUTTON_JUMP2          = 1 shl 19
HHWIN_BUTTON_ZOOM           = 1 shl 20
HHWIN_BUTTON_TOC_NEXT       = 1 shl 21
HHWIN_BUTTON_TOC_PREV       = 1 shl 22

HHWIN_DEF_BUTTONS =HHWIN_BUTTON_EXPAND or HHWIN_BUTTON_BACK or HHWIN_BUTTON_OPTIONS or HHWIN_BUTTON_PRINT

; Button IDs
IDTB_EXPAND             = 200
IDTB_CONTRACT           = 201
IDTB_STOP               = 202
IDTB_REFRESH            = 203
IDTB_BACK               = 204
IDTB_HOME               = 205
IDTB_SYNC               = 206
IDTB_PRINT              = 207
IDTB_OPTIONS            = 208
IDTB_FORWARD            = 209
IDTB_NOTES              = 210 ; not implemented
IDTB_BROWSE_FWD         = 211
IDTB_BROWSE_BACK        = 212
IDTB_CONTENTS           = 213 ; not implemented
IDTB_INDEX              = 214 ; not implemented
IDTB_SEARCH             = 215 ; not implemented
IDTB_HISTORY            = 216 ; not implemented
IDTB_FAVORITES          = 217 ; not implemented
IDTB_JUMP1              = 218
IDTB_JUMP2              = 219
IDTB_CUSTOMIZE          = 221
IDTB_ZOOM               = 222
IDTB_TOC_NEXT           = 223
IDTB_TOC_PREV           = 224

; Notification codes

HHN_FIRST = 0-860
HHN_LAST  = 0-879

HHN_NAVCOMPLETE   = HHN_FIRST-0
HHN_TRACK         = HHN_FIRST-1
HHN_WINDOW_CREATE = HHN_FIRST-2

struct HHN_NOTIFY
    .hdr    dd ?
    .pszUrl dd ? ; Multi-byte, null-terminated string
ends

struct HH_POPUP
    .cbStruct      dd ?     ; sizeof this structure
    .hinst         dd ?     ; instance handle for string resource
    .idString      dd ?     ; string resource id, or text id if pszFile is specified in HtmlHelp call
    .pszText       dd ?     ; used if idString is zero
    .pt            POINT    ; top center of popup window
    .clrForeground dd ?     ; use -1 for default
    .clrBackground dd ?     ; use -1 for default
    .rcMargins     RECT     ; amount of space between edges of window and text, -1 for each member to ignore
    .pszFont       dd ?     ; facename, point size, char set, BOLD ITALIC UNDERLINE
ends

struct HH_AKLINK
    .cbStruct     dd ?     ; sizeof this structure
    .fReserved    dd ?     ; must be FALSE (really!)
    .pszKeywords  dd ?     ; semi-colon separated keywords
    .pszUrl       dd ?     ; URL to jump to if no keywords found (may be NULL)
    .pszMsgText   dd ?     ; Message text to display in MessageBox if pszUrl is NULL and no keyword match
    .pszMsgTitle  dd ?     ; Message text to display in MessageBox if pszUrl is NULL and no keyword match
    .pszWindow    dd ?     ; Window to display URL in
    .fIndexOnFail dd ?     ; Displays index if keyword lookup fails.
ends


HHWIN_NAVTYPE_TOC          = 0
HHWIN_NAVTYPE_INDEX        = 1
HHWIN_NAVTYPE_SEARCH       = 2
HHWIN_NAVTYPE_FAVORITES    = 3
HHWIN_NAVTYPE_HISTORY      = 4  ; not implemented
HHWIN_NAVTYPE_AUTHOR       = 5
HHWIN_NAVTYPE_CUSTOM_FIRST = 11


IT_INCLUSIVE = 0
IT_EXCLUSIVE = 1
IT_HIDDEN    = 2


struct HH_ENUM_IT
    .cbStruct         dd ?       ; size of this structure
    .iType            dd ?       ; the type of the information type ie. Inclusive, Exclusive, or Hidden
    .pszCatName       dd ?       ; Set to the name of the Category to enumerate the info types in a category; else NULL
    .pszITName        dd ?       ; volitile pointer to the name of the infotype. Allocated by call. Caller responsible for freeing
    .pszITDescription dd ?       ; volitile pointer to the description of the infotype.
ends

struct HH_ENUM_CAT
    .cbStruct          dd ?     ; size of this structure
    .pszCatName        dd ?     ; volitile pointer to the category name
    .pszCatDescription dd ?     ; volitile pointer to the category description
ends

struct HH_SET_INFOTYPE
    .cbStruct        dd ?        ; the size of this structure
    .pszCatName      dd ?        ; the name of the category, if any, the InfoType is a member of.
    .pszInfoTypeName dd ?        ; the name of the info type to add to the filter
ends


HHWIN_NAVTAB_TOP    = 0
HHWIN_NAVTAB_LEFT   = 1
HHWIN_NAVTAB_BOTTOM = 2


HH_MAX_TABS = 19  ; maximum number of tabs


HH_TAB_CONTENTS     = 0
HH_TAB_INDEX        = 1
HH_TAB_SEARCH       = 2
HH_TAB_FAVORITES    = 3
HH_TAB_HISTORY      = 4
HH_TAB_AUTHOR       = 5
HH_TAB_CUSTOM_FIRST = 11
HH_TAB_CUSTOM_LAST  = HH_MAX_TABS


HH_MAX_TABS_CUSTOM  = HH_TAB_CUSTOM_LAST - HH_TAB_CUSTOM_FIRST + 1

; HH_DISPLAY_SEARCH Command Related Structures and Constants

HH_FTS_DEFAULT_PROXIMITY = -1

struct HH_FTS_QUERY
   .cbStruct        dd ?   ; Sizeof structure in bytes.
   .fUniCodeStrings dd ?   ; TRUE if all strings are unicode.
   .pszSearchQuery  dd ?   ; String containing the search query.
   .iProximity      dd ?   ; Word proximity.
   .fStemmedSearch  dd ?   ; TRUE for StemmedSearch only.
   .fTitleOnly      dd ?   ; TRUE for Title search only.
   .fExecute        dd ?   ; TRUE to initiate the search.
   .pszWindow       dd ?   ; Window to display in
ends

; HH_WINTYPE Structure

struct HH_WINTYPE
    .cbStruct        dd ? ; IN: size of this structure including all Information Types
    .fUniCodeStrings dd ? ; IN/OUT: TRUE if all strings are in UNICODE
    .pszType         dd ? ; IN/OUT: Name of a type of window
    .fsValidMembers  dd ? ; IN: Bit flag of valid members (HHWIN_PARAM_)
    .fsWinProperties dd ? ; IN/OUT: Properties/attributes of the window (HHWIN_)
    .pszCaption      dd ?  ; IN/OUT: Window title
    .dwStyles        dd ?  ; IN/OUT: Window styles
    .dwExStyles      dd ?  ; IN/OUT: Extended Window styles
    .rcWindowPos     RECT  ; IN: Starting position, OUT: current position
    .nShowState      dd ?  ; IN: show state (e.g., SW_SHOW)
    .hwndHelp        dd ?    ; OUT: window handle
    .hwndCaller      dd ?    ; OUT: who called this window
    .paInfoTypes     dd ?    ; IN: Pointer to an array of Information Types
    ; The following members are only valid if HHWIN_PROP_TRI_PANE is set
    .hwndToolBar     dd ?  ; OUT: toolbar window in tri-pane window
    .hwndNavigation  dd ?  ; OUT: navigation window in tri-pane window
    .hwndHTML        dd ?  ; OUT: window displaying HTML in tri-pane window
    .iNavWidth       dd ?  ; IN/OUT: width of navigation window
    .rcHTML          RECT  ; OUT: HTML window coordinates
    .pszToc          dd ?  ; IN: Location of the table of contents file
    .pszIndex        dd ? ; IN: Location of the index file
    .pszFile         dd ? ; IN: Default location of the html file
    .pszHome         dd ? ; IN/OUT: html file to display when Home button is clicked
    .fsToolBarFlags  dd ? ; IN: flags controling the appearance of the toolbar
    .fNotExpanded    dd ? ; IN: TRUE/FALSE to contract or expand, OUT: current state
    .curNavType      dd ? ; IN/OUT: UI to display in the navigational pane
    .tabpos          dd ? ; IN/OUT: HHWIN_NAVTAB_TOP, HHWIN_NAVTAB_LEFT, or HHWIN_NAVTAB_BOTTOM
    .idNotify        dd ? ; IN: ID to use for WM_NOTIFY messages
    .tabOrder        rb HH_MAX_TABS + 1    ; IN/OUT: tab order: Contents, Index, Search, History, Favorites, Reserved 1-5, Custom tabs
    .cHistory        dd ? ; IN/OUT: number of history items to keep (default is 30)
    .pszJump1        dd ? ; Text for HHWIN_BUTTON_JUMP1
    .pszJump2        dd ? ; Text for HHWIN_BUTTON_JUMP2
    .pszUrlJump1     dd ? ; URL for HHWIN_BUTTON_JUMP1
    .pszUrlJump2     dd ? ; URL for HHWIN_BUTTON_JUMP2
    .rcMinSize       RECT ; Minimum size for window (ignored in version 1)
    .cbInfoTypes     dd ? ; size of paInfoTypes;
    .pszCustomTabs   dd ? ; multiple zero-terminated strings
ends

HHACT_TAB_CONTENTS  = 0
HHACT_TAB_INDEX     = 1
HHACT_TAB_SEARCH    = 2
HHACT_TAB_HISTORY   = 3
HHACT_TAB_FAVORITES = 4

HHACT_EXPAND    = 0
HHACT_CONTRACT  = 1
HHACT_BACK      = 2
HHACT_FORWARD   = 3
HHACT_STOP      = 4
HHACT_REFRESH   = 5
HHACT_HOME      = 6
HHACT_SYNC      = 7
HHACT_OPTIONS   = 8
HHACT_PRINT     = 9
HHACT_HIGHLIGHT = 10
HHACT_CUSTOMIZE = 11
HHACT_JUMP1     = 12
HHACT_JUMP2     = 13
HHACT_ZOOM      = 14
HHACT_TOC_NEXT  = 15
HHACT_TOC_PREV  = 16
HHACT_NOTES     = 17
HHACT_LAST_ENUM = 18


struct HHNTRACK
    .hdr        dd ?
    .pszCurUrl  dd ?  ; Multi-byte, null-terminated string
    .idAction   dd ?  ; HHACT_ value
    .phhWinType dd ?  ; Current window type structure
ends


HH_GPROPID_SINGLETHREAD=1      ; VARIANT_BOOL: True for single thread
HH_GPROPID_TOOLBAR_MARGIN=2    ; long: Provides a left/right margin around the toolbar.
HH_GPROPID_UI_LANGUAGE=3       ; long: LangId of the UI.
HH_GPROPID_CURRENT_SUBSET=4    ; BSTR: Current subset.
HH_GPROPID_CONTENT_LANGUAGE=5  ; long: LandId for desired content.


struct HH_GLOBAL_PROPERTY
    .id  dd ?
    .var dd ?
ends
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Win32/_KERNEL32.INC.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: KERNEL32.DLL structures and constants
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


struct SYSTEM_INFO
  .wProcessorArchitecture      dw ?
  .wReserved                   dw ?
  .dwPageSize                  dd ?
  .lpMinimumApplicationAddress dd ?
  .lpMaximumApplicationAddress dd ?
  .dwActiveProcessorMask       dd ?
  .dwNumberOfProcessors        dd ?
  .dwProcessorType             dd ?
  .dwAllocationGranularity     dd ?
  .wProcessorLevel             dw ?
  .wProcessorRevision          dw ?
ends

struct OSVERSIONINFO
  .dwOSVersionInfoSize dd ?
  .dwMajorVersion      dd ?
  .dwMinorVersion      dd ?
  .dwBuildNumber       dd ?
  .dwPlatformId        dd ?
  .szCSDVersion        rb 128
ends

struct MEMORYSTATUS
  .dwiLength       dd ?
  .dwMemoryLoad    dd ?
  .dwTotalPhys     dd ?
  .dwAvailPhys     dd ?
  .dwTotalPageFile dd ?
  .dwAvailPageFile dd ?
  .dwTotalVirtual  dd ?
  .dwAvailVirtual  dd ?
ends

struct STARTUPINFO
  .cb              dd ?
  .lpReserved      dd ?
  .lpDesktop       dd ?
  .lpTitle         dd ?
  .dwX             dd ?
  .dwY             dd ?
  .dwXSize         dd ?
  .dwYSize         dd ?
  .dwXCountChars   dd ?
  .dwYCountChars   dd ?
  .dwFillAttribute dd ?
  .dwFlags         dd ?
  .wShowWindow     dw ?
  .cbReserved2     dw ?
  .lpReserved2     dd ?
  .hStdInput       dd ?
  .hStdOutput      dd ?
  .hStdError       dd ?
ends

struct PROCESS_INFORMATION
  .hProcess    dd ?
  .hThread     dd ?
  .dwProcessId dd ?
  .dwThreadId  dd ?
ends

struct FILETIME
  .dwLowDateTime  dd ?
  .dwHighDateTime dd ?
ends

struct SYSTEMTIME
  .wYear         dw ?
  .wMonth        dw ?
  .wDayOfWeek    dw ?
  .wDay          dw ?
  .wHour         dw ?
  .wMinute       dw ?
  .wSecond       dw ?
  .wMilliseconds dw ?
ends

struct BY_HANDLE_FILE_INFORMATION
  .dwFileAttributes     dd ?
  .ftCreationTime       FILETIME
  .ftLastAccessTime     FILETIME
  .ftLastWriteTime      FILETIME
  .dwVolumeSerialNumber dd ?
  .nFileSizeHigh        dd ?
  .nFileSizeLow         dd ?
  .nNumberOfLinks       dd ?
  .nFileIndexHigh       dd ?
  .nFileIndexLow        dd ?
ends

struct FINDDATA
  .dwFileAttributes   dd ?
  .ftCreationTime     FILETIME
  .ftLastAccessTime   FILETIME
  .ftLastWriteTime    FILETIME
  .nFileSizeHigh      dd ?
  .nFileSizeLow       dd ?
  .dwReserved0        dd ?
  .dwReserved1        dd ?
  .cFileName          rb 260
  .cAlternateFileName rb 14
ends

struct FINDDATAW
  .dwFileAttributes   dd ?
  .ftCreationTime     FILETIME
  .ftLastAccessTime   FILETIME
  .ftLastWriteTime    FILETIME
  .nFileSizeHigh      dd ?
  .nFileSizeLow       dd ?
  .dwReserved0        dd ?
  .dwReserved1        dd ?
  .cFileName          rw 260
  .cAlternateFileName rw 14
ends

; findnext error

ERROR_NO_MORE_FILES = 18


struct PROCESSINFO
   .hProcess    dd ?
   .hThread     dd ?
   .dwProcessId dd ?
   .dwThreadId  dd ?
ends



struct TIME_ZONE_INFORMATION
  .bias         dd ?
  .StandardName rw 32
  .StandardDate SYSTEMTIME
  .StandardBias dd ?
  .DaylightName rw 32
  .DaylightDate SYSTEMTIME
  .DaylightBias dd ?
ends

TIME_ZODE_ID_UNKNOWN  = 0
TIME_ZONE_ID_STANDARD = 1
TIME_ZONE_ID_DAYLIGHT = 2


; General constants

NULL  = 0
TRUE  = 1
FALSE = 0

MAX_PATH = 260


; Access rights

DELETE_RIGHT              = 00010000h
READ_CONTROL              = 00020000h
WRITE_DAC                 = 00040000h
WRITE_OWNER               = 00080000h
SYNCHRONIZE               = 00100000h
STANDARD_RIGHTS_READ      = READ_CONTROL
STANDARD_RIGHTS_WRITE     = READ_CONTROL
STANDARD_RIGHTS_EXECUTE   = READ_CONTROL
STANDARD_RIGHTS_REQUIRED  = 000F0000h
STANDARD_RIGHTS_ALL       = 001F0000h
SPECIFIC_RIGHTS_ALL       = 0000FFFFh
ACCESS_SYSTEM_SECURITY    = 01000000h
MAXIMUM_ALLOWED           = 02000000h
GENERIC_READ              = 80000000h
GENERIC_WRITE             = 40000000h
GENERIC_EXECUTE           = 20000000h
GENERIC_ALL               = 10000000h
PROCESS_TERMINATE         = 00000001h
PROCESS_CREATE_THREAD     = 00000002h
PROCESS_VM_OPERATION      = 00000008h
PROCESS_VM_READ           = 00000010h
PROCESS_VM_WRITE          = 00000020h
PROCESS_DUP_HANDLE        = 00000040h
PROCESS_CREATE_PROCESS    = 00000080h
PROCESS_SET_QUOTA         = 00000100h
PROCESS_SET_INFORMATION   = 00000200h
PROCESS_QUERY_INFORMATION = 00000400h
PROCESS_ALL_ACCESS        = STANDARD_RIGHTS_REQUIRED or SYNCHRONIZE or 0FFFh
FILE_SHARE_READ           = 00000001h
FILE_SHARE_WRITE          = 00000002h
FILE_SHARE_DELETE         = 00000004h

; CreateFile actions

CREATE_NEW        = 1
CREATE_ALWAYS     = 2
OPEN_EXISTING     = 3
OPEN_ALWAYS       = 4
TRUNCATE_EXISTING = 5

; OpenFile modes

OF_READ             = 0000h
OF_WRITE            = 0001h
OF_READWRITE        = 0002h
OF_SHARE_COMPAT     = 0000h
OF_SHARE_EXCLUSIVE  = 0010h
OF_SHARE_DENY_WRITE = 0020h
OF_SHARE_DENY_READ  = 0030h
OF_SHARE_DENY_NONE  = 0040h
OF_PARSE            = 0100h
OF_DELETE           = 0200h
OF_VERIFY           = 0400h
OF_CANCEL           = 0800h
OF_CREATE           = 1000h
OF_PROMPT           = 2000h
OF_EXIST            = 4000h
OF_REOPEN           = 8000h

; SetFilePointer methods

FILE_BEGIN   = 0
FILE_CURRENT = 1
FILE_END     = 2

; File attributes

FILE_ATTRIBUTE_READONLY   = 001h
FILE_ATTRIBUTE_HIDDEN     = 002h
FILE_ATTRIBUTE_SYSTEM     = 004h
FILE_ATTRIBUTE_DIRECTORY  = 010h
FILE_ATTRIBUTE_ARCHIVE    = 020h
FILE_ATTRIBUTE_NORMAL     = 080h
FILE_ATTRIBUTE_TEMPORARY  = 100h
FILE_ATTRIBUTE_COMPRESSED = 800h

; File flags

FILE_FLAG_WRITE_THROUGH    = 80000000h
FILE_FLAG_OVERLAPPED       = 40000000h
FILE_FLAG_NO_BUFFERING     = 20000000h
FILE_FLAG_RANDOM_ACCESS    = 10000000h
FILE_FLAG_SEQUENTIAL_SCAN  = 08000000h
FILE_FLAG_DELETE_ON_CLOSE  = 04000000h
FILE_FLAG_BACKUP_SEMANTICS = 02000000h
FILE_FLAG_POSIX_SEMANTICS  = 01000000h

; Notify filters

FILE_NOTIFY_CHANGE_FILE_NAME  = 001h
FILE_NOTIFY_CHANGE_DIR_NAME   = 002h
FILE_NOTIFY_CHANGE_ATTRIBUTES = 004h
FILE_NOTIFY_CHANGE_SIZE       = 008h
FILE_NOTIFY_CHANGE_LAST_WRITE = 010h
FILE_NOTIFY_CHANGE_SECURITY   = 100h

; File types

FILE_TYPE_UNKNOWN = 0
FILE_TYPE_DISK    = 1
FILE_TYPE_CHAR    = 2
FILE_TYPE_PIPE    = 3
FILE_TYPE_REMOTE  = 8000h

; LockFileEx flags

LOCKFILE_FAIL_IMMEDIATELY = 1
LOCKFILE_EXCLUSIVE_LOCK   = 2

; MoveFileEx flags

MOVEFILE_REPLACE_EXISTING   = 1
MOVEFILE_COPY_ALLOWED       = 2
MOVEFILE_DELAY_UNTIL_REBOOT = 4
MOVEFILE_WRITE_THROUGH      = 8

; FindFirstFileEx flags

FIND_FIRST_EX_CASE_SENSITIVE = 1

; Device handles

INVALID_HANDLE_VALUE = -1
STD_INPUT_HANDLE     = -10
STD_OUTPUT_HANDLE    = -11
STD_ERROR_HANDLE     = -12

; DuplicateHandle options

DUPLICATE_CLOSE_SOURCE = 1
DUPLICATE_SAME_ACCESS  = 2

; File mapping acccess rights

SECTION_QUERY       = 01h
SECTION_MAP_WRITE   = 02h
SECTION_MAP_READ    = 04h
SECTION_MAP_EXECUTE = 08h
SECTION_EXTEND_SIZE = 10h
SECTION_ALL_ACCESS  = STANDARD_RIGHTS_REQUIRED or SECTION_QUERY or SECTION_MAP_WRITE or SECTION_MAP_READ or SECTION_MAP_EXECUTE or SECTION_EXTEND_SIZE
FILE_MAP_COPY       = SECTION_QUERY
FILE_MAP_WRITE      = SECTION_MAP_WRITE
FILE_MAP_READ       = SECTION_MAP_READ
FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS

; File system flags

FILE_CASE_SENSITIVE_SEARCH = 0001h
FILE_CASE_PRESERVED_NAMES  = 0002h
FILE_UNICODE_ON_DISK       = 0004h
FILE_PERSISTENT_ACLS       = 0008h
FILE_FILE_COMPRESSION      = 0010h
FILE_VOLUME_IS_COMPRESSED  = 8000h
FS_CASE_IS_PRESERVED       = FILE_CASE_PRESERVED_NAMES
FS_CASE_SENSITIVE          = FILE_CASE_SENSITIVE_SEARCH
FS_UNICODE_STORED_ON_DISK  = FILE_UNICODE_ON_DISK
FS_PERSISTENT_ACLS         = FILE_PERSISTENT_ACLS

; Drive types

DRIVE_UNKNOWN     = 0
DRIVE_NO_ROOT_DIR = 1
DRIVE_REMOVABLE   = 2
DRIVE_FIXED       = 3
DRIVE_REMOTE      = 4
DRIVE_CDROM       = 5
DRIVE_RAMDISK     = 6

; Pipe modes

PIPE_ACCESS_INBOUND      = 1
PIPE_ACCESS_OUTBOUND     = 2
PIPE_ACCESS_DUPLEX       = 3
PIPE_CLIENT_END          = 0
PIPE_SERVER_END          = 1
PIPE_WAIT                = 0
PIPE_NOWAIT              = 1
PIPE_READMODE_BYTE       = 0
PIPE_READMODE_MESSAGE    = 2
PIPE_TYPE_BYTE           = 0
PIPE_TYPE_MESSAGE        = 4
PIPE_UNLIMITED_INSTANCES = 255

; file/pipe error codes

ERROR_MORE_DATA = 234

; Global memory flags

GMEM_FIXED             = 0000h
GMEM_MOVEABLE          = 0002h
GMEM_NOCOMPACT         = 0010h
GMEM_NODISCARD         = 0020h
GMEM_ZEROINIT          = 0040h
GMEM_MODIFY            = 0080h
GMEM_DISCARDABLE       = 0100h
GMEM_NOT_BANKED        = 1000h
GMEM_SHARE             = 2000h
GMEM_DDESHARE          = 2000h
GMEM_NOTIFY            = 4000h
GMEM_LOWER             = GMEM_NOT_BANKED
GMEM_VALID_FLAGS       = 7F72h
GMEM_INVALID_HANDLE    = 8000h
GMEM_DISCARDED         = 4000h
GMEM_LOCKCOUNT         = 0FFh
GHND                   = GMEM_MOVEABLE + GMEM_ZEROINIT
GPTR                   = GMEM_FIXED + GMEM_ZEROINIT

; Local memory flags

LMEM_FIXED             = 0000h
LMEM_MOVEABLE          = 0002h
LMEM_NOCOMPACT         = 0010h
LMEM_NODISCARD         = 0020h
LMEM_ZEROINIT          = 0040h
LMEM_MODIFY            = 0080h
LMEM_DISCARDABLE       = 0F00h
LMEM_VALID_FLAGS       = 0F72h
LMEM_INVALID_HANDLE    = 8000h
LHND                   = LMEM_MOVEABLE + LMEM_ZEROINIT
LPTR                   = LMEM_FIXED + LMEM_ZEROINIT
LMEM_DISCARDED         = 4000h
LMEM_LOCKCOUNT         = 00FFh

; Page access flags

PAGE_NOACCESS          = 001h
PAGE_READONLY          = 002h
PAGE_READWRITE         = 004h
PAGE_WRITECOPY         = 008h
PAGE_EXECUTE           = 010h
PAGE_EXECUTE_READ      = 020h
PAGE_EXECUTE_READWRITE = 040h
PAGE_EXECUTE_WRITECOPY = 080h
PAGE_GUARD             = 100h
PAGE_NOCACHE           = 200h

; Memory allocation flags

MEM_COMMIT             = 001000h
MEM_RESERVE            = 002000h
MEM_DECOMMIT           = 004000h
MEM_RELEASE            = 008000h
MEM_FREE               = 010000h
MEM_PRIVATE            = 020000h
MEM_MAPPED             = 040000h
MEM_RESET              = 080000h
MEM_TOP_DOWN           = 100000h

; Heap allocation flags

HEAP_NO_SERIALIZE        = 1
HEAP_GENERATE_EXCEPTIONS = 4
HEAP_ZERO_MEMORY         = 8

; Platform identifiers

VER_PLATFORM_WIN32s        = 0
VER_PLATFORM_WIN32_WINDOWS = 1
VER_PLATFORM_WIN32_NT      = 2

; GetBinaryType return values

SCS_32BIT_BINARY = 0
SCS_DOS_BINARY   = 1
SCS_WOW_BINARY   = 2
SCS_PIF_BINARY   = 3
SCS_POSIX_BINARY = 4
SCS_OS216_BINARY = 5

; CreateProcess flags

DEBUG_PROCESS            = 001h
DEBUG_ONLY_THIS_PROCESS  = 002h
CREATE_SUSPENDED         = 004h
DETACHED_PROCESS         = 008h
CREATE_NEW_CONSOLE       = 010h
NORMAL_PRIORITY_CLASS    = 020h
IDLE_PRIORITY_CLASS      = 040h
HIGH_PRIORITY_CLASS      = 080h
REALTIME_PRIORITY_CLASS  = 100h
CREATE_NEW_PROCESS_GROUP = 200h
CREATE_SEPARATE_WOW_VDM  = 800h

; Thread priority values

THREAD_BASE_PRIORITY_MIN      = -2
THREAD_BASE_PRIORITY_MAX      = 2
THREAD_BASE_PRIORITY_LOWRT    = 15
THREAD_BASE_PRIORITY_IDLE     = -15
THREAD_PRIORITY_LOWEST        = THREAD_BASE_PRIORITY_MIN
THREAD_PRIORITY_BELOW_NORMAL  = THREAD_PRIORITY_LOWEST + 1
THREAD_PRIORITY_NORMAL        = 0
THREAD_PRIORITY_HIGHEST       = THREAD_BASE_PRIORITY_MAX
THREAD_PRIORITY_ABOVE_NORMAL  = THREAD_PRIORITY_HIGHEST - 1
THREAD_PRIORITY_ERROR_RETURN  = 7FFFFFFFh
THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
THREAD_PRIORITY_IDLE          = THREAD_BASE_PRIORITY_IDLE

; Startup flags

STARTF_USESHOWWINDOW    = 001h
STARTF_USESIZE          = 002h
STARTF_USEPOSITION      = 004h
STARTF_USECOUNTCHARS    = 008h
STARTF_USEFILLATTRIBUTE = 010h
STARTF_RUNFULLSCREEN    = 020h
STARTF_FORCEONFEEDBACK  = 040h
STARTF_FORCEOFFFEEDBACK = 080h
STARTF_USESTDHANDLES    = 100h

; Shutdown flags

SHUTDOWN_NORETRY = 1h

; LoadLibraryEx flags

DONT_RESOLVE_DLL_REFERENCES   = 1
LOAD_LIBRARY_AS_DATAFILE      = 2
LOAD_WITH_ALTERED_SEARCH_PATH = 8

; DLL entry-point calls

DLL_PROCESS_DETACH = 0
DLL_PROCESS_ATTACH = 1
DLL_THREAD_ATTACH  = 2
DLL_THREAD_DETACH  = 3

; Status codes

STATUS_WAIT_0                   = 000000000h
STATUS_ABANDONED_WAIT_0         = 000000080h
STATUS_USER_APC                 = 0000000C0h
STATUS_TIMEOUT                  = 000000102h
STATUS_PENDING                  = 000000103h
STATUS_DATATYPE_MISALIGNMENT    = 080000002h
STATUS_BREAKPOINT               = 080000003h
STATUS_SINGLE_STEP              = 080000004h
STATUS_ACCESS_VIOLATION         = 0C0000005h
STATUS_IN_PAGE_ERROR            = 0C0000006h
STATUS_NO_MEMORY                = 0C0000017h
STATUS_ILLEGAL_INSTRUCTION      = 0C000001Dh
STATUS_NONCONTINUABLE_EXCEPTION = 0C0000025h
STATUS_INVALID_DISPOSITION      = 0C0000026h
STATUS_ARRAY_BOUNDS_EXCEEDED    = 0C000008Ch
STATUS_FLOAT_DENORMAL_OPERAND   = 0C000008Dh
STATUS_FLOAT_DIVIDE_BY_ZERO     = 0C000008Eh
STATUS_FLOAT_INEXACT_RESULT     = 0C000008Fh
STATUS_FLOAT_INVALID_OPERATION  = 0C0000090h
STATUS_FLOAT_OVERFLOW           = 0C0000091h
STATUS_FLOAT_STACK_CHECK        = 0C0000092h
STATUS_FLOAT_UNDERFLOW          = 0C0000093h
STATUS_INTEGER_DIVIDE_BY_ZERO   = 0C0000094h
STATUS_INTEGER_OVERFLOW         = 0C0000095h
STATUS_PRIVILEGED_INSTRUCTION   = 0C0000096h
STATUS_STACK_OVERFLOW           = 0C00000FDh
STATUS_CONTROL_C_EXIT           = 0C000013Ah
WAIT_FAILED                     = -1
WAIT_OBJECT_0                   = STATUS_WAIT_0
WAIT_ABANDONED                  = STATUS_ABANDONED_WAIT_0
WAIT_ABANDONED_0                = STATUS_ABANDONED_WAIT_0
WAIT_TIMEOUT                    = STATUS_TIMEOUT
WAIT_IO_COMPLETION              = STATUS_USER_APC
STILL_ACTIVE                    = STATUS_PENDING

; Exception codes

EXCEPTION_CONTINUABLE           = 0
EXCEPTION_NONCONTINUABLE        = 1
EXCEPTION_ACCESS_VIOLATION      = STATUS_ACCESS_VIOLATION
EXCEPTION_DATATYPE_MISALIGNMENT = STATUS_DATATYPE_MISALIGNMENT
EXCEPTION_BREAKPOINT            = STATUS_BREAKPOINT
EXCEPTION_SINGLE_STEP           = STATUS_SINGLE_STEP
EXCEPTION_ARRAY_BOUNDS_EXCEEDED = STATUS_ARRAY_BOUNDS_EXCEEDED
EXCEPTION_FLT_DENORMAL_OPERAND  = STATUS_FLOAT_DENORMAL_OPERAND
EXCEPTION_FLT_DIVIDE_BY_ZERO    = STATUS_FLOAT_DIVIDE_BY_ZERO
EXCEPTION_FLT_INEXACT_RESULT    = STATUS_FLOAT_INEXACT_RESULT
EXCEPTION_FLT_INVALID_OPERATION = STATUS_FLOAT_INVALID_OPERATION
EXCEPTION_FLT_OVERFLOW          = STATUS_FLOAT_OVERFLOW
EXCEPTION_FLT_STACK_CHECK       = STATUS_FLOAT_STACK_CHECK
EXCEPTION_FLT_UNDERFLOW         = STATUS_FLOAT_UNDERFLOW
EXCEPTION_INT_DIVIDE_BY_ZERO    = STATUS_INTEGER_DIVIDE_BY_ZERO
EXCEPTION_INT_OVERFLOW          = STATUS_INTEGER_OVERFLOW
EXCEPTION_ILLEGAL_INSTRUCTION   = STATUS_ILLEGAL_INSTRUCTION
EXCEPTION_PRIV_INSTRUCTION      = STATUS_PRIVILEGED_INSTRUCTION
EXCEPTION_IN_PAGE_ERROR         = STATUS_IN_PAGE_ERROR

; Registry options

REG_OPTION_RESERVED            = 0
REG_OPTION_NON_VOLATILE        = 0
REG_OPTION_VOLATILE            = 1
REG_OPTION_CREATE_LINK         = 2
REG_OPTION_BACKUP_RESTORE      = 4
REG_CREATED_NEW_KEY            = 1
REG_OPENED_EXISTING_KEY        = 2
REG_WHOLE_HIVE_VOLATILE        = 1
REG_REFRESH_HIVE               = 2
REG_NOTIFY_CHANGE_NAME         = 1
REG_NOTIFY_CHANGE_ATTRIBUTES   = 2
REG_NOTIFY_CHANGE_LAST_SET     = 4
REG_NOTIFY_CHANGE_SECURITY     = 8
REG_LEGAL_CHANGE_FILTER        = REG_NOTIFY_CHANGE_NAME or REG_NOTIFY_CHANGE_ATTRIBUTES or REG_NOTIFY_CHANGE_LAST_SET or REG_NOTIFY_CHANGE_SECURITY
REG_LEGAL_OPTION               = REG_OPTION_RESERVED or REG_OPTION_NON_VOLATILE or REG_OPTION_VOLATILE or REG_OPTION_CREATE_LINK or REG_OPTION_BACKUP_RESTORE
REG_NONE                       = 0
REG_SZ                         = 1
REG_EXPAND_SZ                  = 2
REG_BINARY                     = 3
REG_DWORD                      = 4
REG_DWORD_LITTLE_ENDIAN        = 4
REG_DWORD_BIG_ENDIAN           = 5
REG_LINK                       = 6
REG_MULTI_SZ                   = 7
REG_RESOURCE_LIST              = 8
REG_FULL_RESOURCE_DESCRIPTOR   = 9
REG_RESOURCE_REQUIREMENTS_LIST = 10

; Registry access modes

KEY_QUERY_VALUE                = 1
KEY_SET_VALUE                  = 2
KEY_CREATE_SUB_KEY             = 4
KEY_ENUMERATE_SUB_KEYS         = 8
KEY_NOTIFY                     = 10h
KEY_CREATE_LINK                = 20h
KEY_READ                       = STANDARD_RIGHTS_READ or KEY_QUERY_VALUE or KEY_ENUMERATE_SUB_KEYS or KEY_NOTIFY and not SYNCHRONIZE
KEY_WRITE                      = STANDARD_RIGHTS_WRITE or KEY_SET_VALUE or KEY_CREATE_SUB_KEY and not SYNCHRONIZE
KEY_EXECUTE                    = KEY_READ
KEY_ALL_ACCESS                 = STANDARD_RIGHTS_ALL or KEY_QUERY_VALUE or KEY_SET_VALUE or KEY_CREATE_SUB_KEY or KEY_ENUMERATE_SUB_KEYS or KEY_NOTIFY or KEY_CREATE_LINK and not SYNCHRONIZE

; Predefined registry keys

HKEY_CLASSES_ROOT     = 80000000h
HKEY_CURRENT_USER     = 80000001h
HKEY_LOCAL_MACHINE    = 80000002h
HKEY_USERS            = 80000003h
HKEY_PERFORMANCE_DATA = 80000004h
HKEY_CURRENT_CONFIG   = 80000005h
HKEY_DYN_DATA         = 80000006h

; FormatMessage flags

FORMAT_MESSAGE_ALLOCATE_BUFFER = 0100h
FORMAT_MESSAGE_IGNORE_INSERTS  = 0200h
FORMAT_MESSAGE_FROM_STRING     = 0400h
FORMAT_MESSAGE_FROM_HMODULE    = 0800h
FORMAT_MESSAGE_FROM_SYSTEM     = 1000h
FORMAT_MESSAGE_ARGUMENT_ARRAY  = 2000h
FORMAT_MESSAGE_MAX_WIDTH_MASK  = 00FFh

; Language identifiers

LANG_NEUTRAL                 = 00h
LANG_BULGARIAN               = 02h
LANG_CHINESE                 = 04h
LANG_CROATIAN                = 1Ah
LANG_CZECH                   = 05h
LANG_DANISH                  = 06h
LANG_DUTCH                   = 13h
LANG_ENGLISH                 = 09h
LANG_FINNISH                 = 0Bh
LANG_FRENCH                  = 0Ch
LANG_GERMAN                  = 07h
LANG_GREEK                   = 08h
LANG_HUNGARIAN               = 0Eh
LANG_ICELANDIC               = 0Fh
LANG_ITALIAN                 = 10h
LANG_JAPANESE                = 11h
LANG_KOREAN                  = 12h
LANG_NORWEGIAN               = 14h
LANG_POLISH                  = 15h
LANG_PORTUGUESE              = 16h
LANG_ROMANIAN                = 18h
LANG_RUSSIAN                 = 19h
LANG_SLOVAK                  = 1Bh
LANG_SLOVENIAN               = 24h
LANG_SPANISH                 = 0Ah
LANG_SWEDISH                 = 1Dh
LANG_THAI                    = 1Eh
LANG_TURKISH                 = 1Fh

; Sublanguage identifiers

SUBLANG_NEUTRAL              = 00h shl 10
SUBLANG_DEFAULT              = 01h shl 10
SUBLANG_SYS_DEFAULT          = 02h shl 10
SUBLANG_CHINESE_TRADITIONAL  = 01h shl 10
SUBLANG_CHINESE_SIMPLIFIED   = 02h shl 10
SUBLANG_CHINESE_HONGKONG     = 03h shl 10
SUBLANG_CHINESE_SINGAPORE    = 04h shl 10
SUBLANG_DUTCH                = 01h shl 10
SUBLANG_DUTCH_BELGIAN        = 02h shl 10
SUBLANG_ENGLISH_US           = 01h shl 10
SUBLANG_ENGLISH_UK           = 02h shl 10
SUBLANG_ENGLISH_AUS          = 03h shl 10
SUBLANG_ENGLISH_CAN          = 04h shl 10
SUBLANG_ENGLISH_NZ           = 05h shl 10
SUBLANG_ENGLISH_EIRE         = 06h shl 10
SUBLANG_FRENCH               = 01h shl 10
SUBLANG_FRENCH_BELGIAN       = 02h shl 10
SUBLANG_FRENCH_CANADIAN      = 03h shl 10
SUBLANG_FRENCH_SWISS         = 04h shl 10
SUBLANG_GERMAN               = 01h shl 10
SUBLANG_GERMAN_SWISS         = 02h shl 10
SUBLANG_GERMAN_AUSTRIAN      = 03h shl 10
SUBLANG_ITALIAN              = 01h shl 10
SUBLANG_ITALIAN_SWISS        = 02h shl 10
SUBLANG_NORWEGIAN_BOKMAL     = 01h shl 10
SUBLANG_NORWEGIAN_NYNORSK    = 02h shl 10
SUBLANG_PORTUGUESE           = 02h shl 10
SUBLANG_PORTUGUESE_BRAZILIAN = 01h shl 10
SUBLANG_SPANISH              = 01h shl 10
SUBLANG_SPANISH_MEXICAN      = 02h shl 10
SUBLANG_SPANISH_MODERN       = 03h shl 10

; Sorting identifiers

SORT_DEFAULT                 = 0 shl 16
SORT_JAPANESE_XJIS           = 0 shl 16
SORT_JAPANESE_UNICODE        = 1 shl 16
SORT_CHINESE_BIG5            = 0 shl 16
SORT_CHINESE_PRCP            = 0 shl 16
SORT_CHINESE_UNICODE         = 1 shl 16
SORT_CHINESE_PRC             = 2 shl 16
SORT_CHINESE_BOPOMOFO        = 3 shl 16
SORT_KOREAN_KSC              = 0 shl 16
SORT_KOREAN_UNICODE          = 1 shl 16
SORT_GERMAN_PHONE_BOOK       = 1 shl 16
SORT_HUNGARIAN_DEFAULT       = 0 shl 16
SORT_HUNGARIAN_TECHNICAL     = 1 shl 16

; Resource types

RT_CURSOR       = 1
RT_BITMAP       = 2
RT_ICON         = 3
RT_MENU         = 4
RT_DIALOG       = 5
RT_STRING       = 6
RT_FONTDIR      = 7
RT_FONT         = 8
RT_ACCELERATOR  = 9
RT_RCDATA       = 10
RT_MESSAGETABLE = 11
RT_GROUP_CURSOR = 12
RT_GROUP_ICON   = 14
RT_VERSION      = 16
RT_DLGINCLUDE   = 17
RT_PLUGPLAY     = 19
RT_VXD          = 20
RT_ANICURSOR    = 21
RT_ANIICON      = 22

; Clipboard formats

CF_TEXT            = 001h
CF_BITMAP          = 002h
CF_METAFILEPICT    = 003h
CF_SYLK            = 004h
CF_DIF             = 005h
CF_TIFF            = 006h
CF_OEMTEXT         = 007h
CF_DIB             = 008h
CF_PALETTE         = 009h
CF_PENDATA         = 00Ah
CF_RIFF            = 00Bh
CF_WAVE            = 00Ch
CF_UNICODETEXT     = 00Dh
CF_ENHMETAFILE     = 00Eh
CF_HDROP           = 00Fh
CF_LOCALE          = 010h
CF_OWNERDISPLAY    = 080h
CF_DSPTEXT         = 081h
CF_DSPBITMAP       = 082h
CF_DSPMETAFILEPICT = 083h
CF_DSPENHMETAFILE  = 08Eh
CF_PRIVATEFIRST    = 200h
CF_PRIVATELAST     = 2FFh
CF_GDIOBJFIRST     = 300h
CF_GDIOBJLAST      = 3FFh

; OS types for version info

VOS_UNKNOWN       = 00000000h
VOS_DOS           = 00010000h
VOS_OS216         = 00020000h
VOS_OS232         = 00030000h
VOS_NT            = 00040000h
VOS__BASE         = 00000000h
VOS__WINDOWS16    = 00000001h
VOS__PM16         = 00000002h
VOS__PM32         = 00000003h
VOS__WINDOWS32    = 00000004h
VOS_DOS_WINDOWS16 = 00010001h
VOS_DOS_WINDOWS32 = 00010004h
VOS_OS216_PM16    = 00020002h
VOS_OS232_PM32    = 00030003h
VOS_NT_WINDOWS32  = 00040004h

; File types for version info

VFT_UNKNOWN    = 00000000h
VFT_APP        = 00000001h
VFT_DLL        = 00000002h
VFT_DRV        = 00000003h
VFT_FONT       = 00000004h
VFT_VXD        = 00000005h
VFT_STATIC_LIB = 00000007h

; File subtypes for version info

VFT2_UNKNOWN               = 00000000h
VFT2_DRV_PRINTER           = 00000001h
VFT2_DRV_KEYBOARD          = 00000002h
VFT2_DRV_LANGUAGE          = 00000003h
VFT2_DRV_DISPLAY           = 00000004h
VFT2_DRV_MOUSE             = 00000005h
VFT2_DRV_NETWORK           = 00000006h
VFT2_DRV_SYSTEM            = 00000007h
VFT2_DRV_INSTALLABLE       = 00000008h
VFT2_DRV_SOUND             = 00000009h
VFT2_DRV_COMM              = 0000000Ah
VFT2_DRV_INPUTMETHOD       = 0000000Bh
VFT2_DRV_VERSIONED_PRINTER = 0000000Ch
VFT2_FONT_RASTER           = 00000001h
VFT2_FONT_VECTOR           = 00000002h
VFT2_FONT_TRUETYPE         = 00000003h


; MultiByteToWideChar constants

CP_ACP = 0
CP_OEMCP = 1
CP_MACCP = 2
CP_THREAD_ACP = 3
CP_SYMBOL = 42
CP_UTF7 = 65000
CP_UTF8 = 65001

; .flags:
MB_PRECOMPOSED       = $00000001     ; use precomposed chars
MB_COMPOSITE         = $00000002     ; use composite chars
MB_USEGLYPHCHARS     = $00000004     ; use glyph chars, not ctrl chars
MB_ERR_INVALID_CHARS = $00000008     ; error for invalid chars
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Win32/_ODBC32.INC.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: ODBC constants and structures.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

SQL_NULL_DATA                   =  -1
SQL_DATA_AT_EXEC                =  -2
SQL_SUCCESS                     =  0
SQL_SUCCESS_WITH_INFO           =  1
SQL_NODATA                      =  100
SQL_ERROR                       =  -1
SQL_INVALID_HANDLE              =  -2
SQL_STILL_EXECUTING             =  2
SQL_NEED_DATA                   =  99
SQL_NTS                         =  -3
SQL_NTSL                        =  -3
SQL_MAX_MESSAGE_LENGTH          =  512
SQL_DATE_LEN                    =  10
SQL_TIME_LEN                    =  8
SQL_TIMESTAMP_LEN               =  19
SQL_HANDLE_ENV                  =  1
SQL_HANDLE_DBC                  =  2
SQL_HANDLE_STMT                 =  3
SQL_HANDLE_DESC                 =  4
SQL_ATTR_OUTPUT_NTS             =  10001
SQL_ATTR_AUTO_IPD               =  10001
SQL_ATTR_METADATA_ID            =  10014
SQL_ATTR_APP_ROW_DESC           =  10010
SQL_ATTR_APP_PARAM_DESC         =  10011
SQL_ATTR_IMP_ROW_DESC           =  10012
SQL_ATTR_IMP_PARAM_DESC         =  10013
SQL_ATTR_CURSOR_SCROLLABLE      =  -1
SQL_ATTR_CURSOR_SENSITIVITY     =  -2
SQL_NONSCROLLABLE               =  0
SQL_SCROLLABLE                  =  1
SQL_DESC_COUNT                  =  1001
SQL_DESC_TYPE                   =  1002
SQL_DESC_LENGTH                 =  1003
SQL_DESC_OCTET_LENGTH_PTR       =  1004
SQL_DESC_PRECISION              =  1005
SQL_DESC_SCALE                  =  1006
SQL_DESC_DATETIME_INTERVAL_CODE =  1007
SQL_DESC_NULLABLE               =  1008
SQL_DESC_INDICATOR_PTR          =  1009
SQL_DESC_DATA_PTR               =  1010
SQL_DESC_NAME                   =  1011
SQL_DESC_UNNAMED                =  1012
SQL_DESC_OCTET_LENGTH           =  1013
SQL_DESC_ALLOC_TYPE             =  1099
SQL_DIAG_RETURNCODE             =  1
SQL_DIAG_NUMBER                 =  2
SQL_DIAG_ROW_COUNT              =  3
SQL_DIAG_SQLSTATE               =  4
SQL_DIAG_NATIVE                 =  5
SQL_DIAG_MESSAGE_TEXT           =  6
SQL_DIAG_DYNAMIC_FUNCTION       =  7
SQL_DIAG_CLASS_ORIGIN           =  8
SQL_DIAG_SUBCLASS_ORIGIN        =  9
SQL_DIAG_CONNECTION_NAME        =  10
SQL_DIAG_SERVER_NAME            =  11
SQL_DIAG_DYNAMIC_FUNCTION_CODE  =  12
SQL_DIAG_ALTER_DOMAIN           =  3
SQL_DIAG_ALTER_TABLE            =  4
SQL_DIAG_CALL                   =  7
SQL_DIAG_CREATE_ASSERTION       =  6
SQL_DIAG_CREATE_CHARACTER_SET   =  8
SQL_DIAG_CREATE_COLLATION       =  10
SQL_DIAG_CREATE_DOMAIN          =  23
SQL_DIAG_CREATE_INDEX           =  -1
SQL_DIAG_CREATE_SCHEMA          =  64
SQL_DIAG_CREATE_TABLE           =  77
SQL_DIAG_CREATE_TRANSLATION     =  79
SQL_DIAG_CREATE_VIEW            =  84
SQL_DIAG_DELETE_WHERE           =  19
SQL_DIAG_DROP_ASSERTION         =  24
SQL_DIAG_DROP_CHARACTER_SET     =  25
SQL_DIAG_DROP_COLLATION         =  26
SQL_DIAG_DROP_DOMAIN            =  27
SQL_DIAG_DROP_INDEX             =  -2
SQL_DIAG_DROP_SCHEMA            =  31
SQL_DIAG_DROP_TABLE             =  32
SQL_DIAG_DROP_TRANSLATION       =  33
SQL_DIAG_DROP_VIEW              =  36
SQL_DIAG_DYNAMIC_DELETE_CURSOR  =  38
SQL_DIAG_DYNAMIC_UPDATE_CURSOR  =  81
SQL_DIAG_GRANT                  =  48
SQL_DIAG_INSERT                 =  50
SQL_DIAG_REVOKE                 =  59
SQL_DIAG_SELECT_CURSOR          =  85
SQL_DIAG_UNKNOWN_STATEMENT      =  0
SQL_DIAG_UPDATE_WHERE           =  82
SQL_UNKNOWN_TYPE                =  0
SQL_CHAR                        =  1
SQL_NUMERIC                     =  2
SQL_DECIMAL                     =  3
SQL_INTEGER                     =  4
SQL_SMALLINT                    =  5
SQL_FLOAT                       =  6
SQL_REAL                        =  7
SQL_DOUBLE                      =  8
SQL_DATETIME                    =  9
SQL_VARCHAR                     =  12
SQL_TYPE_DATE                   =  91
SQL_TYPE_TIME                   =  92
SQL_TYPE_TIMESTAMP              =  93
SQL_UNSPECIFIED                 =  0
SQL_INSENSITIVE                 =  1
SQL_SENSITIVE                   =  2
SQL_ALL_TYPES                   =  0
SQL_DEFAULT                     =  99
SQL_ARD_TYPE                    =  -99
SQL_CODE_DATE                   =  1
SQL_CODE_TIME                   =  2
SQL_CODE_TIMESTAMP              =  3
SQL_FALSE                       =  0
SQL_TRUE                        =  1
SQL_NO_NULLS                    =  0
SQL_NULLABLE                    =  1
SQL_NULLABLE_UNKNOWN            =  2
SQL_PRED_NONE                   =  0
SQL_PRED_CHAR                   =  1
SQL_PRED_BASIC                  =  2
SQL_NAMED                       =  0
SQL_UNNAMED                     =  1
SQL_DESC_ALLOC_AUTO             =  1
SQL_DESC_ALLOC_USER             =  2
SQL_CLOSE                       =  0
SQL_DROP                        =  1
SQL_UNBIND                      =  2
SQL_RESET_PARAMS                =  3
SQL_FETCH_NEXT                  =  1
SQL_FETCH_FIRST                 =  2
SQL_FETCH_LAST                  =  3
SQL_FETCH_PRIOR                 =  4
SQL_FETCH_ABSOLUTE              =  5
SQL_FETCH_RELATIVE              =  6
SQL_COMMIT                      =  0
SQL_ROLLBACK                    =  1
SQL_NULL_HENV                   =  0
SQL_NULL_HDBC                   =  0
SQL_NULL_HSTMT                  =  0
SQL_NULL_HDESC                  =  0
SQL_NULL_HANDLE                 =  0
SQL_SCOPE_CURROW                =  0
SQL_SCOPE_TRANSACTION           =  1
SQL_SCOPE_SESSION               =  2
SQL_PC_UNKNOWN                  =  0
SQL_PC_NON_PSEUDO               =  1
SQL_PC_PSEUDO                   =  2
SQL_ROW_IDENTIFIER              =  1
SQL_INDEX_UNIQUE                =  0
SQL_INDEX_ALL                   =  1
SQL_INDEX_CLUSTERED             =  1
SQL_INDEX_HASHED                =  2
SQL_INDEX_OTHER                 =  3
SQL_API_SQLALLOCCONNECT         =  1
SQL_API_SQLALLOCENV             =  2
SQL_API_SQLALLOCHANDLE          =  1001
SQL_API_SQLALLOCSTMT            =  3
SQL_API_SQLBINDCOL              =  4
SQL_API_SQLBINDPARAM            =  1002
SQL_API_SQLCANCEL               =  5
SQL_API_SQLCLOSECURSOR          =  1003
SQL_API_SQLCOLATTRIBUTE         =  6
SQL_API_SQLCOLUMNS              =  40
SQL_API_SQLCONNECT              =  7
SQL_API_SQLCOPYDESC             =  1004
SQL_API_SQLDATASOURCES          =  57
SQL_API_SQLDESCRIBECOL          =  8
SQL_API_SQLDISCONNECT           =  9
SQL_API_SQLENDTRAN              =  1005
SQL_API_SQLERROR                =  10
SQL_API_SQLEXECDIRECT           =  11
SQL_API_SQLEXECUTE              =  12
SQL_API_SQLFETCH                =  13
SQL_API_SQLFETCHSCROLL          =  1021
SQL_API_SQLFREECONNECT          =  14
SQL_API_SQLFREEENV              =  15
SQL_API_SQLFREEHANDLE           =  1006
SQL_API_SQLFREESTMT             =  16
SQL_API_SQLGETCONNECTATTR       =  1007
SQL_API_SQLGETCONNECTOPTION     =  42
SQL_API_SQLGETCURSORNAME        =  17
SQL_API_SQLGETDATA              =  43
SQL_API_SQLGETDESCFIELD         =  1008
SQL_API_SQLGETDESCREC           =  1009
SQL_API_SQLGETDIAGFIELD         =  1010
SQL_API_SQLGETDIAGREC           =  1011
SQL_API_SQLGETENVATTR           =  1012
SQL_API_SQLGETFUNCTIONS         =  44
SQL_API_SQLGETINFO              =  45
SQL_API_SQLGETSTMTATTR          =  1014
SQL_API_SQLGETSTMTOPTION        =  46
SQL_API_SQLGETTYPEINFO          =  47
SQL_API_SQLNUMRESULTCOLS        =  18
SQL_API_SQLPARAMDATA            =  48
SQL_API_SQLPREPARE              =  19
SQL_API_SQLPUTDATA              =  49
SQL_API_SQLROWCOUNT             =  20
SQL_API_SQLSETCONNECTATTR       =  1016
SQL_API_SQLSETCONNECTOPTION     =  50
SQL_API_SQLSETCURSORNAME        =  21
SQL_API_SQLSETDESCFIELD         =  1017
SQL_API_SQLSETDESCREC           =  1018
SQL_API_SQLSETENVATTR           =  1019
SQL_API_SQLSETPARAM             =  22
SQL_API_SQLSETSTMTATTR          =  1020
SQL_API_SQLSETSTMTOPTION        =  51
SQL_API_SQLSPECIALCOLUMNS       =  52
SQL_API_SQLSTATISTICS           =  53
SQL_API_SQLTABLES               =  54
SQL_API_SQLTRANSACT             =  23
SQL_MAX_DRIVER_CONNECTIONS      =  0
SQL_MAXIMUM_DRIVER_CONNECTIONS  =  SQL_MAX_DRIVER_CONNECTIONS
SQL_MAX_CONCURRENT_ACTIVITIES   =  1
SQL_MAXIMUM_CONCURRENT_ACTIVITIES =  SQL_MAX_CONCURRENT_ACTIVITIES
SQL_DATA_SOURCE_NAME            =  2
SQL_FETCH_DIRECTION             =  8
SQL_SERVER_NAME                 =  13
SQL_SEARCH_PATTERN_ESCAPE       =  14
SQL_DBMS_NAME                   =  17
SQL_DBMS_VER                    =  18
SQL_ACCESSIBLE_TABLES           =  19
SQL_ACCESSIBLE_PROCEDURES       =  20
SQL_CURSOR_COMMIT_BEHAVIOR      =  23
SQL_DATA_SOURCE_READ_ONLY       =  25
SQL_DEFAULT_TXN_ISOLATION       =  26
SQL_IDENTIFIER_CASE             =  28
SQL_IDENTIFIER_QUOTE_CHAR       =  29
SQL_MAX_COLUMN_NAME_LEN         =  30
SQL_MAXIMUM_COLUMN_NAME_LENGTH  =  SQL_MAX_COLUMN_NAME_LEN
SQL_MAX_CURSOR_NAME_LEN         =  31
SQL_MAXIMUM_CURSOR_NAME_LENGTH  =  SQL_MAX_CURSOR_NAME_LEN
SQL_MAX_SCHEMA_NAME_LEN         =  32
SQL_MAXIMUM_SCHEMA_NAME_LENGTH  =  SQL_MAX_SCHEMA_NAME_LEN
SQL_MAX_CATALOG_NAME_LEN        =  34
SQL_MAXIMUM_CATALOG_NAME_LENGTH =  SQL_MAX_CATALOG_NAME_LEN
SQL_MAX_TABLE_NAME_LEN          =  35
SQL_SCROLL_CONCURRENCY          =  43
SQL_TXN_CAPABLE                 =  46
SQL_TRANSACTION_CAPABLE         =  SQL_TXN_CAPABLE
SQL_USER_NAME                   =  47
SQL_TXN_ISOLATION_OPTION        =  72
SQL_TRANSACTION_ISOLATION_OPTION =  SQL_TXN_ISOLATION_OPTION
SQL_INTEGRITY                   =  73
SQL_GETDATA_EXTENSIONS          =  81
SQL_NULL_COLLATION              =  85
SQL_ALTER_TABLE                 =  86
SQL_ORDER_BY_COLUMNS_IN_SELECT  =  90
SQL_SPECIAL_CHARACTERS          =  94
SQL_MAX_COLUMNS_IN_GROUP_BY     =  97
SQL_MAXIMUM_COLUMNS_IN_GROUP_BY =  SQL_MAX_COLUMNS_IN_GROUP_BY
SQL_MAX_COLUMNS_IN_INDEX        =  98
SQL_MAXIMUM_COLUMNS_IN_INDEX    =  SQL_MAX_COLUMNS_IN_INDEX
SQL_MAX_COLUMNS_IN_ORDER_BY     =  99
SQL_MAXIMUM_COLUMNS_IN_ORDER_BY =  SQL_MAX_COLUMNS_IN_ORDER_BY
SQL_MAX_COLUMNS_IN_SELECT       =  100
SQL_MAXIMUM_COLUMNS_IN_SELECT   =  SQL_MAX_COLUMNS_IN_SELECT
SQL_MAX_COLUMNS_IN_TABLE        =  101
SQL_MAX_INDEX_SIZE              =  102
SQL_MAXIMUM_INDEX_SIZE          =  SQL_MAX_INDEX_SIZE
SQL_MAX_ROW_SIZE                =  104
SQL_MAXIMUM_ROW_SIZE            =  SQL_MAX_ROW_SIZE
SQL_MAX_STATEMENT_LEN           =  105
SQL_MAXIMUM_STATEMENT_LENGTH    =  SQL_MAX_STATEMENT_LEN
SQL_MAX_TABLES_IN_SELECT        =  106
SQL_MAXIMUM_TABLES_IN_SELECT    =  SQL_MAX_TABLES_IN_SELECT
SQL_MAX_USER_NAME_LEN           =  107
SQL_MAXIMUM_USER_NAME_LENGTH    =  SQL_MAX_USER_NAME_LEN
SQL_OJ_CAPABILITIES             =  115
SQL_OUTER_JOIN_CAPABILITIES     =  SQL_OJ_CAPABILITIES
SQL_XOPEN_CLI_YEAR              =  10000
SQL_CURSOR_SENSITIVITY          =  10001
SQL_DESCRIBE_PARAMETER          =  10002
SQL_CATALOG_NAME                =  10003
SQL_COLLATION_SEQ               =  10004
SQL_MAX_IDENTIFIER_LEN          =  10005
SQL_MAXIMUM_IDENTIFIER_LENGTH   =  SQL_MAX_IDENTIFIER_LEN
SQL_AT_ADD_COLUMN               =  1
SQL_AT_DROP_COLUMN              =  2
SQL_AT_ADD_CONSTRAINT           =  8
SQL_AT_COLUMN_SINGLE            =  20h
SQL_AT_ADD_COLUMN_DEFAULT       =  40h
SQL_AT_ADD_COLUMN_COLLATION     =  80h
SQL_AT_SET_COLUMN_DEFAULT       =  100h
SQL_AT_DROP_COLUMN_DEFAULT      =  200h
SQL_AT_DROP_COLUMN_CASCADE      =  400h
SQL_AT_DROP_COLUMN_RESTRICT     =  800h
SQL_AT_ADD_TABLE_CONSTRAINT     =  1000h
SQL_AT_DROP_TABLE_CONSTRAINT_CASCADE =  2000h
SQL_AT_DROP_TABLE_CONSTRAINT_RESTRICT =  4000h
SQL_AT_CONSTRAINT_NAME_DEFINITION =  8000h
SQL_AT_CONSTRAINT_INITIALLY_DEFERRED =  10000h
SQL_AT_CONSTRAINT_INITIALLY_IMMEDIATE =  20000h
SQL_AT_CONSTRAINT_DEFERRABLE =  40000h
SQL_AT_CONSTRAINT_NON_DEFERRABLE =  80000h
SQL_AM_NONE                     =  0
SQL_AM_CONNECTION               =  1
SQL_AM_STATEMENT                =  2
SQL_CB_DELETE                   =  0
SQL_CB_CLOSE                    =  1
SQL_CB_PRESERVE                 =  2
SQL_FD_FETCH_NEXT               =  1
SQL_FD_FETCH_FIRST              =  2
SQL_FD_FETCH_LAST               =  4
SQL_FD_FETCH_PRIOR              =  8
SQL_FD_FETCH_ABSOLUTE           =  10h
SQL_FD_FETCH_RELATIVE           =  20h
SQL_GD_ANY_COLUMN               =  1
SQL_GD_ANY_ORDER                =  2
SQL_IC_UPPER                    =  1
SQL_IC_LOWER                    =  2
SQL_IC_SENSITIVE                =  3
SQL_IC_MIXED                    =  4
SQL_OJ_LEFT                     =  1
SQL_OJ_RIGHT                    =  2
SQL_OJ_FULL                     =  4
SQL_OJ_NESTED                   =  8
SQL_OJ_NOT_ORDERED              =  10h
SQL_OJ_INNER                    =  20h
SQL_OJ_ALL_COMPARISON_OPS       =  40h
SQL_SCCO_READ_ONLY              =  1
SQL_SCCO_LOCK                   =  2
SQL_SCCO_OPT_ROWVER             =  4
SQL_SCCO_OPT_VALUES             =  8
SQL_TC_NONE                     =  0
SQL_TC_DML                      =  1
SQL_TC_ALL                      =  2
SQL_TC_DDL_COMMIT               =  3
SQL_TC_DDL_IGNORE               =  4
SQL_TXN_READ_UNCOMMITTED        =  1
SQL_TRANSACTION_READ_UNCOMMITTED = SQL_TXN_READ_UNCOMMITTED
SQL_TXN_READ_COMMITTED          =  2
SQL_TRANSACTION_READ_COMMITTED  =  SQL_TXN_READ_COMMITTED
SQL_TXN_REPEATABLE_READ         =  4
SQL_TRANSACTION_REPEATABLE_READ =  SQL_TXN_REPEATABLE_READ
SQL_TXN_SERIALIZABLE            =  8
SQL_TRANSACTION_SERIALIZABLE    =  SQL_TXN_SERIALIZABLE
SQL_NC_HIGH                     =  0
SQL_NC_LOW                      =  1


SQL_SPEC_MAJOR                  =  3
SQL_SPEC_MINOR                  =  51
SQL_SPEC_STRING                 =  "03.51"
SQL_SQLSTATE_SIZE               =  5
SQL_MAX_DSN_LENGTH              =  32
SQL_MAX_OPTION_STRING_LENGTH    =  256
SQL_NODATAFOUND               =  SQL_NODATA
SQL_HANDLE_SENV                 =  5
SQL_ATTR_ODBC_VERSION           =  200
SQL_ATTR_CONNECTION_POOLING     =  201
SQL_ATTR_CP_MATCH               =  202
SQL_CP_OFF                      =  0
SQL_CP_ONE_PER_DRIVER           =  1
SQL_CP_ONE_PER_HENV             =  2
SQL_CP_DEFAULT                  =  SQL_CP_OFF
SQL_CP_STRICT_MATCH             =  0
SQL_CP_RELAXED_MATCH            =  1
SQL_CP_MATCH_DEFAULT            =  SQL_CP_STRICT_MATCH
SQL_OV_ODBC2                    =  2
SQL_OV_ODBC3                    =  3
SQL_ACCESS_MODE                 =  101
SQL_AUTOCOMMIT                  =  102
SQL_LOGIN_TIMEOUT               =  103
SQL_OPT_TRACE                   =  104
SQL_OPT_TRACEFILE               =  105
SQL_TRANSLATE_DLL               =  106
SQL_TRANSLATE_OPTION            =  107
SQL_TXN_ISOLATION               =  108
SQL_CURRENT_QUALIFIER           =  109
SQL_ODBC_CURSORS                =  110
SQL_QUIET_MODE                  =  111
SQL_PACKET_SIZE                 =  112
SQL_ATTR_ACCESS_MODE            =  SQL_ACCESS_MODE
SQL_ATTR_AUTOCOMMIT             =  SQL_AUTOCOMMIT
SQL_ATTR_CONNECTION_TIMEOUT     =  113
SQL_ATTR_CURRENT_CATALOG        =  SQL_CURRENT_QUALIFIER
SQL_ATTR_DISCONNECT_BEHAVIOR    =  114
SQL_ATTR_ENLIST_IN_DTC          =  1207
SQL_ATTR_ENLIST_IN_XA           =  1208
SQL_ATTR_LOGIN_TIMEOUT          =  SQL_LOGIN_TIMEOUT
SQL_ATTR_ODBC_CURSORS           =  SQL_ODBC_CURSORS
SQL_ATTR_PACKET_SIZE            =  SQL_PACKET_SIZE
SQL_ATTR_QUIET_MODE             =  SQL_QUIET_MODE
SQL_ATTR_TRACE                  =  SQL_OPT_TRACE
SQL_ATTR_TRACEFILE              =  SQL_OPT_TRACEFILE
SQL_ATTR_TRANSLATE_LIB          =  SQL_TRANSLATE_DLL
SQL_ATTR_TRANSLATE_OPTION       =  SQL_TRANSLATE_OPTION
SQL_ATTR_TXN_ISOLATION          =  SQL_TXN_ISOLATION
SQL_ATTR_CONNECTION_DEAD        =  1209
SQL_ATTR_ANSI_APP               =  115
SQL_MODE_READ_WRITE             =  0
SQL_MODE_READ_ONLY              =  1
SQL_MODE_DEFAULT                =  SQL_MODE_READ_WRITE
SQL_AUTOCOMMIT_OFF              =  0
SQL_AUTOCOMMIT_ON               =  1
SQL_AUTOCOMMIT_DEFAULT          =  SQL_AUTOCOMMIT_ON
SQL_LOGIN_TIMEOUT_DEFAULT       =  15
SQL_OPT_TRACE_OFF               =  0
SQL_OPT_TRACE_ON                =  1
SQL_OPT_TRACE_DEFAULT           =  SQL_OPT_TRACE_OFF
SQL_OPT_TRACE_FILE_DEFAULT      equ  "\\SQL.LOG"
SQL_CUR_USE_IF_NEEDED           =  0
SQL_CUR_USE_ODBC                =  1
SQL_CUR_USE_DRIVER              =  2
SQL_CUR_DEFAULT                 =  SQL_CUR_USE_DRIVER
SQL_DB_RETURN_TO_POOL           =  0
SQL_DB_DISCONNECT               =  1
SQL_DB_DEFAULT                  =  SQL_DB_RETURN_TO_POOL
SQL_DTC_DONE                    =  0
SQL_CD_TRUE                     =  1
SQL_CD_FALSE                    =  0
SQL_AA_TRUE                     =  1
SQL_AA_FALSE                    =  0
SQL_QUERY_TIMEOUT               =  0
SQL_MAX_ROWS                    =  1
SQL_NOSCAN                      =  2
SQL_MAX_LENGTH                  =  3
SQL_ASYNC_ENABLE                =  4
SQL_BIND_TYPE                   =  5
SQL_CURSOR_TYPE                 =  6
SQL_CONCURRENCY                 =  7
SQL_KEYSET_SIZE                 =  8
SQL_ROWSET_SIZE                 =  9
SQL_SIMULATE_CURSOR             =  10
SQL_RETRIEVE_DATA               =  11
SQL_USE_BOOKMARKS               =  12
SQL_GET_BOOKMARK                =  13
SQL_ROW_NUMBER                  =  14
SQL_ATTR_ASYNC_ENABLE           =  4
SQL_ATTR_CONCURRENCY            =  SQL_CONCURRENCY
SQL_ATTR_CURSOR_TYPE            =  SQL_CURSOR_TYPE
SQL_ATTR_ENABLE_AUTO_IPD        =  15
SQL_ATTR_FETCH_BOOKMARK_PTR     =  16
SQL_ATTR_KEYSET_SIZE            =  SQL_KEYSET_SIZE
SQL_ATTR_MAX_LENGTH             =  SQL_MAX_LENGTH
SQL_ATTR_MAX_ROWS               =  SQL_MAX_ROWS
SQL_ATTR_NOSCAN                 =  SQL_NOSCAN
SQL_ATTR_PARAM_BIND_OFFSET_PTR  =  17
SQL_ATTR_PARAM_BIND_TYPE        =  18
SQL_ATTR_PARAM_OPERATION_PTR    =  19
SQL_ATTR_PARAM_STATUS_PTR       =  20
SQL_ATTR_PARAMS_PROCESSED_PTR   =  21
SQL_ATTR_PARAMSET_SIZE          =  22
SQL_ATTR_QUERY_TIMEOUT          =  SQL_QUERY_TIMEOUT
SQL_ATTR_RETRIEVE_DATA          =  SQL_RETRIEVE_DATA
SQL_ATTR_ROW_BIND_OFFSET_PTR    =  23
SQL_ATTR_ROW_BIND_TYPE          =  SQL_BIND_TYPE
SQL_ATTR_ROW_NUMBER             =  SQL_ROW_NUMBER
SQL_ATTR_ROW_OPERATION_PTR      =  24
SQL_ATTR_ROW_STATUS_PTR         =  25
SQL_ATTR_ROWS_FETCHED_PTR       =  26
SQL_ATTR_ROW_ARRAY_SIZE         =  27
SQL_ATTR_SIMULATE_CURSOR        =  SQL_SIMULATE_CURSOR
SQL_ATTR_USE_BOOKMARKS          =  SQL_USE_BOOKMARKS
SQL_COL_PRED_CHAR               =  SQL_LIKE_ONLY
SQL_COL_PRED_BASIC              =  SQL_ALL_EXCEPT_LIKE
SQL_IS_POINTER                  =  -4
SQL_IS_UINTEGER                 =  -5
SQL_IS_INTEGER                  =  -6
SQL_IS_USMALLINT                =  -7
SQL_IS_SMALLINT                 =  -8
SQL_PARAM_BIND_BY_COLUMN        =  0
SQL_PARAM_BIND_TYPE_DEFAULT     =  SQL_PARAM_BIND_BY_COLUMN
SQL_QUERY_TIMEOUT_DEFAULT       =  0
SQL_MAX_ROWS_DEFAULT            =  0
SQL_NOSCAN_OFF                  =  0
SQL_NOSCAN_ON                   =  1
SQL_NOSCAN_DEFAULT              =  SQL_NOSCAN_OFF
SQL_MAX_LENGTH_DEFAULT          =  0
SQL_ASYNC_ENABLE_OFF            =  0
SQL_ASYNC_ENABLE_ON             =  1
SQL_ASYNC_ENABLE_DEFAULT        =  SQL_ASYNC_ENABLE_OFF
SQL_BIND_BY_COLUMN              =  0
SQL_BIND_TYPE_DEFAULT           =  SQL_BIND_BY_COLUMN
SQL_CONCUR_READ_ONLY            =  1
SQL_CONCUR_LOCK                 =  2
SQL_CONCUR_ROWVER               =  3
SQL_CONCUR_VALUES               =  4
SQL_CONCUR_DEFAULT              =  SQL_CONCUR_READ_ONLY
SQL_CURSOR_FORWARD_ONLY         =  0
SQL_CURSOR_KEYSET_DRIVEN        =  1
SQL_CURSOR_DYNAMIC              =  2
SQL_CURSOR_STATIC               =  3
SQL_CURSOR_TYPE_DEFAULT         =  SQL_CURSOR_FORWARD_ONLY
SQL_ROWSET_SIZE_DEFAULT         =  1
SQL_KEYSET_SIZE_DEFAULT         =  0
SQL_SC_NON_UNIQUE               =  0
SQL_SC_TRY_UNIQUE               =  1
SQL_SC_UNIQUE                   =  2
SQL_RD_OFF                      =  0
SQL_RD_ON                       =  1
SQL_RD_DEFAULT                  =  SQL_RD_ON
SQL_UB_OFF                      =  0
SQL_UB_ON                       =  01
SQL_UB_DEFAULT                  =  SQL_UB_OFF
SQL_UB_FIXED                    =  SQL_UB_ON
SQL_UB_VARIABLE                 =  2
SQL_DESC_ARRAY_SIZE             =  20
SQL_DESC_ARRAY_STATUS_PTR       =  21
SQL_DESC_AUTO_UNIQUE_VALUE      =  SQL_COLUMN_AUTO_INCREMENT
SQL_DESC_BASE_COLUMN_NAME       =  22
SQL_DESC_BASE_TABLE_NAME        =  23
SQL_DESC_BIND_OFFSET_PTR        =  24
SQL_DESC_BIND_TYPE              =  25
SQL_DESC_CASE_SENSITIVE         =  SQL_COLUMN_CASE_SENSITIVE
SQL_DESC_CATALOG_NAME           =  SQL_COLUMN_QUALIFIER_NAME
SQL_DESC_CONCISE_TYPE           =  SQL_COLUMN_TYPE
SQL_DESC_DATETIME_INTERVAL_PRECISION =  26
SQL_DESC_DISPLAY_SIZE           =  SQL_COLUMN_DISPLAY_SIZE
SQL_DESC_FIXED_PREC_SCALE       =  SQL_COLUMN_MONEY
SQL_DESC_LABEL                  =  SQL_COLUMN_LABEL
SQL_DESC_LITERAL_PREFIX         =  27
SQL_DESC_LITERAL_SUFFIX         =  28
SQL_DESC_LOCAL_TYPE_NAME        =  29
SQL_DESC_MAXIMUM_SCALE          =  30
SQL_DESC_MINIMUM_SCALE          =  31
SQL_DESC_NUM_PREC_RADIX         =  32
SQL_DESC_PARAMETER_TYPE         =  33
SQL_DESC_ROWS_PROCESSED_PTR     =  34
SQL_DESC_ROWVER                 =  35
SQL_DESC_SCHEMA_NAME            =  SQL_COLUMN_OWNER_NAME
SQL_DESC_SEARCHABLE             =  SQL_COLUMN_SEARCHABLE
SQL_DESC_TYPE_NAME              =  SQL_COLUMN_TYPE_NAME
SQL_DESC_TABLE_NAME             =  SQL_COLUMN_TABLE_NAME
SQL_DESC_UNSIGNED               =  SQL_COLUMN_UNSIGNED
SQL_DESC_UPDATABLE              =  SQL_COLUMN_UPDATABLE
SQL_DIAG_CURSOR_ROW_COUNT       =  -1249
SQL_DIAG_ROW_NUMBER             =  -1248
SQL_DIAG_COLUMN_NUMBER          =  -1247
SQL_DATE                        =  9
SQL_INTERVAL                    =  10
SQL_TIME                        =  10
SQL_TIMESTAMP                   =  11
SQL_LONGVARCHAR                 =  -1
SQL_BINARY                      =  -2
SQL_VARBINARY                   =  -3
SQL_LONGVARBINARY               =  -4
SQL_BIGINT                      =  -5
SQL_TINYINT                     =  -6
SQL_BIT                         =  -7
SQL_GUID                        =  -11
SQL_CODE_YEAR                   =  1
SQL_CODE_MONTH                  =  2
SQL_CODE_DAY                    =  3
SQL_CODE_HOUR                   =  4
SQL_CODE_MINUTE                 =  5
SQL_CODE_SECOND                 =  6
SQL_CODE_YEAR_TO_MONTH          =  7
SQL_CODE_DAY_TO_HOUR            =  8
SQL_CODE_DAY_TO_MINUTE          =  9
SQL_CODE_DAY_TO_SECOND          =  10
SQL_CODE_HOUR_TO_MINUTE         =  11
SQL_CODE_HOUR_TO_SECOND         =  12
SQL_CODE_MINUTE_TO_SECOND       =  13
SQL_INTERVAL_YEAR               =  100 + SQL_CODE_YEAR
SQL_INTERVAL_MONTH              =  100 + SQL_CODE_MONTH
SQL_INTERVAL_DAY                =  100 + SQL_CODE_DAY
SQL_INTERVAL_HOUR               =  100 + SQL_CODE_HOUR
SQL_INTERVAL_MINUTE             =  100 + SQL_CODE_MINUTE
SQL_INTERVAL_SECOND             =  100 + SQL_CODE_SECOND
SQL_INTERVAL_YEAR_TO_MONTH      =  100 + SQL_CODE_YEAR_TO_MONTH
SQL_INTERVAL_DAY_TO_HOUR        =  100 + SQL_CODE_DAY_TO_HOUR
SQL_INTERVAL_DAY_TO_MINUTE      =  100 + SQL_CODE_DAY_TO_MINUTE
SQL_INTERVAL_DAY_TO_SECOND      =  100 + SQL_CODE_DAY_TO_SECOND
SQL_INTERVAL_HOUR_TO_MINUTE     =  100 + SQL_CODE_HOUR_TO_MINUTE
SQL_INTERVAL_HOUR_TO_SECOND     =  100 + SQL_CODE_HOUR_TO_SECOND
SQL_INTERVAL_MINUTE_TO_SECOND   =  100 + SQL_CODE_MINUTE_TO_SECOND

;???? SQL_UNICODE                     =  SQL_WCHAR
;???? SQL_UNICODE_VARCHAR             =  SQL_WVARCHAR
;???? SQL_UNICODE_LONGVARCHAR         =  SQL_WLONGVARCHAR
;???? SQL_UNICODE_CHAR                =  SQL_WCHAR

SQL_C_CHAR                      =  SQL_CHAR
SQL_C_LONG                      =  SQL_INTEGER
SQL_C_SHORT                     =  SQL_SMALLINT
SQL_C_FLOAT                     =  SQL_REAL
SQL_C_DOUBLE                    =  SQL_DOUBLE
SQL_C_NUMERIC                   =  SQL_NUMERIC
SQL_C_DEFAULT                   =  99
SQL_SIGNED_OFFSET               =  -20
SQL_UNSIGNED_OFFSET             =  -22
SQL_C_DATE                      =  SQL_DATE
SQL_C_TIME                      =  SQL_TIME
SQL_C_TIMESTAMP                 =  SQL_TIMESTAMP
SQL_C_TYPE_DATE                 =  SQL_TYPE_DATE
SQL_C_TYPE_TIME                 =  SQL_TYPE_TIME
SQL_C_TYPE_TIMESTAMP            =  SQL_TYPE_TIMESTAMP
SQL_C_INTERVAL_YEAR             =  SQL_INTERVAL_YEAR
SQL_C_INTERVAL_MONTH            =  SQL_INTERVAL_MONTH
SQL_C_INTERVAL_DAY              =  SQL_INTERVAL_DAY
SQL_C_INTERVAL_HOUR             =  SQL_INTERVAL_HOUR
SQL_C_INTERVAL_MINUTE           =  SQL_INTERVAL_MINUTE
SQL_C_INTERVAL_SECOND           =  SQL_INTERVAL_SECOND
SQL_C_INTERVAL_YEAR_TO_MONTH    =  SQL_INTERVAL_YEAR_TO_MONTH
SQL_C_INTERVAL_DAY_TO_HOUR      =  SQL_INTERVAL_DAY_TO_HOUR
SQL_C_INTERVAL_DAY_TO_MINUTE    =  SQL_INTERVAL_DAY_TO_MINUTE
SQL_C_INTERVAL_DAY_TO_SECOND    =  SQL_INTERVAL_DAY_TO_SECOND
SQL_C_INTERVAL_HOUR_TO_MINUTE   =  SQL_INTERVAL_HOUR_TO_MINUTE
SQL_C_INTERVAL_HOUR_TO_SECOND   =  SQL_INTERVAL_HOUR_TO_SECOND
SQL_C_INTERVAL_MINUTE_TO_SECOND =  SQL_INTERVAL_MINUTE_TO_SECOND
SQL_C_BINARY                    =  SQL_BINARY
SQL_C_BIT                       =  SQL_BIT
SQL_C_SBIGINT                   =  SQL_BIGINT+SQL_SIGNED_OFFSET
SQL_C_UBIGINT                   =  SQL_BIGINT+SQL_UNSIGNED_OFFSET
SQL_C_TINYINT                   =  SQL_TINYINT
SQL_C_SLONG                     =  SQL_C_LONG+SQL_SIGNED_OFFSET
SQL_C_SSHORT                    =  SQL_C_SHORT+SQL_SIGNED_OFFSET
SQL_C_STINYINT                  =  SQL_TINYINT+SQL_SIGNED_OFFSET
SQL_C_ULONG                     =  SQL_C_LONG+SQL_UNSIGNED_OFFSET
SQL_C_USHORT                    =  SQL_C_SHORT+SQL_UNSIGNED_OFFSET
SQL_C_UTINYINT                  =  SQL_TINYINT+SQL_UNSIGNED_OFFSET
SQL_C_BOOKMARK                  =  SQL_C_ULONG
SQL_C_GUID                      =  SQL_GUID
SQL_TYPE_NULL                   =  0
SQL_C_VARBOOKMARK               =  SQL_C_BINARY
SQL_NO_ROW_NUMBER               =  -1
SQL_NO_COLUMN_NUMBER            =  -1
SQL_ROW_NUMBER_UNKNOWN          =  -2
SQL_COLUMN_NUMBER_UNKNOWN       =  -2
SQL_DEFAULT_PARAM               =  -5
SQL_IGNORE                      =  -6
SQL_COLUMN_IGNORE               =  SQL_IGNORE
SQL_LEN_DATA_AT_EXEC_OFFSET     =  -100
SQL_LEN_BINARY_ATTR_OFFSET      =  -100
SQL_PARAM_TYPE_DEFAULT          =  SQL_PARAM_INPUT_OUTPUT
SQL_SETPARAM_VALUE_MAX          =  -1
SQL_COLUMN_COUNT                =  0
SQL_COLUMN_NAME                 =  1
SQL_COLUMN_TYPE                 =  2
SQL_COLUMN_LENGTH               =  3
SQL_COLUMN_PRECISION            =  4
SQL_COLUMN_SCALE                =  5
SQL_COLUMN_DISPLAY_SIZE         =  6
SQL_COLUMN_NULLABLE             =  7
SQL_COLUMN_UNSIGNED             =  8
SQL_COLUMN_MONEY                =  9
SQL_COLUMN_UPDATABLE            =  10
SQL_COLUMN_AUTO_INCREMENT       =  11
SQL_COLUMN_CASE_SENSITIVE       =  12
SQL_COLUMN_SEARCHABLE           =  13
SQL_COLUMN_TYPE_NAME            =  14
SQL_COLUMN_TABLE_NAME           =  15
SQL_COLUMN_OWNER_NAME           =  16
SQL_COLUMN_QUALIFIER_NAME       =  17
SQL_COLUMN_LABEL                =  18
SQL_COLATT_OPT_MAX              =  SQL_COLUMN_LABEL
SQL_COLATT_OPT_MIN              =  SQL_COLUMN_COUNT
SQL_ATTR_READONLY               =  0
SQL_ATTR_WRITE                  =  1
SQL_ATTR_READWRITE_UNKNOWN      =  2
SQL_UNSEARCHABLE                =  0
SQL_LIKE_ONLY                   =  1
SQL_ALL_EXCEPT_LIKE             =  2
SQL_SEARCHABLE                  =  3
SQL_PRED_SEARCHABLE             =  SQL_SEARCHABLE
SQL_NO_TOTAL                    =  -4
SQL_API_SQLALLOCHANDLESTD       =  73
SQL_API_SQLBULKOPERATIONS       =  24
SQL_API_SQLBINDPARAMETER        =  72
SQL_API_SQLBROWSECONNECT        =  55
SQL_API_SQLCOLATTRIBUTES        =  6
SQL_API_SQLCOLUMNPRIVILEGES     =  56
SQL_API_SQLDESCRIBEPARAM        =  58
SQL_API_SQLDRIVERCONNECT        =  41
SQL_API_SQLDRIVERS              =  71
SQL_API_SQLEXTENDEDFETCH        =  59
SQL_API_SQLFOREIGNKEYS          =  60
SQL_API_SQLMORERESULTS          =  61
SQL_API_SQLNATIVESQL            =  62
SQL_API_SQLNUMPARAMS            =  63
SQL_API_SQLPARAMOPTIONS         =  64
SQL_API_SQLPRIMARYKEYS          =  65
SQL_API_SQLPROCEDURECOLUMNS     =  66
SQL_API_SQLPROCEDURES           =  67
SQL_API_SQLSETPOS               =  68
SQL_API_SQLSETSCROLLOPTIONS     =  69
SQL_API_SQLTABLEPRIVILEGES      =  70
SQL_API_ALL_FUNCTIONS           =  0
SQL_API_LOADBYORDINAL           =  199
SQL_API_ODBC3_ALL_FUNCTIONS     =  999
SQL_API_ODBC3_ALL_FUNCTIONS_SIZE =  250
SQL_INFO_FIRST                  =  0
SQL_ACTIVE_CONNECTIONS          =  0
SQL_ACTIVE_STATEMENTS           =  1
SQL_DRIVER_HDBC                 =  3
SQL_DRIVER_HENV                 =  4
SQL_DRIVER_HSTMT                =  5
SQL_DRIVER_NAME                 =  6
SQL_DRIVER_VER                  =  7
SQL_ODBC_API_CONFORMANCE        =  9
SQL_ODBC_VER                    =  10
SQL_ROW_UPDATES                 =  11
SQL_ODBC_SAG_CLI_CONFORMANCE    =  12
SQL_ODBC_SQL_CONFORMANCE        =  15
SQL_PROCEDURES                  =  21
SQL_CONCAT_NULL_BEHAVIOR        =  22
SQL_CURSOR_ROLLBACK_BEHAVIOR    =  24
SQL_EXPRESSIONS_IN_ORDERBY      =  27
SQL_MAX_OWNER_NAME_LEN          =  32
SQL_MAX_PROCEDURE_NAME_LEN      =  33
SQL_MAX_QUALIFIER_NAME_LEN      =  34
SQL_MULT_RESULT_SETS            =  36
SQL_MULTIPLE_ACTIVE_TXN         =  37
SQL_OUTER_JOINS                 =  38
SQL_OWNER_TERM                  =  39
SQL_PROCEDURE_TERM              =  40
SQL_QUALIFIER_NAME_SEPARATOR    =  41
SQL_QUALIFIER_TERM              =  42
SQL_SCROLL_OPTIONS              =  44
SQL_TABLE_TERM                  =  45
SQL_CONVERT_FUNCTIONS           =  48
SQL_NUMERIC_FUNCTIONS           =  49
SQL_STRING_FUNCTIONS            =  50
SQL_SYSTEM_FUNCTIONS            =  51
SQL_TIMEDATE_FUNCTIONS          =  52
SQL_CONVERT_BIGINT              =  53
SQL_CONVERT_BINARY              =  54
SQL_CONVERT_BIT                 =  55
SQL_CONVERT_CHAR                =  56
SQL_CONVERT_DATE                =  57
SQL_CONVERT_DECIMAL             =  58
SQL_CONVERT_DOUBLE              =  59
SQL_CONVERT_FLOAT               =  60
SQL_CONVERT_INTEGER             =  61
SQL_CONVERT_LONGVARCHAR         =  62
SQL_CONVERT_NUMERIC             =  63
SQL_CONVERT_REAL                =  64
SQL_CONVERT_SMALLINT            =  65
SQL_CONVERT_TIME                =  66
SQL_CONVERT_TIMESTAMP           =  67
SQL_CONVERT_TINYINT             =  68
SQL_CONVERT_VARBINARY           =  69
SQL_CONVERT_VARCHAR             =  70
SQL_CONVERT_LONGVARBINARY       =  71
SQL_ODBC_SQL_OPT_IEF            =  73
SQL_CORRELATION_NAME            =  74
SQL_NON_NULLABLE_COLUMNS        =  75
SQL_DRIVER_HLIB                 =  76
SQL_DRIVER_ODBC_VER             =  77
SQL_LOCK_TYPES                  =  78
SQL_POS_OPERATIONS              =  79
SQL_POSITIONED_STATEMENTS       =  80
SQL_BOOKMARK_PERSISTENCE        =  82
SQL_STATIC_SENSITIVITY          =  83
SQL_FILE_USAGE                  =  84
SQL_COLUMN_ALIAS                =  87
SQL_GROUP_BY                    =  88
SQL_KEYWORDS                    =  89
SQL_OWNER_USAGE                 =  91
SQL_QUALIFIER_USAGE             =  92
SQL_QUOTED_IDENTIFIER_CASE      =  93
SQL_SUBQUERIES                  =  95
SQL_UNION                       =  96
SQL_MAX_ROW_SIZE_INCLUDES_LONG  =  103
SQL_MAX_CHAR_LITERAL_LEN        =  108
SQL_TIMEDATE_ADD_INTERVALS      =  109
SQL_TIMEDATE_DIFF_INTERVALS     =  110
SQL_NEED_LONG_DATA_LEN          =  111
SQL_MAX_BINARY_LITERAL_LEN      =  112
SQL_LIKE_ESCAPE_CLAUSE          =  113
SQL_QUALIFIER_LOCATION          =  114
SQL_ACTIVE_ENVIRONMENTS         =  116
SQL_ALTER_DOMAIN                =  117
SQL_SQL_CONFORMANCE             =  118
SQL_DATETIME_LITERALS           =  119
SQL_ASYNC_MODE                  =  10021
SQL_BATCH_ROW_COUNT             =  120
SQL_BATCH_SUPPORT               =  121
SQL_CATALOG_LOCATION            =  SQL_QUALIFIER_LOCATION
SQL_CATALOG_NAME_SEPARATOR      =  SQL_QUALIFIER_NAME_SEPARATOR
SQL_CATALOG_TERM                =  SQL_QUALIFIER_TERM
SQL_CATALOG_USAGE               =  SQL_QUALIFIER_USAGE
SQL_CONVERT_WCHAR               =  122
SQL_CONVERT_INTERVAL_DAY_TIME   =  123
SQL_CONVERT_INTERVAL_YEAR_MONTH =  124
SQL_CONVERT_WLONGVARCHAR        =  125
SQL_CONVERT_WVARCHAR            =  126
SQL_CREATE_ASSERTION            =  127
SQL_CREATE_CHARACTER_SET        =  128
SQL_CREATE_COLLATION            =  129
SQL_CREATE_DOMAIN               =  130
SQL_CREATE_SCHEMA               =  131
SQL_CREATE_TABLE                =  132
SQL_CREATE_TRANSLATION          =  133
SQL_CREATE_VIEW                 =  134
SQL_DRIVER_HDESC                =  135
SQL_DROP_ASSERTION              =  136
SQL_DROP_CHARACTER_SET          =  137
SQL_DROP_COLLATION              =  138
SQL_DROP_DOMAIN                 =  139
SQL_DROP_SCHEMA                 =  140
SQL_DROP_TABLE                  =  141
SQL_DROP_TRANSLATION            =  142
SQL_DROP_VIEW                   =  143
SQL_DYNAMIC_CURSOR_ATTRIBUTES1  =  144
SQL_DYNAMIC_CURSOR_ATTRIBUTES2  =  145
SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 =  146
SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 =  147
SQL_INDEX_KEYWORDS              =  148
SQL_INFO_SCHEMA_VIEWS           =  149
SQL_KEYSET_CURSOR_ATTRIBUTES1   =  150
SQL_KEYSET_CURSOR_ATTRIBUTES2   =  151
SQL_MAX_ASYNC_CONCURRENT_STATEMENTS =  10022
SQL_ODBC_INTERFACE_CONFORMANCE  =  152
SQL_PARAM_ARRAY_ROW_COUNTS      =  153
SQL_PARAM_ARRAY_SELECTS         =  154
SQL_SCHEMA_TERM                 =  SQL_OWNER_TERM
SQL_SCHEMA_USAGE                =  SQL_OWNER_USAGE
SQL_SQL92_DATETIME_FUNCTIONS    =  155
SQL_SQL92_FOREIGN_KEY_DELETE_RULE =  156
SQL_SQL92_FOREIGN_KEY_UPDATE_RULE =  157
SQL_SQL92_GRANT                 =  158
SQL_SQL92_NUMERIC_VALUE_FUNCTIONS =  159
SQL_SQL92_PREDICATES            =  160
SQL_SQL92_RELATIONAL_JOIN_OPERATORS =  161
SQL_SQL92_REVOKE                =  162
SQL_SQL92_ROW_VALUE_CONSTRUCTOR =  163
SQL_SQL92_STRING_FUNCTIONS      =  164
SQL_SQL92_VALUE_EXPRESSIONS     =  165
SQL_STANDARD_CLI_CONFORMANCE    =  166
SQL_STATIC_CURSOR_ATTRIBUTES1   =  167
SQL_STATIC_CURSOR_ATTRIBUTES2   =  168
SQL_AGGREGATE_FUNCTIONS         =  169
SQL_DDL_INDEX                   =  170
SQL_DM_VER                      =  171
SQL_INSERT_STATEMENT            =  172
SQL_UNION_STATEMENT             =  SQL_UNION
SQL_DTC_TRANSITION_COST         =  1750
SQL_AT_ADD_COLUMN_SINGLE        =  20h
SQL_CVT_CHAR                    =  1
SQL_CVT_NUMERIC                 =  2
SQL_CVT_DECIMAL                 =  4
SQL_CVT_INTEGER                 =  8
SQL_CVT_SMALLINT                =  10h
SQL_CVT_FLOAT                   =  20h
SQL_CVT_REAL                    =  40h
SQL_CVT_DOUBLE                  =  80h
SQL_CVT_VARCHAR                 =  100h
SQL_CVT_LONGVARCHAR             =  200h
SQL_CVT_BINARY                  =  400h
SQL_CVT_VARBINARY               =  800h
SQL_CVT_BIT                     =  1000h
SQL_CVT_TINYINT                 =  2000h
SQL_CVT_BIGINT                  =  4000h
SQL_CVT_DATE                    =  8000h
SQL_CVT_TIME                    =  10000h
SQL_CVT_TIMESTAMP               =  20000h
SQL_CVT_LONGVARBINARY           =  40000h
SQL_CVT_INTERVAL_YEAR_MONTH     =  80000h
SQL_CVT_INTERVAL_DAY_TIME       =  100000h
SQL_CVT_WCHAR                   =  200000h
SQL_CVT_WLONGVARCHAR            =  400000h
SQL_CVT_WVARCHAR                =  800000h
SQL_FN_CVT_CONVERT              =  1
SQL_FN_CVT_CAST                 =  2
SQL_FN_STR_CONCAT               =  1
SQL_FN_STR_INSERT               =  2
SQL_FN_STR_LEFT                 =  4
SQL_FN_STR_LTRIM                =  8
SQL_FN_STR_LENGTH               =  10h
SQL_FN_STR_LOCATE               =  20h
SQL_FN_STR_LCASE                =  40h
SQL_FN_STR_REPEAT               =  80h
SQL_FN_STR_REPLACE              =  100h
SQL_FN_STR_RIGHT                =  200h
SQL_FN_STR_RTRIM                =  400h
SQL_FN_STR_SUBSTRING            =  800h
SQL_FN_STR_UCASE                =  1000h
SQL_FN_STR_ASCII                =  2000h
SQL_FN_STR_CHAR                 =  4000h
SQL_FN_STR_DIFFERENCE           =  8000h
SQL_FN_STR_LOCATE_2             =  10000h
SQL_FN_STR_SOUNDEX              =  20000h
SQL_FN_STR_SPACE                =  40000h
SQL_FN_STR_BIT_LENGTH           =  80000h
SQL_FN_STR_CHAR_LENGTH          =  100000h
SQL_FN_STR_CHARACTER_LENGTH     =  200000h
SQL_FN_STR_OCTET_LENGTH         =  400000h
SQL_FN_STR_POSITION             =  800000h
SQL_SSF_CONVERT                 =  1
SQL_SSF_LOWER                   =  2
SQL_SSF_UPPER                   =  4
SQL_SSF_SUBSTRING               =  8
SQL_SSF_TRANSLATE               =  10h
SQL_SSF_TRIM_BOTH               =  20h
SQL_SSF_TRIM_LEADING            =  40h
SQL_SSF_TRIM_TRAILING           =  80h
SQL_FN_NUM_ABS                  =  1
SQL_FN_NUM_ACOS                 =  2
SQL_FN_NUM_ASIN                 =  4
SQL_FN_NUM_ATAN                 =  8
SQL_FN_NUM_ATAN2                =  10h
SQL_FN_NUM_CEILING              =  20h
SQL_FN_NUM_COS                  =  40h
SQL_FN_NUM_COT                  =  80h
SQL_FN_NUM_EXP                  =  100h
SQL_FN_NUM_FLOOR                =  200h
SQL_FN_NUM_LOG                  =  400h
SQL_FN_NUM_MOD                  =  800h
SQL_FN_NUM_SIGN                 =  1000h
SQL_FN_NUM_SIN                  =  2000h
SQL_FN_NUM_SQRT                 =  4000h
SQL_FN_NUM_TAN                  =  8000h
SQL_FN_NUM_PI                   =  10000h
SQL_FN_NUM_RAND                 =  20000h
SQL_FN_NUM_DEGREES              =  40000h
SQL_FN_NUM_LOG10                =  80000h
SQL_FN_NUM_POWER                =  100000h
SQL_FN_NUM_RADIANS              =  200000h
SQL_FN_NUM_ROUND                =  400000h
SQL_FN_NUM_TRUNCATE             =  800000h
SQL_SNVF_BIT_LENGTH             =  1
SQL_SNVF_CHAR_LENGTH            =  2
SQL_SNVF_CHARACTER_LENGTH       =  4
SQL_SNVF_EXTRACT                =  8
SQL_SNVF_OCTET_LENGTH           =  10h
SQL_SNVF_POSITION               =  20h
SQL_FN_TD_NOW                   =  1
SQL_FN_TD_CURDATE               =  2
SQL_FN_TD_DAYOFMONTH            =  4
SQL_FN_TD_DAYOFWEEK             =  8
SQL_FN_TD_DAYOFYEAR             =  10h
SQL_FN_TD_MONTH                 =  20h
SQL_FN_TD_QUARTER               =  40h
SQL_FN_TD_WEEK                  =  80h
SQL_FN_TD_YEAR                  =  100h
SQL_FN_TD_CURTIME               =  200h
SQL_FN_TD_HOUR                  =  400h
SQL_FN_TD_MINUTE                =  800h
SQL_FN_TD_SECOND                =  1000h
SQL_FN_TD_TIMESTAMPADD          =  2000h
SQL_FN_TD_TIMESTAMPDIFF         =  4000h
SQL_FN_TD_DAYNAME               =  8000h
SQL_FN_TD_MONTHNAME             =  10000h
SQL_FN_TD_CURRENT_DATE          =  20000h
SQL_FN_TD_CURRENT_TIME          =  40000h
SQL_FN_TD_CURRENT_TIMESTAMP     =  80000h
SQL_FN_TD_EXTRACT               =  100000h
SQL_SDF_CURRENT_DATE            =  1
SQL_SDF_CURRENT_TIME            =  2
SQL_SDF_CURRENT_TIMESTAMP       =  4
SQL_FN_SYS_USERNAME             =  1
SQL_FN_SYS_DBNAME               =  2
SQL_FN_SYS_IFNULL               =  4
SQL_FN_TSI_FRAC_SECOND          =  1
SQL_FN_TSI_SECOND               =  2
SQL_FN_TSI_MINUTE               =  4
SQL_FN_TSI_HOUR                 =  8
SQL_FN_TSI_DAY                  =  10h
SQL_FN_TSI_WEEK                 =  20h
SQL_FN_TSI_MONTH                =  40h
SQL_FN_TSI_QUARTER              =  80h
SQL_FN_TSI_YEAR                 =  100h
SQL_CA1_NEXT                    =  1
SQL_CA1_ABSOLUTE                =  2
SQL_CA1_RELATIVE                =  4
SQL_CA1_BOOKMARK                =  8
SQL_CA1_LOCK_NO_CHANGE          =  40h
SQL_CA1_LOCK_EXCLUSIVE          =  80h
SQL_CA1_LOCK_UNLOCK             =  100h
SQL_CA1_POS_POSITION            =  200h
SQL_CA1_POS_UPDATE              =  400h
SQL_CA1_POS_DELETE              =  800h
SQL_CA1_POS_REFRESH             =  1000h
SQL_CA1_POSITIONED_UPDATE       =  2000h
SQL_CA1_POSITIONED_DELETE       =  4000h
SQL_CA1_SELECT_FOR_UPDATE       =  8000h
SQL_CA1_BULK_ADD                =  10000h
SQL_CA1_BULK_UPDATE_BY_BOOKMARK =  20000h
SQL_CA1_BULK_DELETE_BY_BOOKMARK =  40000h
SQL_CA1_BULK_FETCH_BY_BOOKMARK  =  80000h
SQL_CA2_READ_ONLY_CONCURRENCY   =  1
SQL_CA2_LOCK_CONCURRENCY        =  2
SQL_CA2_OPT_ROWVER_CONCURRENCY  =  4
SQL_CA2_OPT_VALUES_CONCURRENCY  =  8
SQL_CA2_SENSITIVITY_ADDITIONS   =  10h
SQL_CA2_SENSITIVITY_DELETIONS   =  20h
SQL_CA2_SENSITIVITY_UPDATES     =  40h
SQL_CA2_MAX_ROWS_SELECT         =  80h
SQL_CA2_MAX_ROWS_INSERT         =  100h
SQL_CA2_MAX_ROWS_DELETE         =  200h
SQL_CA2_MAX_ROWS_UPDATE         =  400h
SQL_CA2_MAX_ROWS_CATALOG        =  800h
SQL_CA2_MAX_ROWS_AFFECTS_ALL    =  SQL_CA2_MAX_ROWS_SELECT + \
                                   SQL_CA2_MAX_ROWS_INSERT + \
                                   SQL_CA2_MAX_ROWS_DELETE + \
                                   SQL_CA2_MAX_ROWS_UPDATE + \
                                   SQL_CA2_MAX_ROWS_CATALOG
SQL_CA2_CRC_EXACT               =  1000h
SQL_CA2_CRC_APPROXIMATE         =  2000h
SQL_CA2_SIMULATE_NON_UNIQUE     =  4000h
SQL_CA2_SIMULATE_TRY_UNIQUE     =  8000h
SQL_CA2_SIMULATE_UNIQUE         =  10000h
SQL_OAC_NONE                    =  0
SQL_OAC_LEVEL1                  =  1
SQL_OAC_LEVEL2                  =  2
SQL_OSCC_NOT_COMPLIANT          =  0
SQL_OSCC_COMPLIANT              =  1
SQL_OSC_MINIMUM                 =  0
SQL_OSC_CORE                    =  1
SQL_OSC_EXTENDED                =  2
SQL_CB_NULL                     =  0
SQL_CB_NON_NULL                 =  1
SQL_SO_FORWARD_ONLY             =  1
SQL_SO_KEYSET_DRIVEN            =  2
SQL_SO_DYNAMIC                  =  4
SQL_SO_MIXED                    =  8
SQL_SO_STATIC                   =  10h
SQL_FD_FETCH_BOOKMARK           =  80h
SQL_CN_NONE                     =  0
SQL_CN_DIFFERENT                =  1
SQL_CN_ANY                      =  2
SQL_NNC_NULL                    =  0
SQL_NNC_NON_NULL                =  1
SQL_NC_START                    =  2
SQL_NC_END                      =  4
SQL_FILE_NOT_SUPPORTED          =  0
SQL_FILE_TABLE                  =  1
SQL_FILE_QUALIFIER              =  2
SQL_FILE_CATALOG                =  SQL_FILE_QUALIFIER
SQL_GD_BLOCK                    =  4
SQL_GD_BOUND                    =  8
SQL_PS_POSITIONED_DELETE        =  1
SQL_PS_POSITIONED_UPDATE        =  2
SQL_PS_SELECT_FOR_UPDATE        =  4
SQL_GB_NOT_SUPPORTED            =  0

ALS_SELECT                      =  1
SQL_GB_GROUP_BY_ = ALS_SELECT

SQL_GB_GROUP_BY_CONTAINS_SELECT =  2
SQL_GB_NO_RELATION              =  3
SQL_GB_COLLATE                  =  4
SQL_OU_DML_STATEMENTS           =  1
SQL_OU_PROCEDURE_INVOCATION     =  2
SQL_OU_TABLE_DEFINITION         =  4
SQL_OU_INDEX_DEFINITION         =  8
SQL_OU_PRIVILEGE_DEFINITION     =  10h
SQL_SU_DML_STATEMENTS           =  SQL_OU_DML_STATEMENTS
SQL_SU_PROCEDURE_INVOCATION     =  SQL_OU_PROCEDURE_INVOCATION
SQL_SU_TABLE_DEFINITION         =  SQL_OU_TABLE_DEFINITION
SQL_SU_INDEX_DEFINITION         =  SQL_OU_INDEX_DEFINITION
SQL_SU_PRIVILEGE_DEFINITION     =  SQL_OU_PRIVILEGE_DEFINITION
SQL_QU_DML_STATEMENTS           =  1
SQL_QU_PROCEDURE_INVOCATION     =  2
SQL_QU_TABLE_DEFINITION         =  4
SQL_QU_INDEX_DEFINITION         =  8
SQL_QU_PRIVILEGE_DEFINITION     =  10h
SQL_CU_DML_STATEMENTS           =  SQL_QU_DML_STATEMENTS
SQL_CU_PROCEDURE_INVOCATION     =  SQL_QU_PROCEDURE_INVOCATION
SQL_CU_TABLE_DEFINITION         =  SQL_QU_TABLE_DEFINITION
SQL_CU_INDEX_DEFINITION         =  SQL_QU_INDEX_DEFINITION
SQL_CU_PRIVILEGE_DEFINITION     =  SQL_QU_PRIVILEGE_DEFINITION
SQL_SQ_COMPARISON               =  1
SQL_SQ_EXISTS                   =  2
SQL_SQ_IN                       =  4
SQL_SQ_QUANTIFIED               =  8
SQL_SQ_CORRELATED_SUBQUERIES    =  10h
SQL_U_UNION                     =  1
SQL_U_UNION_ALL                 =  2
SQL_BP_CLOSE                    =  1
SQL_BP_DELETE                   =  2
SQL_BP_DROP                     =  4
SQL_BP_TRANSACTION              =  8
SQL_BP_UPDATE                   =  10h
SQL_BP_OTHER_HSTMT              =  20h
SQL_BP_SCROLL                   =  40h
SQL_SS_ADDITIONS                =  1
SQL_SS_DELETIONS                =  2
SQL_SS_UPDATES                  =  4
SQL_CV_CREATE_VIEW              =  1
SQL_CV_CHECK_OPTION             =  2
SQL_CV_CASCADED                 =  4
SQL_CV_LOCAL                    =  8
SQL_LCK_NO_CHANGE               =  1
SQL_LCK_EXCLUSIVE               =  2
SQL_LCK_UNLOCK                  =  4
SQL_POS_POSITION                =  1
SQL_POS_REFRESH                 =  2
SQL_POS_UPDATE                  =  4
SQL_POS_DELETE                  =  8
SQL_POS_ADD                     =  10h
SQL_QL_START                    =  1
SQL_QL_END                      =  2
SQL_AF_AVG                      =  1
SQL_AF_COUNT                    =  2
SQL_AF_MAX                      =  4
SQL_AF_MIN                      =  8
SQL_AF_SUM                      =  10h
SQL_AF_DISTINCT                 =  20h
SQL_AF_ALL                      =  40h
SQL_SC_SQL92_ENTRY              =  1
SQL_SC_FIPS127_2_TRANSITIONAL   =  2
SQL_SC_SQL92_INTERMEDIATE       =  4
SQL_SC_SQL92_FULL               =  8
SQL_DL_SQL92_DATE               =  1
SQL_DL_SQL92_TIME               =  2
SQL_DL_SQL92_TIMESTAMP          =  4
SQL_DL_SQL92_INTERVAL_YEAR      =  8
SQL_DL_SQL92_INTERVAL_MONTH     =  10h
SQL_DL_SQL92_INTERVAL_DAY       =  20h
SQL_DL_SQL92_INTERVAL_HOUR      =  40h
SQL_DL_SQL92_INTERVAL_MINUTE    =  80h
SQL_DL_SQL92_INTERVAL_SECOND    =  100h
SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH =  200h
SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR   =  400h
SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE =  800h
SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND =  1000h
SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE =  2000h
SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND =  4000h
SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND =  8000h
SQL_CL_START                    =  SQL_QL_START
SQL_CL_END                      =  SQL_QL_END
SQL_BRC_PROCEDURES              =  1
SQL_BRC_EXPLICIT                =  2
SQL_BRC_ROLLED_UP               =  4
SQL_BS_SELECT_EXPLICIT          =  1
SQL_BS_ROW_COUNT_EXPLICIT       =  2
SQL_BS_SELECT_PROC              =  4
SQL_BS_ROW_COUNT_PROC           =  8
SQL_PARC_BATCH                  =  1
SQL_PARC_NO_BATCH               =  2
SQL_PAS_BATCH                   =  1
SQL_PAS_NO_BATCH                =  2
SQL_PAS_NO_SELECT               =  3
SQL_IK_NONE                     =  0
SQL_IK_ASC                      =  1
SQL_IK_DESC                     =  2
SQL_IK_ALL                      =  SQL_IK_ASC + SQL_IK_DESC
SQL_ISV_ASSERTIONS              =  1
SQL_ISV_CHARACTER_SETS          =  2
SQL_ISV_CHECK_CONSTRAINTS       =  4
SQL_ISV_COLLATIONS              =  8
SQL_ISV_COLUMN_DOMAIN_USAGE     =  10h
SQL_ISV_COLUMN_PRIVILEGES       =  20h
SQL_ISV_COLUMNS                 =  40h
SQL_ISV_CONSTRAINT_COLUMN_USAGE =  80h
SQL_ISV_CONSTRAINT_TABLE_USAGE  =  100h
SQL_ISV_DOMAIN_CONSTRAINTS      =  200h
SQL_ISV_DOMAINS                 =  400h
SQL_ISV_KEY_COLUMN_USAGE        =  800h
SQL_ISV_REFERENTIAL_CONSTRAINTS =  1000h
SQL_ISV_SCHEMATA                =  2000h
SQL_ISV_SQL_LANGUAGES           =  4000h
SQL_ISV_TABLE_CONSTRAINTS       =  8000h
SQL_ISV_TABLE_PRIVILEGES        =  10000h
SQL_ISV_TABLES                  =  20000h
SQL_ISV_TRANSLATIONS            =  40000h
SQL_ISV_USAGE_PRIVILEGES        =  80000h
SQL_ISV_VIEW_COLUMN_USAGE       =  100000h
SQL_ISV_VIEW_TABLE_USAGE        =  200000h
SQL_ISV_VIEWS                   =  400000h
SQL_AM_NONE                     =  0
SQL_AD_CONSTRAINT_NAME_DEFINITION =  1
SQL_AD_ADD_DOMAIN_CONSTRAINT    =  2
SQL_AD_DROP_DOMAIN_CONSTRAINT   =  4
SQL_AD_ADD_DOMAIN_DEFAULT       =  8
SQL_AD_DROP_DOMAIN_DEFAULT      =  10h
SQL_AD_ADD_CONSTRAINT_INITIALLY_DEFERRED =  20h
SQL_AD_ADD_CONSTRAINT_INITIALLY_IMMEDIATE =  40h
SQL_AD_ADD_CONSTRAINT_DEFERRABLE =  80h
SQL_AD_ADD_CONSTRAINT_NON_DEFERRABLE =  100h
SQL_CS_CREATE_SCHEMA            =  1
SQL_CS_AUTHORIZATION            =  2
SQL_CS_DEFAULT_CHARACTER_SET    =  4
SQL_CTR_CREATE_TRANSLATION      =  1
SQL_CA_CREATE_ASSERTION         =  1
SQL_CA_CONSTRAINT_INITIALLY_DEFERRED =  10h
SQL_CA_CONSTRAINT_INITIALLY_IMMEDIATE =  20h
SQL_CA_CONSTRAINT_DEFERRABLE    =  40h
SQL_CA_CONSTRAINT_NON_DEFERRABLE =  80h
SQL_CCS_CREATE_CHARACTER_SET    =  1
SQL_CCS_COLLATE_CLAUSE          =  2
SQL_CCS_LIMITED_COLLATION       =  4
SQL_CCOL_CREATE_COLLATION       =  1
SQL_CDO_CREATE_DOMAIN           =  1
SQL_CDO_DEFAULT                 =  2
SQL_CDO_CONSTRAINT              =  4
SQL_CDO_COLLATION               =  8
SQL_CDO_CONSTRAINT_NAME_DEFINITION =  10h
SQL_CDO_CONSTRAINT_INITIALLY_DEFERRED =  20h
SQL_CDO_CONSTRAINT_INITIALLY_IMMEDIATE =  40h
SQL_CDO_CONSTRAINT_DEFERRABLE   =  80h
SQL_CDO_CONSTRAINT_NON_DEFERRABLE =  100h
SQL_CT_CREATE_TABLE             =  1
SQL_CT_COMMIT_PRESERVE          =  2
SQL_CT_COMMIT_DELETE            =  4
SQL_CT_GLOBAL_TEMPORARY         =  8
SQL_CT_LOCAL_TEMPORARY          =  10h
SQL_CT_CONSTRAINT_INITIALLY_DEFERRED =  20h
SQL_CT_CONSTRAINT_INITIALLY_IMMEDIATE =  40h
SQL_CT_CONSTRAINT_DEFERRABLE    =  80h
SQL_CT_CONSTRAINT_NON_DEFERRABLE =  100h
SQL_CT_COLUMN_CONSTRAINT        =  200h
SQL_CT_COLUMN_DEFAULT           =  400h
SQL_CT_COLUMN_COLLATION         =  800h
SQL_CT_TABLE_CONSTRAINT         =  1000h
SQL_CT_CONSTRAINT_NAME_DEFINITION =  2000h
SQL_DI_CREATE_INDEX             =  1
SQL_DI_DROP_INDEX               =  2
SQL_DC_DROP_COLLATION           =  1
SQL_DD_DROP_DOMAIN              =  1
SQL_DD_RESTRICT                 =  2
SQL_DD_CASCADE                  =  4
SQL_DS_DROP_SCHEMA              =  1
SQL_DS_RESTRICT                 =  2
SQL_DS_CASCADE                  =  4
SQL_DCS_DROP_CHARACTER_SET      =  1
SQL_DA_DROP_ASSERTION           =  1
SQL_DT_DROP_TABLE               =  1
SQL_DT_RESTRICT                 =  2
SQL_DT_CASCADE                  =  4
SQL_DTR_DROP_TRANSLATION        =  1
SQL_DV_DROP_VIEW                =  1
SQL_DV_RESTRICT                 =  2
SQL_DV_CASCADE                  =  4
SQL_IS_INSERT_LITERALS          =  1
SQL_IS_INSERT_SEARCHED          =  2
SQL_IS_SELECT_INTO              =  4
SQL_OIC_CORE                    =  1
SQL_OIC_LEVEL1                  =  2
SQL_OIC_LEVEL2                  =  3
SQL_SFKD_CASCADE                =  1
SQL_SFKD_NO_ACTION              =  2
SQL_SFKD_SET_DEFAULT            =  4
SQL_SFKD_SET_NULL               =  8
SQL_SFKU_CASCADE                =  1
SQL_SFKU_NO_ACTION              =  2
SQL_SFKU_SET_DEFAULT            =  4
SQL_SFKU_SET_NULL               =  8
SQL_SG_USAGE_ON_DOMAIN          =  1
SQL_SG_USAGE_ON_CHARACTER_SET   =  2
SQL_SG_USAGE_ON_COLLATION       =  4
SQL_SG_USAGE_ON_TRANSLATION     =  8
SQL_SG_WITH_GRANT_OPTION        =  10h
SQL_SG_DELETE_TABLE             =  20h
SQL_SG_INSERT_TABLE             =  40h
SQL_SG_INSERT_COLUMN            =  80h
SQL_SG_REFERENCES_TABLE         =  100h
SQL_SG_REFERENCES_COLUMN        =  200h
SQL_SG_SELECT_TABLE             =  400h
SQL_SG_UPDATE_TABLE             =  800h
SQL_SG_UPDATE_COLUMN            =  1000h
SQL_SP_EXISTS                   =  1
SQL_SP_ISNOTNULL                =  2
SQL_SP_ISNULL                   =  4
SQL_SP_MATCH_FULL               =  8
SQL_SP_MATCH_PARTIAL            =  10h
SQL_SP_MATCH_UNIQUE_FULL        =  20h
SQL_SP_MATCH_UNIQUE_PARTIAL     =  40h
SQL_SP_OVERLAPS                 =  80h
SQL_SP_UNIQUE                   =  100h
SQL_SP_LIKE                     =  200h
SQL_SP_IN                       =  400h
SQL_SP_BETWEEN                  =  800h
SQL_SP_COMPARISON               =  1000h
SQL_SP_QUANTIFIED_COMPARISON    =  2000h
SQL_SRJO_CORRESPONDING_CLAUSE   =  1
SQL_SRJO_CROSS_JOIN             =  2
SQL_SRJO_EXCEPT_JOIN            =  4
SQL_SRJO_FULL_OUTER_JOIN        =  8
SQL_SRJO_INNER_JOIN             =  10h
SQL_SRJO_INTERSECT_JOIN         =  20h
SQL_SRJO_LEFT_OUTER_JOIN        =  40h
SQL_SRJO_NATURAL_JOIN           =  80h
SQL_SRJO_RIGHT_OUTER_JOIN       =  100h
SQL_SRJO_UNION_JOIN             =  200h
SQL_SR_USAGE_ON_DOMAIN          =  1
SQL_SR_USAGE_ON_CHARACTER_SET   =  2
SQL_SR_USAGE_ON_COLLATION       =  4
SQL_SR_USAGE_ON_TRANSLATION     =  8
SQL_SR_GRANT_OPTION_FOR         =  10h
SQL_SR_CASCADE                  =  20h
SQL_SR_RESTRICT                 =  40h
SQL_SR_DELETE_TABLE             =  80h
SQL_SR_INSERT_TABLE             =  100h
SQL_SR_INSERT_COLUMN            =  200h
SQL_SR_REFERENCES_TABLE         =  400h
SQL_SR_REFERENCES_COLUMN        =  800h
SQL_SR_SELECT_TABLE             =  1000h
SQL_SR_UPDATE_TABLE             =  2000h
SQL_SR_UPDATE_COLUMN            =  4000h
SQL_SRVC_VALUE_EXPRESSION       =  1
SQL_SRVC_NULL                   =  2
SQL_SRVC_DEFAULT                =  4
SQL_SRVC_ROW_SUBQUERY           =  8
SQL_SVE_CASE                    =  1
SQL_SVE_CAST                    =  2
SQL_SVE_COALESCE                =  4
SQL_SVE_NULLIF                  =  8
SQL_SCC_XOPEN_CLI_VERSION1      =  1
SQL_SCC_ISO92_CLI               =  2
SQL_US_UNION                    =  SQL_U_UNION
SQL_US_UNION_ALL                =  SQL_U_UNION_ALL
SQL_DTC_ENLIST_EXPENSIVE        =  1
SQL_DTC_UNENLIST_EXPENSIVE      =  2
SQL_FETCH_FIRST_USER            =  31
SQL_FETCH_FIRST_SYSTEM          =  32
SQL_ENTIRE_ROWSET               =  0
SQL_POSITION                    =  0
SQL_REFRESH                     =  1
SQL_UPDATE                      =  2
SQL_DELETE                      =  3
SQL_ADD                         =  4
SQL_SETPOS_MAX_OPTION_VALUE     =  SQL_ADD
SQL_UPDATE_BY_BOOKMARK          =  5
SQL_DELETE_BY_BOOKMARK          =  6
SQL_FETCH_BY_BOOKMARK           =  7
SQL_LOCK_NO_CHANGE              =  0
SQL_LOCK_EXCLUSIVE              =  1
SQL_LOCK_UNLOCK                 =  2
SQL_SETPOS_MAX_LOCK_VALUE       =  SQL_LOCK_UNLOCK
SQL_BEST_ROWID                  =  1
SQL_ROWVER                      =  2
SQL_PC_NOT_PSEUDO               =  1
SQL_QUICK                       =  0
SQL_ENSURE                      =  1
SQL_TABLE_STAT                  =  0

SQL_ALL_CATALOGS  equ  "%"
SQL_ALL_SCHEMAS  equ  "%"
SQL_ALL_TABLE_TYPES equ  "%"

SQL_DRIVER_NOPROMPT             =  0
SQL_DRIVER_COMPLETE             =  1
SQL_DRIVER_PROMPT               =  2
IRED  =  3
SQL_DRIVER_COMPLETE_R = IRED

SQL_FETCH_BOOKMARK              =  8
SQL_ROW_SUCCESS                 =  0
SQL_ROW_DELETED                 =  1
SQL_ROW_UPDATED                 =  2
SQL_ROW_NOROW                   =  3
SQL_ROW_ADDED                   =  4
SQL_ROW_ERROR                   =  5
SQL_ROW_SUCCESS_WITH_INFO       =  6
SQL_ROW_PROCEED                 =  0
SQL_ROW_IGNORE                  =  1
SQL_PARAM_SUCCESS               =  0
SQL_PARAM_SUCCESS_WITH_INFO     =  6
SQL_PARAM_ERROR                 =  5
SQL_PARAM_UNUSED                =  7
SQL_PARAM_DIAG_UNAVAILABLE      =  1
SQL_PARAM_PROCEED               =  0
SQL_PARAM_IGNORE                =  1
SQL_CASCADE                     =  0
SQL_RESTRICT                    =  1
SQL_SET_NULL                    =  2
SQL_NO_ACTION                   =  3
SQL_SET_DEFAULT                 =  4
SQL_INITIALLY_DEFERRED          =  5
SQL_INITIALLY_IMMEDIATE         =  6
SQL_NOT_DEFERRABLE              =  7
SQL_PARAM_TYPE_UNKNOWN          =  0
SQL_PARAM_INPUT                 =  1
SQL_PARAM_INPUT_OUTPUT          =  2
SQL_RESULT_COL                  =  3
SQL_PARAM_OUTPUT                =  4
SQL_RETURN_VALUE                =  5
SQL_PT_UNKNOWN                  =  0
SQL_PT_PROCEDURE                =  1
SQL_PT_FUNCTION                 =  2
SQL_YEAR                        =  SQL_CODE_YEAR
SQL_MONTH                       =  SQL_CODE_MONTH
SQL_DAY                         =  SQL_CODE_DAY
SQL_HOUR                        =  SQL_CODE_HOUR
SQL_MINUTE                      =  SQL_CODE_MINUTE
SQL_SECOND                      =  SQL_CODE_SECOND
SQL_YEAR_TO_MONTH               =  SQL_CODE_YEAR_TO_MONTH
SQL_DAY_TO_HOUR                 =  SQL_CODE_DAY_TO_HOUR
SQL_DAY_TO_MINUTE               =  SQL_CODE_DAY_TO_MINUTE
SQL_DAY_TO_SECOND               =  SQL_CODE_DAY_TO_SECOND
SQL_HOUR_TO_MINUTE              =  SQL_CODE_HOUR_TO_MINUTE
SQL_HOUR_TO_SECOND              =  SQL_CODE_HOUR_TO_SECOND
SQL_MINUTE_TO_SECOND            =  SQL_CODE_MINUTE_TO_SECOND
SQL_DATABASE_NAME               =  16
SQL_FD_FETCH_PREV               =  SQL_FD_FETCH_PRIOR
SQL_FETCH_PREV                  =  SQL_FETCH_PRIOR
SQL_CONCUR_TIMESTAMP            =  SQL_CONCUR_ROWVER
SQL_SCCO_OPT_TIMESTAMP          =  SQL_SCCO_OPT_ROWVER
SQL_CC_DELETE                   =  SQL_CB_DELETE
SQL_CR_DELETE                   =  SQL_CB_DELETE
SQL_CC_CLOSE                    =  SQL_CB_CLOSE
SQL_CR_CLOSE                    =  SQL_CB_CLOSE
SQL_CC_PRESERVE                 =  SQL_CB_PRESERVE
SQL_CR_PRESERVE                 =  SQL_CB_PRESERVE
SQL_SCROLL_FORWARD_ONLY         =  0
SQL_SCROLL_KEYSET_DRIVEN        =  -1
SQL_SCROLL_DYNAMIC              =  -2
SQL_SCROLL_STATIC               =  -3
TRACE_VERSION                   =  1000
TRACE_ON                        =  1
TRACE_VS_EVENT_ON               =  2
ODBC_VS_FLAG_UNICODE_ARG        =  1
ODBC_VS_FLAG_UNICODE_COR        =  2
ODBC_VS_FLAG_RETCODE            =  4
ODBC_VS_FLAG_STOP               =  8



struct DATESTRUCT
  .year  dw ?
  .month dw ?
  .day   dw ?
ends

SQL_DATE_STRUCT  equ  DATESTRUCT

struct TIME_STRUCT
  .hour   dw ?
  .minute dw ?
  .second dw ?
ends

SQL_TIME_STRUCT  equ  TIME_STRUCT

struct TIMESTAMPSTRUCT
  .year     dw ?
  .month    dw ?
  .day      dw ?
  .hour     dw ?
  .minute   dw ?
  .second   dw ?
  .fraction dd ?
ends

SQL_TIMESTAMP_STRUCT  equ  TIMESTAMPSTRUCT


SQL_IS_YEAR             =  1
SQL_IS_MONTH            =  2
SQL_IS_DAY              =  3
SQL_IS_HOUR             =  4
SQL_IS_MINUTE           =  5
SQL_IS_SECOND           =  6
SQL_IS_YEAR_TO_MONTH    =  7
SQL_IS_DAY_TO_HOUR      =  8
SQL_IS_DAY_TO_MINUTE    =  9
SQL_IS_DAY_TO_SECOND    =  10
SQL_IS_HOUR_TO_MINUTE   =  11
SQL_IS_HOUR_TO_SECOND   =  12
SQL_IS_MINUTE_TO_SECOND =  13

struct SQL_YEAR_MONTH_STRUCT
  .year  dw ?
  .month dw ?
ends


struct SQL_DAY_SECOND_STRUCT
  .day      dw ?
  .hour     dw ?
  .minute   dw ?
  .second   dw ?
  .fraction dw ?
ends


SQL_MAX_NUMERIC_LEN  =  16

struct SQL_NUMERIC_STRUCT
  .precision db ?
  .scale     db ?
  .sign      db ?
  .val       rb SQL_MAX_NUMERIC_LEN
ends

struct SQLGUID
  .Data1 dd ?
  .Data2 dw ?
  .Data3 dw ?
  .Data4  rb 8
ends
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Win32/_RichEdit32.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: RichEdit32.dll constants and structures.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


MAX_TAB_STOPS = 32


struct CHARFORMAT
  .cbSize          dd ?
  .dwMask          dd ?
  .dwEffects       dd ?
  .yHeight         dd ?
  .yOffset         dd ?
  .crTextColor     dd ?
  .bCharSet        db ?
  .bPitchAndFamily db ?
  .szFaceName      rb 32
  ._wPad2          dw ?
ends


struct CHARFORMAT2
  .cbSize       dd ?
  .dwMask       dd ?
  .dwEffects    dd ?
  .yHeight      dd ?
  .yOffset      dd ?
  .crTextColor  dd ?
  .bCharSet     db ?
  .bPitchAndFamily db ?
  .szFaceName   rb 32
  ._wPad2       dw ?
  .wWeight      dw ?
  .sSpacing     dw ?
  .crBackColor  dd ?
  .lcid         dd ?
  .dwReserved   dd ?
  .sStyle       dw ?
  .wKerning     dw ?
  .bUnderlineType db ?
  .bAnimation     db ?
  .bRevAuthor     db ?
  .bReserved1     db ?
ends


struct SETTEXTEX
  .flags dd ?
  .codepage dd ?
ends

struct CHARRANGE
  .cpMin dd ?
  .cpMax dd ?
ends


struct ENLINK
  .nmhdr   NMHDR
  .msg     dd ?
  .wParam  dd ?
  .lParam  dd ?
  .chrg    CHARRANGE
ends

struct TEXTRANGE
  .chrg      CHARRANGE
  .lpstrText dd ?
ends


struct PARAFORMAT2
  .cbSize           dd  ?
  .dwMask           dd  ?
  .wNumbering       dw  ?
  .wEffects         dw  ?
  .dxStartIndent    dd  ?
  .dxRightIndent    dd  ?
  .dxOffset         dd  ?
  .wAlignment       dw  ?
  .cTabCount        dw  ?
  .rgxTabs          rd  MAX_TAB_STOPS
  .dySpaceBefore    dd  ?
  .dySpaceAfter     dd  ?
  .dyLineSpacing    dd  ?
  .sStyle           dw  ?
  .bLineSpacingRule db  ?
  .bOutlineLevel    db  ?
  .wShadingWeight   dw  ?
  .wShadingStyle    dw  ?
  .wNumberingStart  dw  ?
  .wNumberingStyle  dw  ?
  .wNumberingTab    dw  ?
  .wBorderSpace     dw  ?
  .wBorderWidth     dw  ?
  .wBorders         dw  ?
ends

ES_NOOLEDRAGDROP        = 000000008h
ES_DISABLENOSCROLL      = 000002000h
ES_SUNKEN               = 000004000h
ES_SAVESEL              = 000008000h
ES_SELFIME              = 000040000h
ES_NOIME                = 000080000h
ES_VERTICAL             = 000400000h
ES_SELECTIONBAR         = 001000000h

ES_EX_NOCALLOLEINIT     = 001000000h

EM_CANPASTE             = WM_USER + 50
EM_DISPLAYBAND          = WM_USER + 51
EM_EXGETSEL             = WM_USER + 52
EM_EXLIMITTEXT          = WM_USER + 53
EM_EXLINEFROMCHAR       = WM_USER + 54
EM_EXSETSEL             = WM_USER + 55
EM_FINDTEXT             = WM_USER + 56
EM_FORMATRANGE          = WM_USER + 57
EM_GETCHARFORMAT        = WM_USER + 58
EM_GETEVENTMASK         = WM_USER + 59
EM_GETOLEINTERFACE      = WM_USER + 60
EM_GETPARAFORMAT        = WM_USER + 61
EM_GETSELTEXT           = WM_USER + 62
EM_HIDESELECTION        = WM_USER + 63
EM_PASTESPECIAL         = WM_USER + 64
EM_REQUESTRESIZE        = WM_USER + 65
EM_SELECTIONTYPE        = WM_USER + 66
EM_SETBKGNDCOLOR        = WM_USER + 67
EM_SETCHARFORMAT        = WM_USER + 68
EM_SETEVENTMASK         = WM_USER + 69
EM_SETOLECALLBACK       = WM_USER + 70
EM_SETPARAFORMAT        = WM_USER + 71
EM_SETTARGETDEVICE      = WM_USER + 72
EM_STREAMIN             = WM_USER + 73
EM_STREAMOUT            = WM_USER + 74
EM_GETTEXTRANGE         = WM_USER + 75
EM_FINDWORDBREAK        = WM_USER + 76
EM_SETOPTIONS           = WM_USER + 77
EM_GETOPTIONS           = WM_USER + 78
EM_FINDTEXTEX           = WM_USER + 79
EM_GETWORDBREAKPROCEX   = WM_USER + 80
EM_SETWORDBREAKPROCEX   = WM_USER + 81
EM_SETUNDOLIMIT         = WM_USER + 82
EM_REDO                 = WM_USER + 84
EM_CANREDO              = WM_USER + 85
EM_GETUNDONAME          = WM_USER + 86
EM_GETREDONAME          = WM_USER + 87
EM_STOPGROUPTYPING      = WM_USER + 88
EM_SETTEXTMODE          = WM_USER + 89
EM_GETTEXTMODE          = WM_USER + 90
EM_AUTOURLDETECT        = WM_USER + 91
EM_GETAUTOURLDETECT     = WM_USER + 92
EM_SETPALETTE           = WM_USER + 93
EM_GETTEXTEX            = WM_USER + 94
EM_GETTEXTLENGTHEX      = WM_USER + 95
EM_SHOWSCROLLBAR        = WM_USER + 96
EM_SETTEXTEX            = WM_USER + 97
EM_SETPUNCTUATION       = WM_USER + 100
EM_GETPUNCTUATION       = WM_USER + 101
EM_SETWORDWRAPMODE      = WM_USER + 102
EM_GETWORDWRAPMODE      = WM_USER + 103
EM_SETIMECOLOR          = WM_USER + 104
EM_GETIMECOLOR          = WM_USER + 105
EM_SETIMEOPTIONS        = WM_USER + 106
EM_GETIMEOPTIONS        = WM_USER + 107
EM_CONVPOSITION         = WM_USER + 108
EM_SETLANGOPTIONS       = WM_USER + 120
EM_GETLANGOPTIONS       = WM_USER + 121
EM_GETIMECOMPMODE       = WM_USER + 122
EM_FINDTEXTW            = WM_USER + 123
EM_FINDTEXTEXW          = WM_USER + 124
EM_RECONVERSION         = WM_USER + 125
EM_SETIMEMODEBIAS       = WM_USER + 126
EM_GETIMEMODEBIAS       = WM_USER + 127
EM_SETBIDIOPTIONS       = WM_USER + 200
EM_GETBIDIOPTIONS       = WM_USER + 201
EM_SETTYPOGRAPHYOPTIONS = WM_USER + 202
EM_GETTYPOGRAPHYOPTIONS = WM_USER + 203
EM_SETEDITSTYLE         = WM_USER + 204
EM_GETEDITSTYLE         = WM_USER + 205
EM_OUTLINE              = WM_USER + 220
EM_GETSCROLLPOS         = WM_USER + 221
EM_SETSCROLLPOS         = WM_USER + 222
EM_SETFONTSIZE          = WM_USER + 223
EM_GETZOOM              = WM_USER + 224
EM_SETZOOM              = WM_USER + 225

CFM_BOLD        = 00000001h
CFM_ITALIC      = 00000002h
CFM_UNDERLINE   = 00000004h
CFM_STRIKEOUT   = 00000008h
CFM_PROTECTED   = 00000010h
CFM_LINK        = 00000020h
CFM_SMALLCAPS   = 00000040h
CFM_ALLCAPS     = 00000080h
CFM_HIDDEN      = 00000100h
CFM_OUTLINE     = 00000200h
CFM_SHADOW      = 00000400h
CFM_EMBOSS      = 00000800h
CFM_IMPRINT     = 00001000h
CFM_DISABLED    = 00002000h
CFM_REVISED     = 00004000h
CFM_REVAUTHOR   = 00008000h
CFM_SUBSCRIPT   = CFE_SUBSCRIPT or CFE_SUPERSCRIPT ; = 00030000h
CFM_ANIMATION   = 00040000h
CFM_STYLE       = 00080000h
CFM_KERNING     = 00100000h
CFM_SPACING     = 00200000h
CFM_WEIGHT      = 00400000h
CFM_UNDERLINETYPE=00800000h
;                = 01000000h
CFM_LCID        = 02000000h
CFM_BACKCOLOR   = 04000000h
CFM_CHARSET     = 08000000h
CFM_OFFSET      = 10000000h
CFM_FACE        = 20000000h
CFM_COLOR       = 40000000h
CFM_SIZE        = 80000000h


CFE_BOLD        = 00000001h
CFE_ITALIC      = 00000002h
CFE_UNDERLINE   = 00000004h
CFE_STRIKEOUT   = 00000008h
CFE_PROTECTED   = 00000010h
CFE_PROTECTED   = 00000010h
CFE_LINK        = 00000020h
CFE_ALLCAPS     = CFM_ALLCAPS
CFE_HIDDEN      = CFM_HIDDEN
CFE_OUTLINE     = CFM_OUTLINE
CFE_SHADOW      = CFM_SHADOW
CFE_EMBOSS      = CFM_EMBOSS
CFE_IMPRINT     = CFM_IMPRINT
CFE_DISABLED    = CFM_DISABLED
CFE_REVISED     = CFM_REVISED
CFE_AUTOBACKCOLOR = CFM_BACKCOLOR

CFE_SUBSCRIPT   = 00010000h
CFE_SUPERSCRIPT = 00020000h

CFE_AUTOCOLOR   = 40000000h



SCF_SELECTION = 0001h
SCF_WORD      = 0002h

SF_TEXT       = 0001h
SF_RTF        = 0002h
SF_RTFNOOBJS  = 0003h
SF_TEXTIZED   = 0004h

SFF_SELECTION = 8000h
SFF_PLAINRTF  = 4000h

ST_DEFAULT      = 0
ST_KEEPUNDO     = 1
ST_SELECTION    = 2
ST_NEWCHARS     = 4


EN_LINK = $0000070b


ENM_NONE = 000000000h
ENM_CHANGE = 000000001h
ENM_UPDATE = 000000002h
ENM_SCROLL = 000000004h
ENM_SCROLLEVENTS = 000000008h
ENM_DRAGDROPDONE = 000000010h
ENM_PARAGRAPHEXPANDED = 000000020h
ENM_PAGECHANGE = 000000040h
ENM_KEYEVENTS = 000010000h
ENM_MOUSEEVENTS = 000020000h
ENM_REQUESTRESIZE = 000040000h
ENM_SELCHANGE = 000080000h
ENM_DROPFILES = 000100000h
ENM_PROTECTED = 000200000h
ENM_CORRECTTEXT = 000400000h
ENM_IMECHANGE = 000800000h
ENM_LANGCHANGE = 001000000h
ENM_OBJECTPOSITIONS = 002000000h
ENM_LINK = 004000000h
ENM_LOWFIRTF = 008000000h

TM_PLAINTEXT            = 1
TM_RICHTEXT             = 2
TM_SINGLELEVELUNDO      = 4
TM_MULTILEVELUNDO       = 8
TM_SINGLECODEPAGE       = 16
TM_MULTICODEPAGE        = 32


PFM_STARTINDENT         = 000000001h
PFM_RIGHTINDENT         = 000000002h
PFM_OFFSET              = 000000004h
PFM_ALIGNMENT           = 000000008h
PFM_TABSTOPS            = 000000010h
PFM_NUMBERING           = 000000020h
PFM_OFFSETINDENT        = 080000000h
PFM_SPACEBEFORE         = 000000040h
PFM_SPACEAFTER          = 000000080h
PFM_LINESPACING         = 000000100h
PFM_STYLE               = 000000400h
PFM_BORDER              = 000000800h
PFM_SHADING             = 000001000h
PFM_NUMBERINGSTYLE      = 000002000h
PFM_NUMBERINGTAB        = 000004000h
PFM_NUMBERINGSTART      = 000008000h
PFM_RTLPARA             = 000010000h
PFM_KEEP                = 000020000h
PFM_KEEPNEXT            = 000040000h
PFM_PAGEBREAKBEFORE     = 000080000h
PFM_NOLINENUMBER        = 000100000h
PFM_NOWIDOWCONTROL      = 000200000h
PFM_DONOTHYPHEN         = 000400000h
PFM_SIDEBYSIDE          = 000800000h
PFM_TABLE               = 040000000h
PFM_TEXTWRAPPINGBREAK   = 020000000h
PFM_TABLEROWDELIMITER   = 010000000h
PFM_COLLAPSED           = 001000000h
PFM_OUTLINELEVEL        = 002000000h
PFM_BOX                 = 004000000h
PFM_RESERVED2           = 008000000h
PFM_ALL                 = PFM_STARTINDENT or PFM_RIGHTINDENT or         \
                          PFM_OFFSET or PFM_ALIGNMENT or                \
                          PFM_TABSTOPS or PFM_NUMBERING or              \
                          PFM_OFFSETINDENT or PFM_RTLPARA

PFM_EFFECTS             = PFM_RTLPARA or PFM_KEEP or PFM_KEEPNEXT or    \
                          PFM_TABLE or PFM_PAGEBREAKBEFORE or           \
                          PFM_NOLINENUMBER or PFM_NOWIDOWCONTROL or     \
                          PFM_DONOTHYPHEN or PFM_SIDEBYSIDE or          \
                          PFM_TABLE or PFM_TABLEROWDELIMITER

PFM_ALL2                = PFM_ALL or PFM_EFFECTS or PFM_SPACEBEFORE or  \
                          PFM_SPACEAFTER or PFM_LINESPACING or          \
                          PFM_STYLE or PFM_SHADING or PFM_BORDER or     \
                          PFM_NUMBERINGTAB or PFM_NUMBERINGSTART or     \
                          PFM_NUMBERINGSTYLE
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Win32/_SHELL32.INC.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: SHELL32.DLL structures and constants
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


struct NOTIFYICONDATA
   .cbSize           dd ?
   .hWnd             dd ?
   .uID              dd ?
   .uFlags           dd ?
   .uCallbackMessage dd ?
   .hIcon            dd ?
   .szTip            du 64
ends

; Taskbar icon messages

NIM_ADD        = 0
NIM_MODIFY     = 1
NIM_DELETE     = 2
NIM_SETFOCUS   = 3
NIM_SETVERSION = 4

; Taskbar icon flags

NIF_MESSAGE    = 01h
NIF_ICON       = 02h
NIF_TIP        = 04h
NIF_STATE      = 08h
NIF_INFO       = 10h
NIF_GUID       = 20h


; for SHBrowseForFolder

struct BROWSEINFO
    .hwndOwner          dd ?
    .pidlRoot           dd ?
    .pszDisplayName     dd ?
    .lpszTitle          dd ?
    .ulFlags            dd ?
    .lpfn               dd ?
    .lParam             dd ?
    .iImage             dd ?
ends

BIF_RETURNONLYFSDIRS   = $0001
BIF_DONTGOBELOWDOMAIN  = $0002
BIF_STATUSTEXT         = $0004
BIF_RETURNFSANCESTORS  = $0008
BIF_EDITBOX            = $0010
BIF_VALIDATE           = $0020

BFFM_INITIALIZED       = 1
BFFM_SELCHANGED        = 2
BFFM_VALIDATEFAILEDA   = 3      ; lParam:szPath ret:TRUE(cont), FALSE(EndDialog)
BFFM_VALIDATEFAILEDW   = 4      ; lParam:wzPath ret:TRUE(cont), FALSE(EndDialog)

; messages to browser

BFFM_SETSTATUSTEXTA    = WM_USER + 100
BFFM_ENABLEOK          = WM_USER + 101
BFFM_SETSELECTIONA     = WM_USER + 102
BFFM_SETSELECTIONW     = WM_USER + 103
BFFM_SETSTATUSTEXTW    = WM_USER + 104

BFFM_SETSTATUSTEXT     = BFFM_SETSTATUSTEXTA
BFFM_SETSELECTION      = BFFM_SETSELECTIONA


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































Deleted freshlib/equates/Win32/_USER32.INC.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: USER32.DLL structures and constants
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


struct POINT
   .x dd ?
   .y dd ?
ends

struct RECT
   .left   dd ?
   .top    dd ?
   .right  dd ?
   .bottom dd ?
ends

struct WNDCLASS
   .style         dd ?
   .lpfnWndProc   dd ?
   .cbClsExtra    dd ?
   .cbWndExtra    dd ?
   .hInstance     dd ?
   .hIcon         dd ?
   .hCursor       dd ?
   .hbrBackground dd ?
   .lpszMenuName  dd ?
   .lpszClassName dd ?
ends

struct WNDCLASSEX
   .cbSize        dd ?
   .style         dd ?
   .lpfnWndProc   dd ?
   .cbClsExtra    dd ?
   .cbWndExtra    dd ?
   .hInstance     dd ?
   .hIcon         dd ?
   .hCursor       dd ?
   .hbrBackground dd ?
   .lpszMenuName  dd ?
   .lpszClassName dd ?
   .hIconSm       dd ?
ends

struct CREATESTRUCT
   .lpCreateParams dd ?
   .hInstance      dd ?
   .hMenu          dd ?
   .hwndParent     dd ?
   .cy             dd ?
   .cx             dd ?
   .y              dd ?
   .x              dd ?
   .style          dd ?
   .lpszName       dd ?
   .lpszClass      dd ?
   .dwExStyle      dd ?
ends

struct CLIENTCREATESTRUCT
   .hWindowMenu  dd ?
   .idFirstChild dd ?
ends

struct MDICREATESTRUCT
   .szClass dd ?
   .szTitle dd ?
   .hOwner  dd ?
   .x       dd ?
   .y       dd ?
   .cx      dd ?
   .cy      dd ?
   .style   dd ?
   .lParam  dd ?
ends

struct SCROLLINFO
   .cbSize    dd ?
   .fMask     dd ?
   .nMin      dd ?
   .nMax      dd ?
   .nPage     dd ?
   .nPos      dd ?
   .nTrackPos dd ?
ends

struct MSG
   .hwnd    dd ?
   .message dd ?
   .wParam  dd ?
   .lParam  dd ?
   .time    dd ?
   .pt      POINT
ends

struct MINMAXINFO
   .ptReserved     POINT
   .ptMaxSize      POINT
   .ptMaxPosition  POINT
   .ptMinTrackSize POINT
   .ptMaxTrackSize POINT
ends

struct WINDOWPLACEMENT
   .length           dd ?
   .flags            dd ?
   .showCmd          dd ?
   .ptMinPosition    POINT
   .ptMaxPosition    POINT
   .rcNormalPosition RECT
ends

struct WINDOWPOS
   .hwnd            dd ?
   .hwndInsertAfter dd ?
   .x               dd ?
   .y               dd ?
   .cx              dd ?
   .cy              dd ?
   .flags           dd ?
ends

struct NMHDR
   .hwndFrom dd ?
   .idFrom   dd ?
   .code     dd ?
ends

struct COPYDATASTRUCT
   .dwData dd ?
   .cbData dd ?
   .lpData dd ?
ends

struct ACCEL
    .fVirt dw ?
    .key   dw ?
    .cmd   dw ?
ends

struct PAINTSTRUCT
   .hdc         dd ?
   .fErase      dd ?
   .rcPaint     RECT
   .fRestore    dd ?
   .fIncUpdate  dd ?
   .rgbReserved rb 32
ends

struct DRAWTEXTPARAMS
   .cbSize        dd ?
   .iTabLength    dd ?
   .iLeftMargin   dd ?
   .iRightMargin  dd ?
   .uiLengthDrawn dd ?
ends

struct DRAWITEMSTRUCT
   .CtlType    dd ?
   .CtlID      dd ?
   .itemID     dd ?
   .itemAction dd ?
   .itemState  dd ?
   .hwndItem   dd ?
   .hDC        dd ?
   .rcItem     RECT
   .itemData   dd ?
ends

struct MENUITEMINFO
   .cbSize        dd ?
   .fMask         dd ?
   .fType         dd ?
   .fState        dd ?
   .wID           dd ?
   .hSubMenu      dd ?
   .hbmpChecked   dd ?
   .hbmpUnchecked dd ?
   .dwItemData    dd ?
   .dwTypeData    dd ?
   .cch           dd ?
ends

struct MEASUREITEMSTRUCT
   .CtlType    dd ?
   .CtlID      dd ?
   .itemID     dd ?
   .itemWidth  dd ?
   .itemHeight dd ?
   .itemData   dd ?
ends

struct MSGBOXPARAMS
  .cbSize             dd ?
  .hwndOwner          dd ?
  .hInstance          dd ?
  .lpszText           dd ?
  .lpszCaption        dd ?
  .dwStyle            dd ?
  .lpszIcon           dd ?
  .dwContextHelpId    dd ?
  .lpfnMsgBoxCallback dd ?
  .dwLanguageId       dd ?
ends

; MessageBox type flags

MB_OK                   = 000000h
MB_OKCANCEL             = 000001h
MB_ABORTRETRYIGNORE     = 000002h
MB_YESNOCANCEL          = 000003h
MB_YESNO                = 000004h
MB_RETRYCANCEL          = 000005h
MB_ICONHAND             = 000010h
MB_ICONQUESTION         = 000020h
MB_ICONEXCLAMATION      = 000030h
MB_ICONASTERISK         = 000040h
MB_USERICON             = 000080h
MB_ICONWARNING          = MB_ICONEXCLAMATION
MB_ICONERROR            = MB_ICONHAND
MB_ICONINFORMATION      = MB_ICONASTERISK
MB_ICONSTOP             = MB_ICONHAND
MB_DEFBUTTON1           = 000000h
MB_DEFBUTTON2           = 000100h
MB_DEFBUTTON3           = 000200h
MB_DEFBUTTON4           = 000300h
MB_APPLMODAL            = 000000h
MB_SYSTEMMODAL          = 001000h
MB_TASKMODAL            = 002000h
MB_HELP                 = 004000h
MB_NOFOCUS              = 008000h
MB_SETFOREGROUND        = 010000h
MB_DEFAULT_DESKTOP_ONLY = 020000h
MB_TOPMOST              = 040000h
MB_RIGHT                = 080000h
MB_RTLREADING           = 100000h
MB_SERVICE_NOTIFICATION = 200000h

; Conventional dialog box and message box command IDs

IDOK     = 1
IDCANCEL = 2
IDABORT  = 3
IDRETRY  = 4
IDIGNORE = 5
IDYES    = 6
IDNO     = 7
IDCLOSE  = 8
IDHELP   = 9

; Class styles

CS_VREDRAW         = 00001h
CS_HREDRAW         = 00002h
CS_KEYCVTWINDOW    = 00004h
CS_DBLCLKS         = 00008h
CS_OWNDC           = 00020h
CS_CLASSDC         = 00040h
CS_PARENTDC        = 00080h
CS_NOKEYCVT        = 00100h
CS_SAVEBITS        = 00800h
CS_NOCLOSE         = 00200h
CS_BYTEALIGNCLIENT = 01000h
CS_BYTEALIGNWINDOW = 02000h
CS_PUBLICCLASS     = 04000h
CS_GLOBALCLASS     = CS_PUBLICCLASS
CS_IME             = 10000h

; Windows styles

WS_OVERLAPPED   = $00000000
WS_ICONICPOPUP  = $C0000000
WS_POPUP        = $80000000
WS_CHILD        = $40000000
WS_MINIMIZE     = $20000000
WS_VISIBLE      = $10000000
WS_DISABLED     = $08000000
WS_CLIPSIBLINGS = $04000000
WS_CLIPCHILDREN = $02000000
WS_MAXIMIZE     = $01000000
WS_CAPTION      = $00C00000
WS_BORDER       = $00800000
WS_DLGFRAME     = $00400000
WS_VSCROLL      = $00200000
WS_HSCROLL      = $00100000
WS_SYSMENU      = $00080000
WS_THICKFRAME   = $00040000
WS_HREDRAW      = $00020000
WS_VREDRAW      = $00010000
WS_GROUP        = $00020000
WS_TABSTOP      = $00010000
WS_MINIMIZEBOX  = $00020000
WS_MAXIMIZEBOX  = $00010000

; Common Window Styles

WS_OVERLAPPEDWINDOW = WS_OVERLAPPED or WS_CAPTION or WS_SYSMENU or WS_THICKFRAME or WS_MINIMIZEBOX or WS_MAXIMIZEBOX
WS_POPUPWINDOW      = WS_POPUP or WS_BORDER or WS_SYSMENU
WS_CHILDWINDOW      = WS_CHILD
WS_TILEDWINDOW      = WS_OVERLAPPEDWINDOW
WS_TILED            = WS_OVERLAPPED
WS_ICONIC           = WS_MINIMIZE
WS_SIZEBOX          = WS_THICKFRAME

; Extended Window Styles

WS_EX_DLGMODALFRAME    = 00001h
WS_EX_DRAGOBJECT       = 00002h
WS_EX_NOPARENTNOTIFY   = 00004h
WS_EX_TOPMOST          = 00008h
WS_EX_ACCEPTFILES      = 00010h
WS_EX_TRANSPARENT      = 00020h
WS_EX_MDICHILD         = 00040h
WS_EX_TOOLWINDOW       = 00080h
WS_EX_WINDOWEDGE       = 00100h
WS_EX_CLIENTEDGE       = 00200h
WS_EX_CONTEXTHELP      = 00400h
WS_EX_RIGHT            = 01000h
WS_EX_LEFT             = 00000h
WS_EX_RTLREADING       = 02000h
WS_EX_LTRREADING       = 00000h
WS_EX_LEFTSCROLLBAR    = 04000h
WS_EX_RIGHTSCROLLBAR   = 00000h
WS_EX_CONTROLPARENT    = 10000h
WS_EX_STATICEDGE       = 20000h
WS_EX_APPWINDOW        = 40000h
WS_EX_LAYERED          = 80000h
WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE or WS_EX_CLIENTEDGE
WS_EX_PALETTEWINDOW    = WS_EX_WINDOWEDGE or WS_EX_TOOLWINDOW or WS_EX_TOPMOST

; MDI client style bits

MDIS_ALLCHILDSTYLES = 1

; Special CreateWindow position value

CW_USEDEFAULT = 8000h

; Predefined window handle

HWND_DESKTOP   = 0

; ShowWindow commands

SW_HIDE            = 0
SW_SHOWNORMAL      = 1
SW_NORMAL          = 1
SW_SHOWMINIMIZED   = 2
SW_SHOWMAXIMIZED   = 3
SW_MAXIMIZE        = 3
SW_SHOWNOACTIVATE  = 4
SW_SHOW            = 5
SW_MINIMIZE        = 6
SW_SHOWMINNOACTIVE = 7
SW_SHOWNA          = 8
SW_RESTORE         = 9
SW_SHOWDEFAULT     = 10

; SetWindowPos flags

SWP_NOSIZE         = 0001h
SWP_NOMOVE         = 0002h
SWP_NOZORDER       = 0004h
SWP_NOREDRAW       = 0008h
SWP_NOACTIVATE     = 0010h
SWP_DRAWFRAME      = 0020h
SWP_SHOWWINDOW     = 0040h
SWP_HIDEWINDOW     = 0080h
SWP_NOCOPYBITS     = 0100h
SWP_NOREPOSITION   = 0200h
SWP_NOSENDCHANGING = 0400h
SWP_DEFERERASE     = 2000h
SWP_ASYNCWINDOWPOS = 4000h

; SetWindowPos special handle values

HWND_TOP       = 0
HWND_BOTTOM    = 1
HWND_TOPMOST   = -1
HWND_NOTOPMOST = -2

; GetWindow flags

GW_HWNDFIRST = 0
GW_HWNDLAST  = 1
GW_HWNDNEXT  = 2
GW_HWNDPREV  = 3
GW_OWNER     = 4
GW_CHILD     = 5

; RedrawWindow flags

RDW_INVALIDATE      = 0001h
RDW_INTERNALPAINT   = 0002h
RDW_ERASE           = 0004h
RDW_VALIDATE        = 0008h
RDW_NOINTERNALPAINT = 0010h
RDW_NOERASE         = 0020h
RDW_NOCHILDREN      = 0040h
RDW_ALLCHILDREN     = 0080h
RDW_UPDATENOW       = 0100h
RDW_ERASENOW        = 0200h
RDW_FRAME           = 0400h
RDW_NOFRAME         = 0800h

; PeekMessage Options

PM_NOREMOVE = 0000h
PM_REMOVE   = 0001h
PM_NOYIELD  = 0002h

; Window state messages

WM_STATE                  = 0000h
WM_NULL                   = 0000h
WM_CREATE                 = 0001h
WM_DESTROY                = 0002h
WM_MOVE                   = 0003h
WM_SIZE                   = 0005h
WM_ACTIVATE               = 0006h
WM_SETFOCUS               = 0007h
WM_KILLFOCUS              = 0008h
WM_ENABLE                 = 000Ah
WM_SETREDRAW              = 000Bh
WM_SETTEXT                = 000Ch
WM_GETTEXT                = 000Dh
WM_GETTEXTLENGTH          = 000Eh
WM_PAINT                  = 000Fh
WM_CLOSE                  = 0010h
WM_QUERYENDSESSION        = 0011h
WM_QUIT                   = 0012h
WM_QUERYOPEN              = 0013h
WM_ERASEBKGND             = 0014h
WM_SYSCOLORCHANGE         = 0015h
WM_ENDSESSION             = 0016h
WM_SYSTEMERROR            = 0017h
WM_SHOWWINDOW             = 0018h
WM_CTLCOLOR               = 0019h
WM_WININICHANGE           = 001Ah
WM_SETTINGCHANGE          = WM_WININICHANGE
WM_DEVMODECHANGE          = 001Bh
WM_ACTIVATEAPP            = 001Ch
WM_FONTCHANGE             = 001Dh
WM_TIMECHANGE             = 001Eh
WM_CANCELMODE             = 001Fh
WM_SETCURSOR              = 0020h
WM_MOUSEACTIVATE          = 0021h
WM_CHILDACTIVATE          = 0022h
WM_QUEUESYNC              = 0023h
WM_GETMINMAXINFO          = 0024h
WM_PAINTICON              = 0026h
WM_ICONERASEBKGND         = 0027h
WM_NEXTDLGCTL             = 0028h
WM_SPOOLERSTATUS          = 002Ah
WM_DRAWITEM               = 002Bh
WM_MEASUREITEM            = 002Ch
WM_DELETEITEM             = 002Dh
WM_VKEYTOITEM             = 002Eh
WM_CHARTOITEM             = 002Fh
WM_SETFONT                = 0030h
WM_GETFONT                = 0031h
WM_SETHOTKEY              = 0032h
WM_QUERYDRAGICON          = 0037h
WM_COMPAREITEM            = 0039h
WM_COMPACTING             = 0041h
WM_COMMNOTIFY             = 0044h
WM_WINDOWPOSCHANGING      = 0046h
WM_WINDOWPOSCHANGED       = 0047h
WM_POWER                  = 0048h
WM_COPYDATA               = 004Ah
WM_CANCELJOURNAL          = 004Bh
WM_NOTIFY                 = 004Eh
WM_INPUTLANGCHANGEREQUEST = 0050h
WM_INPUTLANGCHANGE        = 0051h
WM_TCARD                  = 0052h
WM_HELP                   = 0053h
WM_USERCHANGED            = 0054h
WM_NOTIFYFORMAT           = 0055h
WM_CONTEXTMENU            = 007Bh
WM_STYLECHANGING          = 007Ch
WM_STYLECHANGED           = 007Dh
WM_DISPLAYCHANGE          = 007Eh
WM_GETICON                = 007Fh
WM_SETICON                = 0080h
WM_NCCREATE               = 0081h
WM_NCDESTROY              = 0082h
WM_NCCALCSIZE             = 0083h
WM_NCHITTEST              = 0084h
WM_NCPAINT                = 0085h
WM_NCACTIVATE             = 0086h
WM_GETDLGCODE             = 0087h
WM_NCMOUSEMOVE            = 00A0h
WM_NCLBUTTONDOWN          = 00A1h
WM_NCLBUTTONUP            = 00A2h
WM_NCLBUTTONDBLCLK        = 00A3h
WM_NCRBUTTONDOWN          = 00A4h
WM_NCRBUTTONUP            = 00A5h
WM_NCRBUTTONDBLCLK        = 00A6h
WM_NCMBUTTONDOWN          = 00A7h
WM_NCMBUTTONUP            = 00A8h
WM_NCMBUTTONDBLCLK        = 00A9h
WM_KEYFIRST               = 0100h
WM_KEYDOWN                = 0100h
WM_KEYUP                  = 0101h
WM_CHAR                   = 0102h
WM_DEADCHAR               = 0103h
WM_SYSKEYDOWN             = 0104h
WM_SYSKEYUP               = 0105h
WM_SYSCHAR                = 0106h
WM_SYSDEADCHAR            = 0107h
WM_KEYLAST                = 0108h
WM_INITDIALOG             = 0110h
WM_COMMAND                = 0111h
WM_SYSCOMMAND             = 0112h
WM_TIMER                  = 0113h
WM_HSCROLL                = 0114h
WM_VSCROLL                = 0115h
WM_INITMENU               = 0116h
WM_INITMENUPOPUP          = 0117h
WM_MENUSELECT             = 011Fh
WM_MENUCHAR               = 0120h
WM_ENTERIDLE              = 0121h
WM_MENURBUTTONUP          = 0122h
WM_MENUDRAG               = 0123h
WM_MENUGETOBJECT          = 0124h
WM_UNINITMENUPOPUP        = 0125h
WM_MENUCOMMAND            = 0126h
WM_CTLCOLORMSGBOX         = 0132h
WM_CTLCOLOREDIT           = 0133h
WM_CTLCOLORLISTBOX        = 0134h
WM_CTLCOLORBTN            = 0135h
WM_CTLCOLORDLG            = 0136h
WM_CTLCOLORSCROLLBAR      = 0137h
WM_CTLCOLORSTATIC         = 0138h
WM_MOUSEFIRST             = 0200h
WM_MOUSEMOVE              = 0200h
WM_LBUTTONDOWN            = 0201h
WM_LBUTTONUP              = 0202h
WM_LBUTTONDBLCLK          = 0203h
WM_RBUTTONDOWN            = 0204h
WM_RBUTTONUP              = 0205h
WM_RBUTTONDBLCLK          = 0206h
WM_MBUTTONDOWN            = 0207h
WM_MBUTTONUP              = 0208h
WM_MBUTTONDBLCLK          = 0209h
WM_MOUSEWHEEL             = 020Ah
WM_MOUSELAST              = 020Ah
WM_PARENTNOTIFY           = 0210h
WM_ENTERMENULOOP          = 0211h
WM_EXITMENULOOP           = 0212h
WM_NEXTMENU               = 0213h
WM_SIZING                 = 0214h
WM_CAPTURECHANGED         = 0215h
WM_MOVING                 = 0216h
WM_POWERBROADCAST         = 0218h
WM_DEVICECHANGE           = 0219h
WM_MDICREATE              = 0220h
WM_MDIDESTROY             = 0221h
WM_MDIACTIVATE            = 0222h
WM_MDIRESTORE             = 0223h
WM_MDINEXT                = 0224h
WM_MDIMAXIMIZE            = 0225h
WM_MDITILE                = 0226h
WM_MDICASCADE             = 0227h
WM_MDIICONARRANGE         = 0228h
WM_MDIGETACTIVE           = 0229h
WM_MDISETMENU             = 0230h
WM_ENTERSIZEMOVE          = 0231h
WM_EXITSIZEMOVE           = 0232h
WM_DROPFILES              = 0233h
WM_MDIREFRESHMENU         = 0234h
WM_IME_SETCONTEXT         = 0281h
WM_IME_NOTIFY             = 0282h
WM_IME_CONTROL            = 0283h
WM_IME_COMPOSITIONFULL    = 0284h
WM_IME_SELECT             = 0285h
WM_IME_CHAR               = 0286h
WM_IME_KEYDOWN            = 0290h
WM_IME_KEYUP              = 0291h
WM_MOUSEHOVER             = 02A1h
WM_MOUSELEAVE             = 02A3h
WM_CUT                    = 0300h
WM_COPY                   = 0301h
WM_PASTE                  = 0302h
WM_CLEAR                  = 0303h
WM_UNDO                   = 0304h
WM_RENDERFORMAT           = 0305h
WM_RENDERALLFORMATS       = 0306h
WM_DESTROYCLIPBOARD       = 0307h
WM_DRAWCLIPBOARD          = 0308h
WM_PAINTCLIPBOARD         = 0309h
WM_VSCROLLCLIPBOARD       = 030Ah
WM_SIZECLIPBOARD          = 030Bh
WM_ASKCBFORMATNAME        = 030Ch
WM_CHANGECBCHAIN          = 030Dh
WM_HSCROLLCLIPBOARD       = 030Eh
WM_QUERYNEWPALETTE        = 030Fh
WM_PALETTEISCHANGING      = 0310h
WM_PALETTECHANGED         = 0311h
WM_HOTKEY                 = 0312h
WM_PRINT                  = 0317h
WM_PRINTCLIENT            = 0318h
WM_HANDHELDFIRST          = 0358h
WM_HANDHELDLAST           = 035Fh
WM_AFXFIRST               = 0360h
WM_AFXLAST                = 037Fh
WM_PENWINFIRST            = 0380h
WM_PENWINLAST             = 038Fh
WM_COALESCE_FIRST         = 0390h
WM_COALESCE_LAST          = 039Fh
WM_USER                   = 0400h

;WM_NCHITTEST result constants
HTBORDER = 18
HTBOTTOM = 15
HTBOTTOMLEFT = 16
HTBOTTOMRIGHT = 17
HTCAPTION = 2
HTCLIENT = 1
HTERROR = -2
HTGROWBOX = 4
HTHSCROLL = 6
HTLEFT = 10
HTMAXBUTTON = 9
HTMENU = 5
HTMINBUTTON = 8
HTNOWHERE = 0
HTRIGHT = 11
HTSYSMENU = 3
HTTOP = 12
HTTOPLEFT = 13
HTTOPRIGHT = 14
HTVSCROLL = 7
HTTRANSPARENT = -1
HTOBJECT = 19
HTCLOSE = 20
HTHELP = 21


; WM_SIZE commands

SIZE_RESTORED  = 0
SIZE_MINIMIZED = 1
SIZE_MAXIMIZED = 2
SIZE_MAXSHOW   = 3
SIZE_MAXHIDE   = 4

; WM_ACTIVATE states

WA_INACTIVE    = 0
WA_ACTIVE      = 1
WA_CLICKACTIVE = 2

; WM_SHOWWINDOW identifiers

SW_PARENTCLOSING = 1
SW_OTHERZOOM     = 2
SW_PARENTOPENING = 3
SW_OTHERUNZOOM   = 4

; WM_MOUSEACTIVATE return codes

MA_ACTIVATE         = 1
MA_ACTIVATEANDEAT   = 2
MA_NOACTIVATE       = 3
MA_NOACTIVATEANDEAT = 4

; WM_MDITILE flags

MDITILE_VERTICAL     = 0
MDITILE_HORIZONTAL   = 1
MDITILE_SKIPDISABLED = 2

; WM_NOTIFY codes

NM_OUTOFMEMORY = -1
NM_CLICK       = -2
NM_DBLCLICK    = -3
NM_RETURN      = -4
NM_RCLICK      = -5
NM_RDBLCLK     = -6
NM_SETFOCUS    = -7
NM_KILLFOCUS   = -8

; WM_SETICON types

ICON_SMALL = 0
ICON_BIG   = 1

; WM_HOTKEY commands

HOTKEYF_SHIFT   = 01h
HOTKEYF_CONTROL = 02h
HOTKEYF_ALT     = 04h
HOTKEYF_EXT     = 08h

; Keystroke flags

KF_EXTENDED = 0100h
KF_DLGMODE  = 0800h
KF_MENUMODE = 1000h
KF_ALTDOWN  = 2000h
KF_REPEAT   = 4000h
KF_UP       = 8000h

; Key state masks for mouse messages

MK_LBUTTON = 01h
MK_RBUTTON = 02h
MK_SHIFT   = 04h
MK_CONTROL = 08h
MK_MBUTTON = 10h

; WM_SIZING codes

WMSZ_LEFT        = 1
WMSZ_RIGHT       = 2
WMSZ_TOP         = 3
WMSZ_TOPLEFT     = 4
WMSZ_TOPRIGHT    = 5
WMSZ_BOTTOM      = 6
WMSZ_BOTTOMLEFT  = 7
WMSZ_BOTTOMRIGHT = 8

; WM_HOTKEY modifiers

MOD_ALT     = 1
MOD_CONTROL = 2
MOD_SHIFT   = 4
MOD_WIN     = 8

; WM_PRINT flags

PRF_CHECKVISIBLE = 01h
PRF_NONCLIENT    = 02h
PRF_CLIENT       = 04h
PRF_ERASEBKGND   = 08h
PRF_CHILDREN     = 10h
PRF_OWNED        = 20h

; Virtual key codes

VK_LBUTTON   = 001h
VK_CANCEL    = 003h
VK_RBUTTON   = 002h
VK_MBUTTON   = 004h
VK_BACK      = 008h
VK_TAB       = 009h
VK_CLEAR     = 00Ch
VK_RETURN    = 00Dh
VK_SHIFT     = 010h
VK_CONTROL   = 011h
VK_MENU      = 012h
VK_PAUSE     = 013h
VK_CAPITAL   = 014h
VK_ESCAPE    = 01Bh
VK_SPACE     = 020h
VK_PRIOR     = 021h
VK_PGUP      = 021h
VK_PGDN      = 022h
VK_NEXT      = 022h
VK_END       = 023h
VK_HOME      = 024h
VK_LEFT      = 025h
VK_UP        = 026h
VK_RIGHT     = 027h
VK_DOWN      = 028h
VK_SELECT    = 029h
VK_PRINT     = 02Ah
VK_EXECUTE   = 02Bh
VK_SNAPSHOT  = 02Ch
VK_INSERT    = 02Dh
VK_DELETE    = 02Eh
VK_HELP      = 02Fh
VK_LWIN      = 05Bh
VK_RWIN      = 05Ch
VK_APPS      = 05Dh
VK_NUMPAD0   = 060h
VK_NUMPAD1   = 061h
VK_NUMPAD2   = 062h
VK_NUMPAD3   = 063h
VK_NUMPAD4   = 064h
VK_NUMPAD5   = 065h
VK_NUMPAD6   = 066h
VK_NUMPAD7   = 067h
VK_NUMPAD8   = 068h
VK_NUMPAD9   = 069h
VK_MULTIPLY  = 06Ah
VK_ADD       = 06Bh
VK_SEPARATOR = 06Ch
VK_SUBTRACT  = 06Dh
VK_DECIMAL   = 06Eh
VK_DIVIDE    = 06Fh
VK_F1        = 070h
VK_F2        = 071h
VK_F3        = 072h
VK_F4        = 073h
VK_F5        = 074h
VK_F6        = 075h
VK_F7        = 076h
VK_F8        = 077h
VK_F9        = 078h
VK_F10       = 079h
VK_F11       = 07Ah
VK_F12       = 07Bh
VK_F13       = 07Ch
VK_F14       = 07Dh
VK_F15       = 07Eh
VK_F16       = 07Fh
VK_F17       = 080h
VK_F18       = 081h
VK_F19       = 082h
VK_F20       = 083h
VK_F21       = 084h
VK_F22       = 085h
VK_F23       = 086h
VK_F24       = 087h
VK_NUMLOCK   = 090h
VK_SCROLL    = 091h
VK_LSHIFT    = 0A0h
VK_RSHIFT    = 0A1h
VK_LCONTROL  = 0A2h
VK_RCONTROL  = 0A3h
VK_LMENU     = 0A4h
VK_RMENU     = 0A5h
VK_ATTN      = 0F6h
VK_CRSEL     = 0F7h
VK_EXSEL     = 0F8h
VK_EREOF     = 0F9h
VK_PLAY      = 0FAh
VK_ZOOM      = 0FBh
VK_NONAME    = 0FCh
VK_PA1       = 0FDh
VK_OEM_CLEAR = 0FEh

; Accelerator flags

FVIRTKEY  = 01h
FNOINVERT = 02h
FSHIFT    = 04h
FCONTROL  = 08h
FALT      = 10h

; GetClassLong offsets

GCL_MENUNAME      = -8
GCL_HBRBACKGROUND = -10
GCL_HCURSOR       = -12
GCL_HICON         = -14
GCL_HMODULE       = -16
GCL_CBWNDEXTRA    = -18
GCL_CBCLSEXTRA    = -20
GCL_WNDPROC       = -24
GCL_STYLE         = -26
GCW_ATOM          = -32
GCL_HICONSM       = -34

; GetWindowLong offsets

GWL_WNDPROC       = -4
GWL_HINSTANCE     = -6
GWL_HWNDPARENT    = -8
GWL_STYLE         = -16
GWL_EXSTYLE       = -20
GWL_USERDATA      = -21
GWL_ID            = -12
DWL_MSGRESULT     = 0
DWL_DLGPROC       = 4
DWL_USER          = 8

; GetSystemMetrics codes

SM_CXSCREEN          = 0
SM_CYSCREEN          = 1
SM_CXVSCROLL         = 2
SM_CYHSCROLL         = 3
SM_CYCAPTION         = 4
SM_CXBORDER          = 5
SM_CYBORDER          = 6
SM_CXDLGFRAME        = 7
SM_CYDLGFRAME        = 8
SM_CYVTHUMB          = 9
SM_CXHTHUMB          = 10
SM_CXICON            = 11
SM_CYICON            = 12
SM_CXCURSOR          = 13
SM_CYCURSOR          = 14
SM_CYMENU            = 15
SM_CXFULLSCREEN      = 16
SM_CYFULLSCREEN      = 17
SM_CYKANJIWINDOW     = 18
SM_MOUSEPRESENT      = 19
SM_CYVSCROLL         = 20
SM_CXHSCROLL         = 21
SM_DEBUG             = 22
SM_SWAPBUTTON        = 23
SM_RESERVED1         = 24
SM_RESERVED2         = 25
SM_RESERVED3         = 26
SM_RESERVED4         = 27
SM_CXMIN             = 28
SM_CYMIN             = 29
SM_CXSIZE            = 30
SM_CYSIZE            = 31
SM_CXFRAME           = 32
SM_CYFRAME           = 33
SM_CXMINTRACK        = 34
SM_CYMINTRACK        = 35
SM_CXDOUBLECLK       = 36
SM_CYDOUBLECLK       = 37
SM_CXICONSPACING     = 38
SM_CYICONSPACING     = 39
SM_MENUDROPALIGNMENT = 40
SM_PENWINDOWS        = 41
SM_DBCSENABLED       = 42
SM_CMOUSEBUTTONS     = 43
SM_CXFIXEDFRAME      = SM_CXDLGFRAME
SM_CYFIXEDFRAME      = SM_CYDLGFRAME
SM_CXSIZEFRAME       = SM_CXFRAME
SM_CYSIZEFRAME       = SM_CYFRAME
SM_SECURE            = 44
SM_CXEDGE            = 45
SM_CYEDGE            = 46
SM_CXMINSPACING      = 47
SM_CYMINSPACING      = 48
SM_CXSMICON          = 49
SM_CYSMICON          = 50
SM_CYSMCAPTION       = 51
SM_CXSMSIZE          = 52
SM_CYSMSIZE          = 53
SM_CXMENUSIZE        = 54
SM_CYMENUSIZE        = 55
SM_ARRANGE           = 56
SM_CXMINIMIZED       = 57
SM_CYMINIMIZED       = 58
SM_CXMAXTRACK        = 59
SM_CYMAXTRACK        = 60
SM_CXMAXIMIZED       = 61
SM_CYMAXIMIZED       = 62
SM_NETWORK           = 63
SM_CLEANBOOT         = 67
SM_CXDRAG            = 68
SM_CYDRAG            = 69
SM_SHOWSOUNDS        = 70
SM_CXMENUCHECK       = 71
SM_CYMENUCHECK       = 72
SM_SLOWMACHINE       = 73
SM_MIDEASTENABLED    = 74
SM_MOUSEWHEELPRESENT = 75
SM_CMETRICS          = 76

; Predefined cursor identifiers

IDC_ARROW       = 32512
IDC_IBEAM       = 32513
IDC_WAIT        = 32514
IDC_CROSS       = 32515
IDC_UPARROW     = 32516
IDC_SIZE        = 32640
IDC_ICON        = 32641
IDC_SIZENWSE    = 32642
IDC_SIZENESW    = 32643
IDC_SIZEWE      = 32644
IDC_SIZENS      = 32645
IDC_SIZEALL     = 32646
IDC_NO          = 32648
IDC_HAND        = 32649
IDC_APPSTARTING = 32650
IDC_HELP        = 32651

; Predefined icon identifiers

IDI_APPLICATION = 32512
IDI_HAND        = 32513
IDI_QUESTION    = 32514
IDI_EXCLAMATION = 32515
IDI_ASTERISK    = 32516
IDI_WINLOGO     = 32517

; System colors

COLOR_SCROLLBAR               = 0
COLOR_BACKGROUND              = 1
COLOR_ACTIVECAPTION           = 2
COLOR_INACTIVECAPTION         = 3
COLOR_MENU                    = 4
COLOR_WINDOW                  = 5
COLOR_WINDOWFRAME             = 6
COLOR_MENUTEXT                = 7
COLOR_WINDOWTEXT              = 8
COLOR_CAPTIONTEXT             = 9
COLOR_ACTIVEBORDER            = 10
COLOR_INACTIVEBORDER          = 11
COLOR_APPWORKSPACE            = 12
COLOR_HIGHLIGHT               = 13
COLOR_HIGHLIGHTTEXT           = 14
COLOR_BTNFACE                 = 15
COLOR_BTNSHADOW               = 16
COLOR_GRAYTEXT                = 17
COLOR_BTNTEXT                 = 18
COLOR_INACTIVECAPTIONTEXT     = 19
COLOR_BTNHIGHLIGHT            = 20
COLOR_3DDKSHADOW              = 21
COLOR_3DLIGHT                 = 22
COLOR_INFOTEXT                = 23
COLOR_INFOBK                  = 24
COLOR_HOTLIGHT                = 26
COLOR_GRADIENTACTIVECAPTION   = 27
COLOR_GRADIENTINACTIVECAPTION = 28

; Button messages

BM_GETCHECK = 00F0h
BM_SETCHECK = 00F1h
BM_GETSTATE = 00F2h
BM_SETSTATE = 00F3h
BM_SETSTYLE = 00F4h
BM_CLICK    = 00F5h
BM_GETIMAGE = 00F6h
BM_SETIMAGE = 00F7h

; Button notifications

BN_CLICKED       = 0
BN_PAINT         = 1
BN_HILITE        = 2
BN_UNHILITE      = 3
BN_DISABLE       = 4
BN_DOUBLECLICKED = 5
BN_SETFOCUS      = 6
BN_KILLFOCUS     = 7
BN_PUSHED        = BN_HILITE
BN_UNPUSHED      = BN_UNHILITE
BN_DBLCLK        = BN_DOUBLECLICKED

; Button styles

BS_PUSHBUTTON      = 0000h
BS_DEFPUSHBUTTON   = 0001h
BS_CHECKBOX        = 0002h
BS_AUTOCHECKBOX    = 0003h
BS_RADIOBUTTON     = 0004h
BS_3STATE          = 0005h
BS_AUTO3STATE      = 0006h
BS_GROUPBOX        = 0007h
BS_USERBUTTON      = 0008h
BS_AUTORADIOBUTTON = 0009h
BS_OWNERDRAW       = 000Bh
BS_TEXT            = 0000h
BS_LEFTTEXT        = 0020h
BS_RIGHTBUTTON     = BS_LEFTTEXT
BS_ICON            = 0040h
BS_BITMAP          = 0080h
BS_LEFT            = 0100h
BS_RIGHT           = 0200h
BS_CENTER          = 0300h
BS_TOP             = 0400h
BS_BOTTOM          = 0800h
BS_VCENTER         = 0C00h
BS_PUSHLIKE        = 1000h
BS_MULTILINE       = 2000h
BS_NOTIFY          = 4000h
BS_FLAT            = 8000h

; Button states

BST_UNCHECKED     = 0
BST_CHECKED       = 1
BST_INDETERMINATE = 2
BST_PUSHED        = 4
BST_FOCUS         = 8

; List box messages

LB_ADDSTRING           = 0180h
LB_INSERTSTRING        = 0181h
LB_DELETESTRING        = 0182h
LB_SELITEMRANGEEX      = 0183h
LB_RESETCONTENT        = 0184h
LB_SETSEL              = 0185h
LB_SETCURSEL           = 0186h
LB_GETSEL              = 0187h
LB_GETCURSEL           = 0188h
LB_GETTEXT             = 0189h
LB_GETTEXTLEN          = 018Ah
LB_GETCOUNT            = 018Bh
LB_SELECTSTRING        = 018Ch
LB_DIR                 = 018Dh
LB_GETTOPINDEX         = 018Eh
LB_FINDSTRING          = 018Fh
LB_GETSELCOUNT         = 0190h
LB_GETSELITEMS         = 0191h
LB_SETTABSTOPS         = 0192h
LB_GETHORIZONTALEXTENT = 0193h
LB_SETHORIZONTALEXTENT = 0194h
LB_SETCOLUMNWIDTH      = 0195h
LB_ADDFILE             = 0196h
LB_SETTOPINDEX         = 0197h
LB_GETITEMRECT         = 0198h
LB_GETITEMDATA         = 0199h
LB_SETITEMDATA         = 019Ah
LB_SELITEMRANGE        = 019Bh
LB_SETANCHORINDEX      = 019Ch
LB_GETANCHORINDEX      = 019Dh
LB_SETCARETINDEX       = 019Eh
LB_GETCARETINDEX       = 019Fh
LB_SETITEMHEIGHT       = 01A0h
LB_GETITEMHEIGHT       = 01A1h
LB_FINDSTRINGEXACT     = 01A2h
LB_SETLOCALE           = 01A5h
LB_GETLOCALE           = 01A6h
LB_SETCOUNT            = 01A7h
LB_INITSTORAGE         = 01A8h
LB_ITEMFROMPOINT       = 01A9h

; List box notifications

LBN_ERRSPACE  = -2
LBN_SELCHANGE = 1
LBN_DBLCLK    = 2
LBN_SELCANCEL = 3
LBN_SETFOCUS  = 4
LBN_KILLFOCUS = 5

; List box styles

LBS_NOTIFY            = 0001h
LBS_SORT              = 0002h
LBS_NOREDRAW          = 0004h
LBS_MULTIPLESEL       = 0008h
LBS_OWNERDRAWFIXED    = 0010h
LBS_OWNERDRAWVARIABLE = 0020h
LBS_HASSTRINGS        = 0040h
LBS_USETABSTOPS       = 0080h
LBS_NOINTEGRALHEIGHT  = 0100h
LBS_MULTICOLUMN       = 0200h
LBS_WANTKEYBOARDINPUT = 0400h
LBS_EXTENDEDSEL       = 0800h
LBS_DISABLENOSCROLL   = 1000h
LBS_NODATA            = 2000h
LBS_NOSEL             = 4000h
LBS_STANDARD          = LBS_NOTIFY or LBS_SORT or WS_VSCROLL or WS_BORDER

; List box return values

LB_OKAY     = 0
LB_ERR      = -1
LB_ERRSPACE = -2

; Combo box messages

CB_GETEDITSEL            = 0140h
CB_LIMITTEXT             = 0141h
CB_SETEDITSEL            = 0142h
CB_ADDSTRING             = 0143h
CB_DELETESTRING          = 0144h
CB_DIR                   = 0145h
CB_GETCOUNT              = 0146h
CB_GETCURSEL             = 0147h
CB_GETLBTEXT             = 0148h
CB_GETLBTEXTLEN          = 0149h
CB_INSERTSTRING          = 014Ah
CB_RESETCONTENT          = 014Bh
CB_FINDSTRING            = 014Ch
CB_SELECTSTRING          = 014Dh
CB_SETCURSEL             = 014Eh
CB_SHOWDROPDOWN          = 014Fh
CB_GETITEMDATA           = 0150h
CB_SETITEMDATA           = 0151h
CB_GETDROPPEDCONTROLRECT = 0152h
CB_SETITEMHEIGHT         = 0153h
CB_GETITEMHEIGHT         = 0154h
CB_SETEXTENDEDUI         = 0155h
CB_GETEXTENDEDUI         = 0156h
CB_GETDROPPEDSTATE       = 0157h
CB_FINDSTRINGEXACT       = 0158h
CB_SETLOCALE             = 0159h
CB_GETLOCALE             = 015Ah
CB_GETTOPINDEX           = 015Bh
CB_SETTOPINDEX           = 015Ch
CB_GETHORIZONTALEXTENT   = 015Dh
CB_SETHORIZONTALEXTENT   = 015Eh
CB_GETDROPPEDWIDTH       = 015Fh
CB_SETDROPPEDWIDTH       = 0160h
CB_INITSTORAGE           = 0161h

; Combo box notifications

CBN_ERRSPACE     = -1
CBN_SELCHANGE    = 1
CBN_DBLCLK       = 2
CBN_SETFOCUS     = 3
CBN_KILLFOCUS    = 4
CBN_EDITCHANGE   = 5
CBN_EDITUPDATE   = 6
CBN_DROPDOWN     = 7
CBN_CLOSEUP      = 8
CBN_SELENDOK     = 9
CBN_SELENDCANCEL = 10

; Combo box styles

CBS_SIMPLE            = 0001h
CBS_DROPDOWN          = 0002h
CBS_DROPDOWNLIST      = 0003h
CBS_OWNERDRAWFIXED    = 0010h
CBS_OWNERDRAWVARIABLE = 0020h
CBS_AUTOHSCROLL       = 0040h
CBS_OEMCONVERT        = 0080h
CBS_SORT              = 0100h
CBS_HASSTRINGS        = 0200h
CBS_NOINTEGRALHEIGHT  = 0400h
CBS_DISABLENOSCROLL   = 0800h
CBS_UPPERCASE         = 2000h
CBS_LOWERCASE         = 4000h

; Combo box return values

CB_OKAY     = 0
CB_ERR      = -1
CB_ERRSPACE = -2

; CB_DIR message flags

DDL_READWRITE   = 0h
DDL_READONLY    = 1h
DDL_HIDDEN      = 2h
DDL_SYSTEM      = 4h
DDL_DIRECTORY   = 10h
DDL_ARCHIVE     = 20h
DDL_POSTMSGS    = 2000h
DDL_DRIVES      = 4000h
DDL_EXCLUSIVE   = 8000h


; Edit control messages

EM_GETSEL              = 00B0h
EM_SETSEL              = 00B1h
EM_GETRECT             = 00B2h
EM_SETRECT             = 00B3h
EM_SETRECTNP           = 00B4h
EM_SCROLL              = 00B5h
EM_LINESCROLL          = 00B6h
EM_SCROLLCARET         = 00B7h
EM_GETMODIFY           = 00B8h
EM_SETMODIFY           = 00B9h
EM_GETLINECOUNT        = 00BAh
EM_LINEINDEX           = 00BBh
EM_SETHANDLE           = 00BCh
EM_GETHANDLE           = 00BDh
EM_GETTHUMB            = 00BEh
EM_LINELENGTH          = 00C1h
EM_REPLACESEL          = 00C2h
EM_GETLINE             = 00C4h
EM_LIMITTEXT           = 00C5h
EM_CANUNDO             = 00C6h
EM_UNDO                = 00C7h
EM_FMTLINES            = 00C8h
EM_LINEFROMCHAR        = 00C9h
EM_SETTABSTOPS         = 00CBh
EM_SETPASSWORDCHAR     = 00CCh
EM_EMPTYUNDOBUFFER     = 00CDh
EM_GETFIRSTVISIBLELINE = 00CEh
EM_SETREADONLY         = 00CFh
EM_SETWORDBREAKPROC    = 00D0h
EM_GETWORDBREAKPROC    = 00D1h
EM_GETPASSWORDCHAR     = 00D2h
EM_SETMARGINS          = 00D3h
EM_GETMARGINS          = 00D4h
EM_SETLIMITTEXT        = EM_LIMITTEXT
EM_GETLIMITTEXT        = 00D5h
EM_POSFROMCHAR         = 00D6h
EM_CHARFROMPOS         = 00D7h

; Edit control EM_SETMARGIN parameters

EC_LEFTMARGIN  = 1
EC_RIGHTMARGIN = 2
EC_USEFONTINFO = 0FFFFh

; Edit control notifications

EN_SETFOCUS  = 0100h
EN_KILLFOCUS = 0200h
EN_CHANGE    = 0300h
EN_UPDATE    = 0400h
EN_ERRSPACE  = 0500h
EN_MAXTEXT   = 0501h
EN_HSCROLL   = 0601h
EN_VSCROLL   = 0602h

; Edit control styles

ES_LEFT        = 0000h
ES_CENTER      = 0001h
ES_RIGHT       = 0002h
ES_MULTILINE   = 0004h
ES_UPPERCASE   = 0008h
ES_LOWERCASE   = 0010h
ES_PASSWORD    = 0020h
ES_AUTOVSCROLL = 0040h
ES_AUTOHSCROLL = 0080h
ES_NOHIDESEL   = 0100h
ES_OEMCONVERT  = 0400h
ES_READONLY    = 0800h
ES_WANTRETURN  = 1000h
ES_NUMBER      = 2000h

; Static window messages

STM_SETICON  = 0170h
STM_GETICON  = 0171h
STM_SETIMAGE = 0172h
STM_GETIMAGE = 0173h

; Static window notifications

STN_CLICKED = 0
STN_DBLCLK  = 1
STN_ENABLE  = 2
STN_DISABLE = 3

; Static window styles

SS_LEFT           = 0000h
SS_CENTER         = 0001h
SS_RIGHT          = 0002h
SS_ICON           = 0003h
SS_BLACKRECT      = 0004h
SS_GRAYRECT       = 0005h
SS_WHITERECT      = 0006h
SS_BLACKFRAME     = 0007h
SS_GRAYFRAME      = 0008h
SS_WHITEFRAME     = 0009h
SS_USERITEM       = 000Ah
SS_SIMPLE         = 000Bh
SS_LEFTNOWORDWRAP = 000Ch
SS_BITMAP         = 000Eh
SS_OWNERDRAW      = 000Dh
SS_ENHMETAFILE    = 000Fh
SS_ETCHEDHORZ     = 0010h
SS_ETCHEDVERT     = 0011h
SS_ETCHEDFRAME    = 0012h
SS_TYPEMASK       = 001Fh
SS_NOPREFIX       = 0080h
SS_NOTIFY         = 0100h
SS_CENTERIMAGE    = 0200h
SS_RIGHTJUST      = 0400h
SS_REALSIZEIMAGE  = 0800h
SS_SUNKEN         = 1000h

; Scroll bar constants

SB_HORZ          = 0
SB_VERT          = 1
SB_CTL           = 2
SB_BOTH          = 3

; Scroll bar messages

SBM_SETPOS         = 00E0h
SBM_GETPOS         = 00E1h
SBM_SETRANGE       = 00E2h
SBM_SETRANGEREDRAW = 00E6h
SBM_GETRANGE       = 00E3h
SBM_ENABLE_ARROWS  = 00E4h
SBM_SETSCROLLINFO  = 00E9h
SBM_GETSCROLLINFO  = 00EAh

; Scroll bar commands

SB_LINEUP        = 0
SB_LINELEFT      = 0
SB_LINEDOWN      = 1
SB_LINERIGHT     = 1
SB_PAGEUP        = 2
SB_PAGELEFT      = 2
SB_PAGEDOWN      = 3
SB_PAGERIGHT     = 3
SB_THUMBPOSITION = 4
SB_THUMBTRACK    = 5
SB_TOP           = 6
SB_LEFT          = 6
SB_BOTTOM        = 7
SB_RIGHT         = 7
SB_ENDSCROLL     = 8

; Scroll bar styles

SBS_HORZ                    = 0000h
SBS_VERT                    = 0001h
SBS_TOPALIGN                = 0002h
SBS_LEFTALIGN               = 0002h
SBS_BOTTOMALIGN             = 0004h
SBS_RIGHTALIGN              = 0004h
SBS_SIZEBOXTOPLEFTALIGN     = 0002h
SBS_SIZEBOXBOTTOMRIGHTALIGN = 0004h
SBS_SIZEBOX                 = 0008h
SBS_SIZEGRIP                = 0010h

; Scroll bar info flags

SIF_RANGE           = 0001h
SIF_PAGE            = 0002h
SIF_POS             = 0004h
SIF_DISABLENOSCROLL = 0008h
SIF_TRACKPOS        = 0010h
SIF_ALL             = SIF_RANGE or SIF_PAGE or SIF_POS or SIF_TRACKPOS

; Dialog styles

DS_ABSALIGN      = 0001h
DS_SYSMODAL      = 0002h
DS_3DLOOK        = 0004h
DS_FIXEDSYS      = 0008h
DS_NOFAILCREATE  = 0010h
DS_LOCALEDIT     = 0020h
DS_SETFONT       = 0040h
DS_MODALFRAME    = 0080h
DS_NOIDLEMSG     = 0100h
DS_SETFOREGROUND = 0200h
DS_CONTROL       = 0400h
DS_CENTER        = 0800h
DS_CENTERMOUSE   = 1000h
DS_CONTEXTHELP   = 2000h

; Dialog codes

DLGC_WANTARROWS      = 0001h
DLGC_WANTTAB         = 0002h
DLGC_WANTALLKEYS     = 0004h
DLGC_WANTMESSAGE     = 0004h
DLGC_HASSETSEL       = 0008h
DLGC_DEFPUSHBUTTON   = 0010h
DLGC_UNDEFPUSHBUTTON = 0020h
DLGC_RADIOBUTTON     = 0040h
DLGC_WANTCHARS       = 0080h
DLGC_STATIC          = 0100h
DLGC_BUTTON          = 2000h

; Menu flags

MF_INSERT          = 0000h
MF_CHANGE          = 0080h
MF_APPEND          = 0100h
MF_DELETE          = 0200h
MF_REMOVE          = 1000h
MF_BYCOMMAND       = 0000h
MF_BYPOSITION      = 0400h
MF_SEPARATOR       = 0800h
MF_UNCHECKED       = 0000h
MF_ENABLED         = 0000h
MF_GRAYED          = 0001h
MF_DISABLED        = 0002h
MF_CHECKED         = 0008h
MF_USECHECKBITMAPS = 0200h
MF_STRING          = 0000h
MF_BITMAP          = 0004h
MF_OWNERDRAW       = 0100h
MF_POPUP           = 0010h
MF_MENUBARBREAK    = 0020h
MF_MENUBREAK       = 0040h
MF_UNHILITE        = 0000h
MF_HILITE          = 0080h
MF_DEFAULT         = 1000h
MF_SYSMENU         = 2000h
MF_HELP            = 4000h
MF_RIGHTJUSTIFY    = 4000h
MF_MOUSESELECT     = 8000h
MF_END             = 0080h
MFT_STRING         = MF_STRING
MFT_BITMAP         = MF_BITMAP
MFT_MENUBARBREAK   = MF_MENUBARBREAK
MFT_MENUBREAK      = MF_MENUBREAK
MFT_OWNERDRAW      = MF_OWNERDRAW
MFT_RADIOCHECK     = 0200h
MFT_SEPARATOR      = MF_SEPARATOR
MFT_RIGHTORDER     = 2000h
MFT_RIGHTJUSTIFY   = MF_RIGHTJUSTIFY
MFS_GRAYED         = 0003h
MFS_DISABLED       = MFS_GRAYED
MFS_CHECKED        = MF_CHECKED
MFS_HILITE         = MF_HILITE
MFS_ENABLED        = MF_ENABLED
MFS_UNCHECKED      = MF_UNCHECKED
MFS_UNHILITE       = MF_UNHILITE
MFS_DEFAULT        = MF_DEFAULT
MFR_POPUP          = 0001h
MFR_END            = MF_END

; System menu command values

SC_SIZE         = 61440
SC_MOVE         = 61456
SC_MINIMIZE     = 61472
SC_MAXIMIZE     = 61488
SC_NEXTWINDOW   = 61504
SC_PREVWINDOW   = 61520
SC_CLOSE        = 61536
SC_VSCROLL      = 61552
SC_HSCROLL      = 61568
SC_MOUSEMENU    = 61584
SC_KEYMENU      = 61696
SC_ARRANGE      = 61712
SC_RESTORE      = 61728
SC_TASKLIST     = 61744
SC_SCREENSAVE   = 61760
SC_HOTKEY       = 61776
SC_DEFAULT      = 61792
SC_MONITORPOWER = 61808
SC_CONTEXTHELP  = 61824
SC_SEPARATOR    = 61455

; Border types

BDR_RAISEDOUTER = 01h
BDR_SUNKENOUTER = 02h
BDR_RAISEDINNER = 04h
BDR_SUNKENINNER = 08h
BDR_OUTER       = 03h
BDR_INNER       = 0Ch
BDR_RAISED      = 05h
BDR_SUNKEN      = 0Ah
EDGE_RAISED     = BDR_RAISEDOUTER or BDR_RAISEDINNER
EDGE_SUNKEN     = BDR_SUNKENOUTER or BDR_SUNKENINNER
EDGE_ETCHED     = BDR_SUNKENOUTER or BDR_RAISEDINNER
EDGE_BUMP       = BDR_RAISEDOUTER or BDR_SUNKENINNER

; Border flags

BF_LEFT                    = 0001h
BF_TOP                     = 0002h
BF_RIGHT                   = 0004h
BF_BOTTOM                  = 0008h
BF_TOPLEFT                 = BF_TOP or BF_LEFT
BF_TOPRIGHT                = BF_TOP or BF_RIGHT
BF_BOTTOMLEFT              = BF_BOTTOM or BF_LEFT
BF_BOTTOMRIGHT             = BF_BOTTOM or BF_RIGHT
BF_RECT                    = BF_LEFT or BF_TOP or BF_RIGHT or BF_BOTTOM
BF_DIAGONAL                = 0010h
BF_DIAGONAL_ENDTOPRIGHT    = BF_DIAGONAL or BF_TOP or BF_RIGHT
BF_DIAGONAL_ENDTOPLEFT     = BF_DIAGONAL or BF_TOP or BF_LEFT
BF_DIAGONAL_ENDBOTTOMLEFT  = BF_DIAGONAL or BF_BOTTOM or BF_LEFT
BF_DIAGONAL_ENDBOTTOMRIGHT = BF_DIAGONAL or BF_BOTTOM or BF_RIGHT
BF_MIDDLE                  = 0800h
BF_SOFT                    = 1000h
BF_ADJUST                  = 2000h
BF_FLAT                    = 4000h
BF_MONO                    = 8000h

; Frame control types

DFC_CAPTION   = 1
DFC_MENU      = 2
DFC_SCROLL    = 3
DFC_BUTTON    = 4
DFC_POPUPMENU = 5

; Frame control states

DFCS_CAPTIONCLOSE        = 0000h
DFCS_CAPTIONMIN          = 0001h
DFCS_CAPTIONMAX          = 0002h
DFCS_CAPTIONRESTORE      = 0003h
DFCS_CAPTIONHELP         = 0004h
DFCS_MENUARROW           = 0000h
DFCS_MENUCHECK           = 0001h
DFCS_MENUBULLET          = 0002h
DFCS_MENUARROWRIGHT      = 0004h
DFCS_SCROLLUP            = 0000h
DFCS_SCROLLDOWN          = 0001h
DFCS_SCROLLLEFT          = 0002h
DFCS_SCROLLRIGHT         = 0003h
DFCS_SCROLLCOMBOBOX      = 0005h
DFCS_SCROLLSIZEGRIP      = 0008h
DFCS_SCROLLSIZEGRIPRIGHT = 0010h
DFCS_BUTTONCHECK         = 0000h
DFCS_BUTTONRADIOIMAGE    = 0001h
DFCS_BUTTONRADIOMASK     = 0002h
DFCS_BUTTONRADIO         = 0004h
DFCS_BUTTON3STATE        = 0008h
DFCS_BUTTONPUSH          = 0010h
DFCS_INACTIVE            = 0100h
DFCS_PUSHED              = 0200h
DFCS_CHECKED             = 0400h
DFCS_TRANSPARENT         = 0800h
DFCS_HOT                 = 1000h
DFCS_ADJUSTRECT          = 2000h
DFCS_FLAT                = 4000h
DFCS_MONO                = 8000h

; DrawCaption flags

DC_ACTIVE   = 01h
DC_SMALLCAP = 02h
DC_ICON     = 04h
DC_TEXT     = 08h
DC_INBUTTON = 10h

; DrawIconEx options

DI_MASK        = 1
DI_IMAGE       = 2
DI_NORMAL      = 3
DI_COMPAT      = 4
DI_DEFAULTSIZE = 8

; DrawText parameters

DT_TOP             = 00000h
DT_LEFT            = 00000h
DT_CENTER          = 00001h
DT_RIGHT           = 00002h
DT_VCENTER         = 00004h
DT_BOTTOM          = 00008h
DT_WORDBREAK       = 00010h
DT_SINGLELINE      = 00020h
DT_EXPANDTABS      = 00040h
DT_TABSTOP         = 00080h
DT_NOCLIP          = 00100h
DT_EXTERNALLEADING = 00200h
DT_CALCRECT        = 00400h
DT_NOPREFIX        = 00800h
DT_INTERNAL        = 01000h
DT_EDITCONTROL     = 02000h
DT_PATH_ELLIPSIS   = 04000h
DT_END_ELLIPSIS    = 08000h
DT_MODIFYSTRING    = 10000h
DT_RTLREADING      = 20000h
DT_WORD_ELLIPSIS   = 40000h

; GetDCEx flags

DCX_WINDOW           = 000001h
DCX_CACHE            = 000002h
DCX_NORESETATTRS     = 000004h
DCX_CLIPCHILDREN     = 000008h
DCX_CLIPSIBLINGS     = 000010h
DCX_PARENTCLIP       = 000020h
DCX_EXCLUDERGN       = 000040h
DCX_INTERSECTRGN     = 000080h
DCX_EXCLUDEUPDATE    = 000100h
DCX_INTERSECTUPDATE  = 000200h
DCX_LOCKWINDOWUPDATE = 000400h
DCX_VALIDATE         = 200000h

; SetWindowsHook codes

WH_MSGFILTER       = -1
WH_JOURNALRECORD   = 0
WH_JOURNALPLAYBACK = 1
WH_KEYBOARD        = 2
WH_GETMESSAGE      = 3
WH_CALLWNDPROC     = 4
WH_CBT             = 5
WH_SYSMSGFILTER    = 6
WH_MOUSE           = 7
WH_HARDWARE        = 8
WH_DEBUG           = 9
WH_SHELL           = 10
WH_FOREGROUNDIDLE  = 11
WH_CALLWNDPROCRET  = 12
WH_KEYBOARD_LL     = 13
WH_MOUSE_LL        = 14

; Hook codes

HC_ACTION      = 0
HC_GETNEXT     = 1
HC_SKIP        = 2
HC_NOREMOVE    = 3
HC_SYSMODALON  = 4
HC_SYSMODALOFF = 5

; CBT hook codes

HCBT_MOVESIZE     = 0
HCBT_MINMAX       = 1
HCBT_QS           = 2
HCBT_CREATEWND    = 3
HCBT_DESTROYWND   = 4
HCBT_ACTIVATE     = 5
HCBT_CLICKSKIPPED = 6
HCBT_KEYSKIPPED   = 7
HCBT_SYSCOMMAND   = 8
HCBT_SETFOCUS     = 9

; ExitWindowsEx flags

EWX_LOGOFF   = 0
EWX_SHUTDOWN = 1
EWX_REBOOT   = 2
EWX_FORCE    = 4
EWX_POWEROFF = 8

; WinHelp commands

HELP_CONTEXT      = 001h
HELP_QUIT         = 002h
HELP_INDEX        = 003h
HELP_CONTENTS     = 003h
HELP_HELPONHELP   = 004h
HELP_SETINDEX     = 005h
HELP_SETCONTENTS  = 005h
HELP_CONTEXTPOPUP = 008h
HELP_FORCEFILE    = 009h
HELP_CONTEXTMENU  = 00Ah
HELP_FINDER       = 00Bh
HELP_WM_HELP      = 00Ch
HELP_SETPOPUP_POS = 00Dh
HELP_KEY          = 101h
HELP_COMMAND      = 102h
HELP_PARTIALKEY   = 105h
HELP_MULTIKEY     = 201h
HELP_SETWINPOS    = 203h

; keybd_event flags

KEYEVENTF_EXTENDEDKEY = 1h
KEYEVENTF_KEYUP       = 2h

; mouse_event flags

MOUSEEVENTF_MOVE       = 0001h
MOUSEEVENTF_LEFTDOWN   = 0002h
MOUSEEVENTF_LEFTUP     = 0004h
MOUSEEVENTF_RIGHTDOWN  = 0008h
MOUSEEVENTF_RIGHTUP    = 0010h
MOUSEEVENTF_MIDDLEDOWN = 0020h
MOUSEEVENTF_MIDDLEUP   = 0040h
MOUSEEVENTF_WHEEL      = 0800h
MOUSEEVENTF_ABSOLUTE   = 8000h

; TrackPopupMenu flags

TPM_LEFTBUTTON      = 0000h
TPM_RIGHTBUTTON     = 0002h
TPM_LEFTALIGN       = 0000h
TPM_CENTERALIGN     = 0004h
TPM_RIGHTALIGN      = 0008h
TPM_TOPALIGN        = 0000h
TPM_VCENTERALIGN    = 0010h
TPM_BOTTOMALIGN     = 0020h
TPM_HORIZONTAL      = 0000h
TPM_VERTICAL        = 0040h
TPM_NONOTIFY        = 0080h
TPM_RETURNCMD       = 0100h
TPM_RECURSE         = 0001h
TPM_HORPOSANIMATION = 0400h
TPM_HORNEGANIMATION = 0800h
TPM_VERPOSANIMATION = 1000h
TPM_VERNEGANIMATION = 2000h
TPM_NOANIMATION     = 4000h
TPM_LAYOUTRTL       = 8000h

; Menu item info mask values

MIIM_STATE      = 001h
MIIM_ID         = 002h
MIIM_SUBMENU    = 004h
MIIM_CHECKMARKS = 008h
MIIM_TYPE       = 010h
MIIM_DATA       = 020h
MIIM_STRING     = 040h
MIIM_BITMAP     = 080h
MIIM_FTYPE      = 100h

; DRAWITEMSTRUCT control types

ODT_MENU     = 1
ODT_LISTBOX  = 2
ODT_COMBOBOX = 3
ODT_BUTTON   = 4
ODT_STATIC   = 5

; DRAWITEMSTRUCT actions

ODA_DRAWENTIRE = 1
ODA_SELECT     = 2
ODA_FOCUS      = 4

; DRAWITEMSTRUCT states

ODS_SELECTED     = 0001h
ODS_GRAYED       = 0002h
ODS_DISABLED     = 0004h
ODS_CHECKED      = 0008h
ODS_FOCUS        = 0010h
ODS_DEFAULT      = 0020h
ODS_COMBOBOXEDIT = 1000h
ODS_HOTLIGHT     = 0040h
ODS_INACTIVE     = 0080h

; Layered window attributes

LWA_COLORKEY = 1
LWA_ALPHA    = 2

; UpdateLayeredWindow flags

ULW_COLORKEY = 1
ULW_ALPHA    = 2
ULW_OPAQUE   = 4

DLGWINDOWEXTRA = 30

; SystemParametersInfo

SPI_GETACCESSTIMEOUT    = 60
SPI_GETANIMATION        = 72
SPI_GETBEEP             = 1
SPI_GETBORDER           = 5
SPI_GETDEFAULTINPUTLANG = 89
SPI_GETDRAGFULLWINDOWS  = 38
SPI_GETFASTTASKSWITCH   = 35
SPI_GETFILTERKEYS       = 50
SPI_GETFONTSMOOTHING    = 74
SPI_GETGRIDGRANULARITY  = 18
SPI_GETHIGHCONTRAST     = 66
SPI_GETICONMETRICS      = 45
SPI_GETICONTITLELOGFONT = 31
SPI_GETICONTITLEWRAP    = 25
SPI_GETKEYBOARDDELAY    = 22
SPI_GETKEYBOARDPREF     = 68
SPI_GETKEYBOARDSPEED    = 10
SPI_GETLOWPOWERACTIVE   = 83
SPI_GETLOWPOWERTIMEOUT  = 79
SPI_GETMENUDROPALIGNMENT = 27
SPI_GETMINIMIZEDMETRICS = 43
SPI_GETMOUSE            = 3
SPI_GETMOUSEKEYS        = 54
SPI_GETMOUSETRAILS      = 94
SPI_GETNONCLIENTMETRICS = 41
SPI_GETPOWEROFFACTIVE   = 84
SPI_GETPOWEROFFTIMEOUT  = 80
SPI_GETSCREENREADER     = 70
SPI_GETSCREENSAVEACTIVE = 16
SPI_GETSCREENSAVETIMEOUT = 14
SPI_GETSERIALKEYS       = 62
SPI_GETSHOWSOUNDS       = 56
SPI_GETSOUNDSENTRY      = 64
SPI_GETSTICKYKEYS       = 58
SPI_GETTOGGLEKEYS       = 52
SPI_GETWINDOWSEXTENSION = 92
SPI_GETWORKAREA         = 48
SPI_ICONHORIZONTALSPACING = 13
SPI_ICONVERTICALSPACING = 24
SPI_LANGDRIVER          = 12
SPI_SCREENSAVERRUNNING  = 97
SPI_SETACCESSTIMEOUT    = 61
SPI_SETANIMATION        = 73
SPI_SETBEEP             = 2
SPI_SETBORDER           = 6
SPI_SETDEFAULTINPUTLANG = 90
SPI_SETDESKPATTERN      = 21
SPI_SETDESKWALLPAPER    = 20
SPI_SETDOUBLECLICKTIME  = 32
SPI_SETDOUBLECLKHEIGHT  = 30
SPI_SETDOUBLECLKWIDTH   = 29
SPI_SETDRAGFULLWINDOWS  = 37
SPI_SETDRAGHEIGHT       = 77
SPI_SETDRAGWIDTH        = 76
SPI_SETFASTTASKSWITCH   = 36
SPI_SETFILTERKEYS       = 51
SPI_SETFONTSMOOTHING    = 75
SPI_SETGRIDGRANULARITY  = 19
SPI_SETHANDHELD         = 78
SPI_SETHIGHCONTRAST     = 67
SPI_SETICONMETRICS      = 46
SPI_SETICONTITLELOGFONT = 34
SPI_SETICONTITLEWRAP    = 26
SPI_SETKEYBOARDDELAY    = 23
SPI_SETKEYBOARDPREF     = 69
SPI_SETKEYBOARDSPEED    = 11
SPI_SETLANGTOGGLE       = 91
SPI_SETLOWPOWERACTIVE   = 85
SPI_SETLOWPOWERTIMEOUT  = 81
SPI_SETMENUDROPALIGNMENT = 28
SPI_SETMINIMIZEDMETRICS = 44
SPI_SETMOUSE            = 4
SPI_SETMOUSEBUTTONSWAP  = 33
SPI_SETMOUSEKEYS        = 55
SPI_SETMOUSETRAILS      = 93
SPI_SETNONCLIENTMETRICS = 42
SPI_SETPENWINDOWS       = 49
SPI_SETPOWEROFFACTIVE   = 86
SPI_SETPOWEROFFTIMEOUT  = 82
SPI_SETSCREENREADER     = 71
SPI_SETSCREENSAVEACTIVE = 17
SPI_SETSCREENSAVERRUNNING = 97
SPI_SETSCREENSAVETIMEOUT = 15
SPI_SETSERIALKEYS       = 63
SPI_SETSHOWSOUNDS       = 57
SPI_SETSOUNDSENTRY      = 65
SPI_SETSTICKYKEYS       = 59
SPI_SETTOGGLEKEYS       = 53
SPI_SETWORKAREA         = 47
SPIF_UPDATEINIFILE      = 1
SPIF_SENDWININICHANGE   = 2

SPI_GETACTIVEWINDOWTRACKING         = $1000
SPI_SETACTIVEWINDOWTRACKING         = $1001
SPI_GETMENUANIMATION                = $1002
SPI_SETMENUANIMATION                = $1003
SPI_GETCOMBOBOXANIMATION            = $1004
SPI_SETCOMBOBOXANIMATION            = $1005
SPI_GETLISTBOXSMOOTHSCROLLING       = $1006
SPI_SETLISTBOXSMOOTHSCROLLING       = $1007
SPI_GETGRADIENTCAPTIONS             = $1008
SPI_SETGRADIENTCAPTIONS             = $1009
SPI_GETKEYBOARDCUES                 = $100A
SPI_SETKEYBOARDCUES                 = $100B
SPI_GETMENUUNDERLINES               = SPI_GETKEYBOARDCUES
SPI_SETMENUUNDERLINES               = SPI_SETKEYBOARDCUES
SPI_GETACTIVEWNDTRKZORDER           = $100C
SPI_SETACTIVEWNDTRKZORDER           = $100D
SPI_GETHOTTRACKING                  = $100E
SPI_SETHOTTRACKING                  = $100F
SPI_GETMENUFADE                     = $1012
SPI_SETMENUFADE                     = $1013
SPI_GETSELECTIONFADE                = $1014
SPI_SETSELECTIONFADE                = $1015
SPI_GETTOOLTIPANIMATION             = $1016
SPI_SETTOOLTIPANIMATION             = $1017
SPI_GETTOOLTIPFADE                  = $1018
SPI_SETTOOLTIPFADE                  = $1019
SPI_GETCURSORSHADOW                 = $101A
SPI_SETCURSORSHADOW                 = $101B

SPI_GETMOUSESONAR                   = $101C
SPI_SETMOUSESONAR                   = $101D
SPI_GETMOUSECLICKLOCK               = $101E
SPI_SETMOUSECLICKLOCK               = $101F
SPI_GETMOUSEVANISH                  = $1020
SPI_SETMOUSEVANISH                  = $1021
SPI_GETFLATMENU                     = $1022
SPI_SETFLATMENU                     = $1023
SPI_GETDROPSHADOW                   = $1024
SPI_SETDROPSHADOW                   = $1025
SPI_GETBLOCKSENDINPUTRESETS         = $1026
SPI_SETBLOCKSENDINPUTRESETS         = $1027

SPI_GETUIEFFECTS                    = $103E
SPI_SETUIEFFECTS                    = $103F

SPI_GETFOREGROUNDLOCKTIMEOUT        = $2000
SPI_SETFOREGROUNDLOCKTIMEOUT        = $2001
SPI_GETACTIVEWNDTRKTIMEOUT          = $2002
SPI_SETACTIVEWNDTRKTIMEOUT          = $2003
SPI_GETFOREGROUNDFLASHCOUNT         = $2004
SPI_SETFOREGROUNDFLASHCOUNT         = $2005
SPI_GETCARETWIDTH                   = $2006
SPI_SETCARETWIDTH                   = $2007

SPI_GETMOUSECLICKLOCKTIME           = $2008
SPI_SETMOUSECLICKLOCKTIME           = $2009
SPI_GETFONTSMOOTHINGTYPE            = $200A
SPI_SETFONTSMOOTHINGTYPE            = $200B

; constants for SPI_GETFONTSMOOTHINGTYPE and SPI_SETFONTSMOOTHINGTYPE:
FE_FONTSMOOTHINGSTANDARD            = $0001
FE_FONTSMOOTHINGCLEARTYPE           = $0002
FE_FONTSMOOTHINGDOCKING             = $8000

SPI_GETFONTSMOOTHINGCONTRAST           = $200C
SPI_SETFONTSMOOTHINGCONTRAST           = $200D

SPI_GETFOCUSBORDERWIDTH             = $200E
SPI_SETFOCUSBORDERWIDTH             = $200F
SPI_GETFOCUSBORDERHEIGHT            = $2010
SPI_SETFOCUSBORDERHEIGHT            = $2011

SPI_GETFONTSMOOTHINGORIENTATION           = $2012
SPI_SETFONTSMOOTHINGORIENTATION           = $2013

; constants for SPI_GETFONTSMOOTHINGORIENTATION and SPI_SETFONTSMOOTHINGORIENTATION:
FE_FONTSMOOTHINGORIENTATIONBGR   = $0000
FE_FONTSMOOTHINGORIENTATIONRGB   = $0001

;
; Flags
;
SPIF_UPDATEINIFILE    = $0001
SPIF_SENDWININICHANGE = $0002
SPIF_SENDCHANGE       = SPIF_SENDWININICHANGE


; LoadBitmap system images
OBM_LFARROWI    =   32734
OBM_RGARROWI    =   32735
OBM_DNARROWI    =   32736
OBM_UPARROWI    =   32737
OBM_COMBO       =   32738
OBM_MNARROW     =   32739
OBM_LFARROWD    =   32740
OBM_RGARROWD    =   32741
OBM_DNARROWD    =   32742
OBM_UPARROWD    =   32743
OBM_RESTORED    =   32744
OBM_ZOOMD       =   32745
OBM_REDUCED     =   32746
OBM_RESTORE     =   32747
OBM_ZOOM        =   32748
OBM_REDUCE      =   32749
OBM_LFARROW     =   32750
OBM_RGARROW     =   32751
OBM_DNARROW     =   32752
OBM_UPARROW     =   32753
OBM_CLOSE       =   32754

OBM_OLD_RESTORE =   32755
OBM_OLD_ZOOM    =   32756
OBM_OLD_REDUCE  =   32757
OBM_BTNCORNERS  =   32758
OBM_CHECKBOXES  =   32759
OBM_CHECK       =   32760
OBM_BTSIZE      =   32761
OBM_OLD_LFARROW =   32762
OBM_OLD_RGARROW =   32763
OBM_OLD_DNARROW =   32764
OBM_OLD_UPARROW =   32765
OBM_SIZE        =   32766
OBM_OLD_CLOSE   =   32767
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/equates/Win32/_WSOCK32.INC.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: WSOCK32.DLL structures and constants
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


struct WSADATA
  .wVersion       dw ?
  .wHighVersion   dw ?
  .szDescription  rb 256+1
  .szSystemStatus rb 128+1
  .iMaxSockets    dw ?
  .iMaxUdpDg      dw ?
  .lpVendorInfo   dd ?
ends

struct hostent
  .h_name      dd ?
  .h_aliases   dd ?
  .h_addrtype  dw ?
  .h_length    dw ?
  .h_addr_list dd ?
ends

struct sockaddr_in
  .sin_family dw ?
  .sin_port   dw ?
  .sin_addr   dd ?
  .sin_zero   rb 8
ends

struct sockaddr
   .sa_family dw ?
   .sa_data rb 14
ends

; Socket error

SOCKET_ERROR = -1


; Socket types

SOCK_STREAM    = 1
SOCK_DGRAM     = 2
SOCK_RAW       = 3
SOCK_RDM       = 4
SOCK_SEQPACKET = 5

; Address formats

AF_UNSPEC    = 0
AF_UNIX      = 1
AF_INET      = 2
AF_IMPLINK   = 3
AF_PUP       = 4
AF_CHAOS     = 5
AF_NS        = 6
AF_IPX       = 6
AF_ISO       = 7
AF_OSI       = AF_ISO
AF_ECMA      = 8
AF_DATAKIT   = 9
AF_CCITT     = 10
AF_SNA       = 11
AF_DECnet    = 12
AF_DLI       = 13
AF_LAT       = 14
AF_HYLINK    = 15
AF_APPLETALK = 16
AF_NETBIOS   = 17

; Protocol formats

PF_UNSPEC    = 0
PF_UNIX      = 1
PF_INET      = 2
PF_IMPLINK   = 3
PF_PUP       = 4
PF_CHAOS     = 5
PF_NS        = 6
PF_IPX       = 6
PF_ISO       = 7
PF_OSI       = PF_ISO
PF_ECMA      = 8
PF_DATAKIT   = 9
PF_CCITT     = 10
PF_SNA       = 11
PF_DECnet    = 12
PF_DLI       = 13
PF_LAT       = 14
PF_HYLINK    = 15
PF_APPLETALK = 16
PF_NETBIOS   = 17

; IP Ports

IPPORT_ECHO        = 7
IPPORT_DISCARD     = 9
IPPORT_SYSTAT      = 11
IPPORT_DAYTIME     = 13
IPPORT_NETSTAT     = 15
IPPORT_FTP         = 21
IPPORT_TELNET      = 23
IPPORT_SMTP        = 25
IPPORT_TIMESERVER  = 37
IPPORT_NAMESERVER  = 42
IPPORT_WHOIS       = 43
IPPORT_MTP         = 57
IPPORT_TFTP        = 69
IPPORT_RJE         = 77
IPPORT_FINGER      = 79
IPPORT_TTYLINK     = 87
IPPORT_SUPDUP      = 95
IPPORT_EXECSERVER  = 512
IPPORT_LOGINSERVER = 513
IPPORT_CMDSERVER   = 514
IPPORT_EFSSERVER   = 520
IPPORT_BIFFUDP     = 512
IPPORT_WHOSERVER   = 513
IPPORT_ROUTESERVER = 520
IPPORT_RESERVED    = 1024

; Notifications

FD_READ         = 01h
FD_WRITE        = 02h
FD_OOB          = 04h
FD_ACCEPT       = 08h
FD_CONNECT      = 10h
FD_CLOSE        = 20h

; commands for ioctlsocket

FIONBIO         = 8004667Eh
FIONSYNC        = 8004667Dh
FIONREAD        = 4004667Fh
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































Deleted freshlib/equates/Win32/_exceptions.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Exception handling constants and structures.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


EXCEPTION_MAXIMUM_PARAMETERS = 15

DBG_CONTINUE                         = 00010002h
DBG_TERMINATE_THREAD                 = 40010003h
DBG_TERMINATE_PROCESS                = 40010004h
DBG_CONTROL_C                        = 40010005h
DBG_CONTROL_BREAK                    = 40010008h
DBG_EXCEPTION_NOT_HANDLED            = 80010001h

EXCEPTION_DEBUG_EVENT                = 1
CREATE_THREAD_DEBUG_EVENT            = 2
CREATE_PROCESS_DEBUG_EVENT           = 3
EXIT_THREAD_DEBUG_EVENT              = 4
EXIT_PROCESS_DEBUG_EVENT             = 5
LOAD_DLL_DEBUG_EVENT                 = 6
UNLOAD_DLL_DEBUG_EVENT               = 7
OUTPUT_DEBUG_STRING_EVENT            = 8
RIP_EVENT                            = 9

CONTEXT_i386 = 00010000h
CONTEXT_i486 = 00010000h
CONTEXT_CONTROL = CONTEXT_i386 OR 00000001h
CONTEXT_INTEGER = CONTEXT_i386 OR 00000002h
CONTEXT_SEGMENTS = CONTEXT_i386 OR 00000004h
CONTEXT_FLOATING_POINT = CONTEXT_i386 OR 00000008h
CONTEXT_DEBUG_REGISTERS = CONTEXT_i386 OR 00000010h
CONTEXT_FULL = CONTEXT_CONTROL OR CONTEXT_INTEGER OR CONTEXT_SEGMENTS



struct EXCEPTION_RECORD
  .ExceptionCode      dd ?
  .ExceptionFlags     dd ?
  .ptrExceptionRecord dd ?
  .ExceptionAddress   dd ?
  .NumberParameters   dd ?
  .ExceptionInformation rd EXCEPTION_MAXIMUM_PARAMETERS
ends

struct EXCEPTION_DEBUG_INFO
  .ExceptionRecord EXCEPTION_RECORD
  .dwFirstChance dd ?
ends

struct CREATE_THREAD_DEBUG_INFO
  .hThread               dd  ?
  .lpThreadLocalBase     dd  ?
  .lpStartAddress        dd  ?
ends

struct CREATE_PROCESS_DEBUG_INFO
  .hFile                 dd  ?
  .hProcess              dd  ?
  .hThread               dd  ?
  .lpBaseOfImage         dd  ?
  .dwDebugInfoFileOffset dd  ?
  .nDebugInfoSize        dd  ?
  .lpThreadLocalBase     dd  ?
  .lpStartAddress        dd  ?
  .lpImageName           dd  ?
  .fUnicode              dw  ?
ends


struct EXIT_THREAD_DEBUG_INFO
  .dwExitCode  dd      ?
ends

struct EXIT_PROCESS_DEBUG_INFO
  .dwExitCode  dd      ?
ends


struct LOAD_DLL_DEBUG_INFO
  .hFile                     dd   ?
  .lpBaseOfDll               dd   ?
  .dwDebugInfoFileOffset     dd   ?
  .nDebugInfoSize            dd   ?
  .lpImageName               dd   ?
  .fUnicode                  dw   ?
ends


struct UNLOAD_DLL_DEBUG_INFO
  .lpBaseOfDll  dd  ?
ends


struct OUTPUT_DEBUG_STRING_INFO
  .lpDebugStringData     dd    ?
  .fUnicode              dw    ?
  .nDebugStringiLength   dw    ?
ends


struct RIP_INFO
  .dwError  dd  ?
  .dwType   dd  ?
ends


SIZE_OF_80387_REGISTERS   = 80
MAXIMUM_SUPPORTED_EXTENSION = 512

struct FLOATING_SAVE_AREA
  .ControlWord   dd      ?
  .StatusWord    dd      ?
  .TagWord       dd      ?
  .ErrorOffset   dd      ?
  .ErrorSelector dd      ?
  .DataOffset    dd      ?
  .DataSelector  dd      ?
  .RegisterArea  rb SIZE_OF_80387_REGISTERS
  .Cr0NpxState   dd      ?
ends

struct CONTEXT
  .ContextFlags  dd      ?
  .iDr0          dd      ?
  .iDr1          dd      ?
  .iDr2          dd      ?
  .iDr3          dd      ?
  .iDr6          dd      ?
  .iDr7          dd      ?
  .FloatSave     FLOATING_SAVE_AREA
  .regGs         dd      ?
  .regFs         dd      ?
  .regEs         dd      ?
  .regDs         dd      ?
  .regEdi        dd      ?
  .regEsi        dd      ?
  .regEbx        dd      ?
  .regEdx        dd      ?
  .regEcx        dd      ?
  .regEax        dd      ?
  .regEbp        dd      ?
  .regEip        dd      ?
  .regCs         dd      ?
  .regFlag       dd      ?
  .regEsp        dd      ?
  .regSs         dd      ?
  .ExtendedRegisters rb MAXIMUM_SUPPORTED_EXTENSION
ends


struct SECURITY_ATTRIBUTES
  .nLength              dd ?
  .lpSecurityDescriptor dd ?
  .bInheritHandle       dd ?
ends





<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































Deleted freshlib/equates/Win32/allequates.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Combined include of all Win32 equate files.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

include '_kernel32.inc'
include '_user32.inc'
include '_gdi32.inc'
include '_comctl32.inc'
include '_comdlg32.inc'
include '_shell32.inc'
include '_wsock32.inc'
include '_RichEdit32.inc'
include '_ODBC32.inc'
include '_HTMLHelp.inc'
include '_exceptions.inc'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































Deleted freshlib/equates/_sqlite3.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: SQLite equates definitions.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

; SQLite result codes

SQLITE_OK         =  0   ; Successful result
SQLITE_ERROR      =  1   ; SQL error or missing database
SQLITE_INTERNAL   =  2   ; An internal logic error in SQLite
SQLITE_PERM       =  3   ; Access permission denied
SQLITE_ABORT      =  4   ; Callback routine requested an abort
SQLITE_BUSY       =  5   ; The database file is locked
SQLITE_LOCKED     =  6   ; A table in the database is locked
SQLITE_NOMEM      =  7   ; A malloc() failed
SQLITE_READONLY   =  8   ; Attempt to write a readonly database
SQLITE_INTERRUPT  =  9   ; Operation terminated by sqlite_interrupt()
SQLITE_IOERR      = 10   ; Some kind of disk I/O error occurred
SQLITE_CORRUPT    = 11   ; The database disk image is malformed
SQLITE_NOTFOUND   = 12   ; (Internal Only) Table or record not found
SQLITE_FULL       = 13   ; Insertion failed because database is full
SQLITE_CANTOPEN   = 14   ; Unable to open the database file
SQLITE_PROTOCOL   = 15   ; Database lock protocol error
SQLITE_EMPTY      = 16   ; (Internal Only) Database table is empty
SQLITE_SCHEMA     = 17   ; The database schema changed
SQLITE_TOOBIG     = 18   ; Too much data for one row of a table
SQLITE_CONSTRAINT = 19   ; Abort due to constraint violation
SQLITE_MISMATCH   = 20   ; Data type mismatch
SQLITE_MISUSE     = 21   ; Library used incorrectly
SQLITE_NOLFS      = 22   ; Uses OS features not supported on host
SQLITE_AUTH       = 23   ; Authorization denied
SQLITE_ROW        = 100  ; sqlite_step() has another row ready
SQLITE_DONE       = 101  ; sqlite_step() has finished executing


SQLITE_CREATE_INDEX        =  1 ;   // Index Name      Table Name      */
SQLITE_CREATE_TABLE        =  2 ;   // Table Name      NULL            */
SQLITE_CREATE_TEMP_INDEX   =  3 ;   // Index Name      Table Name      */
SQLITE_CREATE_TEMP_TABLE   =  4 ;   // Table Name      NULL            */
SQLITE_CREATE_TEMP_TRIGGER =  5 ;   // Trigger Name    Table Name      */
SQLITE_CREATE_TEMP_VIEW    =  6 ;   // View Name       NULL            */
SQLITE_CREATE_TRIGGER      =  7 ;   // Trigger Name    Table Name      */
SQLITE_CREATE_VIEW         =  8 ;   // View Name       NULL            */
SQLITE_DELETE              =  9 ;   // Table Name      NULL            */
SQLITE_DROP_INDEX          = 10 ;   // Index Name      Table Name      */
SQLITE_DROP_TABLE          = 11 ;   // Table Name      NULL            */
SQLITE_DROP_TEMP_INDEX     = 12 ;   // Index Name      Table Name      */
SQLITE_DROP_TEMP_TABLE     = 13 ;   // Table Name      NULL            */
SQLITE_DROP_TEMP_TRIGGER   = 14 ;   // Trigger Name    Table Name      */
SQLITE_DROP_TEMP_VIEW      = 15 ;   // View Name       NULL            */
SQLITE_DROP_TRIGGER        = 16 ;   // Trigger Name    Table Name      */
SQLITE_DROP_VIEW           = 17 ;   // View Name       NULL            */
SQLITE_INSERT              = 18 ;   // Table Name      NULL            */
SQLITE_PRAGMA              = 19 ;   // Pragma Name     1st arg or NULL */
SQLITE_READ                = 20 ;   // Table Name      Column Name     */
SQLITE_SELECT              = 21 ;   // NULL            NULL            */
SQLITE_TRANSACTION         = 22 ;   // NULL            NULL            */
SQLITE_UPDATE              = 23 ;   // Table Name      Column Name     */
SQLITE_ATTACH              = 24 ;   // Filename        NULL            */
SQLITE_DETACH              = 25 ;   // Database Name   NULL            */

SQLITE_DENY   = 1       ;   // Abort the SQL statement with an error */
SQLITE_IGNORE = 2       ;   // Don't allow access, but don't generate an error */


; These are the allowed values for the eTextRep argument to
; sqliteCreateCollation and sqliteCreateFunction.

SQLITE_UTF8       = 1
SQLITE_UTF16LE    = 2
SQLITE_UTF16BE    = 3
SQLITE_UTF16      = 4   ;   Use native byte order
SQLITE_ANY        = 5

; values returned by sqliteColumnType
SQLITE_INTEGER    = 1
SQLITE_FLOAT      = 2
SQLITE_TEXT       = 3
SQLITE_BLOB       = 4
SQLITE_NULL       = 5


SQLITE_STATIC     = 0
SQLITE_TRANSIENT  = -1
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































Deleted freshlib/equates/_zlib1.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Constants and structures definitions for ZLIB library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

; zlib.h -- interface of the 'zlib' general purpose compression library
;  version 1.2.3, July 18th, 2005
;
;  Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
;
;  This software is provided 'as-is', without any express or implied
;  warranty.  In no event will the authors be held liable for any damages
;  arising from the use of this software.
;
;  Permission is granted to anyone to use this software for any purpose,
;  including commercial applications, and to alter it and redistribute it
;  freely, subject to the following restrictions:
;
;  1. The origin of this software must not be misrepresented; you must not
;     claim that you wrote the original software. If you use this software
;     in a product, an acknowledgment in the product documentation would be
;     appreciated but is not required.
;  2. Altered source versions must be plainly marked as such, and must not be
;     misrepresented as being the original software.
;  3. This notice may not be removed or altered from any source distribution.
;
;  Jean-loup Gailly        Mark Adler
;  jloup@gzip.org          madler@alumni.caltech.edu
;
;
;  The data format used by the zlib library is described by RFCs (Request for
;  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
;  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
;


; zconf.h -- configuration of the zlib compression library
; Copyright (C) 1995-2005 Jean-loup Gailly.
; For conditions of distribution and use, see copyright notice in zlib.h
;

MAX_MEM_LEVEL = 9
MAX_WBITS     = 15 ; 32K LZ77 window

ZLIB_VERSION equ "1.2.3"
ZLIB_VERNUM = $1230


struct z_stream

    ptrNextIn   dd      ?    ;  next input byte
    AvailIn     dd      ?    ;  number of bytes available at next_in
    TotalIn     dd  ?    ;  total nb of input bytes read so far

    ptrNextOut  dd  ?    ;  next output byte should be put there
    AvailOut    dd  ?    ;  remaining free space at next_out
    TotalOut    dd  ?    ;  total nb of bytes output so far

    ptrMsg      dd  ?    ;  last error message, NULL if no error

    ptrState    dd  ?    ;  not visible by applications

    zalloc      dd  ?    ;  used to allocate the internal state
    zfree       dd  ?    ;  used to free the internal state
    opaque      dd  ?    ;  private data object passed to zalloc and zfree

    data_type   dd  ?    ;  best guess about the data type: binary or text
    adler       dd  ?    ;  adler32 value of the uncompressed data
    reserved    dd  ?    ;  reserved for future use
ends


; constants

; Allowed flush values; see deflate() and inflate() below for details
Z_NO_FLUSH      =       0
Z_PARTIAL_FLUSH =       1       ; will be removed, use Z_SYNC_FLUSH instead
Z_SYNC_FLUSH    =       2
Z_FULL_FLUSH    =       3
Z_FINISH        =       4
Z_BLOCK         =       5

; Return codes for the compression/decompression functions. Negative
; values are errors, positive values are used for special but normal events.

Z_OK            =       0
Z_STREAM_END    =       1
Z_NEED_DICT     =       2
Z_ERRNO         =       -1
Z_STREAM_ERROR  =       -2
Z_DATA_ERROR    =       -3
Z_MEM_ERROR     =       -4
Z_BUF_ERROR     =       -5
Z_VERSION_ERROR =       -6

; compression levels
Z_NO_COMPRESSION        =       0
Z_BEST_SPEED            =       1
Z_BEST_COMPRESSION      =       9
Z_DEFAULT_COMPRESSION   =       -1

; compression strategy; see deflateInit2() below for details */

Z_FILTERED              =       1
Z_HUFFMAN_ONLY          =       2
Z_RLE                   =       3
Z_FIXED                 =       4
Z_DEFAULT_STRATEGY      =       0


; Possible values of the data_type field (though see inflate()) */

Z_BINARY        =       0
Z_TEXT          =       1
Z_ASCII         =       Z_TEXT   ; for compatibility with 1.2.2 and earlier
Z_UNKNOWN       =       2

; The deflate compression method (the only one supported in this version)
Z_DEFLATED      =       8

Z_NULL          =       0  ; for initializing zalloc, zfree, opaque

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































Deleted freshlib/equates/allequates.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Combined include of all equates.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

TRUE = 1
FALSE = 0

NULL = 0

include '%TargetOS%/allequates.inc'

include '_sqlite3.inc'
include '_zlib1.inc'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































Deleted freshlib/freshlib.asm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: FreshLib amalgamation include file for the library code.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

include 'simpledebug/debug.asm'

include 'system/all.asm'
include 'data/all.asm'
include 'graphics/all.asm'
include 'gui/all.asm'

include 'FreshEdit/FreshEdit.asm'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































Deleted freshlib/freshlib.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: FreshLib amalgamation include file for the non code definitions.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

include 'compiler/executable.inc'
include 'macros/allmacros.inc'
include 'equates/allequates.inc'

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































Deleted freshlib/graphics/Linux/backbuffer.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Provides raster bitmap, to be used for double buffer painting.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________



proc CreateBackBuffer, .hwin, .width, .height
begin
        push    ebx ecx edx

        stdcall GetMem, sizeof.TBackBuffer
        mov     ebx, eax

        mov     ecx, [.width]
        mov     edx, [.height]

        xor     eax, eax
        inc     eax

        cmp     ecx, eax
        jge     @f
        mov     ecx, eax
@@:
        cmp     edx, eax
        jge     @f
        mov     edx, eax
@@:
        mov     [ebx+TBackBuffer.width], ecx
        mov     [ebx+TBackBuffer.height], edx

        cinvoke XCreatePixmap, [hApplicationDisplay], [.hwin], [ebx+TBackBuffer.width], [ebx+TBackBuffer.height], 24
        mov     [ebx+TBackBuffer.raster], eax
        mov     eax, ebx
        pop     edx ecx ebx
        return
endp




proc DestroyBackBuffer, .pBackBuffer
begin
        push    eax ecx edx
        mov     eax, [.pBackBuffer]
        push    eax
        cinvoke XFreePixmap, [hApplicationDisplay], [eax+TBackBuffer.raster]
        stdcall FreeMem ; from the stack
        pop     edx ecx eax
        return
endp






proc DrawBackBuffer, .context, .pBackBuffer, .x, .y
begin
        push    eax ecx edx
        mov     eax, [.pBackBuffer]
        mov     ecx, [.context]

        cinvoke XCopyArea, [hApplicationDisplay], [eax+TBackBuffer.raster], [ecx+TContext.raster], [ecx+TContext.handle], 0, 0, [eax+TBackBuffer.width], [eax+TBackBuffer.height], [.x], [.y]

        pop     edx ecx eax
        return
endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































Deleted freshlib/graphics/Linux/context.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Context is a object that represents drawing surface in FreshLib
;
;  Target OS: Linux
;
;  Dependencies: memory.asm
;
;  Notes:
;_________________________________________________________________________________________


cmClear       =       GXclear
cmAnd         =       GXand
cmAndReverse  =       GXandReverse
cmCopy        =       GXcopy
cmAndInverted =       GXandInverted
cmNoOp        =       GXnoop
cmXor         =       GXxor
cmOr          =       GXor
cmNor         =       GXnor
cmEquiv       =       GXequiv
cmInvert      =       GXinvert
cmXorReverse  =       GXorReverse
cmCopyInverted =      GXcopyInverted
cmOrInverted   =      GXorInverted
cmNand         =      GXnand
cmSet          =      GXset


image_pointer_context = 2

proc AllocateContext, .raster
begin
        push    ebx ecx edx

        stdcall GetMem, sizeof.TContext
        jc      .error
        mov     ebx, eax

        mov     eax, [.raster]
        mov     [ebx+TContext.raster], eax

        cinvoke XCreateGC, [hApplicationDisplay], [ebx+TContext.raster], 0, 0
        mov     [ebx+TContext.handle], eax
        mov     eax, ebx

.exit:
        pop     edx ecx ebx
        clc
        return

.error:
        DebugMsg 'Error allocating context.'
        xor     eax, eax
        pop     edx ecx ebx
        stc
        return
endp




proc ReleaseContext, .context
begin
        push    eax ebx ecx edx
        mov     ebx, [.context]
        cinvoke XFlush, [hApplicationDisplay]
        cinvoke XFreeGC, [hApplicationDisplay], [ebx+TContext.handle]
        cmp     [ebx+TContext.clipregion], 0
        je      @f
        cinvoke XDestroyRegion, [ebx+TContext.clipregion]
@@:
        stdcall FreeMem, ebx

        clc
        pop     edx ecx ebx eax
        return
endp



proc SetLineStyle, .context, .pLineStyle
.color dd ?
begin
        push    eax ebx ecx edx esi

        mov     ebx, [.context]
        mov     esi, [.pLineStyle]

        mov     eax, [esi+TLineStyle.flags]
        mov     ecx, eax
        shr     ecx, 8
        and     eax, $ff        ; cap_style
        and     ecx, $ff        ; join_style

        mov     edx, LineSolid
        cmp     [esi+TLineStyle.DashCount], 0
        je      @f
        mov     edx, LineDoubleDash
@@:
        cinvoke XSetLineAttributes, [hApplicationDisplay], [ebx+TContext.handle], [esi+TLineStyle.width], edx, eax, ecx
        cinvoke XSetForeground,     [hApplicationDisplay], [ebx+TContext.handle], [esi+TLineStyle.color]

        cmp     [esi+TLineStyle.DashCount], 0
        je      .exit

        lea     ecx, [esi+TLineStyle.DashItems]
        cinvoke XSetDashes, [hApplicationDisplay], [ebx+TContext.handle], 0, ecx, [esi+TLineStyle.DashCount]
        cinvoke XSetBackground, [hApplicationDisplay], [ebx+TContext.handle], [esi+TLineStyle.clSpace]

.exit:
        pop     esi edx ecx ebx eax
        return
endp


proc  SetDrawMode, .context, .mode
begin
        push    eax ecx edx
        mov     eax, [.context]
        cinvoke XSetFunction, [hApplicationDisplay], [eax+TContext.handle], [.mode]
        pop     edx ecx eax
        return
endp





proc SetClipRectangle, .context, .pBounds
.rect XRectangle
begin
        push    eax ecx edx esi

        mov     esi, [.context]

        cmp     [esi+TContext.clipregion], 0
        je      @f
        cinvoke XDestroyRegion, [esi+TContext.clipregion]
@@:
        cinvoke XCreateRegion
        mov     [esi+TContext.clipregion], eax

        mov     edx, [.pBounds]
        test    edx, edx
        jz      .remove

        mov     eax, [edx+TBounds.x]
        mov     [.rect.x], ax

        mov     eax, [edx+TBounds.y]
        mov     [.rect.y], ax

        mov     eax, [edx+TBounds.width]
        mov     [.rect.width], ax

        mov     eax, [edx+TBounds.height]
        mov     [.rect.height], ax

        lea     edx, [.rect]
        cinvoke XUnionRectWithRegion, edx, [esi+TContext.clipregion], [esi+TContext.clipregion]
        cinvoke XSetRegion, [hApplicationDisplay], [esi+TContext.handle], [esi+TContext.clipregion]

.exit:
        pop     esi edx ecx eax
        return

.remove:
        cinvoke XSetClipMask, [hApplicationDisplay], [esi+TContext.handle], None
        jmp     .exit
endp




proc IsDrawable, .raster
begin

;       cinvoke  XSetErrorHandler,





endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































































Deleted freshlib/graphics/Linux/draw.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Draw library contains procedures for drawing oprtations.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

lsEndCapRound = CapRound
lsEndCapSquare = CapButt
lsEndCapFlat   = CapProjecting

lsJoinRound = JoinRound shl 8
lsJoinBevel = JoinBevel shl 8
lsJoinMiter = JoinMiter shl 8



proc DrawLine, .context, .x1, .y1, .x2, .y2
begin
        push    eax ebx ecx edx

        mov     ebx, [.context]
        cinvoke XDrawLine, [hApplicationDisplay], [ebx+TContext.raster], [ebx+TContext.handle], [.x1], [.y1], [.x2], [.y2]
        pop     edx ecx ebx eax
        return
endp


proc DrawFillRect, .context, .x, .y, .width, .height, .color
begin
        push    eax ebx ecx edx
        mov     ebx, [.context]
        cinvoke XSetForeground, [hApplicationDisplay], [ebx+TContext.handle], [.color]
        cinvoke XFillRectangle, [hApplicationDisplay], [ebx+TContext.raster], [ebx+TContext.handle], [.x], [.y], [.width], [.height]
        pop     edx ecx ebx eax
        return
endp



macro Outline [type, x, y] {
  common
local ..types, ..points, ..count
     dd  ..count
     dd  ..types
     dd  ..points
  common
    label ..types byte
  forward
     db type
  common
    label ..points dword
  forward
    dd  x
    dd  y
}



;proc Draw, .context, .pDrawPoints
;begin
;
;        return
;endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































Deleted freshlib/graphics/Linux/fonts.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Fonts managing library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


proc FontCreate, .fontname, .size, .weight, .flags
begin
        push    ebx ecx edx
        stdcall StrDup, [.fontname]
        mov     ebx, eax

        test    [.flags], ffMonospaced
        jz      @f
        stdcall StrCat, ebx, FontAttr.mono
@@:
        sub     [.size], 2
        cmp     [.size], 0
        jle     @f

        stdcall StrCat, ebx, FontAttr.size
        stdcall NumToStr, [.size], ntsDec or ntsUnsigned
        push    eax
        stdcall StrCat, ebx, eax
        stdcall StrDel ; from the stack
@@:
        cmp     [.weight], 0
        je      @f
        shr     [.weight], 2
        stdcall StrCat, ebx, FontAttr.weight
        stdcall NumToStr, [.weight], ntsDec or ntsUnsigned
        push    eax
        stdcall StrCat, ebx, eax
        stdcall StrDel ; from the stack

@@:
        test    [.flags], ffItalic
        jz      @f
        stdcall StrCat, ebx, FontAttr.italic
@@:

        stdcall StrPtr, ebx
        cinvoke XftFontOpenName, [hApplicationDisplay], 0, eax

        stdcall StrDel, ebx
        pop     edx ecx ebx
        return
endp


iglobal
  if used FontCreate
    label FontAttr byte
    .mono db ',Mono', 0
    .size db ':pixelsize=', 0
    .weight db ':weight=', 0
    .italic db ':slant=italic', 0
  end if
endg










macro XftPushArg field, type, value {
      push value
      push type
      push field
      add  ebx, 12
}

macro XftStartArguments {
      push 0
      mov  ebx, 4
}

XftFamily  text 'family'
XftStyle   text 'style'
XftSpacing text 'spacing'
XftSlant   text 'slant'
XftWeight  text 'weight'
XftWidth   text 'width'
XftPixelSize text 'pixelsize'
XftAntialias text 'antialias'
XftAutohint  text 'autohint'
XftHintStyle text 'hintstyle'
XftHinting   text 'hinting'
XftRGBA      text 'rgba'


proc FontCreate3, .fontname, .size, .weight, .flags
begin
        push    ebx ecx edx


        XftStartArguments

        cmp     [.fontname], 0
        je      @f
        stdcall StrPtr, [.fontname]
        XftPushArg XftFamily, XftTypeString, eax
@@:

        cmp     [.size], 2
        jle     @f
        sub     [.size], 2
        XftPushArg XftPixelSize, XftTypeInteger, [.size]
@@:

        cmp     [.weight], 0
        jle     @f
        shr     [.weight], 1
        XftPushArg XftWeight,    XftTypeInteger, [.weight]
@@:

        test    [.flags], ffItalic
        jz      @f
        XftPushArg XftSlant, XftTypeInteger, XFT_SLANT_ITALIC
@@:

        test    [.flags], ffMonospaced
        jz      @f
        XftPushArg XftSpacing, XftTypeInteger, XFT_MONO
@@:
        XftPushArg XftAntialias, XftTypeBool, 0
        XftPushArg XftHinting, XftTypeBool, 0
        XftPushArg XftHintStyle, XftTypeInteger, 0
        XftPushArg XftRGBA, XftTypeInteger, 5
        XftPushArg XftWidth, XftTypeInteger, 100

        invoke  XftFontOpen, [hApplicationDisplay], 0
        add     ebx, 8
        add     esp, ebx

        pop     edx ecx ebx
        return
endp




proc FontDestroy, .font
begin
        stdcall XftFontClose, [hApplicationDisplay], [.font]
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































Deleted freshlib/graphics/Linux/images.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Memory based images manipulation library.
;
;  Target OS: Linux
;
;  Dependencies: memory.asm
;
;  Notes:
;_________________________________________________________________________________________

; only 16, 24 and 32 bpp are supported.
; It is stupid to support palleted modes and even 24bpp is not good...
proc CreateImage, .width, .height, .bpp
.scanline dd ?
begin
        push    ebx ecx edx esi

        stdcall GetMem, sizeof.TImage
        jc      .finish

        mov     esi, eax

        cmp     [.width], 0
        jg     @f
        mov     [.width], 1
@@:
        cmp     [.height], 0
        jg     @f
        mov     [.height], 1
@@:

        push    [.width] [.height] [.bpp]
        pop     [esi+TImage.bpp] [esi+TImage.height] [esi+TImage.width]

; allocate image data

        mov     ecx, [.bpp]
        mov     eax, [.height]
        shr     ecx, 3
        imul    ecx, [.width]
        add     ecx, 3
        and     ecx, $fffffffc  ; align scanline to dword.
        mov     [.scanline], ecx
        imul    eax, ecx

        stdcall GetMem, eax
        jc      .error_free
        mov     [esi+TImage.pData], eax

; IMPORTANT!
; The depth - 3rd argument MUST be $18 - I tested it on 16bpp and 32bpp screen setting and it works.
; in all other settings XPutImage fails with segmentation fault or with BadMatch error.
; This procedure is tested only with 32bit images - [.bpp]=32.
; This issue needs some more research, but the documentation is pretty obscure and I am not so good in Linux programming.
        mov     eax, [.bpp]
        add     eax, $0f
        and     eax, $f0
        cinvoke XCreateImage, [hApplicationDisplay], 0, $18, ZPixmap, 0, [esi+TImage.pData], [.width], [.height], eax, [.scanline]
        mov     [esi+TImage.raster], eax

        clc
        mov     eax, esi
.finish:
        pop     esi edx ecx ebx
        return

.error_free:
        stdcall FreeMem, esi
        stc
        jmp     .finish
endp




proc DestroyImage, .ptrImage
begin
        push    eax ecx edx esi

        mov     esi, [.ptrImage]
        test    esi, esi
        jz      @f

        cinvoke XDestroyImage, [esi+TImage.raster]
        stdcall FreeMem, esi
@@:
        pop     esi edx ecx eax
        return
endp




proc DrawImage, .context, .pImage, .x, .y
begin
        push    eax ecx edx

        mov     eax, [.pImage]
        test    eax, eax
        jz      .exit

        mov     ecx, [.context]
        cinvoke XPutImage, [hApplicationDisplay], [ecx+TContext.raster], [ecx+TContext.handle], [eax+TImage.raster], 0, 0, [.x], [.y], [eax+TImage.width], [eax+TImage.height]
.exit:
        pop     edx ecx eax
        return
endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































Deleted freshlib/graphics/Linux/text.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Text drawing library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes: Uses XFT library to renter the text.
;_________________________________________________________________________________________


proc __ColorToRender, .color, .rendercolor
begin
        push    eax ecx edx

        mov     edx, [.rendercolor]

        xor     eax, eax
        xor     ecx, ecx

        mov     ah, byte [.color]
        mov     ch, byte [.color+1]

        mov     [edx+_XftColor.color.blue], ax
        mov     [edx+_XftColor.color.green], cx

        mov     ah, byte [.color+2]
        mov     ch, byte [.color+3]
        xor     ch, $ff
        mov     [edx+_XftColor.color.red], ax
        mov     [edx+_XftColor.color.alpha], cx

        pop     edx ecx eax
        return
endp



proc DrawString, .context, .ptrString, .len, .x, .y, .font, .color
  .cltxt   _XftColor
begin
        push    eax ebx ecx edx esi edi

        cmp     [.font], 0
        jne     @f

        mov     eax, [_SystemFont]
        mov     [.font], eax

@@:
        cinvoke XDefaultVisual, [hApplicationDisplay], 0
        mov     ecx, [.context]
        cinvoke XftDrawCreate, [hApplicationDisplay], [ecx+TContext.raster], eax, 0
        mov     ebx, eax

        mov     ecx, [.context]
        cinvoke XftDrawSetClip, ebx, [ecx+TContext.clipregion]

        lea     eax, [.cltxt]
        stdcall __ColorToRender, [.color], eax

        cinvoke XftDrawStringUtf8, ebx, eax, [.font], [.x], [.y], [.ptrString], [.len]
        cinvoke XftDrawDestroy, ebx

        pop     edi esi edx ecx ebx eax
        return
endp




proc DrawStringOpaque, .context, .ptrString, .len, .x, .y, .font, .color, .background
  .cltxt   _XftColor
begin
        push    eax ebx ecx edx esi edi

        cmp     [.font], 0
        jne     @f

        mov     eax, [_SystemFont]
        mov     [.font], eax

@@:
        cinvoke XDefaultVisual, [hApplicationDisplay], 0
        mov     ecx, [.context]
        cinvoke XftDrawCreate, [hApplicationDisplay], [ecx+TContext.raster], eax, 0
        mov     ebx, eax

        mov     ecx, [.context]
        cinvoke XftDrawSetClip, ebx, [ecx+TContext.clipregion]

        lea     eax, [.cltxt]
        stdcall __ColorToRender, [.color], eax

        cinvoke XftDrawStringUtf8, ebx, eax, [.font], [.x], [.y], [.ptrString], [.len]
        cinvoke XftDrawDestroy, ebx

        pop     edi esi edx ecx ebx eax
        return
endp



proc DrawColoredString, .context, .ptrString, .pCharAttr, .str_len_bytes, .x, .y, .char_offs, .fontwidth, .fontheight
.xbeg   dd ?
.cltxt  _XftColor
.char   dd ?
.height dd ?
.offs   dd ?
.skip   dd ?
begin
        push    eax ebx ecx edx esi edi

        mov     esi, [.pCharAttr]

        mov     eax, [.x]
        mov     [.xbeg], eax

        cinvoke XDefaultVisual, [hApplicationDisplay], 0
        mov     ecx, [.context]
        cinvoke XftDrawCreate, [hApplicationDisplay], [ecx+TContext.raster], eax, 0
        mov     ebx, eax

        mov     ecx, [.context]
        cinvoke XftDrawSetClip, ebx, [ecx+TContext.clipregion]

        lea     edi, [.cltxt]

        stdcall GetTextBounds, [.context], __HeightProbeString, __HeightProbeString.length, [esi+TCharAttr.font]
        mov     [.height], edx

        stdcall GetTextOffset, [.context], __HeightProbeString, __HeightProbeString.length, [esi+TCharAttr.font]
        mov     [.offs], edx

.skip_offset:
        mov     ecx, [.char_offs]
        mov     [.skip], ecx

.drawloop:
        cmp     [.str_len_bytes], 0
        jle     .enddraw

        mov     ecx, [.ptrString]
        stdcall DecodeUtf8, [ecx]
        mov     [.char], edx

        cmp     eax, $01        ; word wrap character
        je      .wrapline

        cmp     [.skip], 0
        jg      .drawok

;        mov     ecx, [.y]
;        sub     ecx, [.offs]
;        sub     ecx, 2
;        stdcall DrawFillRect, [.context], [.x], ecx, [.fontwidth], [.height], [esi+TCharAttr.backbround]

        stdcall __ColorToRender, [esi+TCharAttr.color], edi
        cinvoke XftDrawStringUtf8, ebx, edi, [esi+TCharAttr.font], [.x], [.y], [.ptrString], [.char]

        mov     eax, [.fontwidth]
        add     [.x], eax
;        sub     [.width], eax
;        js      .enddraw

.drawok:
        dec     [.skip]
        mov     eax, [.char]
        add     [.ptrString], eax
        sub     [.str_len_bytes], eax

        add     esi, sizeof.TCharAttr
        jne     .drawloop

.enddraw:
        cinvoke XftDrawDestroy, ebx
        pop     edi esi edx ecx ebx eax
        return

.wrapline:
        mov     eax, [.fontheight]
        add     [.y], eax
        mov     eax, [.xbeg]
        mov     [.x], eax

        mov     eax, [.char]
        add     [.ptrString], eax
        sub     [.str_len_bytes], eax

        add     esi, sizeof.TCharAttr
        jmp     .skip_offset

endp







; returns:
;       eax - width of the string in pixels.
;       edx - heigth of the string in pixels.


proc GetTextBounds, .context, .ptrString, .len, .font
.extents _XGlyphInfo
begin
        push    esi ecx

        cmp     [.font], 0
        jne     @f

        mov     eax, [_SystemFont]
        mov     [.font], eax

@@:
        lea     esi, [.extents]
        cinvoke   XftTextExtentsUtf8, [hApplicationDisplay], [.font], [.ptrString], [.len], esi

        movzx   eax, [esi+_XGlyphInfo.xOff]
        movzx   edx, [esi+_XGlyphInfo.height]
        add     edx, 2

        pop     ecx esi
        return
endp


; returns:
;       eax - x offset of the baseline of the string.
;       edx - y offset of the baseline of the string.

proc GetTextOffset, .context, .ptrString, .len, .font
.extents _XGlyphInfo
begin
        push    esi ecx

        cmp     [.font], 0
        jne     @f

        mov     eax, [_SystemFont]
        mov     [.font], eax

@@:
        lea     esi, [.extents]
        cinvoke   XftTextExtentsUtf8, [hApplicationDisplay], [.font], [.ptrString], [.len], esi

        movzx   eax, [esi+_XGlyphInfo.x]
        movzx   edx, [esi+_XGlyphInfo.y]
        add     edx, 2

        pop     ecx esi
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































































Deleted freshlib/graphics/Win32/backbuffer.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Provides raster bitmap, to be used for double buffer painting.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________



proc CreateBackBuffer, .hwin, .width, .height
begin
        push    ebx ecx edx

        stdcall GetMem, sizeof.TBackBuffer
        mov     ebx, eax

        mov     ecx, [.width]
        mov     edx, [.height]

        test    ecx, ecx
        jns     @f
        xor     ecx, ecx
@@:
        test    edx, edx
        jns     @f
        xor     edx, edx
@@:
        mov     [ebx+TBackBuffer.width], ecx
        mov     [ebx+TBackBuffer.height], edx

        invoke  GetDC, [.hwin]
        push    eax
        invoke  CreateCompatibleBitmap, eax, [ebx+TBackBuffer.width], [ebx+TBackBuffer.height]
        mov     [ebx+TBackBuffer.raster], eax

        invoke  ReleaseDC, [.hwin] ; from the stack

        mov     eax, ebx
        pop     edx ecx ebx
        return
endp



proc DestroyBackBuffer, .pBackBuffer
begin
        push    eax ecx edx
        mov     eax, [.pBackBuffer]
        push    eax
        invoke  DeleteObject, [eax+TBackBuffer.raster]
        stdcall FreeMem ; from the stack
        pop     edx ecx eax
        return
endp



proc DrawBackBuffer, .context, .pBackBuffer, .x, .y
begin
        push    eax ecx edx esi edi
        mov     esi, [.pBackBuffer]

        stdcall AllocateContext, [esi+TBackBuffer.raster]
        jc      .exit
        mov     edi, eax

        mov     ecx, [.context]
        invoke  BitBlt, [ecx+TContext.handle], [.x], [.y], [esi+TBackBuffer.width], [esi+TBackBuffer.height], [edi+TContext.handle], 0, 0, SRCCOPY

        stdcall ReleaseContext, edi

.exit:
        pop     edi esi edx ecx eax
        return


endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































Deleted freshlib/graphics/Win32/context.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Context is a object that represents drawing surface in FreshLib
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

; Some of these constants are probably wrong!
cmClear       =     R2_BLACK
cmAnd         =     R2_MASKPEN
cmAndReverse  =     R2_NOTMASKPEN
cmCopy        =     R2_COPYPEN
cmAndInverted =     R2_MASKPENNOT
cmNoOp        =     R2_NOP
cmXor         =     R2_XORPEN
cmOr          =     R2_MERGEPEN
cmNor         =     R2_NOTMERGEPEN
cmEquiv       =     R2_NOTXORPEN
cmInvert      =     R2_NOT
cmXorReverse  =     R2_NOTXORPEN
cmCopyInverted =    R2_NOTCOPYPEN
cmOrInverted   =    R2_NOTMERGEPEN
cmNand         =    R2_NOTMASKPEN
cmSet          =    R2_WHITE


proc AllocateContext, .raster
begin
        push    ebx ecx edx

        stdcall GetMem, sizeof.TContext
        mov     ebx, eax

        push    [.raster]
        pop     [ebx+TContext.raster]

        invoke  IsWindow, [.raster]
        test    eax, eax
        jz      .not_window

        invoke  GetDC, [.raster]
        mov     [ebx+TContext.handle], eax
        test    eax, eax
        jz      .error

        invoke  SaveDC, [ebx+TContext.handle]

.exit_ok:
        clc
        mov     eax, ebx
        pop     edx ecx ebx
        return

.not_window:    ; then it must be handle to image bitmap...
        invoke  GetObjectType, [.raster]
        cmp     eax, OBJ_BITMAP
        jne     .error

        invoke  CreateCompatibleDC, 0
        mov     [ebx+TContext.handle], eax
        test    eax, eax
        jz      .error

        invoke  SaveDC, ebx
        invoke  SelectObject, [ebx+TContext.handle], [.raster]
        jmp     .exit_ok

.error:
        stc
        pop     edx ecx ebx
        return
endp




proc ReleaseContext, .context
begin
        push    eax ebx ecx edx

        mov     ebx, [.context]

; delete all selected objects...
        invoke  GetCurrentObject, [ebx+TContext.handle], OBJ_PEN
        push    eax
        invoke  GetCurrentObject, [ebx+TContext.handle], OBJ_BRUSH
        push    eax
        invoke  GetCurrentObject, [ebx+TContext.handle], OBJ_FONT
        push    eax

        invoke  RestoreDC, [ebx+TContext.handle], -1

        invoke  DeleteObject ; from the stack
        invoke  DeleteObject ; from the stack
        invoke  DeleteObject ; from the stack

        invoke  GetObjectType, [ebx+TContext.handle]
        cmp     eax, OBJ_MEMDC
        je      .delete

        cmp     eax, OBJ_DC
        je      .release

        stc
.exit:
        pop     edx ecx ebx eax
        return

.delete:
        invoke  DeleteDC, [ebx+TContext.handle]
        jmp     .free

.release:
        invoke  ReleaseDC, [ebx+TContext.raster] , [ebx+TContext.handle]

.free:
        stdcall FreeMem, ebx
        clc
        jmp     .exit
endp



proc  SetDrawMode, .context, .mode
begin
        push    eax ebx ecx edx
        mov     ebx, [.context]
        test    ebx, ebx
        jz      .finish

        push    [.mode]
        pop     [ebx+TContext.drawmode]
        invoke  SetROP2, [ebx+TContext.handle], [.mode]

.finish:
        pop     edx ecx ebx eax
        return
endp




proc SetLineStyle, .context, .pLineStyle
begin
        push    eax ebx ecx edx esi

        mov     ebx, [.pLineStyle]
        mov     esi, [.context]

        mov     eax, [ebx+TLineStyle.color]
        bswap   eax                             ; FreshLib uses Linux type color - red in the MSB
        ror     eax, 8

        mov     edx, PS_SOLID
        cmp     [ebx+TLineStyle.DashCount], 0
        je      @f
        mov     edx, PS_DOT
        mov     [ebx+TLineStyle.width], 0
@@:
        invoke  CreatePen, edx, [ebx+TLineStyle.width], eax     ;[ebx+TLineStyle.color]
        invoke  SelectObject, [esi+TContext.handle], eax
        invoke  DeleteObject, eax

        cmp     [ebx+TLineStyle.DashCount], 0
        je      .exit

        mov     eax, [ebx+TLineStyle.clSpace]
        bswap   eax                             ; FreshLib uses Linux type color - red in the MSB
        ror     eax, 8

        invoke  SetBkColor, [esi+TContext.handle], eax
        invoke  SetBkMode, [esi+TContext.handle], OPAQUE


.exit:
        pop     esi edx ecx ebx eax
        return
endp






proc SetClipRectangle, .context, .pBounds
begin
        push    eax ebx ecx edx

        xor     ebx, ebx
        mov     edx, [.pBounds]
        test    edx, edx
        jz      .setit

        mov     eax, [edx+TBounds.width]
        mov     ecx, [edx+TBounds.height]
        add     eax, [edx+TBounds.x]
        add     ecx, [edx+TBounds.y]
        invoke  CreateRectRgn, [edx+TBounds.x], [edx+TBounds.y], eax, ecx
        mov     ebx, eax

.setit:
        mov     edx, [.context]
        invoke  SelectClipRgn, [edx+TContext.handle], ebx

        test    ebx, ebx
        jz      .exit
        invoke  DeleteObject, ebx
.exit:
        pop     edx ecx ebx eax
        return
endp




;proc SetLineStyle, .context, .pLineStyle
;.brush LOGBRUSH
;.width dd ?
;.dashcount dd ?
;.dashes rd 16
;begin
;        push    eax ebx ecx edx esi
;
;        mov     ebx, [.pLineStyle]
;        mov     esi, [.context]
;
;        mov     ecx, [ebx+TLineStyle.DashCount]
;        cmp     ecx, 16
;        jbe     @f
;        mov     ecx, 16
;@@:
;        mov     [.dashcount], ecx
;
;.dashloop:
;        dec     ecx
;        js      .enddash
;        movzx   eax, byte [ebx+TLineStyle.DashItems+ecx]
;        mov     [.dashes+4*ecx], eax
;        jmp     .dashloop
;
;.enddash:
;        push    [ebx+TLineStyle.width]
;        pop     [.width]
;
;        mov     [.brush.lbStyle], BS_SOLID
;        mov     eax, [ebx+TLineStyle.color]
;        bswap   eax                             ; FreshLib uses Linux type color - red in the MSB
;        ror     eax, 8
;
;        mov     [.brush.lbColor], eax
;
;        mov     edx, PS_SOLID
;        xor     ecx, ecx
;        cmp     [.dashcount], 0
;        je      @f
;        mov     edx, PS_USERSTYLE
;        lea     ecx, [.dashes]
;@@:
;
;        or      edx, PS_GEOMETRIC
;        cmp     [.width], 0
;        jne     @f
;        and     edx, not PS_GEOMETRIC
;        inc     [.width]
;@@:
;        or      edx, [ebx+TLineStyle.flags]
;        lea     eax, [.brush]
;
;        invoke  ExtCreatePen, edx, [.width], eax, [.dashcount], ecx
;        invoke  SelectObject, [esi+TContext.handle], eax
;
;
;        invoke  SetBkMode, [esi+TContext.handle], OPAQUE
;
;        mov     eax, [ebx+TLineStyle.color]
;        cmp     [ebx+TLineStyle.DashCount], 0
;        je      @f
;        mov     eax, [ebx+TLineStyle.clSpace]
;@@:
;        bswap   eax                             ; FreshLib uses Linux type color - red in the MSB
;        ror     eax, 8
;
;        invoke  SetBkColor, [esi+TContext.handle], eax
;
;        pop     esi edx ecx ebx eax
;        return
;endp
;


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































































































































































































































































































Deleted freshlib/graphics/Win32/draw.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Draw library contains procedures for drawing oprtations.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

lsEndCapRound = PS_ENDCAP_ROUND
lsEndCapSquare = PS_ENDCAP_SQUARE
lsEndCapFlat   = PS_ENDCAP_FLAT

lsJoinRound = PS_JOIN_ROUND
lsJoinBevel = PS_JOIN_BEVEL
lsJoinMiter = PS_JOIN_MITER



proc DrawLine, .context, .x1, .y1, .x2, .y2
begin
        push    eax ebx ecx edx
        mov     ebx, [.context]

        invoke  MoveToEx, [ebx+TContext.handle], [.x1], [.y1], 0
        invoke  LineTo, [ebx+TContext.handle], [.x2], [.y2]

        pop     edx ecx ebx eax
        return
endp




proc DrawFillRect, .context, .x, .y, .width, .height, .color
begin
        push    eax ebx ecx edx esi

        mov     ebx, [.context]

        mov     eax, [.color]
        bswap   eax
        ror     eax, 8
        mov     esi, eax
        invoke  CreateSolidBrush, esi
        invoke  SelectObject, [ebx+TContext.handle], eax
        push    eax

        invoke  CreatePen, PS_SOLID, 0, esi
        invoke  SelectObject, [ebx+TContext.handle], eax
        push    eax

        mov     eax, [.x]
        mov     ecx, [.y]
        add     eax, [.width]
        add     ecx, [.height]

        cmp     [.width], 1
        je      .line1
        cmp     [.height], 1
        jne     .rect

        dec     ecx
        jmp     .line

.line1:
        dec     eax
.line:
        invoke  MoveToEx, [ebx+TContext.handle], eax, ecx, 0
        invoke  LineTo, [ebx+TContext.handle], [.x], [.y]
        inc     [.x]
        invoke  LineTo, [ebx+TContext.handle],[.x], [.y]
        jmp     .free

.rect:
        invoke  Rectangle, [ebx+TContext.handle], [.x], [.y], eax, ecx

;        lea     ecx, [.x]
;        invoke  FillRect, [ebx+TContext.handle], ecx, eax
.free:
        invoke  SelectObject, [ebx+TContext.handle] ; from the stack.
        invoke  DeleteObject, eax
        invoke  SelectObject, [ebx+TContext.handle] ; from the stack.
        invoke  DeleteObject, eax
        pop     esi edx ecx ebx eax
        return
endp





macro Outline [type, x, y] {
  common
local ..types, ..points, ..count
     dd  ..count
     dd  ..types
     dd  ..points
  common
    label ..types byte
  forward
     db type
  common
    label ..points dword
  forward
    dd  x
    dd  y
}




proc Draw, .raster, .pDrawPoints
begin

        return
endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































Deleted freshlib/graphics/Win32/fonts.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Fonts managing library.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


proc FontCreate, .fontface, .size, .weight, .flags
.pwc dd ?
begin
        push    ebx ecx edx esi edi

        neg     [.size]

        stdcall StrLen, [.fontface]
        mov     ebx, eax

        stdcall StrPtr, [.fontface]
        mov     [.fontface], eax

        lea     ecx, [8*ebx]
        stdcall GetMem, ecx
        mov     edi, eax

        invoke  MultiByteToWideChar, CP_UTF8, 0, [.fontface], ebx, edi, ecx

        mov     eax, [.flags]
        mov     ebx, eax
        mov     ecx, eax
        mov     edx, eax
        and     ebx, ffItalic
        and     ecx, ffUnderline
        and     edx, ffStrikeOut
        and     eax, ffMonospaced
        jz      @f
        mov     eax, FIXED_PITCH
@@:
        invoke  CreateFont, [.size], 0, 0, 0, [.weight], ebx, ecx, edx,         \
                                    DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,        \
                                    CLIP_DEFAULT_PRECIS, PROOF_QUALITY, eax,  \
                                    edi

        stdcall FreeMem, edi
        pop     edi esi edx ecx ebx
        return
endp


proc FontDestroy, .font
begin
        push    eax ecx edx
        invoke  DeleteObject, [.font]
        pop     edx ecx eax
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































Deleted freshlib/graphics/Win32/images.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Memory based images manipulation library.
;
;  Target OS: Win32
;
;  Dependencies: memory.asm
;
;  Notes:
;_________________________________________________________________________________________


; only 16, 24 and 32 bpp are supported.
; It is stupid to support palleted modes and even 24bpp is not good...
proc CreateImage, .width, .height, .bpp
.bmi BITMAPINFOHEADER
begin
        push    ebx ecx edx esi

        stdcall GetMem, sizeof.TImage
        jc      .finish

        mov     esi, eax

        cmp     [.width], 0
        jge     @f
        mov     [.width], 0
@@:
        cmp     [.height], 0
        jge     @f
        mov     [.height], 0
@@:
        push    [.width] [.height] [.bpp]
        pop     [esi+TImage.bpp] [esi+TImage.height] [esi+TImage.width]

        lea     eax, [.bmi]
        mov     [eax+BITMAPINFOHEADER.biSize], sizeof.BITMAPINFOHEADER
        mov     [eax+BITMAPINFOHEADER.biPlanes], 1
        mov     [eax+BITMAPINFOHEADER.biCompression], BI_RGB
        mov     [eax+BITMAPINFOHEADER.biSizeImage], 0
        mov     [eax+BITMAPINFOHEADER.biXPelsPerMeter], 96      ; ???
        mov     [eax+BITMAPINFOHEADER.biYPelsPerMeter], 96      ; ???
        mov     [eax+BITMAPINFOHEADER.biClrUsed], 0
        mov     [eax+BITMAPINFOHEADER.biClrImportant], 0

        mov     ecx, [.bpp]
        mov     [eax+BITMAPINFOHEADER.biBitCount], cx
        push    [.width] [.height]
        neg     dword [esp]
        pop     [eax+BITMAPINFOHEADER.biHeight] [eax+BITMAPINFOHEADER.biWidth]

        lea     ecx, [esi+TImage.pData]
        invoke  CreateDIBSection, 0, eax, DIB_RGB_COLORS, ecx, 0, 0
        mov     [esi+TImage.raster], eax

        clc
        mov     eax, esi

.finish:
        pop     esi edx ecx ebx
        return
endp


proc DestroyImage, .ptrImage
begin
        push    eax ecx edx esi

        mov     esi, [.ptrImage]
        cmp     esi, 0
        je      @f
        invoke  DeleteObject, [esi+TImage.raster]
        stdcall FreeMem, esi
@@:
        pop     esi edx ecx eax
        return
endp




proc DrawImage, .context, .pImage, .x, .y
begin
        push    eax ecx edx esi edi
        mov     esi, [.pImage]
        test    esi, esi
        jz      .exit

        stdcall AllocateContext, [esi+TImage.raster]
        jc      .exit
        mov     edi, eax

        mov     ecx, [.context]
        mov     eax, [ecx+TContext.drawmode]
        dec     eax
        and     eax, $0f
        invoke  BitBlt, [ecx+TContext.handle], [.x], [.y], [esi+TImage.width], [esi+TImage.height], [edi+TContext.handle], 0, 0, [4*eax+__RopTable]

        stdcall ReleaseContext, edi

.exit:
        pop     edi esi edx ecx eax
        return
endp

; NEEDS some edit to fill the zeroes.

if used __RopTable
__RopTable dd  BLACKNESS, PATPAINT,    0,          NOTSRCCOPY, \
               0,         DSTINVERT,   SRCINVERT,  SRCERASE,   \
               SRCAND,    0,           0,          0,          \
               SRCCOPY,   MERGEPAINT,  SRCPAINT,   WHITENESS
end if


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































Deleted freshlib/graphics/Win32/text.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Text drawing library.
;
;  Target OS: Win32
;
;  Dependencies: memory.asm
;
;  Notes:
;_________________________________________________________________________________________



proc DrawString, .context, .ptrString, .len, .x, .y, .font, .color
.pwc dd ?
.pwl dd ?
.buffer  rb 256
.charlen dd ?
begin
        push    eax ebx ecx edx

; first convert the string:
        lea     eax, [.buffer]
        mov     ecx, [.len]
        shl     ecx, 3
        cmp     ecx, $100
        jbe     @f

        stdcall GetMem, ecx

@@:
        mov     [.pwl], ecx
        mov     [.pwc], eax

        invoke  MultiByteToWideChar, CP_UTF8, 0, [.ptrString], [.len], [.pwc], ecx
        mov     [.charlen], eax

        mov     ebx, [.context]

        cmp     [.font], 0
        jne     @f

        invoke  GetStockObject, DEFAULT_GUI_FONT
        mov     [.font], eax

@@:
        invoke  SelectObject, [ebx+TContext.handle], [.font]
        push    eax

        invoke  SetBkMode, [ebx+TContext.handle], TRANSPARENT
        invoke  SetTextAlign, [ebx+TContext.handle], TA_NOUPDATECP or TA_LEFT or TA_BASELINE

        mov     eax, [.color]
        bswap   eax
        ror     eax, 8
        invoke  SetTextColor, [ebx+TContext.handle], eax
        invoke  TextOut, [ebx+TContext.handle], [.x], [.y], [.pwc], [.charlen]

        invoke  SelectObject, [ebx+TContext.handle] ; old font from the stack.

        cmp     [.pwl], $100
        jbe     @f
        stdcall FreeMem, [.pwc]
@@:
        pop     edx ecx ebx eax
        return
endp



proc DrawStringOpaque, .context, .ptrString, .len, .x, .y, .font, .color, .background
.pwc dd ?
.pwl dd ?
.buffer  rb 256
.charlen dd ?
begin
        push    eax ebx ecx edx

; first convert the string:
        lea     eax, [.buffer]
        mov     ecx, [.len]
        shl     ecx, 2
        cmp     ecx, $100
        jbe     @f

        stdcall GetMem, ecx

@@:
        mov     [.pwl], ecx
        mov     [.pwc], eax

        invoke  MultiByteToWideChar, CP_UTF8, 0, [.ptrString], [.len], [.pwc], ecx
        mov     [.charlen], eax

        mov     ebx, [.context]

        cmp     [.font], 0
        jne     @f

        invoke  GetStockObject, DEFAULT_GUI_FONT
        mov     [.font], eax

@@:
        invoke  SelectObject, [ebx+TContext.handle], [.font]
        push    eax

        invoke  SetBkMode, [ebx+TContext.handle], OPAQUE
        mov     eax, [.background]
        bswap   eax
        ror     eax, 8
        invoke  SetBkColor, [ebx+TContext.handle], eax
        invoke  SetTextAlign, [ebx+TContext.handle], TA_NOUPDATECP or TA_LEFT or TA_BASELINE

        mov     eax, [.color]
        bswap   eax
        ror     eax, 8
        invoke  SetTextColor, [ebx+TContext.handle], eax
        invoke  TextOut, [ebx+TContext.handle], [.x], [.y], [.pwc], [.charlen]

        invoke  SelectObject, [ebx+TContext.handle] ; old font from the stack.

        cmp     [.pwl], $100
        jbe     @f
        stdcall FreeMem, [.pwc]
@@:
        pop     edx ecx ebx eax
        return
endp




proc DrawColoredString, .context, .ptrString, .pCharAttr, .str_len_bytes, .x, .y, .char_offs, .fontwidth, .fontheight
.xbeg    dd ?
;.wbeg    dd ?
.pwc     dd ?
.charlen dd ?
.point   POINT
begin
        push    eax ebx ecx edx esi edi

        mov     eax, [.x]
;        mov     ecx, [.width]
        mov     [.xbeg], eax
;        mov     [.wbeg], ecx

; first convert the string:
        mov     ecx, [.str_len_bytes]
        shl     ecx, 2
        stdcall GetMem, ecx
        mov     esi, eax
        mov     [.pwc], eax

        invoke  MultiByteToWideChar, CP_UTF8, 0, [.ptrString], [.str_len_bytes], esi, ecx
        mov     [.charlen], eax

        mov     ebx, [.context]
        mov     edi, [.pCharAttr]

        invoke  SaveDC, [ebx+TContext.handle]

        invoke  SetBkMode,    [ebx+TContext.handle], TRANSPARENT
        invoke  SetTextAlign, [ebx+TContext.handle], TA_LEFT or TA_BASELINE

.skip_offset:
        mov     ecx, [.char_offs]

.offsloop:
        jecxz   .loop

        lodsw
        add     edi, sizeof.TCharAttr
        dec     [.charlen]
        jz      .endline

        dec     ecx
        cmp     eax, $01
        jne     .offsloop

        mov     eax, [.fontheight]
        add     [.y], eax
        jmp     .skip_offset

.loop:
        cmp     word [esi], $01
        je      .wrapline

        mov     eax, [edi+TCharAttr.font]
        test    eax, eax
        jnz     @f

        invoke  GetStockObject, DEFAULT_GUI_FONT
@@:
        invoke  SelectObject, [ebx+TContext.handle], eax
        mov     eax, [edi+TCharAttr.background]
        bswap   eax
        ror     eax, 8
        invoke  SetBkColor, [ebx+TContext.handle], $ff0000

        mov     eax, [edi+TCharAttr.color]
        bswap   eax
        ror     eax, 8
        invoke  SetTextColor, [ebx+TContext.handle], eax

        invoke  TextOut, [ebx+TContext.handle], [.x], [.y], esi, 1

        mov     eax, [.fontwidth]
        add     [.x], eax
;        sub     [.width], eax
;        jl      .endline

.nextchar:
        add     esi, 2
        add     edi, sizeof.TCharAttr
        dec     [.charlen]
        jnz     .loop

.endline:
        invoke  RestoreDC, [ebx+TContext.handle], -1
        stdcall FreeMem, [.pwc]
        pop     edi esi edx ecx ebx eax
        return

.wrapline:
        mov     eax, [.fontheight]
        add     [.y], eax
        mov     eax, [.xbeg]
;        mov     ecx, [.wbeg]
        mov     [.x], eax
;        mov     [.width], ecx

        add     esi, 2
        add     edi, sizeof.TCharAttr
        dec     [.charlen]
        jnz     .skip_offset
        jmp     .endline
endp






proc GetTextBounds, .context, .ptrString, .len, .font
.size SIZE
.pwc dd ?
.charlen dd ?
begin
        push    ebx ecx

; first convert the string:
        mov     ecx, [.len]
        shl     ecx, 3
        stdcall GetMem, ecx
        mov     [.pwc], eax
        invoke  MultiByteToWideChar, CP_UTF8, 0, [.ptrString], [.len], [.pwc], ecx
        mov     [.charlen], eax

        mov     ebx, [.context]

        cmp     [.font], 0
        jne     @f
        invoke  GetStockObject, DEFAULT_GUI_FONT
        mov     [.font], eax

@@:
        invoke  SelectObject, [ebx+TContext.handle], [.font]
        push    eax

        lea     eax, [.size]
        invoke  GetTextExtentPoint32, [ebx+TContext.handle], [.pwc], [.charlen], eax
        invoke  SelectObject, [ebx+TContext.handle] ; from the stack.

        mov     eax, [.size.cx]
        mov     edx, [.size.cy]

        stdcall FreeMem, [.pwc]
        pop     ecx ebx
        return
endp


; returns:
;       eax - x offset of the baseline of the string.
;       edx - y offset of the baseline of the string.

proc GetTextOffset, .context, .ptrString, .len, .font
.metrics TEXTMETRIC
.pwc dd ?
.charlen dd ?
begin
        push    ebx ecx

; first convert the string:
        mov     ecx, [.len]
        shl     ecx, 3
        stdcall GetMem, ecx
        mov     [.pwc], eax
        invoke  MultiByteToWideChar, CP_UTF8, 0, [.ptrString], [.len], [.pwc], ecx
        mov     [.charlen], eax

        mov     ebx, [.context]

        cmp     [.font], 0
        jne     @f
        invoke  GetStockObject, DEFAULT_GUI_FONT
        mov     [.font], eax

@@:
        invoke  SelectObject, [ebx+TContext.handle], [.font]
        push    eax

        lea     eax, [.metrics]
        invoke  GetTextMetrics, [ebx+TContext.handle], eax
        invoke  SelectObject, [ebx+TContext.handle] ; from the stack.

        xor     eax, eax
        mov     edx, [.metrics.tmAscent]
        sub     edx, [.metrics.tmInternalLeading]

        stdcall FreeMem, [.pwc]
        pop     ecx ebx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































































































































































































































































































































































































































































































Deleted freshlib/graphics/all.asm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Graphics amalgamation include file.
;               Includes all graphic libraries of FreshLib
;
;  Target OS: Any
;_________________________________________________________________________________________


include 'context.asm'
include 'images.asm'
include 'backbuffer.asm'
include 'draw.asm'
include 'giflib.asm'
include 'fonts.asm'
include 'text.asm'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































Deleted freshlib/graphics/backbuffer.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Provides raster bitmap, to be used for double buffer painting.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________
module "BackBuffer library"

; should be equal to the first 3 members of TImage in order to use the same draw procedure.

struct TBackBuffer
  .width  dd ?
  .height dd ?
  .raster dd ?
ends


include '%TargetOS%/backbuffer.asm'

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































Deleted freshlib/graphics/context.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Context is a object that represents drawing surface in FreshLib
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: This file contains OS independent part and includes OS dependent files.
;_________________________________________________________________________________________
module "Graphic context library"

struct TBounds
  .x      dd ?
  .y      dd ?
  .width  dd ?
  .height dd ?
ends



struct TContext
  .raster     dd ?          ; handle to raster object (depends on TargetOS)
  .handle     dd ?          ; handle to context object (depends on TargetOS)
  .clipregion dd ?          ; clipping region.
  .drawmode   dd ?
ends


struct TDashListItem
  .dash  dd ?
  .space dd ?
ends


struct TLineStyle
  .width dd ?                   ; width of the line in pixels. Width 0 is 1px width. It have special meaning in Linux for example.
  .color dd ?                   ; color of the line in format (from LSB to MSB) bb, gg, rr, aa ; Use of alpha value is something not very clear for all implementations...
  .flags dd ?                   ; set of lsEndCapXXX; lsJoinXXX
  .clSpace dd ?                 ; space color.
  .DashCount dd ?               ; count of dash items in the dash list. For solid lines DashCount=0
  .DashItems:                   ; arbitrary count of TDashListItem
ends


; Creates static TLineStyle structure in design time.

struc LineStyle width*, color*, flags, spacecolor, [dash, space] {
common
local ..count, ..dashcount
  ..count = 0

common
  dd width
  dd color
  if flags eq
    dd lsEndCapRound or lsJoinRound
  else
    dd flags
  end if

  if spacecolor eq
    dd 0
  else
    dd spacecolor
  end if

  dd ..dashcount

forward
  if ~dash eq
    db dash, space
    ..count = ..count + 2
  end if

common
  ..dashcount = ..count
}



proc SetSimpleLine, .context, .color
.style TLineStyle
       rd 16
begin
        push    eax

        lea     eax, [.style]
        mov     [eax+TLineStyle.width], 0
        mov     [eax+TLineStyle.flags], 0
        mov     [eax+TLineStyle.DashCount], 0
        mov     [eax+TLineStyle.clSpace],0

        push    [.color]
        pop     [eax+TLineStyle.color]


        stdcall SetLineStyle, [.context], eax
        pop     eax
        return
endp



include '%TargetOS%/context.asm'

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































Deleted freshlib/graphics/draw.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Draw library contains procedures for drawing oprtations.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: This file contains OS independent part and includes OS dependent files.
;_________________________________________________________________________________________
module "Draw library"


include "%TargetOS%/draw.asm"


proc DrawRectangle, .context, .pBounds, .color
begin
        push    eax ecx edx

        mov     edx, [.pBounds]

        mov     eax, [edx+TBounds.x]
        mov     ecx, [edx+TBounds.y]
        add     eax, [edx+TBounds.width]
        add     ecx, [edx+TBounds.height]
        dec     eax
        dec     ecx

        stdcall SetSimpleLine, [.context], [.color]
        stdcall DrawLine, [.context], [edx+TBounds.x], [edx+TBounds.y], eax, [edx+TBounds.y]
        stdcall DrawLine, [.context], eax, [edx+TBounds.y], eax, ecx
        stdcall DrawLine, [.context], [edx+TBounds.x], ecx, eax, ecx
        stdcall DrawLine, [.context], [edx+TBounds.x], [edx+TBounds.y], [edx+TBounds.x], ecx

        pop     edx ecx eax
        return
endp


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































Deleted freshlib/graphics/fonts.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Fonts managing library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: This file contains OS independent part of the library and includes respective
;         OS dependent files.
;_________________________________________________________________________________________
module "Fonts library"

ffItalic    = 1
ffUnderline = 2
ffStrikeOut = 4

ffMonospaced = $80


include '%TargetOS%/fonts.asm'

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































Deleted freshlib/graphics/giflib.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: GIF images decoding library.
;
;  Target OS: Any
;
;  Dependencies: memory.asm; files.asm
;
;  Notes:
;         Original source code by Exagone
;         http://exagone.cjb.net | http://www.exagone.org
;         _thomas_@mailroom.com
;_________________________________________________________________________________________
module "GIF library"

struct TGifInfo
;--- Header ---
  .GIFVersion       rb      3    ; 3 byte string (not 0-terminated) that identifies
                                 ; the GIF Version (like 97a or 98a)
; --- Logical screen descriptor ---
  .dwLSWidth        dd      ?    ; Logical screen width
  .dwLSHeight       dd      ?    ; Logical screen height
                                 ; NOTE: Use ImageWidth/Height to find the dimensions,
                                 ; This one can be different from the logical screen
                                 ; width and height.
; --- Color info ---
  .lpColorTable     dd      ?    ; Pointer to the color table
  .ColorCount       dd      ?    ; Number of colors in image (and color table)
  .fTransparent     dd      ?    ; if TRUE - the image have transparent color.
  .iTrasparentColor dd      ?    ; index of transparent color in the color table.

; --- Image info ---
  .dwImageWidth     dd      ?    ; Width of image
  .dwImageHeight    dd      ?    ; Height of image

; --- Image data ---
  .lpImageData      dd      ?    ; Pointer to the actual image data

; --- Input data ---
  .lpGIFData        dd      ?    ; Pointer to the GIF File data
  .dwGIFDataSize    dd      ?    ; Size of GIF Data

; --- Internal data ---
; Don't touch this data below, it is used internally by GIFLIB
  .lpLZWTable       dd      ?    ; Pointer to LZW Table
  .dwLZWTableSize   dd      ?    ; Current maximum size of table
                                 ; This size is dynamic and changes
                                 ; if the codesize exceeds 9 bits

  .dwLZWTableCount  dd      ?    ; Current nr of entries in the LZW table
  .fGlobalCTable    db      ?    ; If set, the GIF file has a global color table
  .dbGCTableSize    db      ?    ; Size of the global color table, if available
  .fLocalCTable     db      ?    ; If set, the first image has a local color table
  .dbLCTableSize    db      ?    ; Size of the local color table, if available
  .lpGIFImage       dd      ?    ; Pointer to the first real image data(Table based image data)
  .lpCurrentByte    dd      ?    ; Pointer to the current byte (used with decompression)
                                 ; note: if this value is -1, end of the file is reached and
                                 ; the code-supplier returns 0 as padding

  .dbBitsAvailable  db      ?    ; Nr of codebits currently available
  .dbCurBitSize     db      ?    ; Current LZW code size
  .dbInitBitSize    db      ?    ; Initial LZW code size
  .lpLastEOSB       dd      ?    ; Pointer to end of current subblock (used with decompression)
  .dwLZWClear       dd      ?    ; Value of LZW Clear code (CC)
  .CurrentBits      dd      ?    ; Holds the current bits loaded
  .IsFirstCode      db      ?    ; Indicates if the first code is being read now
  .PixelCounter     dd      ?    ; Counts nr of PIXELS outputted
ends


EXTENSIONBLOCK           =  021h
IMAGEDESCRIPTOR          =  02Ch
GRAPHICCONTROLEXTENSTION =  0F9h
COMMENTEXTENSION         =  0FEh
PLAINTEXTEXTENSION       =  001h
APPLICATIONEXTENSION     =  0FFh


; Creates TImage from the compressed GIF image.
; Arguments:
;   pGifImage - pointer to memory, where compressed image resides.
;   DataSize  - size of the image.
; Returns:
;   CF=1 if error;
;   CF=0 and eax=TImage if success.
proc    CreateImageGIF, .pGifImage, .DataSize   ;
.gifinfo TGifInfo
begin
        push    ecx edx esi edi

        lea     esi, [.gifinfo]

        push    [.DataSize] [.pGifImage]
        pop     [esi+TGifInfo.lpGIFData] [esi+TGifInfo.dwGIFDataSize]

        stdcall _GIFLoadHeader, esi
        jz      .quit

        stdcall _GIFInitalizeDecoder, esi
        jz       .quit

        stdcall CreateImage, [esi+TGifInfo.dwImageWidth], [esi+TGifInfo.dwImageHeight], 32
        jc      .error
        mov     edi, eax

        push    [edi+TImage.pData]
        pop     [esi+TGifInfo.lpImageData]

        stdcall _GIFDecompress, esi
        jz      .quit

        stdcall _GIFCleanup, esi

        mov     eax, edi

.quit:
.error:
        pop     edi esi edx ecx
        return
endp


;===============================================================================
;       GIFLoadFile
;===============================================================================
; Loads gif data from a file
; returns pointer to TImage
proc ImageGifLoafFromFile, .lpFile
begin
        push    ecx

        stdcall LoadBinaryFile, [.lpFile]
        push    eax

        stdcall CreateImageGIF, eax, ecx
        stdcall FreeMem ; from the stack
        pop     ecx
        return
endp



;===============================================================================
;       GIFCleanup
;===============================================================================
; Cleanup
;
proc _GIFCleanup, .lpGifInfo
begin
        push    esi
        mov     esi, [.lpGifInfo]
        stdcall FreeMem, [esi+TGifInfo.lpLZWTable]
        pop     esi
        return
endp


;===============================================================================
;       GIFDecompress
;===============================================================================
; Decompresses the gif and outputs
; returns:
; 0  - color format not allowed
; 1  - success
; -1 - failed
proc _GIFDecompress, .lpGifInfo
begin
        push    esi edi ebx

        mov     esi, [.lpGifInfo]
        mov     edi, [esi+TGifInfo.lpImageData]

        ; --- Initially, load 4 bytes ---
        mov     [esi+TGifInfo.CurrentBits], 0
        mov     [esi+TGifInfo.dbBitsAvailable], 0

        mov     ebx, 4
.while:
        stdcall _LoadNextByte, esi
        dec     ebx
        jne     .while

        stdcall _DECInitialize, esi
        stdcall _DECDecodeGIF, [.lpGifInfo]

        xor     eax, eax
        inc     eax
        pop     ebx edi esi
        return

.qfalse:
        xor     eax, eax
        pop     ebx edi esi
        return
endp

;===============================================================================
;       _DECDecodeGIF
;===============================================================================
; The actual decoder
;
proc _DECDecodeGIF, .lpGifInfo
 .OldCode            dd ?
 .FirstCharOfOldCode db ?
 .FirstCharOfCode    db ?
 .dummyalign         dw ?
 .NrCodesToOutput    dd ?
begin
        push    esi edi ebx

        mov     esi, [.lpGifInfo]

        ; --- set counters ---
        mov     [esi+TGifInfo.PixelCounter], 0   ;0 codes outputted
        mov     eax, [esi+TGifInfo.dwImageWidth]
        mul     [esi+TGifInfo.dwImageHeight]
        mov     [.NrCodesToOutput], eax    ;this is an OUTPUT CODE counter, not nr of compressed codes

; LZW Decompression
;     [1] Initialize string table;
;     [2] get first code: <code>;
;     [3] output the string for <code> to the charstream;
;     [4] <old> = <code>;
;     [5] <code> <- next code in codestream;
;     [6] does <code> exist in the string table?
;      (yes: output the string for <code> to the charstream;            (A)
;            [...] <- translation for <old>;                            (B)
;            K <- first character of translation for <code>;            (C)
;            add [...]K to the string table;                            (D)
;                        <old> <- <code>;  )                            (E)
;      (no: [...] <- translation for <old>;                             (F)
;           K <- first character of [...];                              (G)
;           output [...]K to charstream and add it to string table;     (H)
;           <old> <- <code>                                             (I)
;      )
;     [7] go to [5];

.mainloop:
        mov     eax, [.NrCodesToOutput]
        cmp     eax, [esi+TGifInfo.PixelCounter]
        je      .endloop

        stdcall _GetNextCode, esi                        ; [1] and [5]
        mov     ebx, eax
        cmp     ebx, [esi+TGifInfo.dwLZWClear]          ; Check for clearcode
        jne     .noclear

        stdcall _DECResetLZW, esi                ; Reset LZW
        jmp     .mainloop

.noclear:
       cmp      [esi+TGifInfo.IsFirstCode], 1   ; Checks if steps [1]-[4] have to be done
       jne      .notfirst

       dec      [esi+TGifInfo.IsFirstCode]      ;[2]
       stdcall  _DECOutputString, esi, ebx       ;[3]
       mov      [.FirstCharOfOldCode], al       ; saved for (G)
       mov      [.OldCode], ebx                 ;[4]
       jmp      .mainloop

.notfirst:
       cmp     [esi+TGifInfo.dwLZWTableCount], ebx  ; [6]   ; DECIsCodeInTable replacement
       jbe     .notintable

       stdcall  _DECOutputString, esi, ebx           ;(B)
       mov      [.FirstCharOfCode], al              ;(C)
       mov      [.FirstCharOfOldCode], al           ; saved for (G)
       stdcall  _DECAddToTable, esi, [.OldCode], eax ;(D)
       mov      [.OldCode], ebx
       jmp      .mainloop

.notintable:                                        ;(F)-(I)
       mov      al, [.FirstCharOfOldCode]           ; (G)
       stdcall  _DECAddToTable, esi, [.OldCode], eax ;(H)
       stdcall  _DECOutputString, esi, ebx           ;(H)
       mov      [.FirstCharOfOldCode], al           ; saved for (G)
       mov      [.OldCode], ebx
       jmp      .mainloop

.endloop:
       xor     eax, eax
       inc     eax
       pop     ebx edi esi
       return
endp


;===============================================================================
; DECAddToTable
;===============================================================================
; Adds an entry to the LZW Table
; The enry consists of a prefix and a suffix (size is calculated automatically)
; returns the code for the new entry
proc _DECAddToTable, .lpGifInfo, .dwPrefix, .dbSuffix
begin
        push    esi edi ebx

        mov     esi, [.lpGifInfo]

        ; --- Check if enough space in the table left
        mov     ecx, [esi+TGifInfo.dwLZWTableSize]
        mov     ebx, [esi+TGifInfo.dwLZWTableCount]

        push    ebx
        shl     ebx, 2

        ; --- If no space left, make the table bigger:
        cmp     ebx, ecx
        jne     .sizeok

        shl     ecx, 1          ;Table size doubles
        mov     [esi+TGifInfo.dwLZWTableSize], ecx

        ; --- Reallocate memory ---
        stdcall ResizeMem, [esi+TGifInfo.lpLZWTable], ecx
        mov     [esi+TGifInfo.lpLZWTable], eax

.sizeok:
        ; --- Create pointer to first free entry ---
        add     ebx, [esi+TGifInfo.lpLZWTable]

        ; --- Find out the size of the string ---
        mov     eax, [.dwPrefix]
        shl     eax, 2
        add     eax, [esi+TGifInfo.lpLZWTable]
        mov     eax, [eax]
        shr     eax, 8
        and     eax, 0FFFh      ;eax now holds the size of the prefix string
        inc     eax

        ; --- Create the entry DWORD ---
        ; (see DECResetLZW for the format)
        mov     ecx, [.dwPrefix]
        shl     ecx, 20
        shl     eax, 8
        or      ecx, eax
        mov     eax, [.dbSuffix]
        and     eax, 0ffh
        or      ecx, eax

        ; --- Store entry ---
        mov     [ebx], ecx

        inc     [esi+TGifInfo.dwLZWTableCount]

        pop     ebx     ;get saved code of new entry

        mov     cl, [esi+TGifInfo.dbCurBitSize]
        xor     eax, eax
        inc     eax
        shl     eax, cl
        dec     eax
        cmp     eax, ebx
        jne     @f

        ;bitsize should be increased
        inc     [esi+TGifInfo.dbCurBitSize]   ;increase bitsize

@@:
        mov     eax, ebx
        pop     ebx edi esi
        return
endp


;===============================================================================
; DECOutputString
;===============================================================================
; Writes the string of dwCode to the output stream
; returns the first character of the string in al
;
proc _DECOutputString, .lpGifInfo, .dwCode
.LastChar     db ?
begin
        push    esi edi ebx

        mov     esi, [.lpGifInfo]
        mov     edi, [esi+TGifInfo.lpLZWTable]  ; --- Set basepointer ---

        mov     eax, [.dwCode]                   ; --- Get entry ---

        mov     ebx, [edi+4*eax]                ; --- Get size of string ---
        shr     ebx, 8                          ; See the description of LZW table below.
        and     ebx, $0fff

; --- Output all codes backwards ---
        mov     edx, [esi+TGifInfo.PixelCounter]
        shl     edx, 2
        add     edx, [esi+TGifInfo.lpImageData]         ; edx is base pointer in the image data.

        add     [esi+TGifInfo.PixelCounter], ebx        ; update the pixel counter.
        dec     ebx                                     ; ebx is the counter and index in image data.

        mov     esi, [esi+TGifInfo.lpColorTable]        ; We don't need TGifInfo anymore.

.outloop:
        mov     eax, [edi+4*eax]
        mov     [.LastChar], al

; Get the color from the color table - esi points to 3 byte  palette array.
        movzx   ecx, al
        lea     ecx, [ecx+2*ecx]  ; = 3*ecx
        mov     ecx, [esi+ecx]
        bswap   ecx
        shr     ecx, 8

; Draw the pixel.
        mov     [edx+4*ebx], ecx

        shr     eax, 20         ; Get the prefix index in the LZW table.
        and     eax, $0fff

        dec     ebx
        jns     .outloop

        mov     al, [.LastChar]
        pop     ebx edi esi
        return
endp



;===============================================================================
; GetNextCode
;===============================================================================
; retrieves the next code from the compressed data stream and loads new bits
; if needed.
proc _GetNextCode, .lpGifInfo
begin
        push    esi edi ebx

        mov     esi, [.lpGifInfo]
        mov     ebx, [esi+TGifInfo.CurrentBits]

        ; --- Create bitmask for current nr of bits ---
        mov     cl, [esi+TGifInfo.dbCurBitSize]
        xor     eax, eax
        inc     eax
        shl     eax, cl
        dec     eax

        ; --- AND ebx with bitmask ---
        and     ebx, eax

        ; --- Shift used bits ---
        mov     cl, [esi+TGifInfo.dbCurBitSize]
        shr     [esi+TGifInfo.CurrentBits], cl

        ; --- Decrease # of bits available ---
        sub     [esi+TGifInfo.dbBitsAvailable], cl

        ; --- Load as many bits as possible ---
.while:
        cmp     [esi+TGifInfo.dbBitsAvailable], 24
        ja      .endwhile
        stdcall _LoadNextByte, esi
        jmp     .while

.endwhile:
        ; --- Return bits ---
        mov     eax, ebx
        pop     ebx edi esi
        return
endp


;===============================================================================
; LoadNextByte
;===============================================================================
; Loads the currentbits entry with new bits
;
proc _LoadNextByte, .lpGifInfo
begin
        push    esi edi ebx
        mov     esi, [.lpGifInfo]

        ; --- Get next byte from datastream ---
        mov     edi, [esi+TGifInfo.lpCurrentByte]
        cmp     edi, -1
        jne     .notend

;end of data already reached
        xor     al, al  ;return 0 as padding
        jmp     .gotbyte

;End of subblock reached?
.notend:
        cmp      edi, [esi+TGifInfo.lpLastEOSB]
        jne      .noteosb

        xor      eax, eax
        mov      al, [edi]       ; new subblock size
        test     al,al
        jnz      .sizeok

        ; if size=0, end of data
        mov      [esi+TGifInfo.lpCurrentByte], -1 ;EOF indicator
        jmp      .gotbyte

.sizeok:
        inc      edi             ; new subblock with size al
        add      eax, edi
        mov      [esi+TGifInfo.lpLastEOSB], eax  ;set new end of subblock
        add      [esi+TGifInfo.lpCurrentByte], 2
        mov      al, [edi]
        jmp      .gotbyte

.noteosb:
        mov      al, [edi]                       ;get next byte
        inc      [esi+TGifInfo.lpCurrentByte]    ;increase for next read

        ; --- Got the new byte from the datasteam ---
.gotbyte:
        mov      cl, [esi+TGifInfo.dbBitsAvailable] ;Get nr of bits available
        mov      edx, [esi+TGifInfo.CurrentBits]    ;Get current bits
        and      eax, 0ffh                          ;eax = al
        shl      eax, cl                            ;Shift bits to right position
        or       edx, eax                           ;OR new bits with current bits
        mov      [esi+TGifInfo.CurrentBits], edx    ;Save bits
        add      [esi+TGifInfo.dbBitsAvailable], 8  ;Set new bits avaialble

        pop     ebx edi esi
        return
endp


;===============================================================================
;       DECInitialize
;===============================================================================
; Initializes the decoder (table for LZW etc)
;
proc _DECInitialize, .lpGifInfo
begin
        push    esi edi

        mov     esi, [.lpGifInfo]
        mov     edi, [esi+TGifInfo.lpGIFImage]

        ; --- Get initial LZW code size ---
        mov     cl, [edi]
        inc     cl
        mov     [esi+TGifInfo.dbInitBitSize], cl

        ; --- Set current bit size to initial bitsize ---
        mov     [esi+TGifInfo.dbCurBitSize], cl

        ; --- Set size of LZW table ---

        cmp     cl, 8
        jae     @f    ;if initial code size is less than 8-bits,
        mov     cl, 8 ;set to 8-bits, if higher, don't change it
@@:
        ; Calculate size of codetable:
        xor     eax, eax
        inc     eax
        add     cl, 2           ; bitsize + 2
        shl     eax, cl         ; eax = 2 ^ (bitsize + 2) = 4 * (2^bitsize)
        mov     [esi+TGifInfo.dwLZWTableSize], eax

        ; --- Allocate memory for LZW Table and store pointer ---
        stdcall GetMem, eax
        mov     [esi+TGifInfo.lpLZWTable], eax

        ; --- Reset LZW ---
        stdcall _DECResetLZW, esi

        xor     eax, eax
        inc     eax
        pop     edi esi
        return
endp



;===============================================================================
; DECResetLZW
;===============================================================================
; Resets the LZW Table and variables (this is the proper action for a clear
; code (CC) in data
proc _DECResetLZW, .lpGifInfo
begin
        push    esi edi ebx
        mov     esi, [.lpGifInfo]

; The LZW table has the following format:
; An array of DWORDS represents an array of string entries
; One entry consists of a prefix code (which is an index to
; another entry that should prefix the entry), a string length,
; and the suffix byte (this byte should be added to the prefix
; to get the full string).
; DWORD:
; | AAAA AAAA | AAAA BBBB | BBBB BBBB | CCCC CCCC |
; ^                                               ^
; MSB                                           LSB
; AAAAAAAAAAAA:  12-bit index in the LZW Table that indicates the prefix
; BBBBBBBBBBBB:  12-bit length of the string
; CCCCCCCC    :   8-bit suffix byte

        ; --- reset LZW Table ---
        ; Reset bit size:

        mov     cl, [esi+TGifInfo.dbInitBitSize]
        mov     [esi+TGifInfo.dbCurBitSize], cl

        ; Get initial nr of entries
        ;mov            eax, [esi].ColorCount
        ;NOTE: THE LINE ABOVE WAS PREVIOUSLY USED TO GET THE NR OF ROOT ENTRIES
        ; THIS DIDN'T WORK BECAUSE 1-BIT GIF'S ARE FOR AN UNKNOWN REASON CODED
        ; AS 2-BIT GIFS, SO THE NR OF ROOT ENTRIES HAS TO BE DETERMINED FROM THE
        ; INITIAL BITSIZE
        dec     cl
        xor     eax, eax
        inc     eax
        shl     eax, cl         ; 2**codesize
        add     eax, 2
        mov     [esi+TGifInfo.dwLZWTableCount], eax
        mov     edx, [esi+TGifInfo.lpLZWTable]
        ; Fill first {2**codcesize+2} entries
        shl     eax, 2
        add     eax, edx
        xor     ecx, ecx
        inc     ch                      ;size of sting is set to 1

.fill:
        mov     [edx], ecx
        inc     cl
        add     edx, 4
        cmp     edx, eax
        jb      .fill

        ; --- set clear code ---
        mov     eax, [esi+TGifInfo.dwLZWTableCount]
        sub     eax, 2
        mov     [esi+TGifInfo.dwLZWClear], eax
        mov     [esi+TGifInfo.IsFirstCode], 1

        ;lpLZWTable             dd      ?   ; Pointer to LZW Table
        ;dwLZWTableSize         dd      ?   ; Current maximum size of table
        ;dwLZWTableCount        dd      ?   ; Current nr of entries in the LZW table
        ;dbCurBitSize           db      ?   ; Current LZW code size
        ;dbInitBitSize          db      ?   ; Initial LZW code size
        ;dwLZWClear             dd      ?   ; Value of LZW Clear code (CC)

        xor     eax, eax
        inc     eax
        pop     ebx edi esi
        return
endp



;===============================================================================
;       GIFLoadHeader
;===============================================================================
; Loads header and logical screen descriptor
;
proc _GIFLoadHeader, .lpGifInfo
begin
        push    esi edi ebx
        mov     esi, [.lpGifInfo]

        ; --- EDI points to GIF Data, EBX is size of data ---
        mov     edi, [esi+TGifInfo.lpGIFData]
        mov     ebx, [esi+TGifInfo.dwGIFDataSize]

        cmp     ebx, 11
        jb      .failed ; ebx smaller than header & Logical screen descr. -> invalid GIF

        ; --- Check first 3 bytes ("GIF" signature) ---
        mov     eax, [edi]
        and     eax, $00ffffff
        cmp     eax, 'GIF'
        jne     .failed

        ; --- Copy version number ---
        lea     ecx, [esi+TGifInfo.GIFVersion]
        mov     ax, [edi+3]
        mov     [ecx], ax
        mov     al, [edi+5]
        mov     [ecx+2], al

        ; --- Copy logical screen sizes ---
        xor     eax, eax
        mov     ax, [edi+6]                     ;Get Logical screen width
        mov     [esi+TGifInfo.dwLSWidth], eax
        mov     ax, [edi+8]                     ;Get Logical screen width
        mov     [esi+TGifInfo.dwLSHeight], eax

        ; --- Set global color table flag and size ---
        mov     cl, [edi+10]
        mov     al, cl
        rol     al, 1
        and     al, 1
        mov     [esi+TGifInfo.fGlobalCTable], al
        and     cl, 111b
        mov     [esi+TGifInfo.dbGCTableSize], cl

        xor     eax, eax
        inc     eax
        pop     ebx edi esi
        return

.failed:
        xor     eax, eax
        pop     ebx edi esi
        return
endp



;===============================================================================
;       GIFInitalizeDecoder
;===============================================================================
; Initializes decoder
;
proc _GIFInitalizeDecoder, .lpGifInfo
begin
        push    esi edi ebx
        mov     esi, [.lpGifInfo]

        ; --- EDI points to GIF Data, EBX to end of data ---
        mov     edi, [esi+TGifInfo.lpGIFData]
        mov     ebx, [esi+TGifInfo.dwGIFDataSize]
        add     ebx, edi

        add     edi, 13         ; skip header and local screen descriptor

        ; --- Get global color tablesize in bytes ---
        mov     cl, [esi+TGifInfo.dbGCTableSize]
        inc     cl
        xor     eax, eax
        inc     eax
        shl     eax, cl
        mov     ecx, eax
        shl     ecx, 1          ;--+--> ecx * 3
        add     ecx, eax        ;--+

        ; --- Skip global color table if available ---
        cmp     [esi+TGifInfo.fGlobalCTable], 0
        je      @f
        add     edi, ecx
@@:
        cmp     edi, ebx
        jae     .failed

        ; --- Search through the GIF blocks for the first graphic block ---
.scanloop:
        cmp     edi, ebx
        jae     .failed

        mov     al, [edi]
        cmp     al, EXTENSIONBLOCK
        jne     .maybe

        stdcall _SkipExtension, edi, ebx
        mov     edi, eax
        jmp     .scanloop

.maybe:
        cmp     al, IMAGEDESCRIPTOR
        jne     .scanloop               ; BUG: loop forever on some circumstances...

        stdcall _ProcessImageDescriptor, [.lpGifInfo], edi, ebx
        add     edi, 11
        stdcall _SkipSubBlocks, edi

        xor     eax, eax
        inc     eax
.quit:
        pop     ebx edi esi
        return

.failed:
        xor     eax, eax
        jmp     .quit
endp



;===============================================================================
; ProcessImageDescriptor
;===============================================================================
; Processes an image desriptor block
proc _ProcessImageDescriptor, .lpGifInfo, .lpStart, .lpEOF
begin
        push    esi edi
        mov     esi, [.lpGifInfo]

        mov     edx, [.lpStart]
        xor     eax, eax

        ; --- copy image width & height ---
        mov     ax, [edx+5]
        mov     [esi+TGifInfo.dwImageWidth], eax
        mov     ax, [edx+7]
        mov     [esi+TGifInfo.dwImageHeight], eax

        ; --- look for local color table ---
        mov     cl, [edx+9]
        mov     al, cl
        rol     cl, 1
        and     cl, 1
        mov     [esi+TGifInfo.fLocalCTable], cl
        and     al, 111b
        mov     [esi+TGifInfo.dbLCTableSize], al

        ; --- Find out which color table to use ---
        cmp     cl, 1
        jne     .setglobal

        ;local color table available
        ; --- Set color count ---
        mov     cl, [esi+TGifInfo.dbLCTableSize]
        inc     cl
        xor     eax, eax
        inc     eax
        shl     eax, cl
        mov     [esi+TGifInfo.ColorCount], eax
        ; --- Set color table pointer ---
        mov     eax, edx
        add     eax, 10 ;move to the local color table
        mov     [esi+TGifInfo.lpColorTable], eax
        jmp     .ctableok

.setglobal:
        ;no local color table, use global color table
        ; --- Set color count ---
        mov     cl, [esi+TGifInfo.dbGCTableSize]
        inc     cl
        xor     eax, eax
        inc     eax
        shl     eax, cl
        mov     [esi+TGifInfo.ColorCount], eax
        ; --- Set color table pointer ---
        mov     eax, [esi+TGifInfo.lpGIFData]
        add     eax, 13 ;move to the global color table (at offset 13 in file)
        mov     [esi+TGifInfo.lpColorTable], eax

.ctableok:
        ; --- Set pointer to real image data (table based image data)
        mov     eax, edx
        add     eax, 10                                 ;Skip image descriptor

        cmp     [esi+TGifInfo.fLocalCTable], 0
        je      .setptr

        mov     ecx, [esi+TGifInfo.ColorCount]   ;-+
        add     eax, ecx                         ; + add size of colortable
        shl     ecx, 1                           ; + (colorcount * 3)
        add     eax, ecx                         ;-+

.setptr:
        mov     [esi+TGifInfo.lpGIFImage], eax

        ; --- Set some pointers to initialize the decompressor
        inc     eax
        mov     [esi+TGifInfo.lpLastEOSB], eax
        mov     [esi+TGifInfo.lpCurrentByte], eax

        xor     eax, eax
        inc     eax
        pop     edi esi
        return
endp



;=====================================================================
; Skips an extension block that starts at lpStart. EOF is at lpEnd.
; returns pointer to the end of block + 1
; or 0 if failed
; esi points at TGifInfo structure.
proc _SkipExtension, .lpStart, .lpEnd
begin
        ; --- Get type of extension ---
        mov     edx, [.lpStart]
        mov     al, [edx+1]

        ; --- Skip each type seperately ---
        cmp     al, GRAPHICCONTROLEXTENSTION
        jne     @f

        ; Get transparent color and flag.
        movzx   eax, byte [edx+3]
        and     eax, 1
        mov     [esi+TGifInfo.fTransparent], eax
        mov     al, [edx+6]
        mov     [esi+TGifInfo.iTrasparentColor], eax

        ; Graphic control extension, has a fixed size of 8 bytes
        add     edx, 8
        mov     eax, edx
        jmp     .endext

@@:
        cmp     al, COMMENTEXTENSION
        jne     @f

        ; Comment extension, consists of subblocks of text
        add     edx, 2  ;move to first subblock
        stdcall _SkipSubBlocks, edx
        jmp     .endext

@@:
        cmp     al, PLAINTEXTEXTENSION
        jne     @f

        ; Plain text extension, 15 header bytes and subblocks follow
        add     edx, 15
        stdcall _SkipSubBlocks, edx
        jmp     .endext

@@:
        cmp     al, APPLICATIONEXTENSION
        jne     .endext

        ; Application extension, 14 header bytes and subblocks follow
        add     edx, 14
        stdcall _SkipSubBlocks, edx
.endext:
        return
endp


;===============================================================================
;       SkipSubBlocks
;===============================================================================
; Skips a sequence of subblocks until a block-terminator is found.
; returns a pointer to the end of the block + 1.
; lpStart points to the start of the subblocks
;
proc _SkipSubBlocks, .lpStart
begin
        mov     eax, [.lpStart]
        xor     ecx, ecx
.skiploop:
        mov     cl, [eax]       ; get size of subblock
        test    cl, cl
        jz      .endloop   ; size=0 means terminator
        inc     eax
        add     eax, ecx        ; add size to pointer
        jmp     .skiploop

.endloop:
        inc     eax
        return
endp


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/graphics/images.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Memory based images manipulation library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Include respective OS dependent files.
;_________________________________________________________________________________________
module "Images library"

struct TImage
  .width  dd ?  ; width in pixels.
  .height dd ?  ; height in pixels.
  .bpp    dd ?  ; bits per pixel.
  .pData  dd ?  ; pointer to memory buffer with scanlines. all scanlines are aligned on dword.
  .raster dd ?  ; OS handle to be used with procedures from other graphics libraries.
ends


proc DrawMaskedImage, .context, .mask, .image, .x, .y
begin
        stdcall SetDrawMode, [.context], cmAnd
        stdcall DrawImage, [.context], [.mask], [.x], [.y]
        stdcall SetDrawMode, [.context], cmXor
        stdcall DrawImage, [.context], [.image], [.x], [.y]
        return
endp


include '%TargetOS%/images.asm'

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































Deleted freshlib/graphics/text.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Text drawing library.
;
;  Target OS: Any
;
;  Dependencies: StrLib
;
;  Notes: This file contains OS independent part of the library and includes respective
;         OS dependent files.
;_________________________________________________________________________________________
module "Text library"

include "%TargetOS%/text.asm"


macro min a, b, use {
        sub     b, a
        sbb     use, use
        and     use, b
        add     a, use
}

macro max a, b, use {
        sub     b, a
        sbb     use, use
        not     use
        and     use, b
        add     a, use
}


struct TTextExtent
  .width  dd ?
  .height dd ?
  .OffsX  dd ?
  .OffsY  dd ?
ends


struct TCharAttr
  .font       dd ?
  .color      dd ?
  .background dd ?
  .flags      dd ?      ; for free use of the client.
ends


; dtfXXX means "draw text flag"

; horizontal align
dtfAlignLeft    = 0
dtfAlignRight   = 1
dtfAlignCenter  = 2
dtfAlignJustify = 3

; vertical align
dtfAlignTop    = 0 shl 2
dtfAlignBottom = 1 shl 2
dtfAlignMiddle = 2 shl 2

; Text layout
dtfCRLF         = $0100
dtfWordWrap     = $0200
dtfTableTabs    = $0400


struct _TTextChunk
  .y      dd ?
  .width  dd ?
  .height dd ?
  .len    dd ?
  .ptr    dd ?
ends

__HeightProbeString text '18ilj.Xygl[_|"`g'
__NumberProbeString text '8888888888888888'

; returns: eax - mean width
; returns: edx - height
; returns: ecx - descent
proc FontGetCharSize, .raster, .font, .probe
begin
        push    ebx

        stdcall AllocateContext, [.raster]
        mov     ebx, eax

        stdcall GetTextOffset, ebx, [.probe], 16, [.font]
        mov     ecx, edx

;        DebugMsg "Text offset y:"
;        OutputRegister regECX, 10

        stdcall GetTextBounds, ebx, [.probe], 16, [.font]
        stdcall ReleaseContext, ebx

        sub     ecx, edx
        shr     eax, 4
        neg     ecx
        pop     ebx
        return
endp




proc AdjustCountUtf8
begin
        push    esi
        lea     esi, [esi+ebx]
        stdcall ScanBackUtf8
        mov     ebx, esi
        pop     esi
        sub     ebx, esi
        return
endp


proc DrawTextBox, .context, .text, .bounds, .flags, .font, .color
.len   dd ?
.count dd ?
.height dd ?
.y      dd ?

.low  dd  ?
.high dd  ?

.linew     dd ?
.lineh     dd ?

.DrawProc dd ?
begin
        pushad

        mov     ecx, DrawString

        mov     eax, [.flags]
        and     eax, $03
        cmp     eax, dtfAlignJustify
        jne     @f
        mov     ecx, DrawStringJustified
@@:
        mov     [.DrawProc], ecx

        stdcall StrLen, [.text]
        mov     [.len], eax

        stdcall StrPtr, [.text]
        mov     esi, eax

        mov     edi, [.bounds]
        mov     eax, [edi+TBounds.height]
;        mov     ecx, [edi+TBounds.y]
        mov     [.height], eax
        mov     [.y], 0 ;ecx

; slice the string on chunks, depending on flags, rectangle width and the string content.
; push _TTextChunk for every chunk in stack.
        mov     [.count], 0
.slice:
        mov     ecx, [.len]

        test    [.flags], dtfCRLF
        jz      .cropit

        xor     ecx, ecx

.scanCRLF:
        cmp     ecx, [.len]
        jae     .cropit

        mov     al, [esi+ecx]

        cmp     al, $0d
        je      .cropit
        cmp     al, $0a
        je      .cropit
        inc     ecx
        jmp     .scanCRLF

.cropit:
        mov     ebx, ecx  ; high limit

        stdcall AdjustCountUtf8
        stdcall GetTextBounds, [.context], esi, ebx, [.font]

        cmp     edx, [.height]
        jg      .drawchunks

        mov     [.lineh], edx

        cmp     eax, [edi+TBounds.width]
        jle     .itfits

        mov     [.high], ebx
        mov     [.low], 0

.croploop:
        mov     ebx, [.low]
        add     ebx, [.high]
        shr     ebx, 1

        stdcall AdjustCountUtf8
        stdcall GetTextBounds, [.context], esi, ebx, [.font]
        cmp     eax, [edi+TBounds.width]
        je      .itfits

        jg      .above

        cmp     ebx, [.low]
        je      .itfits

        mov     [.low], ebx
        jmp     .croploop

.above:
        mov     [.high], ebx
        jmp     .croploop

.itfits: ; here ebx contains the len of string that fits in the rectangle.
        mov     ecx, ebx
        mov     [.linew], eax

        test    [.flags], dtfWordWrap
        jz      .pushit

; search the last space or tab that separates words:
        mov     edx, ecx
        cmp     byte [esi+edx], $0d
        je      .found
        cmp     byte [esi+edx], $0a
        je      .found

.searchword:
        cmp     byte [esi+edx], 0
        je      .found
        cmp     byte [esi+edx], ' '
        je      .found
        cmp     byte [esi+edx], $09
        je      .found
        cmp     byte [esi+edx], $0d
        je      .found
        cmp     byte [esi+edx], $0a
        je      .found

        dec     edx
        jnz     .searchword

        mov     edx, ecx

.found:
        push    ebx
        mov     ebx, edx
        stdcall AdjustCountUtf8
        stdcall GetTextBounds, [.context], esi, ebx, [.font]
        mov     [.linew], eax
        mov     [.lineh], edx
        mov     ecx, ebx
        pop     ebx

.pushit:
        push    esi             ; pointer to the string.
        push    ecx             ; length of the string.
        push    [.lineh]        ; height of the line.
        push    [.linew]        ; width of the line.
        push    [.y]            ;

        inc     [.count]

        mov     eax, [.lineh]
        add     [.y], eax
        sub     [.height], eax

        lea     esi, [esi+ecx]
        sub     [.len], ecx
        jz      .drawchunks

        xor     ecx, ecx

; search for the whitespace that have to be skip
.skiploop:
        mov     al, [esi]
        cmp     al, $0d
        je      .skipcrlf
        cmp     al, $0a
        je      .skipcrlf
        cmp     al, $20
        je      .skipspace
        cmp     al, $09
        je      .skipspace

        jmp     .slice

.skipspace:
        inc     esi
        dec     [.len]
        jnz     .skiploop
        jmp     .drawchunks

.skipcrlf:
        inc     esi
        dec     [.len]
        xor     al, $0d xor $0a
        cmp     [esi], al
        jne     .slice
        inc     esi
        dec     [.len]
        jnz     .slice

; pop the _TTextChunk structures and draw, depending on flags.
.drawchunks:
        mov     ebx, esp
        stdcall GetTextOffset, [.context], [ebx+_TTextChunk.ptr], [ebx+_TTextChunk.len], [.font]
        mov     eax, [ebx+_TTextChunk.height]
        sub     eax, edx        ; it should be the line y descent
        test    [.flags], dtfAlignBottom
        jnz     @f
        sub     [.y], eax
@@:
        mov     edx, [.flags]
        and     edx, dtfAlignBottom or dtfAlignMiddle

        mov     ecx, [edi+TBounds.height]
        sub     ecx, [.y]

        cmp     edx, dtfAlignBottom
        je      .yalignok

        sar     ecx, 1
        cmp     edx, dtfAlignMiddle
        je      .yalignok

        xor     ecx, ecx

.yalignok:
.drawloop:
        cmp     [.count], 0
        je      .finish

        mov     ebx, esp

        mov     eax, [edi+TBounds.width]
        sub     eax, [ebx+_TTextChunk.width]

        mov     edx, [.flags]
        and     edx, $03

        cmp     edx, dtfAlignRight
        je      .hready

        shr     eax, 1
        cmp     edx, dtfAlignCenter
        je      .hready

        xor     eax, eax

.hready:
        add     eax, [edi+TBounds.x]

        push    eax
        stdcall GetTextOffset, [.context], [ebx+_TTextChunk.ptr], [ebx+_TTextChunk.len], [.font]
        add     edx, ecx
        add     edx, [ebx+_TTextChunk.y]
        add     edx, [edi+TBounds.y]
        pop     eax

        stdcall [.DrawProc], [.context], [ebx+_TTextChunk.ptr], [ebx+_TTextChunk.len], eax, edx, [.font], [.color]

; draws lines on every row of text. For debug purposes.
iglobal
  if used __UnderlineStyle
    __UnderlineStyle LineStyle 0, $808080
  end if
endg

if defined options.DebugMode & options.DebugMode
        stdcall SetLineStyle, [.context], __UnderlineStyle
        stdcall DrawLine, [.context], [edi+TBounds.x], edx, [edi+TBounds.width], edx
end if
; end debug code


        add     esp, sizeof._TTextChunk
        dec     [.count]
        jmp     .drawloop

.finish:
        popad
        return
endp




proc DrawStringJustified, .raster, .ptrString, .len, .x, .y, .font, .color
.XX    dd ?
.rem   dd ?
.crem  dd ?
.endptr dd ?
begin
        pushad

        mov     esi, [.ptrString]
        mov     eax, [.len]
        add     eax, esi
        mov     [.endptr], eax

        stdcall StrLenUtf8, esi, [.len]
        mov     ecx, eax
        dec     ecx
        jg      @f
        mov     ecx, 1
@@:

        stdcall GetTextBounds, [.raster], esi, [.len], [.font]

        sub     eax, [edi+TBounds.width]
        neg     eax

        cdq
        div    ecx

        cmp     eax, 4
        jge     .cantjustify    ; the needed space is too big for justify, so just draw it left aligned

        mov     ecx, eax
        mov     [.rem], edx
        mov     [.crem], edx

        mov     ebx, [.len]
        push    [.x]
        pop     [.XX]

.drawloop:
        cmp     esi, [.endptr]
        jae     .finish

        stdcall DecodeUtf8, [esi]
        jc      .finish

        push    edx
        stdcall DrawString, [.raster], esi, edx, [.XX], [.y], [.font], [.color]
        stdcall GetTextBounds, [.raster], esi, edx, [.font]
        pop     edx
        add     esi, edx
        add     [.XX], eax
        add     [.XX], ecx

        cmp     [.crem], 0
        je      .drawloop

        sub     ebx, [.rem]
        jge     .drawloop

        inc     [.XX]
        dec     [.crem]
        mov     ebx, [.len]
        sub     ebx, [.rem]
        jmp     .drawloop

.finish:
        popad
        return

.cantjustify:
        stdcall DrawString, [.raster], [.ptrString], [.len], [.x], [.y], [.font], [.color]
        jmp     .finish
endp



endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/Linux/Main.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Main procedure of GUI application library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes: Organize the main message/event loop needed by every GUI engine.
;_________________________________________________________________________________________

uglobal
  if used fGlobalTerminate
    fGlobalTerminate dd ?
  end if
endg


proc ProcessSystemEvents
  .event  XEvent
begin
        push    ebx ecx edx

.event_loop:
; check for quit
        mov     eax, [pApplication]
        mov     eax, [eax+TApplication.MainWindow]
        test    eax, eax
        jz      .continue     ; ???????????

        cmp     dword [eax], 0
        jne     .continue

        cinvoke XFlush, [hApplicationDisplay]
        xor     eax, eax
        mov     [fGlobalTerminate], 1
        stc
        pop     edx ecx ebx
        return

.continue:
        cinvoke XPending, [hApplicationDisplay]
        test    eax, eax
        jz      .noevents

        lea     ebx, [.event]
        cinvoke  XNextEvent, [hApplicationDisplay], ebx
        stdcall  __ProcessOneSystemEvent, ebx
        jmp      .event_loop

.noevents:
        clc
        pop     edx ecx ebx
        return

endp




proc WaitForSystemEvent
.event XEvent
begin
        push    eax ecx edx
        lea     eax, [.event]
        cinvoke XPeekEvent, [hApplicationDisplay], eax
        pop     edx ecx eax
        return
endp




;proc EventsQueued, .pWin
;begin
;        push    eax ecx edx
;        cinvoke XQLength, [hApplicationDisplay]
;        test    eax, eax
;        clc
;        jz      @f
;        stc
;@@:
;        pop     edx ecx eax
;        return
;endp




proc __ProcessOneSystemEvent, .linux_event
.event  rd 64
begin
        push    eax ebx ecx edx esi edi

        mov     ebx, [.linux_event]

        stdcall _GetWindowStruct, [ebx+XEvent.window]
        mov     esi, eax
        lea     edi, [.event]
        mov     eax, [ebx+XEvent.type]

        cmp     eax, DestroyNotify
        je      .destroy

        test    esi, esi
        jz      .notprocessed

        cmp     eax, MotionNotify
        je      .mousemove

        cmp     eax, EnterNotify
        je      .mouseenter

        cmp     eax, LeaveNotify
         je      .mouseleave

        cmp     eax, ButtonPress
        je      .mouse_btn_press

        cmp     eax, ButtonRelease
        je      .mouse_btn_release

        cmp     eax, Expose
        je      .paint_window

        cmp     eax, ClientMessage        ; event from the window manager - button close for example.
        je      .clientmessage

        cmp     eax, KeyPress
        je      .key_press

        cmp     eax, KeyRelease
        je      .key_release

        cmp     eax, MappingNotify
        je      .mapping_notify

        cmp     eax, FocusIn
        je      .focusin

        cmp     eax, FocusOut
        je      .focusout

        cmp     eax, ConfigureNotify
        je      .moveresize

.notprocessed:
        pop     edi esi edx ecx ebx eax
        stc
        return

.exec_event:
        pushad
        stdcall ExecEvent, esi, edi
        popad

.finish:
        pop     edi esi edx ecx ebx eax
        clc
        return

;.........................................................................
; Resize events
.moveresize:
locals
  .xevent XConfigureEvent
endl
        lea     eax, [.xevent]
        cinvoke XCheckTypedWindowEvent, [hApplicationDisplay], [ebx+XConfigureEvent.window], ConfigureNotify, eax
        test    eax, eax
        jz      .process

        lea     eax, [.xevent]
        cinvoke XPutBackEvent, [hApplicationDisplay], eax

        mov     eax, [.xevent.x]
        cmp     eax, [ebx+XConfigureEvent.x]
        jne     .finish

        mov     eax, [.xevent.y]
        cmp     eax, [ebx+XConfigureEvent.y]
        jne     .finish

        mov     eax, [.xevent.width]
        cmp     eax, [ebx+XConfigureEvent.width]
        jne     .finish

        mov     eax, [.xevent.height]
        cmp     eax, [ebx+XConfigureEvent.height]
        jne     .finish

.process:
        mov     [edi+TMoveResizeEvent.event], seMoveResize

        mov     eax, [ebx+XConfigureEvent.x]
        mov     ecx, [ebx+XConfigureEvent.y]
        mov     [edi+TMoveResizeEvent.newX], eax
        mov     [edi+TMoveResizeEvent.newY], ecx

        cmp     [ebx+XConfigureEvent.height], 100
        jl      @f
;        DebugMsg "NewX NewY"
;        OutputRegister regEAX, 10
;        OutputRegister regECX, 10
@@:
        mov     eax, [ebx+XConfigureEvent.width]
        mov     ecx, [ebx+XConfigureEvent.height]
        mov     [edi+TMoveResizeEvent.newWidth], eax
        mov     [edi+TMoveResizeEvent.newHeight], ecx

        cmp     [ebx+XConfigureEvent.height], 100
        jl      @f
;        DebugMsg "NewW NewH"
;        OutputRegister regEAX, 10
;        OutputRegister regECX, 10
@@:
        jmp     .exec_event

;.........................................................................
; Focus events
.focusout:
        mov     [edi+TFocusOutEvent.event], seFocusOut
        jmp     .setIC

.focusin:
        mov     [edi+TFocusInEvent.event], seFocusIn

.setIC:
        cinvoke XSetICValues, [hInputContext], XNFocusWindow, [esi+TWindow.handle], 0
        jmp     .exec_event

;.........................................................................
; DestroyNotify handler it invalidates the handle in TWindow structure and then destroys TWindow.
.destroy:
        DebugMsg "Destroy notify"
        OutputNumber [ebx+XDestroyWindowEvent.window], 16, 8
        DebugMsg "h <<< Window handle"

        test    esi, esi
        jz      .finish

        DebugMsg "Destroy the object"

        mov     [esi+TWindow.handle], 0
        stdcall Destroy, esi
        jmp     .finish

;.........................................................................
; Mouse event handlers

.mouseleave:
        mov     [edi+TMouseEnterEvent.event], seMouseLeave
        jmp     .exec_event

.mouseenter:
        mov     [edi+TMouseEnterEvent.event], seMouseEnter
        jmp     .exec_event

.mousemove:
        mov     [edi+TMouseMoveEvent.event], seMouseMove
        mov     eax, [ebx+XMotionEvent.x]
        mov     ecx, [ebx+XMotionEvent.y]
        mov     [edi+TMouseMoveEvent.x], eax
        mov     [edi+TMouseMoveEvent.y], ecx
        jmp     .exec_event

.mouse_btn_press:
.mouse_btn_release:

        mov     eax, [ebx+XButtonEvent.type]
        mov     [edi+TMouseButtonEvent.event], eax      ; seMouseBtnPress=ButtonPress and seMouseBtnRelease = ButtonRelease

        mov     eax, [ebx+XButtonEvent.button]
        dec     eax

        cmp     [edi+TScrollEvent.event], seMouseBtnRelease
        je      @f

        cmp     eax, 3
        jge     .wheelscroll

@@:
        mov     [edi+TMouseButtonEvent.Button], eax

        mov     eax, [ebx+XButtonEvent.state]
        mov     [edi+TMouseButtonEvent.kbdStatus], eax

        mov     eax, [ebx+XButtonEvent.x]
        mov     ecx, [ebx+XButtonEvent.y]
        mov     [edi+TMouseButtonEvent.x], eax
        mov     [edi+TMouseButtonEvent.y], ecx

        jmp     .exec_event

.wheelscroll:
        mov     ecx, scWheelUp
        je      @f
        mov     ecx, scWheelDn
@@:
        mov     [edi+TScrollEvent.event], seScroll
        mov     [edi+TScrollEvent.ScrollBar], scrollY
        mov     [edi+TScrollEvent.ScrollCmd], ecx
        mov     [edi+TScrollEvent.Value], 1
        jmp     .exec_event

;.........................................................................
; Window paint event

.paint_window:
;        cmp     [ebx+XExposeEvent.count], 0
;        jne     .finish

        lea     eax, [ebx+XExposeEvent.x]
        stdcall __PaintWindow, esi, eax

        jmp     .finish

;.........................................................................
; Keyboard events.

locals
  .utf8buff rb 16
endl

.key_press:
        mov     ecx, seKbdKeyPress
        mov     [edi+TKeyboardEvent.event], ecx
        mov     ecx, [ebx+XKeyEvent.state]
        mov     [edi+TKeyboardEvent.kbdStatus], ecx

        mov     dword [.utf8buff], 0
        lea     eax, [.utf8buff]
        cinvoke Xutf8LookupString, [hInputContext], ebx, eax, 16, 0, 0

; here, .utg8buff contains the utf-8 string with the character typed on the keyboard.
        mov     eax, dword [.utf8buff]
        mov     [edi+TKeyboardEvent.key], eax

.scancode:
        mov     eax, [ebx+XKeyEvent.keycode]
        cinvoke XKeycodeToKeysym, [hApplicationDisplay], eax, 0
        mov     [edi+TKeyboardEvent.scancode], eax
        jmp     .exec_event


.key_release:
        mov     ecx, seKbdKeyRelease
        mov     eax, [ebx+XKeyEvent.state]

        mov     [edi+TKeyboardEvent.event], ecx
        mov     [edi+TKeyboardEvent.kbdStatus], eax
        mov     [edi+TKeyboardEvent.key], 0
        jmp     .scancode



; refreshes keyboard mapping information, stored locally in XLib.
.mapping_notify:
        cinvoke XRefreshKeyboardMapping, ebx
        jmp     .finish


;.........................................................................
; This event is sent from the window manager, when the user click on the close button of the
; window or close it some other way. So, the window have to decide whether to close or not.

.clientmessage:
        mov     eax, dword [ebx+XClientMessageEvent.data]
        cmp     eax, [atomWMDelete]
        jne     .finish

; The window is closed by click on close button or by pressing Alt+F4 or by other WM method
;.close_from_wm:
        mov     [edi+TCloseEvent.event], seCloseRequest
        mov     [edi+TCloseEvent.reason], cerFromUser
        jmp     .exec_event
endp








proc __PaintWindow, .pWindow, .ptrBounds
.event TPaintEvent
.caret dd ?
begin
        push    eax ebx ecx edx esi edi

        lea     edi, [.event]
        mov     esi, [.pWindow]

if defined Caret
        mov     [.caret], -1
        cmp     esi, [Caret.pWindow]
        jne     @f
        stdcall CaretShow, FALSE
        mov     [.caret], eax
@@:
end if
        mov     [edi+TPaintEvent.event], sePaint

        stdcall AllocateContext, [esi+TWindow.handle]
        mov     ebx, eax
        mov     [edi+TPaintEvent.context], eax

        xor     eax, eax
        mov     [edi+TPaintEvent.rect.left], eax
        mov     [edi+TPaintEvent.rect.top], eax
        mov     eax, $7fffffff
        mov     [edi+TPaintEvent.rect.right], eax
        mov     [edi+TPaintEvent.rect.bottom], eax

        mov     edx, [.ptrBounds]
        test    edx, edx
        jz      .rectok

        mov     eax, [edx+TBounds.x]
        mov     ecx, [edx+TBounds.y]

        mov     [edi+TPaintEvent.rect.left], eax
        mov     [edi+TPaintEvent.rect.top], ecx

        mov     eax, [edx+TBounds.width]
        mov     ecx, [edx+TBounds.height]
        add     eax, [edi+TPaintEvent.rect.left]
        add     ecx, [edi+TPaintEvent.rect.top]
        mov     [edi+TPaintEvent.rect.right], eax
        mov     [edi+TPaintEvent.rect.bottom], ecx

.rectok:
        pushad
        stdcall ExecEvent, esi, edi
        popad

        stdcall ReleaseContext, ebx

if defined Caret
        cmp     [.caret], -1
        je      @f
        stdcall CaretShow, [.caret]
@@:
end if
        pop     edi esi edx ecx ebx eax
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/Linux/TApplication.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TApplication object class.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes: TApplication by the idea is the base of GUI application, but the implementation
;         somehow need fixing...
;_________________________________________________________________________________________


uglobal
  if used CApplication
    hApplicationDisplay dd ?
    hRootWindow         dd ?

    hInputMethod        dd ?
    hInputContext       dd ?

    _SystemFont         dd ?

    atomWMDelete        dd ?
  end if
endg

;cDefaultFont text 'Tahoma-8'
cDefaultFont text 'Liberation Sans-9'
cDefaultFontSize = 9
;cDefaultFont text 'Ubuntu-9:rgba=rgb'
;cDefaultFont text 'Unifont-12' ; this one have unicode support;


; String constants needed for XLib
; Why, they needed so many strings????????????????? For arguments!??????????
_cWinDeleteName   text 'WM_DELETE_WINDOW'

XNVaNestedList                text "XNVaNestedList"
XNSeparatorofNestedList       text "separatorofNestedList"
XNQueryInputStyle             text "queryInputStyle"
XNClientWindow                text "clientWindow"
XNInputStyle                  text "inputStyle"
XNFocusWindow                 text "focusWindow"
XNResourceName                text "resourceName"
XNResourceClass               text "resourceClass"
XNGeometryCallback            text "geometryCallback"
XNDestroyCallback             text "destroyCallback"
XNFilterEvents                text "filterEvents"
XNPreeditStartCallback        text "preeditStartCallback"
XNPreeditDoneCallback         text "preeditDoneCallback"
XNPreeditDrawCallback         text "preeditDrawCallback"
XNPreeditCaretCallback        text "preeditCaretCallback"
XNPreeditStateNotifyCallback  text "preeditStateNotifyCallback"
XNPreeditAttributes           text "preeditAttributes"
XNStatusStartCallback         text "statusStartCallback"
XNStatusDoneCallback          text "statusDoneCallback"
XNStatusDrawCallback          text "statusDrawCallback"
XNStatusAttributes            text "statusAttributes"
XNArea                        text "area"
XNAreaNeeded                  text "areaNeeded"
XNSpotLocation                text "spotLocation"
XNColormap                    text "colorMap"
XNStdColormap                 text "stdColorMap"
XNForeground                  text "foreground"
XNBackground                  text "background"
XNBackgroundPixmap            text "backgroundPixmap"
XNFontSet                     text "fontSet"
XNLineSpace                   text "lineSpace"
XNCursor                      text "cursor"
XNQueryIMValuesList           text "queryIMValuesList"
XNQueryICValuesList           text "queryICValuesList"
XNStringConversionCallback    text "stringConversionCallback"
XNStringConversion            text "stringConversion"
XNResetState                  text "resetState"
XNHotKey                      text "hotkey"
XNHotKeyState                 text "hotkeyState"
XNPreeditState                text "preeditState"
XNVisiblePosition             text "visiblePosition"
XNR6PreeditCallbackBehavior   text "r6PreeditCallback"
XNRequiredCharSet             text "requiredCharSet"
XNQueryOrientation            text "queryOrientation"
XNDirectionalDependentDrawing text "directionalDependentDrawing"
XNContextualDrawing           text "contextualDrawing"
XNBaseFontName                text "baseFontName"
XNMissingCharSet              text "missingCharSet"
XNDefaultString               text "defaultString"
XNOrientation                 text "orientation"
XNFontInfo                    text "fontInfo"
XNOMAutomatic                 text "omAutomatic"



proc TApplication.Create, .obj
.ptr dd ?
begin
        push    eax ecx edx

        cinvoke XInitThreads
        test    eax, eax
        jz      .exit_error

        cinvoke XSetErrorHandler, __FreshXErrorHandler

        cinvoke XOpenDisplay, 0
        test    eax, eax
        jz      .second_try

.continue:
        DebugMsg 'Display opened.'

        mov     [hApplicationDisplay], eax

        cinvoke XDefaultRootWindow, eax
        mov     [hRootWindow], eax

        cinvoke XOpenIM, [hApplicationDisplay], 0, 0, 0
        mov     [hInputMethod], eax

        lea     eax, [.ptr]
        cinvoke XGetIMValues, [hInputMethod], XNQueryInputStyle, eax, 0

        mov     eax, [.ptr]
        mov     eax, [eax+4]
        cinvoke XCreateIC, [hInputMethod], XNInputStyle, [eax], 0
        mov     [hInputContext], eax

        cinvoke XFree, [.ptr]

        stdcall InitMouseCursors

; Creating internal atoms that to be used with Window manager of the application windows...
; Maybe this code should reside somewhere else, not in application. In initialize TWindow???

        cinvoke XInternAtom, [hApplicationDisplay], _cWinDeleteName, 0
        mov     [atomWMDelete], eax

        cinvoke XftFontOpenName, [hApplicationDisplay], 0, cDefaultFont
        mov     [_SystemFont], eax


; clipboard initialization.
if __UseClipboard = 1
        stdcall   __InitLinuxClipboard
end if

        clc
        pop     edx ecx eax
        return

.second_try:
        stdcall Sleep, 200      ; wait a little.

        cinvoke XOpenDisplay, 0
        test    eax, eax
        jnz     .continue

.exit_error:
        Message 'Error open display.'
        stc
        pop     edx ecx eax
        return




endp




proc TApplication.Get, .obj, .paramID
begin
        stc
        return
endp



proc TApplication.Set, .obj, .paramID, .value
begin
        stc
        return
endp



proc TApplication.SysEventHandler
begin
        clc
        return
endp




cXErrorMsg text 'X server error:'
cXErrorMsg2 text 10, 0
cXErrorMsg3 text 'Request: '
cXErrorMsg4 text 'Minor code: '
cXErrorMsg5 text 'ResourceID: $'

proc __FreshXErrorHandler, .display, .error
.buff rb 256
begin
if (defined options.DebugMode) & options.DebugMode
        cmp     [fGlobalTerminate], 0
        jne     .exit

        stdcall Output, cXErrorMsg
        mov      ebx, [.error]

        movzx    eax, [ebx+XErrorEvent.error_code]
        lea      ecx, [.buff]
        cinvoke XGetErrorText, [.display], eax, ecx, 256

        lea     ecx, [.buff]
        stdcall Output, ecx
        stdcall Output, cXErrorMsg2

        stdcall Output, cXErrorMsg3
        movzx    eax, [ebx+XErrorEvent.request_code]
        stdcall OutputNumber, eax, 10, 3
        stdcall Output, cXErrorMsg2

        stdcall Output, cXErrorMsg4
        movzx    eax, [ebx+XErrorEvent.minor_code]
        stdcall OutputNumber, eax, 10, 3
        stdcall Output, cXErrorMsg2

        stdcall Output, cXErrorMsg5
        stdcall OutputNumber, [ebx+XErrorEvent.resourceid], 16, 8
        stdcall Output, cXErrorMsg2
        stdcall Output, cXErrorMsg2
end if
.exit:
        cret
endp




; This code and data possibly will be used in FreshLib, but I hope, not very soon. :)

;        cinvoke XInternAtom, [hApplicationDisplay], _cWinSyncRequest, 0
;        mov     [atomSyncRequest], eax
;
;
;        cinvoke XInternAtom, [hApplicationDisplay], _cAtomTypeAtom, 0
;        mov     [atomTypeATOM], eax
;
;; _NET_WM_WINDOW_TYPE
;        cinvoke XInternAtom, [hApplicationDisplay], _cWinTypeAtomName, 0
;        mov     [atomWMType], eax
;
;        cinvoke XInternAtom, [hApplicationDisplay], _cWinTypeDlg, 0
;        mov     [atomWinTypeDlg], eax
;
;        cinvoke XInternAtom, [hApplicationDisplay], _cWinTypeTool, 0
;        mov     [atomWinTypeTool], eax
;
;        cinvoke XInternAtom, [hApplicationDisplay], _cWinTypeDock, 0
;        mov     [atomWinTypeDock], eax
;
;        cinvoke XInternAtom, [hApplicationDisplay], _cWinTypeNormal, 0
;        mov     [atomWinTypeNormal], eax
;
;        cinvoke XInternAtom, [hApplicationDisplay], atomAllowedActions.text, 0
;        mov     [atomAllowedActions], eax
;
;        cinvoke XInternAtom, [hApplicationDisplay], atomAllowedActions.minimize.text, 0
;        mov     [atomAllowedActions.minimize], eax
;
;        cinvoke XInternAtom, [hApplicationDisplay], atomAllowedActions.close.text, 0
;        mov     [atomAllowedActions.close], eax
;
;        cinvoke XInternAtom, [hApplicationDisplay], atomWMState.text, 0
;        mov     [atomWMState], eax
;
;        cinvoke XInternAtom, [hApplicationDisplay], atomWMState.modal.text, 0
;        mov     [atomWMState.modal], eax
;

;_cWinTypeAtomName text '_NET_WM_WINDOW_TYPE'
;  _cWinTypeDlg      text '_NET_WM_WINDOW_TYPE_DIALOG'
;  _cWinTypeTool     text '_NET_WM_WINDOW_TYPE_TOOLBAR'          ; it is with normal toolbar, but with only close button.
;  _cWinTypeDock     text '_NET_WM_WINDOW_TYPE_DOCK'             ; without title bar and above all other windows???
;  _cWinTypeNormal   text '_NET_WM_WINDOW_TYPE_NORMAL'

;_cWinSyncRequest  text '_NET_WM_SYNC_REQUEST'
;_cAtomTypeAtom  text 'ATOM'

; notes on different types, regarding XFWM window manager:
;  _NET_WM_WINDOW_TYPE_SPLASH - no title, goes up on activation.
;  _NET_WM_WINDOW_TYPE_DOCK   - no title, always on top
;  _NET_WM_WINDOW_TYPE_DROPDOWN_MENU - ???
;  _NET_WM_WINDOW_TYPE_NOTIFICATION - ???
;  _
;


;macro atomset lbl, name, [valname, value] {
;common
;  lbl dd ?
;forward
;  valname dd ?
;common
;  lbl#.text text `name
;forward
;  lbl#valname#.text text `value
;}
;

;uglobal
;  atomSyncRequest dd ?
;
;  atomTypeATOM  dd ?
;
;  atomWMType          dd ?
;    atomWinTypeDlg      dd ?
;    atomWinTypeTool     dd ?
;    atomWinTypeDock     dd ?
;    atomWinTypeNormal   dd ?
;endg
;
;
;iglobal
;  atomset atomAllowedActions, _NET_WM_ALLOWED_ACTIONS,    \
;            .move, _NET_WM_ACTION_MOVE,                     \
;            .resize, _NET_WM_ACTION_RESIZE,                 \
;            .minimize, _NET_WM_ACTION_MINIMIZE,             \
;            .shade, _NET_WM_ACTION_SHADE,                   \
;            .stick, _NET_WM_ACTION_STICK,                   \
;            .maximize_horz, _NET_WM_ACTION_MAXIMIZE_HORZ,   \
;            .maximize_vert, _NET_WM_ACTION_MAXIMIZE_VERT,   \
;            .fullscreen, _NET_WM_ACTION_FULLSCREEN,         \
;            .change_desktop, _NET_WM_ACTION_CHANGE_DESKTOP, \
;            .close, _NET_WM_ACTION_CLOSE
;
;  atomset atomWMState, _NET_WM_STATE,           \
;            .modal, _NET_WM_STATE_MODAL
;
;endg
;
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/Linux/keycodes.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: This file contains scan code values for control keyboard keys.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

keyHomeNumpad   = $ff95
keyUpNumpad     = $ff97
keyPgUpNumpad   = $ff9a
keyLeftNumpad   = $ff96
key5Numpad      = $ff9d
keyRightNumpad  = $ff98
keyEndNumpad    = $ff9c
keyDownNumpad   = $ff99
keyPgDnNumpad   = $ff9b
keyInsNumpad    = $ff9e
keyDelNumpad    = $ff9f
keyEnterNumpad  = $ff8d
keyPlusNumpad   = $ffab
keyMinusNumpad  = $ffad
keyAsteriskNumpad = $ffaa
keySlashNumpad  = $ffaf

keyNumLock      = $ff7f
keyScrollLock   = $ff14
keyPause        = $ff13


keyLeft         = $ff51
keyRight        = $ff53
keyUp           = $ff52
keyDown         = $ff54

keyInsert       = $ff63
keyDelete       = $ffff
keyHome         = $ff50
keyEnd          = $ff57
keyPgUp         = $ff55
keyPgDown       = $ff56

keyF1           =  $ffbe
keyF2           =  $ffbf
keyF3           =  $ffc0
keyF4           =  $ffc1

keyF5           =  $ffc2
keyF6           =  $ffc3
keyF7           =  $ffc4
keyF8           =  $ffc5

keyF9           =  $ffc6
keyF10          =  $ffc7
keyF11          =  $ffc8
keyF12          =  $ffc9

keyCapsLock     = $ffe5
keyShiftLeft    = $ffe1
keyCtrlLeft     = $ffe3
;keyWndLeft     =
;keyWndRight    =
keyAltLeft      = $ffe9
keyAltRight     = $ffea
keyPopupMenu    = $ff67
keyShiftRight   = $ffe2
keyCtrlRight    = $ffe4
keyBackSpace    = $ff08
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































Deleted freshlib/gui/Linux/mouse.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Provides unified access to standard mouse cursors.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

iglobal
  if used _Xcursors
    _Xcursors db 68, 152, 34, 108, 116, 40, 40, 150   ; X standard cursor font
  end if
endg


uglobal
  if used StockCursors
    StockCursors rd mcCount
  end if
endg


proc InitMouseCursors
begin
        push    eax ecx edx ebx
        mov     ebx, mcCount-1

.create_cursor_loop:
        movzx   eax, [_Xcursors+ebx]
        cinvoke XCreateFontCursor, [hApplicationDisplay], eax
        mov     [StockCursors+4*ebx], eax

        dec     ebx
        jns     .create_cursor_loop
        pop     ebx edx ecx eax
        return
endp



if used InitMouseCursors
finalize FinalizeMouseCursors
begin
        mov     ebx, mcCount-1
        cmp     [hApplicationDisplay], 0
        je      .exit

.free_cursor_loop:
        cinvoke XFreeCursor, [hApplicationDisplay], [StockCursors+4*ebx]
        dec     ebx
        jns     .free_cursor_loop

.exit:
        return
endp
end if


proc SetMouseCursor, .hCursor
begin
        push    eax ecx edx
        cinvoke XDefineCursor, [hApplicationDisplay], [hRootWindow], [.hCursor]
        pop     edx ecx eax
        return
endp



proc GetStockCursor, .index
begin
        mov     eax, [.index]
        and     eax, 7
        mov     eax, [StockCursors+4*eax]
        return
endp


proc MouseCapture, .hwnd
begin
        push    eax ecx edx
        cmp     [.hwnd], 0
        je      .release

        cinvoke XGrabPointer, [hApplicationDisplay], [.hwnd], FALSE, PointerMotionMask or ButtonPressMask or ButtonReleaseMask, \
                              GrabModeAsync, GrabModeAsync, None, None, CurrentTime

.finish:
        pop     edx ecx eax
        return

.release:
        cinvoke XUngrabPointer, [hApplicationDisplay], CurrentTime
        jmp     .finish
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































Deleted freshlib/gui/Linux/windows.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Window management OS interface functions.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


proc _CreateNullWindow
.attr XSetWindowAttributes
begin
        push    ecx edx esi

        lea     eax, [.attr]
        mov     [eax+XSetWindowAttributes.override_redirect], 1
        mov     [eax+XSetWindowAttributes.backing_store], NotUseful
        mov     [eax+XSetWindowAttributes.background_pixmap], None
        cinvoke XCreateWindow, [hApplicationDisplay], [hRootWindow], 0, 0, 1, 1, 0, CopyFromParent, InputOutput, CopyFromParent,  0, CWBackingStore or CWOverrideRedirect or CWBackPixmap, eax
        mov     esi, eax
        test    eax, eax
        jz      .exit

        cinvoke XSelectInput, [hApplicationDisplay], esi, ExposureMask or StructureNotifyMask or FocusChangeMask or   \
                                                          KeyPressMask or KeyReleaseMask or            \
                                                          ButtonPressMask or ButtonReleaseMask or      \
                                                          EnterWindowMask or LeaveWindowMask or        \
                                                          PointerMotionMask

        cinvoke XSetWMProtocols, [hApplicationDisplay], esi, atomWMDelete, 1
        mov     eax, esi
.exit:
        pop     esi edx ecx
        return
endp



;_________________________________________________________________________________________



proc _DestroyWindow, .hwnd
begin
        push    eax ecx edx
        stdcall _SetWindowStruct, [.hwnd], 0
        cinvoke XDestroyWindow, [hApplicationDisplay], [.hwnd]
        pop     edx ecx eax
        return
endp



;_________________________________________________________________________________________



proc _GetParent, .hwnd
.root dd ?
.parent dd ?
.children dd ?
.count    dd ?
begin
        push    ecx edx esi

        lea     esi, [.count]
        lea     edx, [.children]
        lea     ecx, [.parent]
        lea     eax, [.root]
        cinvoke XQueryTree, [hApplicationDisplay], [.hwnd], eax, ecx, edx, esi
        test    eax, eax
        jz      .exit   ; function failed

        cinvoke XFree, [.children]

        mov     eax, [.parent]

.exit:
        pop     esi edx ecx
        return
endp



;_________________________________________________________________________________________


proc _GetChildren, .hwnd
  .root dd ?
  .parent dd ?
  .children dd ?
  .count    dd ?
begin
        push    ebx ecx edx esi


        lea     ebx, [.count]
        lea     edx, [.children]
        lea     ecx, [.parent]
        lea     eax, [.root]
        cinvoke XQueryTree, [hApplicationDisplay], [.hwnd], eax, ecx, edx, ebx
        test    eax, eax
        jz      .exit   ; function failed

        xor     ebx, ebx
        mov     esi, [.children]
        test    esi, esi
        jz      .endchildren

        stdcall CreateArray, sizeof.TWinArrayItem
        mov     ebx, eax
        mov     ecx, [.count]

.loophwnd:
        dec     ecx
        js      .endchildren_free

        stdcall AddArrayItems, ebx, 1
        mov     ebx, edx

        mov     edx, [esi+4*ecx]
        mov     [eax+TWinArrayItem.handle], edx

        jmp     .loophwnd

.endchildren_free:
        cinvoke XFree, esi

.endchildren:
        mov     eax, ebx
.exit:
        pop     esi edx ecx ebx
        return
endp


;_________________________________________________________________________________________



proc _GetVisible, .hwnd
.attr XWindowAttributes
begin
        push    ebx ecx edx

        lea     ebx, [.attr]
        cinvoke XGetWindowAttributes, [hApplicationDisplay], [.hwnd], ebx
        mov     eax, [ebx+XWindowAttributes.map_state]
        test    eax, eax
        jz      @f
        mov     eax, 1
@@:
        pop     edx ecx ebx
        return
endp

;_________________________________________________________________________________________


proc _GetWindowBounds, .hwnd, .pBounds
begin
        push    eax ecx edx

        int3
        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________


proc _SetWindowBounds, .hwnd, .pBounds
  .wch XWindowChanges
begin
        push    eax ecx edx

        lea     eax, [.wch]
        mov     edx, [.pBounds]

        push    [edx+TBounds.x] [edx+TBounds.y] [edx+TBounds.width] [edx+TBounds.height]
        pop     [.wch.height] [.wch.width] [.wch.y] [.wch.x]

        cmp     [.wch.width], 0
        jnz     @f
        inc     [.wch.width]
@@:
        cmp     [.wch.height], 0
        jnz     @f
        inc     [.wch.height]
@@:
        cinvoke XConfigureWindow, [hApplicationDisplay], [.hwnd], CWX or CWY or CWWidth or CWHeight, eax

        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________



proc _SetWindowBorder, .hwnd, .brdType
  .attr XSetWindowAttributes
begin
        push    eax ecx edx

        mov     [.attr.override_redirect], 1
        cmp     [.brdType], borderNone
        je      @f
        mov     [.attr.override_redirect], 0
@@:
        lea     eax, [.attr]
        cinvoke XChangeWindowAttributes, [hApplicationDisplay], [.hwnd], CWOverrideRedirect, eax

        pop     edx ecx eax
        return
endp

;_________________________________________________________________________________________


proc _ShowWindow, .hwnd, .flag
begin
        push    eax ecx edx

        mov     ecx, XUnmapWindow
        cmp     [.flag], 0
        je      @f
        mov     ecx, XMapWindow
@@:
        ccall   dword [ecx], [hApplicationDisplay], [.hwnd]
        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________


proc _RefreshWindow, .hwnd
begin
        push    eax ecx edx
        cinvoke XClearArea, [hApplicationDisplay], [.hwnd], 0, 0, 0, 0, TRUE
        cinvoke XFlush, [hApplicationDisplay]
        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________


proc _SetFocus, .hwnd
begin
        push    eax ecx edx
        cinvoke XSetInputFocus, [hApplicationDisplay], [.hwnd], RevertToParent, CurrentTime
        pop     edx ecx eax
        return
endp

;_________________________________________________________________________________________

proc _AddChild, .hwnd, .child
begin
        push    eax ecx edx
        cinvoke XReparentWindow, [hApplicationDisplay], [.child], [.hwnd], 10, 10
        pop     edx ecx eax
        return
endp

;_________________________________________________________________________________________


proc _SetWindowTextUtf8, .hwnd, .ptrUtf8
begin
        push    eax ecx edx
        cinvoke XStoreName, [hApplicationDisplay], [.hwnd], [.ptrUtf8]
        pop     edx ecx eax
        return
endp



;_________________________________________________________________________________________



proc _GetWindowTextUtf8, .hwnd, .ptrUtf8
begin
        return
endp




;_________________________________________________________________________________________

proc _EnableWindow, .hwnd, .flag
begin
        push    eax ecx edx

        stdcall _GetChildren, [.hwnd]
        test    eax, eax
        jz      .children_ok

        mov     edx, [eax+TArray.count]
.child_loop:
        dec     edx
        js      .end_children

        stdcall _EnableWindow, [eax+TArray.array+sizeof.TWinArrayItem*edx+TWinArrayItem.handle], [.flag]
        jmp     .child_loop

.end_children:
        stdcall FreeMem, eax

.children_ok:
        mov     ecx, ExposureMask or StructureNotifyMask or EnterWindowMask or LeaveWindowMask or PointerMotionMask
        cmp     [.flag], 0
        je      @f
        or      ecx, FocusChangeMask or KeyPressMask or KeyReleaseMask or    \
                     ButtonPressMask or ButtonReleaseMask
@@:
        cinvoke XSelectInput, [hApplicationDisplay], [.hwnd], ecx

        pop     edx ecx eax
        return
endp

;_________________________________________________________________________________________

proc _SetModalTowards, .hwnd, .hwndParent
begin
        push    eax ecx edx
        cinvoke XSetTransientForHint, [hApplicationDisplay], [.hwnd], [.hwndParent]
        pop     edx ecx eax
        return
endp

;_________________________________________________________________________________________

proc _FinalizeModal, .hwnd, .hwndParent
  .flushevent XEvent
begin
        push    eax ecx edx

        DebugMsg "Finalize modal"

; dirty hack, but the button receives LeaveNotify after DestroyNotify
        cinvoke XSync, [hApplicationDisplay], FALSE
.loop_flush:
        lea     eax, [.flushevent]
        cinvoke XCheckMaskEvent, [hApplicationDisplay], LeaveWindowMask, eax
        test    eax, eax
        jnz     .loop_flush

        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________


win_structure_context = 1


proc _GetWindowStruct, .hwin
  .user_data dd ?
begin
        push    ecx edx
        lea     eax, [.user_data]
        cinvoke XFindContext, [hApplicationDisplay], [.hwin], win_structure_context, eax
        test    eax, eax
        jnz     .error

        mov     eax, [.user_data]
        clc
        pop     edx ecx
        return

.error:
        DebugMsg 'FreshLib: Error find context.'
        mov      edx, [ebp+4]
        OutputRegister regEDX, 16

        xor      eax, eax
        pop      edx ecx
        return
endp




;_________________________________________________________________________________________



proc _SetWindowStruct, .hwin, .value
begin
        push    eax ecx edx
        cinvoke XSaveContext, [hApplicationDisplay], [.hwin], win_structure_context, [.value]
        pop     edx ecx eax
        return
endp






<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/Main.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Main procedure of GUI application library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Organize the main message/event loop needed by every GUI engine.
;         This file contains only OS independent part and includes OS dependent files.
;_________________________________________________________________________________________
module "Main library"

uglobal
  if used pApplication
    pApplication dd ?
  end if
endg


proc Run
begin
.mainloop:
        stdcall ProcessSystemEvents
        jc      .terminate

        mov     eax, [pApplication]
        test    eax, eax
        jz      .eventok

        cmp     [eax+TApplication.OnIdle], 0
        je      .eventok

        pushad
        stdcall [eax+TApplication.OnIdle], eax
        popad

.eventok:
        stdcall WaitForSystemEvent
        jmp     .mainloop

.terminate:
        return
endp




proc ShowModal, .pForm, .pParent
.prev dd ?
begin
        push    ecx edx
        mov     ecx, [.pParent]
        mov     edx, [.pForm]

        jecxz   @f
        stdcall _SetModalTowards, [edx+TForm.handle], [ecx+TWindow.handle]
@@:
        stdcall Set, edx, TForm.Visible, TRUE

        jecxz   @f
        stdcall _EnableWindow, [ecx+TWindow.handle], FALSE
@@:

        mov     [edx+TForm.ModalResult], 0

        stdcall Get, edx, TForm.OnClose
        mov     [.prev], eax
        stdcall Set, edx, TForm.OnClose, __ModalOnClose

.modal_loop:
        stdcall ProcessSystemEvents
        jc      .exit_modal

        cmp     [edx+TForm.ModalResult], 0
        jne     .exit_modal

        stdcall Get, edx, TWindow.Visible
        test    eax, eax
        jz      .exit_modal

.vis_ok:
        stdcall WaitForSystemEvent
        jmp     .modal_loop

.exit_modal:
        jecxz   @f
        stdcall _EnableWindow, [ecx+TWindow.handle], TRUE
@@:

        stdcall Set, edx, TForm.OnClose, [.prev]
        stdcall Set, edx, TForm.Visible, FALSE

        jecxz   @f
        mov     ecx, [ecx+TWindow.handle]
@@:
        stdcall _FinalizeModal, [edx+TForm.handle], ecx

        mov     eax, [edx+TForm.ModalResult]
        pop     edx ecx
        return
endp


; prevent destroy of the form from the close button or Alt+F4
proc __ModalOnClose, .self, .reason
begin
        push    eax
        mov     eax, [.self]
        mov     [eax+TForm.ModalResult], mrCancel
        stc
        pop     eax
        return
endp





include '%TargetOS%/Main.asm'

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































Deleted freshlib/gui/ObjTemplates.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Objects template engine
;
;  Target OS: Any
;
;  Dependencies: objects.asm
;
;  Notes:
;_________________________________________________________________________________________
module "Templates library"

tfChild  = 0
tfParent = 1
tfEnd    = 2


struct TObjTemplate
  .flags     dd  ?         ; tfParent; tfEnd
  .class     dd  ?
  .ptrVar    dd  ?         ; can be NULL
  .paramsize dd  ?
  .params:
ends


macro ObjTemplate  flags, class, name, [id, param] {
common
local ..paramsize, ..prms
      dd  flags
      dd  C#class
      dd  name
      dd  ..paramsize
..prms:
forward
local ..value
      dd  T#class#.#id
      dd  ..value
common
      dd  -1
forward
  if param eqtype 2
    ..value = param
  else
    ..value db param, 0
  end if
common
  name dd ?
  ..paramsize = $ - ..prms
}


; returns the last created window in ebx.

proc CreateFromTemplate, .ptrTemplate, .parent
begin
        push    esi

        mov     esi, [.ptrTemplate]
        stdcall _DoCreateFromTemplate, [.parent]

        pop     esi
        return
endp


proc _DoCreateFromTemplate, .parent
begin
        push    eax ecx edx

.createloop:
        stdcall Create, [esi+TObjTemplate.class]
        execute [.parent], TObject.AddChild, ebx

        lea     ecx, [esi+TObjTemplate.params]

.paramloop:
        cmp     dword [ecx], -1
        je      .paramsok

        push    ebx ecx edx esi edi
        stdcall Set, ebx, [ecx], [ecx+4]
        pop     edi esi edx ecx ebx
        add     ecx, 8
        jmp     .paramloop

.paramsok:
        mov     eax, [esi+TObjTemplate.ptrVar]
        test    eax, eax
        jz      .oncreate

        mov     [ebx+TObject.ptrVar], eax       ; back link to the object instance variable.
        mov     [eax], ebx      ; returned pointer/handle to the object.

.oncreate:
        cmp     [ebx+TObject.OnCreate], 0
        je      .gonext

; execute user OnCreate event.
        pushad
        stdcall [ebx+TObject.OnCreate], ebx
        popad

.gonext:
        mov     edx, [esi+TObjTemplate.flags]

        mov     eax, sizeof.TObjTemplate
        add     eax, [esi+TObjTemplate.paramsize]
        add     esi, eax

        test    edx, tfParent
        jz      .childrenok

        push    ebx
        stdcall _DoCreateFromTemplate, ebx
        pop     ebx

.childrenok:
        test    edx, tfEnd
        jz      .createloop

.exit:
        pop     edx ecx eax
        return
endp


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































Deleted freshlib/gui/TAction.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Actions management library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: "Action" is set of executable code, combined with user interface attributes -
;         caption, accelerator keys, enable/disable status flag etc.
;         Different UI elements, such as buttons, menu items etc. can be attached to
;         the action object and to use its attributes. When the programmer changes
;         something in the action, all UI elements are updated automatically.
;_________________________________________________________________________________________

struc TAction caption, hint, icon, FastKey, enabled, OnExecute, OnIdle {
common
  .Text      dd  caption    ; handle or pointer to the caption string.
  .Hint      dd  hint       ; handle or pointer to the Hint text.
  .icon      dd  icon       ; pointer to TImage
  .FastKey   dd  FastKey    ; pointer to keyboard accelerator combination.
  .Enabled   dd  enabled    ; if FALSE, the action is not active.
  .OnExecute dd  OnExecute  ; pointer to procedure to be executed on activation of the action.
  .OnIdle    dd  OnIdle     ; pointer to procedure that to be executed once, when there is no other events in the queue.
}

virtual at 0
  TAction TAction ?, ?, ?, ?, ?, ?, ?
end virtual


struc TFastKey flags, key, action {
  .flags  dd flags
  .key    dd key
  .action dd action
}
virtual at 0
  TFastKey TFastKey ?, ?, ?
end virtual


struct TActionList
  .count dd ?
  .accelerators dd ?
  .actions:
ends



macro ActionList name, [actname, caption, hint, icon, FastKey, OnExecute, OnIdle] {
common
  local i, count, acclist
  i = 0
  label name dword
  .count dd count
  .accelerators dd acclist
forward
  local .accitem, txtlbl, hintlbl

  txtlbl text caption
  hintlbl text hint

  actname TAction txtlbl, hintlbl, icon, accitem, 1, OnExecute, OnIdle

  i = i + 1
common
  count = i
  label acclist dword

forward
  if FastKey eq NONE
    accitem = 0
  else
    .accitem TFastKey FastKey, name#actname
  end if
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































Deleted freshlib/gui/TApplication.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TApplication object class.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: TApplication by the idea is the base of GUI application, but the implementation
;         somehow need fixing...
;_________________________________________________________________________________________
module "TApplication library"

ObjectClass Application,        \
    Object,                     \
    TApplication.Create,        \
    0,                          \
    TApplication.Get,           \
    TApplication.Set,           \
    0,                          \
    TApplication.SysEventHandler



; The root object in the application.
; every other object will be child on the TApplication.MainWindow.
; only one instance of TApplication should be created.
;
object TApplication, TObject
  .MainWindow   dd ?    ; pointer to a variable that contains pointer to the main window of the application. When this variable becomes 0 the application terminates.
  .Accelerators dd ?    ; table of application wide hot keys.
  .OnIdle       dd ?    ; user event handler for idle state.
endobj


include '%TargetOS%/TApplication.asm'


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































Deleted freshlib/gui/TButton.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TButton object class
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Represents GUI button.
;_________________________________________________________________________________________
module "TButton library"

ObjectClass Button,                     \
            Window,                     \
            0,                          \
            0,                          \
            TButton.Get,                \
            TButton.Set,                \
            0,                          \
            TButton.SysEventHandler


; Button states for the field TButton.state
btnNormal    = 0
btnPressed   = 1
btnPointed   = 2
btnChecked   = 3




object TButton, TWindow
  .state      dd ?
  .Ficon      dd ?
  .FiconAlign dd ?
  .Ftextalign dd ?

  .ModalResult dd ?
  .OnClick dd ?

  param .TextAlign
  param .Icon
  param .IconPosition
endobj



proc TButton.Get, .obj, .paramID
begin
        mov     eax, [.obj]

        stdcall IsObject, eax, CButton
        jc      .exit

        cmp     [.paramID], TButton.TextAlign
        je      .gettextalign

        cmp     [.paramID], TButton.IconPosition
        je      .geticonposition

        cmp     [.paramID], TButton.Icon
        je      .geticon

        stc
.exit:
        return

.geticonposition:
        mov     eax, [eax+TButton.FiconAlign]
        clc
        return

.geticon:
        mov     eax, [eax+TButton.Ficon]
        clc
        return

.gettextalign:
        mov     eax, [eax+TButton.Ftextalign]
        clc
        return
endp




proc TButton.Set, .obj, .paramID, .value
begin
        push    eax

        mov     eax, [.obj]
        stdcall IsObject, eax, CButton
        jc      .exit

        cmp     [.paramID], TButton.TextAlign
        je      .settextalign

        cmp     [.paramID], TButton.Icon
        je      .seticon

        cmp     [.paramID], TButton.IconPosition
        je      .seticonposition

        stc
.exit:
        pop     eax
        return

.refresh:
        execute [.obj], TWindow.Refresh
        clc
        pop     eax
        return

.seticonposition:
        push    [.value]
        pop     [eax+TButton.FiconAlign]
        jmp     .refresh

.seticon:
        push    [.value]
        pop     [eax+TButton.Ficon]
        jmp     .refresh

.seticonalign:
        push    [.value]
        pop     [eax+TButton.FiconAlign]
        jmp     .refresh

.settextalign:
        push    [.value]
        pop     [eax+TButton.Ftextalign]
        jmp     .refresh
endp



proc TButton.SysEventHandler, .pObj, .pEvent
begin
        push    eax ebx ecx edx esi edi

        mov     esi, [.pObj]
        mov     ebx, [.pEvent]
        mov     eax, [ebx+TSysEvent.event]
        cmp     eax, sePaint
        je      .onpaint

        cmp     eax, seMouseEnter
        je      .enter
        cmp     eax, seMouseLeave
        je      .leave

        cmp     eax, seMouseBtnPress
        je      .pressed
        cmp     eax, seMouseBtnRelease
        je      .released

.finish:
        stc
        pop     edi esi edx ecx ebx eax
        return

.pressed:
        mov     [esi+TButton.state], btnPressed
        execute esi, TWindow.Refresh
        jmp     .finish

.released:
;        test    [ebx+TMouseButtonEvent.kbdStatus], maskBtnLeft or maskBtnMiddle or maskBtnRight
;        jnz     .finish

        cmp     [esi+TButton.state], btnPressed
        jne     .finish

        mov     [esi+TButton.state], btnPointed
        execute esi, TButton.Refresh

        cmp     [esi+TButton.ModalResult], mrNone
        je      @f

        stdcall Get, esi, TButton.Parent
        stdcall IsObject, eax, CForm
        jc      @f

        push    [esi+TButton.ModalResult]
        pop     [eax+TForm.ModalResult]

@@:
        cmp     [esi+TButton.OnClick], 0
        je      .finish

        pushad
        stdcall [esi+TButton.OnClick], esi, [ebx+TMouseButtonEvent.Button]
        popad
        jmp     .finish

.enter:
        mov     [esi+TButton.state], btnPointed
        execute esi, TButton.Refresh
        jmp     .finish

.leave:
        mov     [esi+TButton.state], btnNormal
        execute esi, TButton.Refresh
        jmp     .finish

; PAINT event is very important.

.onpaint:
        mov     edx, bxFlat
        mov     edi, [clButtonBk]       ; background
        mov     ecx, [clButtonTxt]      ; text

        cmp     [esi+TButton.state], btnNormal
        je      .drawit

        mov     edx, bxRaised
        mov     edi, [clButtonHotBk]
        mov     ecx, [clButtonHotTxt]

        cmp     [esi+TButton.state], btnPointed
        je      .drawit

        mov     edx, bxSunken
        mov     edi, [clButtonBk]
        mov     ecx, [clButtonHotTxt]

        cmp     [esi+TButton.state], btnPressed
        je      .drawit

        mov     edx, bxFlat

.drawit:
locals
 .bounds TBounds
 .clTxt dd ?
endl
        mov     [.clTxt], ecx

        mov     ecx, [esi+TButton._width]
        mov     eax, [esi+TButton._height]
        mov     [.bounds.x], 0
        mov     [.bounds.y], 0
        mov     [.bounds.width], ecx
        mov     [.bounds.height], eax
        lea     eax, [.bounds]
        stdcall [DrawBox], [ebx+TPaintEvent.context], eax, edi, edx

; first draw the icon and then resize bounds for the text.
        mov     edi, [esi+TButton.Ficon]
        test    edi, edi
        jz      .draw_text

        cmp     [esi+TButton.FiconAlign], AlignLeft
        jne     @f

; align left
        mov     eax, [.bounds.x]
        mov     ecx, [.bounds.height]
        add     eax, 2
        sub     ecx, [edi+TImage.height]
        sar     ecx, 1
        add     ecx, [.bounds.y]

        mov     edx, [edi+TImage.width]
        add     edx, 4
        add     [.bounds.x], edx
        sub     [.bounds.width], edx
        jmp     .draw_icon

@@:
        cmp     [esi+TButton.FiconAlign], AlignRight
        jne     @f

; align right
        mov     edx, [edi+TImage.width]

        mov     eax, [.bounds.x]
        add     eax, [.bounds.width]
        sub     eax, edx
        sub     eax, 2
        sub     [.bounds.width], edx
        sub     [.bounds.width], 4

        mov     ecx, [.bounds.height]
        sub     ecx, [edi+TImage.height]
        sar     ecx, 1
        add     ecx, [.bounds.y]
        jmp     .draw_icon

@@:
        cmp     [esi+TButton.FiconAlign], AlignTop
        jne     @f

; align top
        mov     ecx, [.bounds.y]
        add     ecx, 2
        mov     eax, [.bounds.width]
        sub     eax, [edi+TImage.width]
        sar     eax, 1
        add     eax, [.bounds.x]

        mov     edx, [edi+TImage.height]
        add     edx, 4
        add     [.bounds.y], edx
        sub     [.bounds.height], edx
        jmp     .draw_icon

@@:
        cmp     [esi+TButton.FiconAlign], AlignBottom
        jne     .draw_text

; align bottom
        mov     edx, [edi+TImage.height]

        mov     ecx, [.bounds.y]
        add     ecx, [.bounds.height]
        sub     ecx, edx
        sub     ecx, 2
        sub     [.bounds.height], edx
        sub     [.bounds.height], 4

        mov     eax, [.bounds.width]
        sub     eax, [edi+TImage.width]
        sar     eax, 1
        add     eax, [.bounds.x]

.draw_icon:
        stdcall DrawImage, [ebx+TPaintEvent.context], [esi+TButton.Ficon], eax, ecx

.draw_text:
        stdcall Get, esi, TWindow.Caption
        test    eax, eax
        jz      .finish

        push    eax eax
        stdcall StrLen, eax
        mov     ecx, eax
        pop     eax
        lea     edx, [.bounds]
        stdcall DrawTextBox, [ebx+TPaintEvent.context], eax, edx, [esi+TButton.Ftextalign], 0, [.clTxt]
        stdcall StrDel ; from the stack
        jmp     .finish
endp


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/TEdit.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TEdit object class
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Represents single line edit control.
;_________________________________________________________________________________________
module "TEdit library"

ObjectClass Edit,                       \
            Window,                     \
            TEdit.Create,               \
            TEdit.Destroy,              \
            TEdit.Get,                  \
            TEdit.Set,                  \
            0,                          \
            TEdit.SysEventHandler


object TEdit, TWindow
  ._Text  dd ?
  ._Len   dd ?  ; the length of the string in characters. (UTF-8)
  ._Start dd ?  ; Where the string begins to be displayed in the edit window.
  ._Pos   dd ?  ; Position of the caret in the string.
  ._Sel   dd ?  ; Position of the selction in the string.

  ._MarginLeft dd ?
  ._MarginRight dd ?

  ._Focused dd ? ; flag

  param .Text
endobj


proc TEdit.Create, .obj
begin
        push    ecx eax
        stdcall StrNew
        mov     ecx, [.obj]
        mov     [ecx+TEdit._Text], eax

; for test. Normal value is 0 for these fields.
;        mov     [ecx+TEdit._MarginLeft], 8
;        mov     [ecx+TEdit._MarginRight], 16

        mov     [ecx+TEdit._cursor], mcText

        pop     eax ecx
        clc
        return
endp


proc TEdit.Destroy, .obj
begin
        mov     eax, [.obj]
        stdcall StrDel, [eax+TEdit._Text]
        return
endp


proc TEdit.Get, .obj, .paramID
begin
        stdcall IsObject, [.obj], CEdit
        jc      .exit

        cmp     [.paramID], TEdit.Text
        je      .gettext

        stc
.exit:
        return

.gettext:
        mov     eax, [.obj]
        stdcall StrDup, [eax+TEdit._Text]
        clc
        return
endp




proc TEdit.Set, .obj, .paramID, .value
begin
        push    esi

        mov     esi, [.obj]

        cmp     [.paramID], TEdit.Text
        je      .settext

        stc
        pop     esi
        return

.settext:
        push    eax
        mov     [esi+TEdit._Start], 0
        mov     [esi+TEdit._Pos], 0
        mov     [esi+TEdit._Sel], 0

        lea     eax, [esi+TEdit._Text]
        stdcall SetString, eax, [.value]
        stdcall StrLenUtf8, [esi+TEdit._Text], -1
        mov     [esi+TEdit._Len], eax

        execute esi, TEdit.Refresh
        clc
        pop     eax
        pop     esi
        return
endp






proc TEdit.SysEventHandler, .pObj, .pEvent
.changes dd ?
.prevpos dd ?
.PosChanged  = 1
.NeedRefresh = 2
.ShowCaret   = 4
begin
        push    eax ebx ecx edx esi edi

        mov     [.changes], 0
        mov     esi, [.pObj]
        mov     ebx, [.pEvent]
        mov     eax, [ebx+TSysEvent.event]

        cmp     eax, sePaint
        je      .onpaint

        cmp     eax, seKbdKeyPress
        je      .keypress

        cmp     eax, seFocusIn
        je      .focusin

        cmp     eax, seFocusOut
        je      .focusout

.finish:
        stc
        pop     edi esi edx ecx ebx eax
        return

;............................................................................................

.focusin:
        mov     [esi+TEdit._Focused], TRUE
        stdcall CaretAttach, esi
        or      [.changes], .PosChanged or .ShowCaret
        jmp     .endmove

.focusout:
        stdcall CaretShow, FALSE
        mov     [esi+TEdit._Focused], FALSE
        or      [.changes], .PosChanged
        jmp     .endmove

;............................................................................................

.keypress:
;        mov     eax, [ebx+TKeyboardEvent.kbdStatus]
;        OutputRegister regEAX, 16

        mov     eax, [esi+TEdit._Pos]
        mov     [.prevpos], eax

        mov     eax, [ebx+TKeyboardEvent.key]
        test    eax, eax
        jz      .no_char

        cmp     eax, $20
        jb      .no_char

        cmp     eax, $7f
        je      .no_char

        push    eax

        call    .ClearSelection

        stdcall StrPtr, [esi+TEdit._Text]
        mov     ecx, eax
        stdcall StrOffsUtf8, eax, [esi+TEdit._Pos]
        sub     ecx, eax
        neg     ecx

        pop     eax
        stdcall StrCharInsert, [esi+TEdit._Text], eax, ecx
        inc     [esi+TEdit._Len]

        mov     [ebx+TKeyboardEvent.kbdStatus], 0
        or      [.changes], .NeedRefresh
        jmp     .right

.no_char:
        mov     eax, [ebx+TKeyboardEvent.scancode]

        cmp     eax, keyLeftNumpad
        je      .left
        cmp     eax, keyLeft
        je      .left

        cmp     eax, keyRightNumpad
        je      .right
        cmp     eax, keyRight
        je      .right

        cmp     eax, keyHomeNumpad
        je      .home
        cmp     eax, keyHome
        je      .home

        cmp     eax, keyEndNumpad
        je      .end
        cmp     eax, keyEnd
        je      .end

        cmp     eax, keyDelNumpad
        je      .del
        cmp     eax, keyDelete
        je      .del

        cmp     eax, keyBackSpace
        je      .backdel

        jmp     .finish

.left:
        cmp     [esi+TEdit._Pos], 0
        jle     .endmove

        or      [.changes], .PosChanged
        dec     [esi+TEdit._Pos]
        jmp     .endmove

.right:
        mov     eax, [esi+TEdit._Pos]
        cmp     eax, [esi+TEdit._Len]
        jae     .finish

        or      [.changes], .PosChanged
        inc     [esi+TEdit._Pos]
        jmp     .endmove

.home:
        mov     [esi+TEdit._Pos], 0
        mov     [esi+TEdit._Start], 0
        mov     [.changes], .PosChanged or .NeedRefresh
        jmp     .endmove

.end:
        mov     eax, [esi+TEdit._Len]
        mov     [esi+TEdit._Pos], eax
        or      [.changes], .PosChanged
        jmp     .endmove

.backdel:
        call    .ClearSelection
        jnc     .endmove

        cmp     [esi+TEdit._Pos], 0
        jle     .endmove

        or      [.changes], .PosChanged
        dec     [esi+TEdit._Pos]

.del:
        call    .ClearSelection
        jnc     .endmove

        mov     eax, [esi+TEdit._Pos]
        cmp     eax, [esi+TEdit._Len]
        jae     .finish                ; can't delete after the end of string.

        stdcall StrPtr, [esi+TEdit._Text]

        mov     ecx, eax
        stdcall StrOffsUtf8, eax, [esi+TEdit._Pos]
        sub     eax, ecx

        stdcall StrSplit, [esi+TEdit._Text], eax
        mov     ebx, eax

        stdcall StrPtr, ebx
        stdcall DecodeUtf8, [eax]

        stdcall StrCopyPart, ebx, ebx, edx, -1
        stdcall StrCat, [esi+TEdit._Text], ebx
        stdcall StrDel, ebx

        dec     [esi+TEdit._Len]
        or      [.changes], .NeedRefresh

.endmove:
        mov     ebx, [.pEvent]
        mov     eax, [esi+TEdit._Pos]
        cmp     [ebx+TSysEvent.event], seKbdKeyPress
        jne     .setselection

        test    [ebx+TKeyboardEvent.kbdStatus], maskShift
        jnz     .refresh

.setselection:
        mov     ecx, [.prevpos]
        cmp     ecx, [esi+TEdit._Sel]
        je      @f
        or      [.changes], .NeedRefresh
@@:
        mov     [esi+TEdit._Sel], eax

        test    [.changes], .NeedRefresh
        jz      .caretmove

.refresh:
        execute [.pObj], TEdit.Refresh

.caretmove:
        cmp     [esi+TEdit._Focused], 0
        je      .finish

        test    [.changes], .PosChanged
        jz      .showcaret

        mov     eax, [esi+TEdit._Pos]
        cmp     eax, [esi+TEdit._Start]
        jl      .scroll

        stdcall StrPtr, [esi+TEdit._Text]
        mov     edi, eax

        stdcall StrOffsUtf8, edi, [esi+TEdit._Pos]
        mov     ecx, eax

        stdcall StrOffsUtf8, edi, [esi+TEdit._Start]
        sub     ecx, eax                           ; offset to char under cursor.
        jns     .leftok

.scroll:
        mov     eax, [esi+TEdit._Start]
        sub     eax, 8
        test    eax, eax
        jns         @f
        xor     eax, eax
@@:
        mov     [esi+TEdit._Start], eax
        mov     [.changes], .PosChanged or .NeedRefresh
        jmp     .endmove

.leftok:
        mov     edi, eax                           ; pointer to start of the text.

        stdcall AllocateContext, [esi+TEdit.handle]
        push    eax

        stdcall GetTextBounds, eax, edi, ecx, 0
        lea     ecx, [eax+2]       ; x coordinate of the cursor.
        add     ecx, [esi+TEdit._MarginLeft]

        stdcall ReleaseContext ; from the stack.

        mov     eax, [esi+TEdit._width]
        sub     eax, [esi+TEdit._MarginRight]
        sub     eax, ecx
        cmp     eax, 2
        jge     .caretok

        mov     eax, [esi+TEdit._Start]
        add     eax, 8
        cmp     eax, [esi+TEdit._Len]
        jle     @f
        mov     eax, [esi+TEdit._Len]
@@:
        mov     [esi+TEdit._Start], eax

        mov     [.changes], .PosChanged or .NeedRefresh
        jmp     .endmove


.caretok:
        mov     edx, [esi+TEdit._height]
        sub     edx, 4

        stdcall CaretChange, ecx, 2, 1, edx

.showcaret:
        test    [.changes], .ShowCaret
        jz      .finish

        stdcall CaretShow, TRUE
        jmp     .finish

;............................................................................................

.onpaint:
locals
 .bounds TBounds
 .selbeg dd ?
 .selend dd ?
 .ypos   dd ?
endl
        mov     eax, [esi+TEdit._Pos]
        mov     ecx, [esi+TEdit._Sel]
        cmp     eax,ecx
        jle     @f
        xchg    eax, ecx
@@:
        mov     [.selbeg], eax
        mov     [.selend], ecx

        mov     ecx, [esi+TEdit._width]
        mov     eax, [esi+TEdit._height]

        mov     [.bounds.x], 0
        mov     [.bounds.y], 0
        mov     [.bounds.width], ecx
        mov     [.bounds.height], eax

        lea     eax, [.bounds]
        stdcall [DrawBox], [ebx+TPaintEvent.context], eax, [clEditBk], bxSunken

        mov     eax, [esi+TEdit._MarginLeft]
        mov     ecx, [esi+TEdit._MarginRight]
        add     [.bounds.x], eax
        sub     [.bounds.width], eax
        sub     [.bounds.width], ecx
        cmp     [.bounds.width], 0
        jle     .finish

        mov     ecx, [esi+TEdit._Start]

        stdcall StrOffsUtf8, [esi+TEdit._Text], ecx
        mov     edi, eax

        mov     eax, [.bounds.y]
        add     eax, [.bounds.height]
        sub     eax, 4
        mov     [.ypos], eax   ; y position of the characters.

.drawloop:
        stdcall DecodeUtf8, [edi]
        jc      .finish

        test    eax, eax
        jz      .eraseremaining

        mov     eax, [clEditTxt]
        cmp     ecx, [.selbeg]
        jl      .colorok
        cmp     ecx, [.selend]
        jge     .colorok
        mov     eax, [clEditSelTxt]
.colorok:
        push    eax  0 [.ypos] [.bounds.x] edx edi

        push    0 edx edi
        add     edi, edx
        stdcall GetTextBounds, [ebx+TPaintEvent.context] ; remaining from the stack

        sub     [.bounds.width], eax
        js      .nodraw

        cmp     ecx, [.selbeg]
        jl      .drawtxt
        cmp     ecx, [.selend]
        jge     .drawtxt

        mov     esi, [.ypos]
        sub     esi, edx
        add     edx, 2
        stdcall DrawFillRect, [ebx+TPaintEvent.context], [.bounds.x], [.bounds.y], eax, [.bounds.height], [clEditSel]

.drawtxt:
        add     [.bounds.x], eax
        stdcall DrawString, [ebx+TPaintEvent.context] ; remaining from the stack

        inc     ecx
        jmp     .drawloop

.nodraw:
        add     esp, 24 ; 6*4
        jmp     .finish

.eraseremaining:
        stdcall DrawFillRect, [ebx+TPaintEvent.context], [.bounds.x], [.bounds.y], [.bounds.width], [.bounds.height], [clEditBk]
        jmp     .finish

.ClearSelection:
        mov     eax, [esi+TEdit._Pos]
        mov     ecx, [esi+TEdit._Sel]
        cmp     eax, [esi+TEdit._Sel]
        je      .noselection            ; there is no selection.
        jg      @f
        xchg    eax, ecx        ; eax=end_selection; ecx=beg_selection
@@:
        add     [esi+TEdit._Len], ecx
        sub     [esi+TEdit._Len], eax
        mov     [esi+TEdit._Pos], ecx
        mov     [esi+TEdit._Sel], ecx

        push    -1
        stdcall StrOffsUtf8, [esi+TEdit._Text], eax
        push    eax
        stdcall StrOffsUtf8, [esi+TEdit._Text], ecx
        push    eax
        stdcall StrPtr, [esi+TEdit._Text]
        sub     [esp], eax     ; begin of the selection
        sub     [esp+4], eax
        mov     eax, [esp]
        sub     [esp+4], eax   ; length of the selection

        stdcall StrSplit, [esi+TEdit._Text]  ; position from the stack
        mov     ecx, eax
        stdcall StrCopyPart, ecx, ecx   ; pos and length from the stack.
        stdcall StrCat, [esi+TEdit._Text], ecx
        stdcall StrDel, ecx

        or      [.changes], .PosChanged or .NeedRefresh
        clc
        retn

.noselection:
        stc
        retn
endp


endmodule


;        stdcall DecodeUtf8, [edi]
;        jc      .finish
;
;        test    eax, eax
;        jz      .eraseremaining
;
;        mov     eax, [clEditTxt]
;        mov     esi, [clEditBk]
;        cmp     ecx, [.selbeg]
;        jl      .colorok
;        cmp     ecx, [.selend]
;        jge     .colorok
;        mov     eax, [clEditSelTxt]
;        mov     esi, [clEditSel]
;.colorok:
;        push    eax  0 [.ypos] [.bounds.x] edx edi
;
;        push    0 edx edi
;        add     edi, edx
;        stdcall GetTextBounds, [ebx+TPaintEvent.context] ; remaining from the stack
;
;        add     eax, 2
;        stdcall DrawFillRect, [ebx+TPaintEvent.context], [.bounds.x], [.bounds.y], eax, [.bounds.height], esi
;        sub     eax, 2
;
;        add     [.bounds.x], eax
;        sub     [.bounds.width], eax
;        jc      .nodraw
;
;        stdcall DrawString, [ebx+TPaintEvent.context] ; remaining from the stack
;
;        inc     ecx
;        jmp     .drawloop
;
;.nodraw:
;        add     esp, 24 ; 6*4
;        jmp     .finish
;
;.eraseremaining:
;        stdcall DrawFillRect, [ebx+TPaintEvent.context], [.bounds.x], [.bounds.y], [.bounds.width], [.bounds.height], [clEditBk]
;        jmp     .finish
;
;endp
;
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/TForm.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TForm object class
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Represents form window that to serve as parent window for other controls.
;_________________________________________________________________________________________
module "TForm library"


ObjectClass Form,                       \
            Window,                     \
            TForm.Create,               \
            0,                          \
            TForm.Get,                  \
            TForm.Set,                  \
            0,                          \
            TForm.SysEventHandler


mrNone   = 0
mrOK     = 1
mrCancel = 2
mrAbort  = 3
mrRetry  = 4
mrIgnore = 5
mrYes    = 6
mrNo     = 7
mrMaybe  = 8


object TForm, TWindow

  .ModalResult  dd ?

  .OnClose dd ?         ; On close window event handler.

  param .type
endobj


proc TForm.Create, .obj
begin
        stdcall Set, [.obj], TWindow.borderKind, borderFull
        return
endp


; OS independent code.

proc TForm.Get, .obj, .paramID
begin
        stc
        return
endp



proc TForm.Set, .obj, .paramID, .value
begin
        stc
        return
endp



proc TForm.SysEventHandler, .pObj, .pEvent
begin
        push    ebx esi
        mov     ebx, [.pEvent]
        cmp     [ebx+TSysEvent.event], sePaint
        je      .onpaint

        cmp     [ebx+TSysEvent.event], seCloseRequest
        je      .close_request

.finish:
        stc
        pop     esi ebx
        return

.onpaint:
        mov     esi, [.pObj]

        mov     eax, [esi+TWindow._width]
        mov     ecx, [esi+TWindow._height]

        stdcall DrawFillRect, [ebx+TPaintEvent.context], 0, 0, eax, ecx, [clDialogBk]
        jmp     .finish

.close_request:
;        DebugMsg "Close request"
        cmp     [esi+TForm.OnClose], 0
        je      @f

        stdcall [esi+TForm.OnClose], esi, [ebx+TCloseEvent.reason]      ; if OnClose return CF=0 the form is destroyed. Else, the form is not destroyed.
        jc      .finish

@@:
        stdcall Set, [.pObj], TForm.Visible, FALSE
        stdcall Destroy, [.pObj]

        DebugMsg "Form destroyed"

.destroyed:
        clc
        pop     esi ebx
        return
endp


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































Deleted freshlib/gui/TImageLabel.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TImageLabel object class
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Represents GUI picture or image.
;_________________________________________________________________________________________
module "TImageLabel library"

ObjectClass ImageLabel,                 \
            Window,                     \
            0,                          \
            0,                          \
            TImageLabel.Get,            \
            TImageLabel.Set,                \
            0,                          \
            TImageLabel.SysEventHandler

iaLeft = 0
iaRight = 1
iaCenter = 2
iaStretchH = 3

iaTop = $0
iaBottom = $100
iaMiddle = $200
iaStrechV = $300

object TImageLabel, TWindow
  .FImageAlign dd ?
  .FImage      dd ?
  .FMask       dd ?
  .FBackground dd ?

  param .ImageAlign       ; image align flags.
  param .Image            ; TImage object
  param .Mask
endobj



proc TImageLabel.Get, .obj, .paramID
begin
        mov     eax, [.obj]

        stdcall IsObject, eax, CImageLabel
        jc      .exit

        cmp     [.paramID], TImageLabel.ImageAlign
        je      .getimagealign

        cmp     [.paramID], TImageLabel.Image
        je      .getimage

        cmp     [.paramID], TImageLabel.Mask
        je      .getmask

        stc
.exit:
        return

.getimagealign:
        mov     eax, [eax+TImageLabel.FImageAlign]
        clc
        return

.getimage:
        mov     eax, [eax+TImageLabel.FImage]
        clc
        return

.getmask:
        mov     eax, [eax+TImageLabel.FMask]
        clc
        return
endp



proc TImageLabel.Set, .obj, .paramID, .value
begin
        push    eax

        mov     eax, [.obj]
        stdcall IsObject, eax, CImageLabel
        jc      .exit

        cmp     [.paramID], TImageLabel.ImageAlign
        je      .setimagealign

        cmp     [.paramID], TImageLabel.Image
        je      .setimage

        cmp     [.paramID], TImageLabel.Mask
        je      .setmask

        stc
.exit:
        pop     eax
        return

.setimage:
        push    [.value]
        pop     [eax+TImageLabel.FImage]
        jmp     .refresh

.setmask:
        push    [.value]
        pop     [eax+TImageLabel.FMask]
        jmp     .refresh

.setimagealign:
        push    [.value]
        pop     [eax+TImageLabel.FImageAlign]

.refresh:
        execute [.obj], TWindow.Refresh
        clc
        pop     eax
        return
endp



proc TImageLabel.SysEventHandler, .pObj, .pEvent
begin
        push    eax ebx ecx edx esi

        mov     esi, [.pObj]
        mov     ebx, [.pEvent]
        mov     eax, [ebx+TSysEvent.event]

        cmp     eax, sePaint
        je      .onpaint

.finish:
        stc
        pop     esi edx ecx ebx eax
        return

.onpaint:
  locals
   .bounds TBounds
  endl
        mov     ecx, [esi+TImageLabel._width]
        mov     eax, [esi+TImageLabel._height]
        mov     [.bounds.x], 0
        mov     [.bounds.y], 0
        mov     [.bounds.width], ecx
        mov     [.bounds.height], eax

        stdcall SetDrawMode, [ebx+TPaintEvent.context], cmCopy
        stdcall DrawFillRect, [ebx+TPaintEvent.context], [.bounds.x], [.bounds.y], [.bounds.width], [.bounds.height], [clDialogBk]

        mov     eax, [esi+TImageLabel.FImage]
        mov     ecx, [.bounds.width]
        mov     edx, [.bounds.height]
        sub     ecx, [eax+TImage.width]
        sub     edx, [eax+TImage.height]

        mov     eax, [esi+TImageLabel.FImageAlign]

        cmp     al, iaRight
        je      .x_ok
        cmp     al, iaCenter
        je      .x_center
        xor     ecx, ecx
        jmp     .x_ok
.x_center:
        sar     ecx, 1
.x_ok:
        cmp     ah, iaBottom /256
        je      .y_ok
        cmp     ah, iaMiddle / 256
        je      .y_center
        xor     edx, edx
        jmp     .y_ok
.y_center:
        sar     edx, 1
.y_ok:
        stdcall DrawMaskedImage, [ebx+TPaintEvent.context], [esi+TImageLabel.FMask], [esi+TImageLabel.FImage], ecx, edx
        jmp     .finish
endp








endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































Deleted freshlib/gui/TLabel.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TLabel object class
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Not finished.
;_________________________________________________________________________________________
module "TLabel library"

ObjectClass Label,           \
            Window,          \
            0,               \
            0,               \
            TLabel.Get,      \
            TLabel.Set,      \
            0,               \
            TLabel.SysEventHandler


object TLabel, TWindow
  .Ftextalign dd ?

  param .TextAlign        ; text align flags.
  param .Control          ; control that to be activated
endobj



proc TLabel.Get, .obj, .paramID
begin
        mov     eax, [.obj]

        stdcall IsObject, eax, CLabel
        jc      .exit

        cmp     [.paramID], TLabel.TextAlign
        je      .gettextalign

        stc
.exit:
        return

.gettextalign:
        mov     eax, [eax+TLabel.Ftextalign]
        clc
        return
endp



proc TLabel.Set, .obj, .paramID, .value
begin
        push    eax

        mov     eax, [.obj]
        stdcall IsObject, eax, CLabel
        jc      .exit

        cmp     [.paramID], TLabel.TextAlign
        je      .settextalign

        stc
.exit:
        pop     eax
        return

.settextalign:
        push    [.value]
        pop     [eax+TLabel.Ftextalign]

.refresh:
        execute [.obj], TWindow.Refresh
        clc
        pop     eax
        return
endp



proc TLabel.SysEventHandler, .pObj, .pEvent
begin
        push    eax ebx ecx edx esi

        mov     esi, [.pObj]
        mov     ebx, [.pEvent]
        mov     eax, [ebx+TSysEvent.event]

        cmp     eax, sePaint
        je      .onpaint

.finish:
        stc
        pop     esi edx ecx ebx eax
        return

.onpaint:
  locals
   .bounds TBounds
  endl

        mov     ecx, [esi+TLabel._width]
        mov     eax, [esi+TLabel._height]
        mov     [.bounds.x], 0
        mov     [.bounds.y], 0
        mov     [.bounds.width], ecx
        mov     [.bounds.height], eax
        lea     eax, [.bounds]
        stdcall [DrawBox], [ebx+TPaintEvent.context], eax, [clDialogBk], bxNone

        stdcall Get, esi, TWindow.Caption
        test    eax, eax
        jz      .finish

        push    eax eax
        stdcall StrLen, eax
        mov     ecx, eax
        pop     eax
        lea     edx, [.bounds]
        stdcall DrawTextBox, [ebx+TPaintEvent.context], eax, edx, [esi+TLabel.Ftextalign], 0, [clDialogTxt]
        stdcall StrDel ; from the stack
        jmp     .finish
endp







endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































Deleted freshlib/gui/TMenu.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TMenu object class
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Represents main menu or popup menu objects.
;_________________________________________________________________________________________
module "TMenu library"

ObjectClass Menu,         \
            Window,       \
            TMenu.Create, \
            TMenu.Destroy,\
            TMenu.Get,    \
            TMenu.Set,    \
            TMenu.ExecCmd,\
            TMenu.SysEventHandler

; The inherited TWindow.caption serves as a menu item caption in the parent menu.
; The children TMenu objects are reparent to the root, and their pointers are stored in the
; list of TMenuItem elements.
object TMenu, TWindow
  .pForm  dd ?       ; pointer to TForm object. If NULL, the menu is popup menu.
  .pItems dd ?       ;

  method .Show, .parent, .kind
endobj



proc TMenu.Create, .obj
begin
        return
endp


proc TMenu.Destroy, .obj
begin
        return
endp


proc TMenu.Get, .obj, .param
begin
        return
endp


proc TMenu.Set, .obj, .param
begin

        return
endp


proc TMenu.ExecCmd, .obj, .method
begin
        cmp     [.method], TMenu.Show
        je      .show

        stc
        return

; Method show
.show:
virtual at esi
  .parent dd ?
  .kind   dd ?
end virtual

        mov     ebx, [.obj]
; First check item count and set proper size of the menu window.




        return
endp


proc TMenu.SysEventHandler, .obj, .event
begin

        return
endp



endmodule


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































Deleted freshlib/gui/TMenuItem.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TMenuItem object class
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: TMenuItems are the items of the GUI menu objects.
;_________________________________________________________________________________________
module "TMenuItem library"

ObjectClass MenuItem,     \
            Object,       \
            TMenu.Create, \
            TMenu.Destroy,\
            TMenu.Get,    \
            TMenu.Set,    \
            TMenu.ExecCmd,\
            TMenu.SysEventHandler

mikCommand   = 0
mikSubmenu   = 1
mikSeparator = 2


object TMenuItem, TObject
  .parent   dd ?        ; pointer to TMenu object.
  .kind     dd ?        ; mikCommand, mikSubmenu or mikSeparator
  .pAction  dd ?        ; depending on the kind. Pointer to TAction or handle of string with the text.
  .child    dd ?        ; pointer to the child TMenu object

  method Paint, .context, .x, .y, .width, .height
endobj


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































Deleted freshlib/gui/TObject.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TObject object class.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: TObject is the root member of FreshLib objects tree.
;_________________________________________________________________________________________
module "TObject library"

ObjectClass  Object,                    \
             Root,                      \
             0,                         \
             TObject.Destroy,           \
             0,                         \
             0,                         \
             0,                         \
             0


object TObject
  .ptrClass     dd ?    ; pointer to the object class structure.

  .mxAccess     dd ?    ; access mutex. Procedures from objects.asm will use it to ensure thread safety.
  .ptrVar       dd ?    ; pointer to the variable that keep the pointer to the object. This field can be 0. If not, Destroy procedure will set it to 0 on destroy.

  .OnCreate     dd ?    ; user event handlers.
  .OnDestroy    dd ?

  method .AddChild, .objchild    ; this method is not implemented in TObject, but every descendent can implement it's own parent/child system.
endobj



proc TObject.Destroy, .obj
begin
        push    eax
        mov     eax, [.obj]

        cmp     [eax+TObject.OnDestroy], 0
        je      .exit

        pushad
        stdcall [eax+TObject.OnDestroy], eax
        popad

.exit:
        pop     eax
        return
endp



endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































Deleted freshlib/gui/TProgressbar.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TProgressBar object class; Simple progress bar control.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________
module "TProgressbar library"

ObjectClass Progress,                   \
            Window,                     \
            0,                          \
            0,                          \
            TProgress.Get,              \
            TProgress.Set,              \
            TProgress.ExecCmd,          \
            TProgress.SysEventHandler

object TProgress, TWindow
  ._Pos   dd ?
  ._Max   dd ?
  ._Color dd ?

  param .Pos
  param .Max
  param .Color

  method .Step
endobj



proc TProgress.Get, .pobj, .paramID
begin
        push    ecx

        stdcall IsObject, [.pobj], CProgress
        jc      .exit

        mov     eax, [.pobj]
        mov     ecx, [.paramID]

        cmp     ecx, TProgress.Pos
        jb      .exit
        cmp     ecx, TProgress.Color
        ja      .exit

        sub     ecx, TProgress.Pos
        pushd   [eax+TProgress._Pos+4*ecx]
        pop     eax

        clc
        pop     ecx
        return

.exit:
        stc
        pop     ecx
        return
endp



proc TProgress.Set, .pobj, .paramID, .value
begin
        push    eax ecx

        stdcall IsObject, [.pobj], CProgress
        jc      .exit

        mov     eax, [.pobj]
        mov     ecx, [.paramID]

        cmp     ecx, TProgress.Pos
        jb      .exit
        cmp     ecx, TProgress.Color
        ja      .exit

        sub     ecx, TProgress.Pos
        pushd   [.value]
        popd    [eax+TProgress._Pos+4*ecx]

        execute [.pobj], TProgress.Refresh

        clc
        pop     ecx eax
        return

.exit:
        stc
        pop     ecx eax
        return
endp


proc TProgress.SysEventHandler, .pobj, .pEvent
begin
        push    eax ebx ecx esi

        mov     ebx, [.pEvent]
        cmp     [ebx+TSysEvent.event], sePaint
        je      .paint

.finish:
        stc
        pop     esi ecx ebx eax
        return

.paint:
locals
  .bounds TBounds
  .style TLineStyle
endl
        mov     [.bounds.x], 0
        mov     [.bounds.y], 0
        mov     eax, [esi+TProgress._width]
        mov     ecx, [esi+TProgress._height]
        mov     [.bounds.width], eax
        mov     [.bounds.height], ecx

        lea     eax, [.bounds]
        stdcall [DrawBox], [ebx+TPaintEvent.context], eax, 0, bxSunken or bxNoFill

        stdcall DrawRectangle, [ebx+TPaintEvent.context], eax, [clDialogBk]

        inc     [.bounds.x]
        inc     [.bounds.y]
        sub     [.bounds.width], 2
        sub     [.bounds.height], 2

        mov     eax, [esi+TProgress._Pos]
        mov     ecx, [esi+TProgress._Max]
        test    ecx, ecx
        jnz     @f
        inc     ecx
@@:
        cmp     eax, ecx
        jle     @f
        mov     eax, ecx
@@:
        imul    eax, [.bounds.width]
        cdq
        idiv    ecx

        stdcall DrawFillRect, [ebx+TPaintEvent.context], [.bounds.x], [.bounds.y], eax, [.bounds.height], [esi+TProgress._Color]
        sub     [.bounds.width], eax
        inc     eax
        inc     [.bounds.width]
        stdcall DrawFillRect, [ebx+TPaintEvent.context], eax, [.bounds.y], [.bounds.width], [.bounds.height], [clDialogBk]

        jmp     .finish
endp




proc TProgress.ExecCmd, .self, .method
begin
        cmp     [.method], TProgress.Step
        je      .step
        stc
        return

;-------------------------------------------------------------------------
.step:
        push    eax ecx

        mov     eax, [.self]
        mov     ecx, [eax+TProgress._Pos]
        cmp     ecx, [eax+TProgress._Max]
        jge     .exit

        inc     [eax+TProgress._Pos]
        execute eax, TProgress.Refresh

.exit:
        pop     ecx eax
        clc
        return
endp



endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































Deleted freshlib/gui/TScrollWindow.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TScrollWindow object class
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: TScrollWindow is window that may have scrollers to scroll the client area.
;_________________________________________________________________________________________
module "TScrollWindow library"

ObjectClass ScrollWindow,               \
            Window,                     \
            TScrollWindow.Create,       \
            0,                          \
            TScrollWindow.Get,          \
            TScrollWindow.Set,          \
            TScrollWindow.ExecCmd,      \
            TScrollWindow.SysEventHandler


struct TScrollbar
  .Max  dd  ?
  .Page dd  ?
  .Pos  dd  ?

  ._Drag dd ?
ends



object TScrollWindow, TWindow
  ._HScroller TScrollbar
  ._VScroller TScrollbar

  method HScrollSet, .Pos, .Max, .Page   ; only params >=0 are set. If<0 ignored.
  method VScrollSet, .Pos, .Max, .Page
endobj


ScrollBarWidth = 16
MinScrollBarWidth = 12

;_________________________________________________________________________________________

proc TScrollWindow.Create, .pobj
begin
;        push    eax
;        mov     eax, [.pobj]

;        mov     [eax+TScrollWindow._HScroller.Max], 255
;        mov     [eax+TScrollWindow._HScroller.Page], 1
;        mov     [eax+TScrollWindow._HScroller.Pos], 10

;        mov     [eax+TScrollWindow._VScroller.Max], 1000
;        mov     [eax+TScrollWindow._VScroller.Page], 1
;        mov     [eax+TScrollWindow._VScroller.Pos], 450

;        pop     eax
        return
endp



;_________________________________________________________________________________________


proc TScrollWindow.Get, .pobj, .paramID
begin
        stc
        return
endp


;_________________________________________________________________________________________


proc TScrollWindow.Set, .pobj, .paramID, .value
begin

        stc
        return
endp


;_________________________________________________________________________________________


proc TScrollWindow.SysEventHandler, .pobj, .pEvent
  .event TScrollEvent
begin
        push    eax ebx edx esi edi
        mov     esi, [.pobj]
        mov     ecx, [.pEvent]

        cmp     [ecx+TSysEvent.event], sePaint
        je      .paint

        cmp     [ecx+TSysEvent.event], seMouseBtnPress
        je      .btnpress

        cmp     [ecx+TSysEvent.event], seMouseBtnRelease
        je      .btnrelease

        cmp     [ecx+TSysEvent.event], seMouseMove
        je      .mousemove

.continue:
        stc
.finish:
        pop     edi esi edx ebx eax
        return


;.........................................................................................

.paint:
locals
  .recth TBounds
  .rectv TBounds
  .rectx TBounds
endl
        stdcall Get, esi, TScrollWindow.FreeArea
        mov     ebx, eax

        mov     eax, [ebx+TBounds.x]
        mov     edx, [ebx+TBounds.y]
        mov     [.recth.x], eax
        mov     [.rectv.y], edx

        add     eax, [ebx+TBounds.width]
        add     edx, [ebx+TBounds.height]
        mov     [.rectv.x], eax
        mov     [.recth.y], edx

        inc     edx
        inc     eax
        mov     [.rectx.y], edx
        mov     [.rectx.x], eax

        mov     [.recth.height], ScrollBarWidth
        mov     [.rectv.width], ScrollBarWidth
        mov     [.rectx.width], ScrollBarWidth-1
        mov     [.rectx.height], ScrollBarWidth-1

        mov     eax, [ebx+TBounds.width]
        mov     edx, [ebx+TBounds.height]
        inc     eax
        inc     edx
        mov     [.recth.width], eax
        mov     [.rectv.height], edx

        lea     eax, [.rectx]
        stdcall [DrawBox], [ecx+TPaintEvent.context], eax, [clDialogBk], bxNone

        lea     eax, [.recth]
        stdcall [DrawBox], [ecx+TPaintEvent.context], eax, [clScrollBk], bxSunken or bxNoFill

        lea     eax, [.rectv]
        stdcall [DrawBox], [ecx+TPaintEvent.context], eax, [clScrollBk], bxSunken or bxNoFill

        lea     eax, [esi+TScrollWindow._HScroller]
        stdcall _SliderPixels, eax, [.recth.width]

        push    esi
        stdcall DrawFillRect, [ecx+TPaintEvent.context], [.recth.x], [.recth.y], eax, [.recth.height], [clScrollBk]
        mov     esi, [.recth.width]
        sub     esi, eax
        sub     esi, edx

        add     eax, [.recth.x]
        lea     edi, [eax+edx]
        stdcall DrawFillRect, [ecx+TPaintEvent.context], edi, [.recth.y], esi, [.recth.height], [clScrollBk]
        pop     esi

        mov     [.rectx.x], eax

        mov     [.rectx.width], edx
        push    [.recth.y] [.recth.height]
        pop     [.rectx.height] [.rectx.y]

        lea     eax, [.rectx]
        stdcall [DrawSlider], [ecx+TPaintEvent.context], eax, [clScrollSlider], sliderHorizontal

        lea     eax, [esi+TScrollWindow._VScroller]
        stdcall _SliderPixels, eax, [.rectv.height]

        push    esi
        stdcall DrawFillRect, [ecx+TPaintEvent.context], [.rectv.x], [.rectv.y], [.rectv.width], eax, [clScrollBk]
        mov     esi, [.rectv.height]
        sub     esi, eax
        sub     esi, edx

        add     eax, [.rectv.y]
        lea     edi, [eax+edx]
        stdcall DrawFillRect, [ecx+TPaintEvent.context], [.rectv.x], edi, [.rectv.width], esi, [clScrollBk]
        pop     esi

        mov     [.rectx.y], eax

        mov     [.rectx.height], edx
        push    [.rectv.x] [.rectv.width]
        pop     [.rectx.width] [.rectx.x]

        lea     eax, [.rectx]
        stdcall [DrawSlider], [ecx+TPaintEvent.context], eax, [clScrollSlider], sliderVertical

        clc
        jmp     .finish

;.........................................................................................

.btnpress:
        stdcall __ScrollSetCursor, esi, [ecx+TMouseButtonEvent.x], [ecx+TMouseButtonEvent.y]

        cmp     [ecx+TMouseButtonEvent.Button], mbLeft
        jne     .continue

        stdcall _WhatScrollbar, esi, [ecx+TMouseButtonEvent.x], [ecx+TMouseButtonEvent.y]
        jc      .continue         ; not found

; here ecx=height of the scrollbar
;      edi= ptr to TScrollbar structure
;      ebx= coordinate of the mouse in the scrollbar

        stdcall _SliderPixels, edi, ecx
        sub     ebx, eax
        jl      .before
        cmp     ebx, edx
        jg      .after

; inside the slider - capture the mouse.
        mov     [edi+TScrollbar._Drag], ebx
        stdcall MouseCapture, [esi+TWindow.handle]
        jmp     .continue

.before:
.after:
        jmp     .continue

;.........................................................................................

.btnrelease:
        stdcall __ScrollSetCursor, esi, [ecx+TMouseButtonEvent.x], [ecx+TMouseButtonEvent.y]

        xor     eax, eax
        mov     [esi+TScrollWindow._HScroller._Drag], eax
        mov     [esi+TScrollWindow._VScroller._Drag], eax

        stdcall MouseCapture, eax
        jmp     .continue

;.........................................................................................

.mousemove:
        mov     ecx, [.pEvent]
        stdcall __ScrollSetCursor, esi, [ecx+TMouseMoveEvent.x], [ecx+TMouseMoveEvent.y]

        mov     ecx, [.pEvent]
        lea     edi, [esi+TScrollWindow._HScroller]
        mov     eax, [ecx+TMouseMoveEvent.x]
        mov     ecx, [esi+TScrollWindow._width]
        mov     [.event.ScrollBar], scrollX
        cmp     [edi+TScrollbar._Drag], 0
        jne     .found

        mov     ecx, [.pEvent]
        lea     edi, [esi+TScrollWindow._VScroller]
        mov     eax, [ecx+TMouseMoveEvent.y]
        mov     ecx, [esi+TScrollWindow._height]
        mov     [.event.ScrollBar], scrollY
        cmp     [edi+TScrollbar._Drag], 0

        je      .continue


.found:
        mov     [.event.event], seScroll
        mov     [.event.ScrollCmd], scTrack

        sub     ecx, ScrollBarWidth
        sub     eax, 2
        sub     eax, [edi+TScrollbar._Drag]
        stdcall _SetSliderPos, edi, eax, ecx
        jc      .endmove

        mov     eax, [edi+TScrollbar.Pos]
        mov     [.event.Value], eax

        lea     eax, [.event]
        stdcall ExecEvent, esi, eax
        jnc     .finish

; ?????? Do we need this?
;        execute esi, TScrollWindow.Refresh

.endmove:
        clc
        jmp     .finish

endp


;_________________________________________________________________________________________


proc TScrollWindow.ExecCmd, .self, .method
begin
        cmp     [.method], TScrollWindow._ComputeFreeArea
        je      .computefreearea

        stc
        return


.computefreearea:
        mov     ecx, [.self]
        sub     [ecx+TScrollWindow._FreeArea.width], ScrollBarWidth
        sub     [ecx+TScrollWindow._FreeArea.height], ScrollBarWidth

        stc
        return
endp


;_________________________________________________________________________________________



proc _SetSliderPos, .pScrollbar, .x, .lengthpx
begin
        push    eax ecx edx

        mov     ecx, [.pScrollbar]
        stdcall _SliderPixels, [.pScrollbar], [.lengthpx]

        sub     [.lengthpx], edx
        jz      .zero

        mov     eax, [ecx+TScrollbar.Max]
        imul    [.x]
        idiv    [.lengthpx]

        cmp     eax, 0
        jge     .ok
        mov     eax, 0
.ok:
        cmp     eax, [ecx+TScrollbar.Max]
        jle     .ok2
        mov     eax, [ecx+TScrollbar.Max]
.ok2:
        cmp     [ecx+TScrollbar.Pos], eax
        stc
        je      @f
        clc
@@:
        mov     [ecx+TScrollbar.Pos], eax
        pop     edx ecx eax
        return

.zero:
        xor     eax, eax
        jmp     .ok2
endp



; returns:
;   eax - position in pixels
;   edx - size in pixels

proc _SliderPixels, .pScrollbar, .length
begin
        push    ecx esi

        mov     ecx, [.pScrollbar]

; page size in pixels.
        mov     esi, [ecx+TScrollbar.Max]
        mov     eax, [.length]
        add     esi, [ecx+TScrollbar.Page]
        test    esi, esi
        jz      .lengthok

        imul     [ecx+TScrollbar.Page]
        idiv     esi

.lengthok:
        cmp     eax, MinScrollBarWidth
        jge     @f
        mov     eax, MinScrollBarWidth
@@:
        cmp     eax, [.length]
        jle     @f
        mov     eax, [.length]
@@:
        push    eax

; position in pixels

        sub     eax, [.length]
        mov     esi, [ecx+TScrollbar.Max]
        test    esi, esi
        jnz     @f
        inc     esi
@@:
        neg     eax
        mul     [ecx+TScrollbar.Pos]
        div     esi

        pop     edx   ; width

        pop     esi ecx
        return
endp


proc __ScrollSetCursor, .window, .x, .y
begin
        pushad

        mov     esi, [.window]
        mov     eax, [esi+TWindow._cursor]
        stdcall _WhatScrollbar, esi, [.x], [.y]
        jc      @f

        mov     eax, mcArrow
@@:
        test    eax, $ffffff00
        jnz     @f
        stdcall GetStockCursor, eax
@@:
        stdcall SetMouseCursor, eax

        popad
        return
endp



; returns:
;      ecx = height of the scrollbar
;      edi = ptr to TScrollbar structure
;      ebx = coordinate of the mouse in the scrollbar
;
; CF=1 if the cursor is not in scrollbar

proc _WhatScrollbar, .window, .x, .y
begin
        push    eax edx esi

        mov     esi, [.window]


        mov     eax, [.x]
        mov     edx, [.y]

        mov     eax, [esi+TWindow._width]
        mov     edx, [esi+TWindow._height]

        sub     eax, ScrollBarWidth
        sub     edx, ScrollBarWidth

        cmp     [.x], eax
        jl      .checkh

        cmp     [.y], edx
        jg      .notfound     ; we are in the dead square.

; mouse in vscrollbar
        mov     ebx, [.y]
        mov     ecx, edx
        lea     edi, [esi+TScrollWindow._VScroller]
        jmp     .found

.checkh:
        cmp     [.y], edx
        jl      .notfound     ; in the client area

; mouse in hscrollbar
        mov     ebx, [.x]
        mov     ecx, eax
        lea     edi, [esi+TScrollWindow._HScroller]

.found:
        clc
        pop     esi edx eax
        return

.notfound:
        stc
        pop     esi edx eax
        return
endp



endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/TTreeView.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TTreeView object class
;
;  Target OS: Any
;
;  Dependencies:
;  Notes:
;_________________________________________________________________________________________
module "TreeView library"

ObjectClass TreeView,                    \
            ScrollWindow,                \
            TTreeView.Create,           \
            TTreeView.Destroy,          \
            TTreeView.Get,              \
            TTreeView.Set,              \
            TTreeView.ExecCmd,          \
            TTreeView.SysEventHandler

; tree-view item state flags.
tvisExpanded = 1
tvisSelected = 2
tvisFocused  = 4


struct TTreeViewItem
  .level      dd ?        ; the level of the element in the tree.

  .caption    dd ?        ; hString of the name.
  .state      dd ?        ; one or more state flags.
  .imgNormal  dd ?        ; index to the icon for normal state
  .iSelected  dd ?        ; index to the icon for selected state

  .pObject    dd ?        ; the object attached to the item
  align 32
  .shift = 5
ends


object TTreeView, TScrollWindow
  ._items dd ?    ; TArray with
  ._first dd ?    ; index of the fisrt visible item.
  ._pShadow dd ?  ; pointer to TBackBuffer

  .OnItemDelete  dd ? ; procedure to be call when the item is deleted. It should free the objects attached to the item.

  param .Focused

  method .AddItem, .iParent
  method .DelItem, .iItem  ;deletes the item and all children.
  method .GetItem, .index
endobj


proc TTreeView.Create, .pobj
begin
        mov     ebx, [.pobj]

        stdcall CreateBackBuffer, [ebx+TTreeView.handle], 1, 1
        mov     [ebx+TTreeView._pShadow], eax

        stdcall CreateArray, sizeof.TTreeViewItem
        mov     [ebx+TTreeView._items], eax

        clc
        return
endp


proc TTreeView.Destroy, .pobj
begin
        mov     ebx, [.pobj]

        stdcall DestroyBackBuffer, [ebx+TTreeView._pShadow]
        execute ebx, TTreeView.DelItem, -1
        stdcall FreeMem, [ebx+TTreeView._items]

        clc
        return
endp


proc TTreeView.Get, .pobj, .paramID
begin
        stc
        return
endp


proc TTreeView.Set, .pobj, .paramID, .value
begin
        stc
        return
endp


proc TTreeView.ExecCmd, .self, .method
begin
        stc
        return
endp


proc TTreeView.SysEventHandler, .pobj, .pEvent
begin
        pushad

        mov     ebx, [.pEvent]
        mov     esi, [.pobj]
        mov     eax, [ebx+TSysEvent.event]

        cmp     eax, sePaint
        je      .paint

        cmp     eax, seMoveResize
        je      .moveresize

.continue:
        popad
        stc
        return

.paint:
        stdcall SetClipRectangle, [ebx+TPaintEvent.context], 0
        stdcall TScrollWindow.SysEventHandler, [.pobj], [.pEvent]
        stdcall DrawBackBuffer, [ebx+TPaintEvent.context], [esi+TTreeView._pShadow], 0, 0
        jmp     .continue

.moveresize:
        stdcall Get, esi, TTreeView.FreeArea

        stdcall DestroyBackBuffer, [esi+TTreeView._pShadow]
        stdcall CreateBackBuffer, [esi+TTreeView.handle], [esi+TTreeView._FreeArea.width], [esi+TTreeView._FreeArea.height]
        mov     [esi+TTreeView._pShadow], eax
        jmp     .continue

endp


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































Deleted freshlib/gui/TWindow.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TWindow object class
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: TWindow is the common ancestor of all visible on the screen controls.
;         This file contains only OS independent part of the library and includes
;         the OS dependent files.
;_________________________________________________________________________________________
module "TWindow library"

ObjectClass Window,             \
            Object,             \
            TWindow.Create,     \
            TWindow.Destroy,    \
            TWindow.Get,        \
            TWindow.Set,        \
            TWindow.ExecCmd,    \
            TWindow.SysEventHandler

; The elements of the array returned by .GetSiblings param
; if handle<>0 and pWindow=0 - it is a native window, not added by FreshLib
struct TWinArrayItem
  .handle   dd ?      ; The native OS handle of the window.
  .pWindow  dd ?      ; pointer to TWindow descendent structure.
ends

; Border kind of window.
borderNone    = 0
borderFull    = 1
borderModal   = 2
borderToolbox = 3

struct __TInternalAlign
  .client        TBounds
  .pClientWindow dd ?
ends
; assign X = 01
; assign Y = 10

; adjheight = 01
; topleft  = 00
; bottomright = 10

;            00 - adjwidht + bottomright

; Window align values.
waNone   = 0
waLeft   = 1
waTop    = 2
waRight  = 3
waBottom = 4
waClient = 5


object TWindow, TObject

  .handle       dd ?   ; it is handle to the system provided window.

  ._x           dd ?
  ._y           dd ?
  ._width       dd ?
  ._height      dd ?

  ._visible     dd ?

  ._bounds_changed dd ?

  ._border      dd ?

  ._align       dd ?         ; window horizontal alignment

  ._FreeArea    TBounds      ; the window area that remains free after all children aligned. [1]

  ._caption     dd ?    ; string handle with window caption.
  ._cursor      dd ?    ; it is a handle to the mouse cursor.

  .OnKeyPress   dd ?    ; key press user handler.

; parameters
  param .x
  param .y
  param .width
  param .height

  param .Align

  param .FreeArea       ; read only.

  param .borderKind
  param .Zorder

  param .Visible
  param .Caption
  param .Parent
  param .Cursor
  param .Children       ; read only. returns array with all children; See the notes [2] below.

  method .Refresh
  method .Focus
  method .AlignChildren
  method .ToBack
  method .ToFront

  method ._ComputeFreeArea
endobj

; NOTES:
; [1]  FreeArea field
;
; [2] The param .children returns an array of TWinArrayItem filled with information about
;     all siblings of the given window.
;     This array is allocated with CreateArray and needs to be free with FreeMem after use.
;     TArray.lparam of the array contains a pointer to the element containing current window


; OS dependend code
include '%TargetOS%/windows.asm'


; OS independent code.


;_________________________________________________________________________________________


proc TWindow.Create, .obj
begin
        push    eax ecx edx
        mov     ebx, [.obj]
        stdcall _CreateNullWindow
        mov     [ebx+TWindow.handle], eax
        stdcall _SetWindowStruct, eax, ebx

        pop     edx ecx eax
        clc
        return
endp


;_________________________________________________________________________________________



proc TWindow.Destroy, .obj
begin
        push    eax
        mov     eax, [.obj]
        cmp     [eax+TWindow.handle], 0
        je      @f
        stdcall _DestroyWindow, [eax+TWindow.handle]
@@:
        pop     eax
        return
endp



;_________________________________________________________________________________________


proc TWindow.Get, .obj, .paramID
.rect RECT
begin
        push    edx esi

        stdcall IsObject, [.obj], CWindow
        jc      .not_processed

        mov     esi, [.obj]
        mov     eax, [.paramID]

        test    eax, maskParameter
        jz      .field

        cmp     eax, TWindow.x
        je      .getrect
        cmp     eax, TWindow.y
        je      .getrect
        cmp     eax, TWindow.width
        je      .getrect
        cmp     eax, TWindow.height
        je      .getrect

        cmp     eax, TWindow.FreeArea
        je      .getfreearea

        cmp     eax, TWindow.Visible
        je      .getvisible

        cmp     eax, TWindow.Caption
        je      .getcaption

        cmp     eax, TWindow.borderKind
        je      .getborder

        cmp     eax, TWindow.Children
        je      .getchildren

        cmp     eax, TWindow.Parent
        je      .getparent


.not_processed:
        stc
        pop     esi edx
        return


.field:
        mov     eax, [esi+eax]


.finish:
        clc
        pop     esi edx
        return

;.........................................................................................

.getparent:
        stdcall _GetParent, [esi+TWindow.handle]
        test    eax, eax
        jz      .finish
        stdcall _GetWindowStruct, eax
        jmp     .finish

;.........................................................................................

.getchildren:
        stdcall _GetChildren, [esi+TWindow.handle]
        test    eax, eax
        jz      .finish

        push    ebx edi

        mov     ebx, eax
        mov     ecx, [ebx+TArray.count]

.loop:
        jecxz   .endloop
        dec     ecx

        stdcall _GetWindowStruct, [ebx+TArray.array+8*ecx+TWinArrayItem.handle]

        mov     [ebx+TArray.array+8*ecx+TWinArrayItem.pWindow], eax
        jmp     .loop

.endloop:
        mov     eax, ebx

        pop     edi ebx
        jmp     .finish


;.........................................................................................


.getfreearea:
        mov     [esi+TWindow._FreeArea.x], 0
        mov     [esi+TWindow._FreeArea.y], 0
        mov     eax, [esi+TWindow._width]
        mov     ecx, [esi+TWindow._height]
        mov     [esi+TWindow._FreeArea.width], eax
        mov     [esi+TWindow._FreeArea.height], ecx

        execute esi, TWindow._ComputeFreeArea

        lea     eax, [esi+TWindow._FreeArea]
        jmp     .finish


;.........................................................................................


.getborder:
        mov     eax, [esi+TWindow._border]
        jmp     .finish


;.........................................................................................


.getcaption:
        stdcall StrDup, [esi+TWindow._caption]
        jmp     .finish

;.........................................................................................

.getvisible:
        mov     eax, [esi+TWindow._visible]
;        stdcall _GetVisible, [esi+TWindow.handle]
        jmp     .finish

;.........................................................................................


.getrect:
        mov     eax, [.paramID]
        sub     eax, TWindow.x
        mov     eax, [esi+TWindow._x+4*eax]
        jmp     .finish
endp


;_________________________________________________________________________________________



proc TWindow.Set, .obj, .paramID, .value
begin
        stdcall IsObject, [.obj], CWindow
        jc      .fault

        push    eax esi

        mov     esi, [.obj]
        mov     eax, [.paramID]

        test    eax, maskParameter
        jz      .field

        cmp     eax, TWindow.x
        je      .setrect
        cmp     eax, TWindow.y
        je      .setrect
        cmp     eax, TWindow.width
        je      .setrect
        cmp     eax, TWindow.height
        je      .setrect

        cmp     eax, TWindow.Visible
        je      .setvisible

        cmp     eax, TWindow.Caption
        je      .setcaption

        cmp     eax, TWindow.borderKind
        je      .setborder

        cmp     eax, TWindow.Align
        je      .setalign

        pop     esi eax
.fault:
        stc
        return

.field:
        pushd   [.value]
        popd    [esi+eax]

.finish:
        clc
        pop     esi eax
        return

;.........................................................................................
.setalign:
locals
  .bounds TBounds
endl
        mov     eax, [.value]
        cmp     eax, [esi+TWindow._align]
        je      .finish

        mov     [esi+TWindow._align], eax

        stdcall Get, esi, TWindow.Parent
        test    eax, eax
        jz      .finish

        execute eax, TWindow.AlignChildren

        jmp     .finish

;.........................................................................................


.setborder:
        mov     eax, [.value]
        xchg    eax, [esi+TWindow._border]
        cmp     eax, [esi+TWindow._border]
        je      .finish

        stdcall _SetWindowBorder, [esi+TWindow.handle], [esi+TWindow._border]
        jmp     .finish

;.........................................................................................

.setcaption:
        lea     eax, [esi+TWindow._caption]
        stdcall SetString, eax, [.value]
        stdcall StrPtr, [eax]

        stdcall _SetWindowTextUtf8, [esi+TWindow.handle], [.value]
        jmp     .finish

;.........................................................................................

.setvisible:
        mov     eax, [.value]
        xchg    [esi+TWindow._visible], eax
        cmp     [esi+TWindow._visible], eax
        je      .finish

        stdcall _ShowWindow, [esi+TWindow.handle], [.value]

        cmp     [.value], 0
        je      .finish

        cmp     [esi+TWindow._align], waNone
        je      .finish

        stdcall Get, esi, TWindow.Parent
        test    eax, eax
        jz      .finish

        execute eax, TWindow.AlignChildren
        jmp     .finish

;.........................................................................................

.setrect:
        mov     eax, [.paramID]
        sub     eax, TWindow.x

        mov     ecx, [.value]
        cmp     ecx, [esi+TWindow._x+4*eax]
        je      .finish

        mov     [esi+TWindow._x+4*eax], ecx

        lea     eax, [esi+TWindow._x]
        stdcall _SetWindowBounds, [esi+TWindow.handle], eax
        mov     [esi+TWindow._bounds_changed], 0

        jmp     .finish
endp


;_________________________________________________________________________________________




proc TWindow.ExecCmd, .self, .method
begin
        push    eax edx

        cmp     [.method], TWindow.Refresh
        je      .refresh

        cmp     [.method], TWindow._ComputeFreeArea
        je      .computefreearea

        cmp     [.method], TWindow.AlignChildren
        je      .alignchildren

        cmp     [.method], TWindow.Focus
        je      .focus

        cmp     [.method], TWindow.AddChild
        je      .addchild

.error:
        stc
        pop     edx eax
        return

;.........................................................................................

.refresh:
        mov     eax, [.self]
        cmp     [eax+TWindow._visible], 0
        je      .finish
        stdcall _RefreshWindow, [eax+TWindow.handle]
.finish:
        clc
        pop     edx eax
        return

;.........................................................................................

.computefreearea:



        jmp     .finish

;.........................................................................................

.alignchildren:
locals
  .winalign  __TInternalAlign
endl
; THIS METHOD is not written very good. It should be revised some day in order to make
; alignment fast and smooth for all OS supported!
        push    esi edi

        stdcall Get, [.self],  TWindow.Children
        test    eax, eax
        jz      .endalign

        mov     edi, eax
        lea     esi, [.winalign]
        mov     ecx, [.self]

        push    [ecx+TWindow._width] [ecx+TWindow._height]
        pop     [esi+__TInternalAlign.client.height] [esi+__TInternalAlign.client.width]

        xor     ecx,ecx

        mov     [esi+__TInternalAlign.client.y], ecx
        mov     [esi+__TInternalAlign.client.x], ecx
        mov     [esi+__TInternalAlign.pClientWindow], ecx

.loop:
        cmp     ecx, [edi+TArray.count]
        je      .endloop

        stdcall __DoAlignOne, [edi+TArray.array+8*ecx+TWinArrayItem.pWindow]
        inc     ecx
        jmp     .loop

.endloop:
        mov     ecx, [.winalign.pClientWindow]
        jecxz   .updatewindows

        mov     eax, [esi+__TInternalAlign.client.x]
        mov     edx, [esi+__TInternalAlign.client.y]
        sub     eax, [ecx+TWindow._x]
        sub     edx, [ecx+TWindow._y]
        mov     ebx, eax
        or      ebx, edx

        mov     eax, [esi+__TInternalAlign.client.width]
        mov     edx, [esi+__TInternalAlign.client.height]
        sub     eax, [ecx+TWindow._width]
        sub     edx, [ecx+TWindow._height]
        or      ebx, eax
        or      ebx, edx
        mov     [ecx+TWindow._bounds_changed], ebx

        push    [esi+__TInternalAlign.client.height] [esi+__TInternalAlign.client.width] [esi+__TInternalAlign.client.y] [esi+__TInternalAlign.client.x]
        pop     [ecx+TWindow._x] [ecx+TWindow._y] [ecx+TWindow._width] [ecx+TWindow._height]

.updatewindows:
        mov     ecx, [edi+TArray.count]

.updateloop:
        dec     ecx
        js      .endupdate

        mov     eax, [edi+8*ecx+TArray.array+TWinArrayItem.pWindow]
        cmp     [eax+TWindow._bounds_changed], 0
        je      .refresh_only

        lea     edx, [eax+TWindow._x]
;        mov     [eax+TWindow._bounds_changed], 0         - it will be zeroed in the seMoveResize event handler.
        stdcall _SetWindowBounds, [eax+TWindow.handle], edx

.refresh_only:
        stdcall _RefreshWindow, [eax+TWindow.handle]
        jmp     .updateloop

.endupdate:
        stdcall FreeMem, edi
        mov     eax, [.self]
        stdcall _RefreshWindow, [eax+TWindow.handle]

.endalign:
        pop     edi esi
        jmp     .finish

;.........................................................................................

.focus:
        mov     eax, [.self]
        stdcall _SetFocus, [eax+TWindow.handle]
        jmp     .finish

;.........................................................................................

.addchild:
; method parameter.
virtual at ebx
  .child dd ?
end virtual
        stdcall IsObject, [.child], CWindow
        jne     .add_non_window

        mov     ebx, [.child]
        mov     eax, [.self]

        stdcall _AddChild, [eax+TWindow.handle], [ebx+TWindow.handle]
        jmp     .finish

.add_non_window:        ; this is possible, but not implemented for now.
        jmp     .error
endp



;_________________________________________________________________________________________


proc TWindow.SysEventHandler, .pObj, .pEvent
begin
        push    eax ecx edx esi edi

        mov     esi, [.pObj]
        mov     ebx, [.pEvent]
        mov     eax, [ebx+TSysEvent.event]

        cmp     eax, seMouseEnter
        je      .mouseenter

        cmp     eax, seMouseLeave
        je      .mouseleave

        cmp     eax, seMouseBtnPress
        je      .btnpress

        cmp     eax, seMoveResize
        je      .moveresize

        cmp     eax, seKbdKeyPress
        je      .keypress

        stc
.finish:
        pop     edi esi edx ecx eax
        return

;.........................................................................................
.moveresize:
        mov     eax, [ebx+TMoveResizeEvent.newX]
        mov     ecx, [ebx+TMoveResizeEvent.newY]
        mov     [esi+TWindow._x], eax
        mov     [esi+TWindow._y], ecx

        mov     eax, [ebx+TMoveResizeEvent.newWidth]
        mov     ecx, [ebx+TMoveResizeEvent.newHeight]
        xchg    [esi+TWindow._width], eax
        xchg    [esi+TWindow._height], ecx
        sub     eax, [esi+TWindow._width]
        sub     ecx, [esi+TWindow._height]
        or      eax, ecx
        jnz     .alignchildren          ; when the resize is as a result of internal windows align, the _width and _height fields are already set.
                                        ; it must be this way, because the resize should be fast, but in Linux there is no DeferWindowPos function like in Win32

        cmp     [esi+TWindow._bounds_changed], 0
        je      .endresize

.alignchildren:
        execute esi, TWindow.AlignChildren
        mov     [esi+TWindow._bounds_changed], 0

.endresize:
        clc
        jmp     .finish

;.........................................................................................

.btnpress:
        execute esi, TWindow.Focus
        clc
        jmp     .finish

;.........................................................................................

.mouseenter:
        mov     eax, [esi+TWindow._cursor]
        test    eax, $ffffff00
        jnz     @f
        stdcall GetStockCursor, eax
@@:
        stdcall SetMouseCursor, eax
        clc
        jmp     .finish

;.........................................................................................
.mouseleave:
        stdcall GetStockCursor, mcArrow
        stdcall SetMouseCursor, eax
        clc
        jmp     .finish

;.........................................................................................

.keypress:
        cmp     [esi+TWindow.OnKeyPress], 0
        je      @f
        stdcall [esi+TWindow.OnKeyPress], esi, ebx
@@:
        clc
        jmp     .finish
endp



proc __DoAlignOne, .pWindow
.bounds TBounds
.align  dd ?
begin
        pushad

        mov     ebx, [.pWindow]
        cmp     [ebx+TWindow._align], waNone
        je      .exit
        cmp     [ebx+TWindow._align], waClient
        ja      .exit

        stdcall Get, ebx, TWindow.Visible
        test    eax, eax
        jz      .exit

        cmp     [ebx+TWindow._align], waClient
        jne     .doalign

; only one window with waClient may exists.
        cmp     [esi+__TInternalAlign.pClientWindow], 0
        jne     .exit

        mov     [esi+__TInternalAlign.pClientWindow], ebx
        jmp     .exit

.doalign:
        mov     eax, [ebx+TWindow._align]
        dec     eax
        mov     [.align], eax

; save the old bounds in order to detect change.
        mov     eax, [ebx+TWindow._x]
        mov     ecx, [ebx+TWindow._y]
        mov     [.bounds.x], eax
        mov     [.bounds.y], ecx
        mov     eax, [ebx+TWindow._width]
        mov     ecx, [ebx+TWindow._height]
        mov     [.bounds.width], eax
        mov     [.bounds.height], ecx

        mov     ecx, TBounds.width
        mov     edx, [ebx+TWindow._height]
        mov     edi, TBounds.y
        bt      [.align], 0     ; 0 - width; 1 - height
        jc      @f
        mov     ecx, TBounds.height
        mov     edx, [ebx+TWindow._width]
        mov     edi, TBounds.x
@@:
        mov     eax, [esi+__TInternalAlign.client+ecx]
        mov     [ebx+TWindow._x+ecx], eax

        mov     eax, [esi+__TInternalAlign.client.x]
        mov     ecx, [esi+__TInternalAlign.client.y]

        bt      [.align], 1     ; 0 - left/top; 1-right/bottom
        jnc     @f

        add     eax, [esi+__TInternalAlign.client.width]
        add     ecx, [esi+__TInternalAlign.client.height]
        sub     eax, [ebx+TWindow._width]
        sub     ecx, [ebx+TWindow._height]
        neg     edx
        add     edi, 8

@@:
        mov     [ebx+TWindow._x], eax
        mov     [ebx+TWindow._y], ecx
        add     [esi+__TInternalAlign.client+edi], edx
        test    edx, edx
        js      @f
        sub     [esi+__TInternalAlign.client+edi+8], edx
@@:
        mov     eax, [ebx+TWindow._x]
        mov     ecx, [ebx+TWindow._y]
        mov     edx, [ebx+TWindow._width]
        mov     edi, [ebx+TWindow._height]
        sub     eax, [.bounds.x]
        sub     ecx, [.bounds.y]
        sub     edx, [.bounds.width]
        sub     edi, [.bounds.height]
        or      ecx, eax
        or      edx, edi
        or      ecx, edx
        mov     [ebx+TWindow._bounds_changed], ecx

.exit:
        popad
        return
endp




endmodule

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/ThemeGUI.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: This file contains procedures and data, that form the appearance of the
;               FreshLib GUI application. Colors, control borders, backgrownd drawing etc.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: The user should be able to change these settings and if he uses external
;         procedures, then the code from this library should not be compiled.
;_________________________________________________________________________________________
module "GUI theme data and code library"

; Box border type
bxNone   = 0
bxRaised = 1
bxSunken = 2
bxFlat   = 3
bxNoFill = $80000000

; Default colors
iglobal
  var clBorderLight   = $ffffff
  var clBorderDark    = $606060 ; soft shadow
  var clBorderNeutral = $a0a0a8

  var clEditBk        = $fffff0
  var clEditTxt       = $000000
  var clEditSel       = $0000a0
  var clEditSelTxt    = $ffffff

  var clButtonBk      = $d0d0d8
  var clButtonTxt     = $000000

  var clButtonHotBk   = $e0e0e8
  var clButtonHotTxt  = $0000ff

  var clDialogBk      = $d0d0d8
  var clDialogTxt     = $000000

  var clScrollBk      = $a0a0a0
  var clScrollSlider  = $d0d0d8

  if ~defined DrawBox | defined ___DrawBox
    var DrawBox = DrawBoxDefault
    ___DrawBox = 1
  end if

  if ~defined DrawSlider | defined ___DrawSlider
    var DrawSlider = DrawSliderDefault
    ___DrawSlider = 1
  end if


endg





; Midnight colors
;iglobal
;  var clBorderLight   = $0000ff
;  var clBorderDark    = $000000
;  var clBorderNeutral = $808080
;
;  var clEditBk        = $0000c0
;  var clEditTxt       = $ffffff
;  var clEditSel       = $0000ff
;  var clEditSelTxt    = $000000
;
;  var clButtonBk      = $000080
;  var clButtonTxt     = $ffffff
;
;  var clButtonHotBk   = $0000a0
;  var clButtonHotTxt  = $ffffff
;
;  var clDialogBk      = $000080
;  var clDialogTxt     = $ffffff
;endg




proc DrawBoxDefault, .context, .pBounds, .bkground, .border
  .brd RECT
begin
        push    eax ecx edx esi


        stdcall SetDrawMode, [.context], cmCopy

        mov     esi, [.pBounds]

        mov     edx, [.border]
        and     edx, $ff
        jz      .borderok

        mov     eax, [esi+TBounds.x]
        mov     ecx, [esi+TBounds.y]
        mov     [.brd.left], eax
        mov     [.brd.top], ecx

        add     eax, [esi+TBounds.width]
        add     ecx, [esi+TBounds.height]
        dec     eax
        dec     ecx
        mov     [.brd.right], eax
        mov     [.brd.bottom], ecx

        sub     [esi+TBounds.width], 2
        sub     [esi+TBounds.height], 2
        inc     [esi+TBounds.x]
        inc     [esi+TBounds.y]

        mov     eax, [clBorderLight]
        mov     ecx, [clBorderDark]

        cmp     edx, bxRaised
        je      .colorok

        xchg    eax, ecx

        cmp     edx, bxSunken
        je      .colorok

        mov     eax, [clBorderNeutral]
        mov     ecx, eax

.colorok:
        stdcall SetSimpleLine, [.context], eax
        stdcall DrawLine, [.context], [.brd.left],  [.brd.top], [.brd.left], [.brd.bottom]
        stdcall DrawLine, [.context], [.brd.left],  [.brd.top], [.brd.right], [.brd.top]

        stdcall SetSimpleLine, [.context], ecx
        stdcall DrawLine, [.context], [.brd.left], [.brd.bottom], [.brd.right], [.brd.bottom]
        inc      [.brd.bottom]
        stdcall DrawLine, [.context], [.brd.right], [.brd.top], [.brd.right], [.brd.bottom]

.borderok:
        bt      [.border], 31
        jc      .fillok
        stdcall DrawFillRect, [.context], [esi+TBounds.x], [esi+TBounds.y], [esi+TBounds.width], [esi+TBounds.height], [.bkground]

; additional 1px margin
        sub     [esi+TBounds.width], 2
        sub     [esi+TBounds.height], 2
        inc     [esi+TBounds.x]
        inc     [esi+TBounds.y]

.fillok:
        pop     esi edx ecx eax
        return
endp


sliderHorizontal = 0
sliderVertical   = 1

proc DrawSliderDefault, .context, .pBounds, .bkground, .type
begin
        stdcall [DrawBox], [.context], [.pBounds], [.bkground], bxRaised
        return
endp



endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































Deleted freshlib/gui/Win32/Main.asm.

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
489
490
491
492
493
494
495
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Main procedure of GUI application library.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes: Organize the main message/event loop needed by every GUI engine.
;_________________________________________________________________________________________

proc ProcessSystemEvents
.msg MSG
begin
        push    ecx edx esi

.msgloop:
        lea     esi, [.msg]
        xor     eax, eax

        invoke  PeekMessage, esi, eax, eax, eax, PM_REMOVE
        test    eax, eax
        jz      .exitok

        cmp     [.msg.message], WM_TIMER
        je      .translate                      ; express dispatching of the timer messages.

        cmp     [.msg.message], WM_QUIT
        je      .terminate

        stdcall __ProcessOneSystemEvent, [esi+MSG.hwnd], [esi+MSG.message], [esi+MSG.wParam], [esi+MSG.lParam]
        jnc     .msgloop                ; the message is translated to system event and the event is executed by the object SysEvent handler.

; the message is for window that is not an FreshLib object, so process with standard windows behaviour.
;        invoke  TranslateMessage, esi
.translate:
        invoke  DispatchMessage, esi
        jmp     .msgloop


.exitok:
        clc
        pop     esi edx ecx
        return


.terminate:
        mov     eax, [.msg.wParam]
        stc
        pop     esi edx ecx
        return
endp




proc WaitForSystemEvent
begin
        push    eax ecx edx
        invoke  WaitMessage
        pop     edx ecx eax
        return
endp




;proc EventsQueued, .pWin
;.msg MSG
;begin
;        push    eax ecx edx
;        mov     eax, [.pWin]
;        mov     ecx, [eax+TWindow.handle]
;        lea     eax, [.msg]
;        invoke  PeekMessage, eax, ecx, 0, 0, PM_NOREMOVE
;        test    eax, eax
;        clc
;        jz      @f
;        stc
;@@:
;        pop     edx ecx eax
;        return
;endp
;

;----------------------------------------------------------------------------------------------------------
; This procedure makes following:
;   1. Takes as arguments one windows message
;   2. Converts this message to FreshLib system event (or not, depending on the message)
;   3. Calls SysEventHandler procedures for the given object (if any) with the created event structure.
;   4. returns CF=0 if the event was properly processed.
;   5. returns CF=1 if the event was not processed.
;
; The event can be not processed in the following cases:
;   1. The window that receives the message is not FreshLib object.
;   2. TObjectClass.procSysEventHandler = 0 for the given class and all parents.
;   3. All procSysEventHandler procedures refuse to process the event (CF=1)
;----------------------------------------------------------------------------------------------------------
uglobal
  if used __LatestPointedObj
    __LatestPointedObj dd ?
  end if
endg


winproc __ProcessOneSystemEvent
.event  rb 32
begin
        push    eax ebx ecx edx esi edi

        stdcall _GetWindowStruct, [.hwnd]
        test    eax, eax
        jz      .ondefault

        mov     esi, eax
        mov     ebx, [.wmsg]
        lea     edi, [.event]

ondefault
        pop     edi esi edx ecx ebx eax
        stc
        return

;.........................................................................................


.exec_event:
        stdcall ExecEvent, esi, edi

.finish:
        pop     edi esi edx ecx ebx eax
        clc
        return

;.........................................................................................

onmessage WM_MOUSEWHEEL

          mov   eax, [.wparam]
          sar   eax, 16
          mov   ecx, scWheelUp
          test  eax, eax
          jns   @f
          mov   ecx, scWheelDn
          neg   eax
@@:
          mov   [edi+TScrollEvent.event], seScroll
          mov   [edi+TScrollEvent.ScrollBar], scrollY
          mov   [edi+TScrollEvent.ScrollCmd], ecx

          xor   edx, edx
          mov   ecx, 120
          idiv  ecx
          mov   [edi+TScrollEvent.Value], eax

          jmp   .exec_event

;.........................................................................................

onmessage WM_WINDOWPOSCHANGED

locals
  .rect RECT
endl
        mov     ebx, [.lparam]

        lea     eax, [edi+TMoveResizeEvent.newX]
        invoke  GetClientRect, [.hwnd], eax

        mov     eax, [ebx+WINDOWPOS.x]
        mov     ecx, [ebx+WINDOWPOS.y]
        mov     [edi+TMoveResizeEvent.newX], eax
        mov     [edi+TMoveResizeEvent.newY], ecx

        mov     [edi+TMoveResizeEvent.event], seMoveResize
        jmp     .exec_event



;.........................................................................................

onmessage WM_SYSKEYDOWN
onmessage WM_SYSKEYUP
onmessage WM_KEYDOWN
onmessage WM_KEYUP
locals
  .keyboard rb 256
  .unicode rw 16
  .utf8    rb 16
endl
        lea     ebx, [.keyboard]
        invoke  GetKeyboardState, ebx
        mov     eax, [.lparam]
        mov     ecx, eax
        shr     eax, 16
        and     ecx, $80000000
        and     eax, $ff
        mov     [edi+TKeyboardEvent.scancode], eax
        or      eax, ecx
        lea     edx, [.unicode]
        invoke  ToUnicode, [.wparam], eax, ebx, edx, 16, 0
        xor     ecx, ecx
        test    eax, eax
        jz      .key_translated    ; the key can not be translated.
        js      .key_translated    ; it is a dead key. What we have to do???

        lea     edx, [.utf8]
        xor     ecx, ecx
        mov     [edx], ecx
        mov     [edx+4], ecx
        lea     ecx, [.unicode]
        invoke  WideCharToMultiByte, CP_UTF8, 0, ecx, eax, edx, 8, 0, 0
        xor     ecx, ecx
        test    eax, eax
        jz      .key_translated

        mov     ecx, dword [.utf8]

.key_translated:
        mov     [edi+TKeyboardEvent.key], ecx

        mov     ecx, seKbdKeyPress
        cmp     [.wmsg], WM_KEYDOWN
        je      @f
        cmp     [.wmsg], WM_SYSKEYDOWN
        je      @f
        mov     ecx, seKbdKeyRelease
@@:
        mov     [edi+TKeyboardEvent.event], ecx

        xor     eax, eax
        test    [.keyboard+VK_CONTROL], $80
        jz      @f
        or      eax, maskCtrl
@@:
        test    [.keyboard+VK_SHIFT], $80
        jz      @f
        or      eax, maskShift
@@:
        test    [.keyboard+VK_MENU], $80
        jz      @f
        or      eax, maskAlt
@@:
        test    [.keyboard+VK_SCROLL], $01
        jz      @f
        or      eax, maskScrLk
@@:
        test    [.keyboard+VK_CAPITAL], $01
        jz      @f
        or      eax, maskCapsLock
@@:

;        or      eax, [__MouseButtonMask]
;        OutputRegister regEAX, 16

        mov     [edi+TKeyboardEvent.kbdStatus], eax
        jmp     .exec_event


;.........................................................................................


onmessage WM_SETFOCUS
        mov     [edi+TFocusInEvent.event], seFocusIn
        jmp     .exec_event


;.........................................................................................


onmessage WM_KILLFOCUS
        mov     [edi+TFocusOutEvent.event], seFocusOut
        jmp     .exec_event


;.........................................................................................


onmessage WM_SETCURSOR

        movzx   eax, word [.lparam]
        cmp     eax, HTCLIENT
        jne     .ondefault

        mov     eax, [esi+TWindow._cursor]
        test    eax, $ffffff00
        jnz     .customcursor

        stdcall GetStockCursor, eax

.customcursor:
        stdcall SetMouseCursor, eax
        jmp     .finish


;.........................................................................................


onmessage WM_MOUSEMOVE
        cmp     esi, [__LatestPointedObj]
        je      .normal_mouse_move

        mov     [edi+TMouseEnterEvent.event], seMouseLeave
        xchg    esi, [__LatestPointedObj]
        test    esi, esi
        jz      .leaveok
        stdcall ExecEvent, esi, edi

.leaveok:
        mov     esi, [__LatestPointedObj]
        mov     [edi+TMouseEnterEvent.event], seMouseEnter
        stdcall ExecEvent, esi, edi

.normal_mouse_move:
        mov     [edi+TMouseMoveEvent.event], seMouseMove
        movsx   eax, word [.lparam]
        movsx   ecx, word [.lparam+2]
        mov     [edi+TMouseMoveEvent.x], eax
        mov     [edi+TMouseMoveEvent.y], ecx
        jmp     .exec_event



;.........................................................................................

onmessage WM_PAINT
locals
  .ps PAINTSTRUCT
  .context TContext
  .caret   dd ?
  .rect2    RECT
endl
        lea     eax, [.rect2]
        invoke  GetUpdateRect, [.hwnd], eax, FALSE
        test    eax, eax
        jz      .endpaint

        lea     eax, [.ps]
        invoke  BeginPaint, [.hwnd], eax

if defined Caret
        mov     [.caret], -1
        cmp     esi, [Caret.pWindow]
        jne     @f

        stdcall CaretShow, FALSE
        mov     [.caret], eax
@@:
end if

        mov     [edi+TPaintEvent.event], sePaint
        push    [.ps.hdc]
        pop     [.context.handle]
        push    [.hwnd]
        pop     [.context.raster]

        lea     eax, [.context]
        mov     [edi+TPaintEvent.context], eax

; ?????????????????????????????
;        push    [.ps.rcPaint.left] [.ps.rcPaint.top]
        push     [.rect2.left] [.rect2.top]
        pop     [edi+TPaintEvent.rect.top] [edi+TPaintEvent.rect.left]
;        push    [.ps.rcPaint.right] [.ps.rcPaint.bottom]
         push    [.rect2.right] [.rect2.bottom]
        pop     [edi+TPaintEvent.rect.bottom] [edi+TPaintEvent.rect.right]

        stdcall ExecEvent, esi, edi

        lea     eax, [.ps]
        invoke  EndPaint, [.hwnd], eax

if defined Caret
        cmp     [.caret], -1
        je      @f
        stdcall CaretShow, [.caret]
@@:
end if

.endpaint:
        pop     edi esi edx ecx ebx eax
        clc
        return


;.........................................................................................


onmessage WM_CLOSE
        mov     eax, [pApplication]
        mov     eax, [eax+TApplication.MainWindow]
        cmp     [eax], esi
        jne     @f

DebugMsg "Quit message posted."
        invoke  PostQuitMessage, 0

@@:
        mov     [edi+TCloseEvent.event], seCloseRequest
        mov     [edi+TCloseEvent.reason], cerFromUser
        jmp     .exec_event

onmessage WM_DESTROY
        cmp     esi, [__LatestPointedObj]
        jne     .ondefault

        mov     [__LatestPointedObj], 0
        jmp     .ondefault

;.........................................................................................


onmessage WM_LBUTTONUP
onmessage WM_RBUTTONUP
onmessage WM_MBUTTONUP
onmessage WM_LBUTTONDOWN
onmessage WM_RBUTTONDOWN
onmessage WM_MBUTTONDOWN
onmessage WM_LBUTTONDBLCLK
onmessage WM_RBUTTONDBLCLK
onmessage WM_MBUTTONDBLCLK

        stdcall __MouseButton, [.wmsg]
        mov     [edi+TMouseButtonEvent.event], ecx
        mov     [edi+TMouseButtonEvent.Button], eax
        stdcall __KeyStatus, [.wparam]
        mov     [edi+TMouseButtonEvent.kbdStatus], eax

        movsx   eax, word [.lparam]
        movsx   ecx, word [.lparam+2]
        mov     [edi+TMouseButtonEvent.x], eax
        mov     [edi+TMouseButtonEvent.y], ecx


        jmp     .exec_event
endwp


proc __MouseButton, .msg
begin
        mov     eax, [.msg]
        sub     eax, WM_LBUTTONDOWN
        movzx   ecx, byte [__mouse_event_table+eax]
        movzx   eax, byte [__mouse_button_table+eax]
        return
endp


iglobal
  if used __mouse_button_table
  __mouse_button_table db mbLeft,        mbLeft,       mbLeft
                       db mbRight,       mbRight,      mbRight
                       db mbMiddle,      mbMiddle,     mbMiddle
  end if

  if used __mouse_event_table
  __mouse_event_table  db seMouseBtnPress, seMouseBtnRelease, seMouseBtnDblClick
                       db seMouseBtnPress, seMouseBtnRelease, seMouseBtnDblClick
                       db seMouseBtnPress, seMouseBtnRelease, seMouseBtnDblClick
  end if
endg


;.........................................................................................



proc __KeyStatus, .status
begin
        xor     eax, eax
        test    [.status], MK_LBUTTON
        jz      @f
        or      eax, maskBtnLeft
@@:
        test    [.status], MK_RBUTTON
        jz      @f
        or      eax, maskBtnRight
@@:
        test    [.status], MK_MBUTTON
        jz      @f
        or      eax, maskBtnMiddle
@@:
        test    [.status], MK_SHIFT
        jz      @f
        or      eax, maskCtrl
@@:
        test    [.status], MK_CONTROL
        jz      @f
        or      eax, maskCtrl
@@:
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/Win32/TApplication.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: TApplication object class.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes: TApplication by the idea is the base of GUI application, but the implementation
;         somehow need fixing...
;_________________________________________________________________________________________

uglobal
  if used hInstance
    hInstance dd ?
  end if
endg


proc TApplication.Create, .obj
begin
        push    eax ecx edx
        invoke  GetModuleHandle, 0
        mov     [hInstance], eax

        clc
        pop     edx ecx eax
        return
endp



proc TApplication.Get, .obj, .paramID
begin
        clc
        return
endp




proc TApplication.Set, .obj, .paramID, .value
begin
        clc
        return
endp



proc TApplication.SysEventHandler, .obj, .event
begin
        clc
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































Deleted freshlib/gui/Win32/keycodes.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: This file contains scan code values for control keyboard keys.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

keyHomeNumpad  = $47
keyUpNumpad    = $48
keyPgUpNumpad  = $49
keyLeftNumpad  = $4b
key5Numpad     = $4c
keyRightNumpad = $4d
keyEndNumpad   = $4f
keyDownNumpad  = $50
keyPgDnNumpad  = $51
keyInsNumpad   = $52
keyDelNumpad   = $53
keyEnterNumpad = $1c    ; it is ASCII $0d
keyPlusNumpad  = $4e
keyMinusNumpad = $4a
keyAsteriskNumpad = $37
keySlashNumpad = $35

keyNumLock     = $45
keyScrollLock  = $46
keyPause       = $45
keyPrtScr      = $37


keyLeft =  $4b
keyRight = $4d
keyUp    = $48
keyDown  = $50

keyInsert  = $52
keyDelete  = $53
keyHome    = $47
keyEnd     = $4f
keyPgUp    = $49
keyPgDown  = $51

keyF1   =  $3b
keyF2   =  $3c
keyF3   =  $3d
keyF4   =  $3e

keyF5   =  $3f
keyF6   =  $40
keyF7   =  $41
keyF8   =  $42

keyF9   =  $43
keyF10  =  $44 ; used for menu and does not generate WM_KEYDOWN.
keyF11  =  $57
keyF12  =  $58

keyCapsLock   = $3a
keyShiftLeft  = $2a
keyCtrlLeft   = $1d
keyWndLeft    = $5b
keyWndRight   = $5c
keyAltLeft    = $38
keyAltRight   = $38
keyPopupMenu  = $5d
keyShiftRight = $36
keyCtrlRight  = $1d

keyBackSpace  = $0e

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































Deleted freshlib/gui/Win32/mouse.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Provides unified access to standard mouse cursors.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

; ToDo: Arbitrary mouse cursors, B&W for the begining.


proc SetMouseCursor, .hCursor
begin
        push    ecx edx
        invoke  SetCursor, [.hCursor]
        pop     edx ecx
        return
endp



proc GetStockCursor, .index
begin
        push    ecx edx
        mov     eax, [.index]
        and     eax, 7
        movzx   eax, [_cursors+2*eax]
        invoke  LoadCursor, 0, eax
        pop     edx ecx
        return
endp

if used _cursors
  _cursors dw IDC_ARROW, IDC_IBEAM, IDC_CROSS, IDC_SIZEWE, IDC_SIZENS, IDC_SIZENWSE, IDC_SIZENESW, IDC_WAIT
end if



proc MouseCapture, .hwnd
begin
        push    eax ecx edx
        cmp     [.hwnd], 0
        je      .release

        invoke  SetCapture, [.hwnd]

.finish:
        pop     edx ecx eax
        return

.release:
        invoke  ReleaseCapture
        jmp     .finish
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































Deleted freshlib/gui/Win32/windows.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Window management OS interface functions.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

iglobal
if used cWindowClassName
  cWindowClassName du 'FreshWin', 0
end if
endg

nWindowExtraBytes = 32
ofsWindowStruct = nWindowExtraBytes - 4

;_________________________________________________________________________________________
;
; Registers common window class
; Call only once
;_________________________________________________________________________________________

if used _CreateNullWindow
initialize __RegisterWindowClass

.wc WNDCLASS

begin
        xor     eax, eax
        lea     edi, [.wc]
        mov     ecx, sizeof.WNDCLASS / 4
        rep stosd

        mov     [.wc.style], CS_OWNDC or CS_DBLCLKS; or CS_VREDRAW or CS_HREDRAW
        mov     [.wc.lpfnWndProc], __CommonWindowProc
        mov     [.wc.cbWndExtra], nWindowExtraBytes

;        invoke  CreateSolidBrush, $0000ff
;        mov     [.wc.hbrBackground], eax

        mov     eax,[hInstance]
        mov     [.wc.hInstance],eax
        mov     [.wc.lpszClassName], cWindowClassName

        lea     eax, [.wc]
        invoke  RegisterClass, eax

        return
endp
end if



;_________________________________________________________________________________________


proc _CreateNullWindow
begin
        push    ecx edx
        invoke  CreateWindowEx, 0, cWindowClassName, 0, WS_CLIPSIBLINGS or WS_CLIPCHILDREN, 0, 0, 0, 0, 0, 0, 0, 0
        pop     edx ecx
        return
endp

;_________________________________________________________________________________________



proc _DestroyWindow, .hwnd
begin
        push    eax ecx edx
        invoke  DestroyWindow, [.hwnd]
        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________


proc _GetParent, .hwnd
begin
        push    ecx edx
        invoke  GetParent, [.hwnd]
        pop     edx ecx
        return
endp

;_________________________________________________________________________________________


proc _GetChildren, .hwnd
begin
        push    ebx ecx edx

        xor     ebx, ebx

        invoke  GetWindow, [.hwnd], GW_CHILD
        mov     ecx, eax
        jecxz   .endchildren

        stdcall CreateArray, sizeof.TWinArrayItem
        mov     ebx, eax

.loophwnd:
        stdcall AddArrayItems, ebx, 1
        mov     ebx, edx

        mov     [eax+TWinArrayItem.handle], ecx

        invoke  GetWindow, ecx, GW_HWNDNEXT
        mov     ecx, eax
        jecxz   .endchildren
        jmp     .loophwnd

.endchildren:
        mov     eax, ebx
        pop     edx ecx ebx
        return
endp


;_________________________________________________________________________________________



proc _GetVisible, .hwnd
begin
        push    ecx edx
        invoke  IsWindowVisible, [.hwnd]
        pop     edx ecx
        return
endp

;_________________________________________________________________________________________


proc _GetWindowBounds, .hwnd, .pBounds
begin
        push    eax ecx edx

        invoke  GetClientRect, [.hwnd], [.pBounds]
        invoke  GetParent, [.hwnd]
        invoke  MapWindowPoints, [.hwnd], eax, [.pBounds], 2

        mov     edx, [.pBounds]
        mov     eax, [edx+TBounds.width]
        mov     ecx, [edx+TBounds.height]
        sub     eax, [edx+TBounds.x]
        sub     ecx, [edx+TBounds.y]
        mov     [edx+TBounds.width], eax
        mov     [edx+TBounds.height], ecx

        pop     edx ecx eax
        return
endp



;_________________________________________________________________________________________


proc _SetWindowBounds, .hwnd, .pBounds
.rect RECT
begin
        push    eax ecx edx

        mov     eax, [.pBounds]
        push    [eax+TBounds.width] [eax+TBounds.height]
        pop     [.rect.bottom] [.rect.right]
        mov     [.rect.left], 0
        mov     [.rect.top], 0

        invoke  GetWindowLong, [.hwnd], GWL_EXSTYLE
        push    eax
        push    FALSE
        invoke  GetWindowLong, [.hwnd], GWL_STYLE
        push    eax

        lea     eax, [.rect]
        invoke  AdjustWindowRectEx, eax ; and from the stack

        mov     eax, [.rect.right]
        mov     ecx, [.rect.bottom]
        sub     eax, [.rect.left]
        sub     ecx, [.rect.top]

        mov     edx, [.pBounds]
        invoke  SetWindowPos, [.hwnd], 0, [edx+TBounds.x], [edx+TBounds.y], eax, ecx, SWP_NOZORDER or SWP_NOREDRAW

        pop     edx ecx eax
        return
endp





;_________________________________________________________________________________________
wsNoneWindowBorder = WS_POPUP
wsFullWindowBorder = WS_BORDER or WS_CAPTION or WS_SYSMENU or WS_SIZEBOX or WS_MINIMIZEBOX or WS_MAXIMIZEBOX
wsModalWindowBorder  = WS_CAPTION or WS_DLGFRAME or WS_SYSMENU
wsToolboxWindowBorder = WS_BORDER or WS_CAPTION or WS_SYSMENU or WS_SIZEBOX

wsAllWindowBorder = wsNoneWindowBorder or wsFullWindowBorder or wsModalWindowBorder or wsToolboxWindowBorder

proc _SetWindowBorder, .hwnd, .brdType
.bounds TBounds
begin
        push    eax ebx ecx edx esi

        invoke  GetWindowLong, [.hwnd], GWL_STYLE
        mov     ebx, eax

        mov     esi, [.brdType]
        and     esi, 3

        invoke  SetWindowLong, [.hwnd], GWL_EXSTYLE, [.exstyles+4*esi]

        and     ebx, not wsAllWindowBorder
        or      ebx, [.styles+4*esi]
        invoke  SetWindowLong, [.hwnd], GWL_STYLE, ebx

        lea     esi, [.bounds]
        stdcall _GetWindowBounds, [.hwnd], esi
        stdcall _SetWindowBounds, [.hwnd], esi

        pop     esi edx ecx ebx eax
        return

.styles dd wsNoneWindowBorder
        dd wsFullWindowBorder
        dd wsModalWindowBorder
        dd wsToolboxWindowBorder

.exstyles dd 0
          dd WS_EX_APPWINDOW
          dd WS_EX_DLGMODALFRAME
          dd WS_EX_TOOLWINDOW

endp

;_________________________________________________________________________________________

proc _ShowWindow, .hwnd, .flag
begin
        push    eax ecx edx
        invoke  ShowWindow, [.hwnd], [.flag]
        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________


proc _RefreshWindow, .hwnd
.rect RECT
begin
        push    eax ecx edx

;        lea     eax, [.rect]
;        invoke  GetClientRect, [.hwnd], eax
;        lea     eax, [.rect]
        invoke  InvalidateRect, [.hwnd], 0, FALSE

        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________


proc _SetFocus, .hwnd
begin
        push    eax ecx edx

        invoke  SetFocus, [.hwnd]

        pop     edx ecx eax
        return
endp

;_________________________________________________________________________________________

proc _AddChild, .hwnd, .child
begin
        push    eax ecx edx

        invoke  GetWindowLong, [.child], GWL_STYLE
        or      eax, WS_CHILD
        and     eax, not (WS_DLGFRAME or WS_BORDER)
        invoke  SetWindowLong, [.child], GWL_STYLE, eax
        invoke  SetParent, [.child], [.hwnd]

        pop     edx ecx eax
        return
endp

;_________________________________________________________________________________________


; Common utility procedures.


;_________________________________________________________________________________________
;
; Returns the window TObject structure, from the window handle.
;_________________________________________________________________________________________

proc _GetWindowStruct, .hwin
begin
        push    ecx edx
        invoke  GetWindowLong, [.hwin], ofsWindowStruct
        pop     edx ecx
        return
endp



;_________________________________________________________________________________________



proc _SetWindowStruct, .hwin, .value
begin
        push    eax ecx edx
        invoke  SetWindowLong, [.hwin], ofsWindowStruct, [.value]
        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________



proc _SetWindowTextUtf8, .hwnd, .ptrUtf8
.pwc dd ?
.charlen dd ?
begin
        stdcall StrLen, [.ptrUtf8]
        lea     ecx, [eax*4]

        stdcall GetMem, ecx
        mov     [.pwc], eax

        invoke  MultiByteToWideChar, CP_UTF8, 0, [.ptrUtf8], -1, [.pwc], ecx
        mov     [.charlen], eax

        invoke  SendMessage, [.hwnd], WM_SETTEXT, 0, [.pwc]
        stdcall FreeMem, [.pwc]
        return
endp



;_________________________________________________________________________________________



proc _GetWindowTextUtf8, .hwnd, .ptrUtf8
.pwc dd ?
.charlen dd ?
begin
        push    ebx ecx edx edi
        stdcall StrNew
        mov     ebx, eax

        invoke  SendMessage, [.hwnd], WM_GETTEXTLENGTH, 0, 0
        mov     [.charlen], eax
        lea     ecx, [eax*4]

        stdcall StrSetCapacity, ebx, ecx
        mov     edi, eax

        stdcall GetMem, ecx
        mov     [.pwc], eax

        invoke  SendMessage, [.hwnd], WM_GETTEXT, [.charlen], [.pwc]
        invoke  WideCharToMultiByte, CP_UTF8, 0, [.pwc], -1, edi, [edi+string.capacity], 0, 0
        stdcall FreeMem, [.pwc]
        stdcall StrFixLen, ebx
        mov     eax, ebx
        pop     edi edx ecx ebx
        return
endp



;_________________________________________________________________________________________


proc _EnableWindow, .hwnd, .flag
begin
        push    eax ecx edx
        invoke  EnableWindow, [.hwnd], [.flag]
        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________


proc _SetModalTowards, .hwnd, .hwndParent
begin
        push    eax ecx edx
        stdcall _SetWindowBorder, [.hwnd], borderModal
        invoke  SetWindowLong, [.hwnd], GWL_HWNDPARENT, [.hwndParent]

        pop     edx ecx eax
        return
endp


;_________________________________________________________________________________________


proc _FinalizeModal, .hwnd, .hwndParent
begin
        return
endp


;_________________________________________________________________________________________


proc __CommonWindowProc, .hwnd, .wmsg, .wparam, .lparam
begin
        stdcall __ProcessOneSystemEvent, [.hwnd], [.wmsg], [.wparam], [.lparam]         ; sometimes windows calls winproc directly instead of using postmessage.
        jnc     .finish

        invoke  DefWindowProc, [.hwnd], [.wmsg], [.wparam], [.lparam]

.finish:
        return
endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/all.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: All GUI libraries combined include.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Includes all GUI libraries at once.
;_________________________________________________________________________________________

AlignLeft   = 0
AlignRight  = 1
AlignTop    = 2
AlignBottom = 3

include 'sysevents.asm'

; includes OS specific utility procedures, data, etc.
include 'progutils.asm'

include 'mouse.asm'
include 'textcaret.asm'

; OS independent support code
include 'objects.asm'
include 'TAction.asm'

; OS independent template engine.
include 'ObjTemplates.asm'

; OS independent components
include 'TObject.asm'
include 'TWindow.asm'
include 'TScrollWindow.asm'

include 'TApplication.asm'
include 'TForm.asm'
include 'TButton.asm'
include 'TEdit.asm'
include 'TLabel.asm'
include 'TImageLabel.asm'
include 'TMenuItem.asm'
include 'TMenu.asm'
include 'TProgressbar.asm'
include 'TTreeView.asm'

include 'ThemeGUI.asm'

include 'dialogs.asm'

; OS independent main procedures.
include 'Main.asm'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































Deleted freshlib/gui/dialogs.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Common dialogs procedures library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________
module "Common dialogs library"


iglobal
   getfile _DlgIconError,       '%lib%/gui/images/error.gif'
   getfile _DlgIconInformation, '%lib%/gui/images/information.gif'
   getfile _DlgIconQuestion,    '%lib%/gui/images/question.gif'
   getfile _DlgIconWarning,     '%lib%/gui/images/warning.gif'
   getfile _DlgMaskDialogIcons, '%lib%/gui/images/icon_mask.gif'

   if used _CommonDialogTemplate
    _CommonDialogTemplate:
        ObjTemplate  tfParent or tfEnd, Form, frmCommonDialog, x, 200, y, 100, width, 480, height, 100
           ObjTemplate tfChild, ImageLabel, .imgIcon,  x, 4, y, 4, width, 50, height, 50, Visible, TRUE, ImageAlign, iaCenter or iaMiddle
           ObjTemplate tfChild, Label,  .LblText,   x,58, y, 4, width, 10, height, 10, TextAlign, dtfAlignLeft or dtfAlignMiddle or dtfWordWrap or dtfCRLF, Visible, TRUE

           ObjTemplate tfChild, Button, .btnOK,     x, 0, y, 0, width, 64, height, 24, TextAlign, dtfAlignCenter  or dtfAlignMiddle, Caption, 'OK',     ModalResult, mrOK
           ObjTemplate tfChild, Button, .btnCancel, x, 0, y, 0, width, 64, height, 24, TextAlign, dtfAlignCenter  or dtfAlignMiddle, Caption, 'Cancel', ModalResult, mrCancel
           ObjTemplate tfChild, Button, .btnAbort,  x, 0, y, 0, width, 64, height, 24, TextAlign, dtfAlignCenter  or dtfAlignMiddle, Caption, 'Abort',  ModalResult, mrAbort
           ObjTemplate tfChild, Button, .btnRetry,  x, 0, y, 0, width, 64, height, 24, TextAlign, dtfAlignCenter  or dtfAlignMiddle, Caption, 'Retry',  ModalResult, mrRetry
           ObjTemplate tfChild, Button, .btnIgnore, x, 0, y, 0, width, 64, height, 24, TextAlign, dtfAlignCenter  or dtfAlignMiddle, Caption, 'Ignore', ModalResult, mrIgnore
           ObjTemplate tfChild, Button, .btnYes,    x, 0, y, 0, width, 64, height, 24, TextAlign, dtfAlignCenter  or dtfAlignMiddle, Caption, 'Yes',    ModalResult, mrYes
           ObjTemplate tfChild, Button, .btnNo,     x, 0, y, 0, width, 64, height, 24, TextAlign, dtfAlignCenter  or dtfAlignMiddle, Caption, 'No',     ModalResult, mrNo
           ObjTemplate tfChild, Button, .btnMaybe,  x, 0, y, 0, width, 64, height, 24, TextAlign, dtfAlignCenter  or dtfAlignMiddle, Caption, 'Maybe',  ModalResult, mrMaybe
           ObjTemplate tfEnd,   Button, .btnHelp,   x, 0, y, 0, width, 64, height, 24, TextAlign, dtfAlignCenter  or dtfAlignMiddle, Caption, 'Help',   ModalResult, mrNone
   end if
endg


; buttons flags used:
smbOK     = $01
smbCancel = $02
smbAbort  = $04
smbRetry  = $08
smbIgnore = $10
smbYes    = $20
smbNo     = $40
smbMaybe  = $80
smbHelp   = $100
smbMaxButton = smbHelp

smiError       = 0
smiInformation = 1
smiQuestion    = 2
smiWarning     = 3



proc ShowMessage, .parent, .icon, .hTitle, .hMessage, .maskButtons
.xrow dd ?
.yrow dd ?
.hicon dd ?
.hmask dd ?
begin
        push    ebx ecx edx esi
        stdcall CreateFromTemplate, _CommonDialogTemplate, 0

; First set the position and size of the dialog box, depending on the flags, and the size of the message.



; Set the message text:
        stdcall Set, [frmCommonDialog.LblText], TLabel.Caption, [.hMessage]

; Set the message title:
        stdcall  Set, ebx, TForm.Caption, [.hTitle]

; arrange the buttons
        mov     eax, [.maskButtons]
        mov     ecx, 32
        xor     edx, edx
.count:
        rol     eax, 1
        adc     edx, 0
        loop    .count

        mov     ecx, edx
        imul    edx, 64         ; button width
        jecxz   @f
        dec     ecx
        imul    ecx, 16
@@:
        add     edx, ecx        ; edx contains the width of the button row in pixels.

        stdcall Get, ebx, TForm.width
        cmp     eax, edx
        jge     .widthok

        lea     eax, [edx+32]
        stdcall Set, ebx, TForm.width, eax

.widthok:
        sub     eax, edx
        sar     eax, 1  ; eax is the begin X coordinate of the row
        mov     [.xrow], eax

        stdcall Get, ebx, TForm.height
        sub     eax, 24+8
        mov     [.yrow], eax

        mov     edx, .btnTable
        mov     ecx, $1

.btnLoop:
        test    [.maskButtons], ecx
        jz      @f

        mov     esi, [edx]
        stdcall Set, [esi], TButton.x, [.xrow]
        stdcall Set, [esi], TButton.y, [.yrow]
        stdcall Set, [esi], TButton.Visible, TRUE
        add     [.xrow], 64+16

@@:
        add     edx, 4
        shl     ecx, 1
        cmp     ecx, smbMaxButton
        jbe     .btnLoop

; set the icon
        mov     eax, [.icon]
        cmp     eax, .iconCount
        jb      @f
        xor     eax, eax
@@:
        stdcall CreateImageGIF, [.iconTable+4*eax], [.iconSizes+4*eax]
        OutputRegister regEAX, 16
        mov     [.hicon], eax
        stdcall Set, [frmCommonDialog.imgIcon], TImageLabel.Image, eax

        stdcall CreateImageGIF, _DlgMaskDialogIcons, _DlgMaskDialogIcons.size
        OutputRegister regEAX, 16
        mov     [.hmask], eax
        stdcall Set, [frmCommonDialog.imgIcon], TImageLabel.Mask, eax

; set the text position and size.
        mov     ecx, [.yrow]
        sub     ecx, 8
        stdcall Set, [frmCommonDialog.LblText], TLabel.height, ecx
        stdcall Set, [frmCommonDialog.imgIcon], TImageLabel.height, ecx

        stdcall Get, [frmCommonDialog], TForm.width
        sub     eax, 66
        stdcall Set, [frmCommonDialog.LblText], TLabel.width, eax

        stdcall ShowModal, ebx, [.parent]
        stdcall Destroy, ebx
        stdcall DestroyImage, [.hicon]
        stdcall DestroyImage, [.hmask]

        pop     esi edx ecx ebx
        return

.btnTable dd frmCommonDialog.btnOK,     \
             frmCommonDialog.btnCancel, \
             frmCommonDialog.btnAbort,  \
             frmCommonDialog.btnRetry,  \
             frmCommonDialog.btnIgnore, \
             frmCommonDialog.btnYes,    \
             frmCommonDialog.btnNo,     \
             frmCommonDialog.btnMaybe,  \
             frmCommonDialog.btnHelp

.iconTable dd _DlgIconError, _DlgIconInformation, _DlgIconQuestion, _DlgIconWarning
.iconCount = ($ - .iconTable)/4
.iconSizes dd _DlgIconError.size, _DlgIconInformation.size, _DlgIconQuestion.size, _DlgIconWarning.size

endp


proc InputString, .parent
begin


        return
endp






endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































Deleted freshlib/gui/images/error.gif.

cannot compute difference between binary files

Deleted freshlib/gui/images/icon_mask.gif.

cannot compute difference between binary files

Deleted freshlib/gui/images/information.gif.

cannot compute difference between binary files

Deleted freshlib/gui/images/question.gif.

cannot compute difference between binary files

Deleted freshlib/gui/images/theme_rhomb/Icons.odg.

cannot compute difference between binary files

Deleted freshlib/gui/images/theme_rhomb/myown/error.gif.

cannot compute difference between binary files

Deleted freshlib/gui/images/theme_rhomb/myown/information.gif.

cannot compute difference between binary files

Deleted freshlib/gui/images/theme_rhomb/myown/mask.gif.

cannot compute difference between binary files

Deleted freshlib/gui/images/theme_rhomb/myown/question.gif.

cannot compute difference between binary files

Deleted freshlib/gui/images/theme_rhomb/myown/warning.gif.

cannot compute difference between binary files

Deleted freshlib/gui/images/warning.gif.

cannot compute difference between binary files

Deleted freshlib/gui/mouse.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Provides unified access to standard mouse cursors.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: This file contains OS independent part and includes OS dependent files.
;_________________________________________________________________________________________
module "Mouse library"

mcArrow = 0
mcText  = 1
mcCross = 2
mcSizeH = 3
mcSizeV = 4
mcSizeUL_LR = 5
mcSizeLL_UR = 6
mcWait      = 7

mcCount = 8

include '%TargetOS%/mouse.asm'

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































Deleted freshlib/gui/objects.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Contains the base procedures for the FreshLib OOP framework
;
;  Target OS: Any
;
;  Dependencies: memory.asm
;
;  Notes:
;
;  TODO: Thread safety! The whole FreshLib should be thread safe. GUI part,as long as
;        uses memory objects should be thread safe. This can be achieved by locking
;        objects, during processing. objects.asm is the proper place for such lock mechanism.
;        The lock should be provided by some kind of mutex objects, associated with the objects.
;
;_________________________________________________________________________________________
module "Objects library"

struct TObjectClass
  .ptrParent        dd 0   ; pointer to the parent TObjectClass
  .dataSize         dd 0   ; size of TObject structure.
  .procCreate       dd 0
  .procDestroy      dd 0
  .procGetParam     dd 0
  .procSetParam     dd 0
  .procExecCmd      dd 0   ; executes method in chain.
  .procSysEventHandler dd 0
ends



macro ObjectClass name*, parent*, procCreate*, procDestroy*, procGetParam*, procSetParam*,  procExecCmd*, procSysEvents* {
  if used C#name
    C#name TObjectClass
    store dword C#parent at C#name#.ptrParent
    store dword sizeof.T#name at C#name#.dataSize
    store dword procCreate at C#name#.procCreate
    store dword procDestroy at C#name#.procDestroy
    store dword procGetParam at C#name#.procGetParam
    store dword procSetParam at C#name#.procSetParam
    store dword procExecCmd at C#name#.procExecCmd
    store dword procSysEvents at C#name#.procSysEventHandler
  end if
}


CRoot = 0


maskParameter = $80000000
Sequence param, maskParameter


macro method name*, [arg] {
common
 local ..argcount
 ..argcount = 0
   param name
 forward
   if ~arg eq
   ..argcount = ..argcount + 1
   end if
 common
   name#.argcount = ..argcount
}


macro execute obj*, meth*, [arg] {
reverse
  if ~arg eq
    pushd arg
  end if
common
  pushd meth#.argcount
  pushd meth
  pushd obj
  call  __Exec
}


macro object name*, parent {
  macro name@object \{ name name \}
  macro size@object \{ sizeof.#name = $ \}
  struc name \{
    param.current = maskParameter
    if ~parent eq
      . parent
    end if
}

endobj fix } obj_helper

macro obj_helper {
  virtual at 0
    name@object
    size@object
  end virtual
  purge name@object
  purge size@object
}


mxTimeout = 1000        ; 1s timeout for the access mutex objects.

; common object procedures
; These procedures work with every TObject descendent object type.


;_________________________________________________________________________________________
;
; proc Create, .class - creates an instance from the given class.
;
; Arguments:
;   .class - pointer to TObjectClass structure for needed object.
;
; Returns:
;   ebx = pointer to the instance of the object.
;
; This procedure calls procCreate for the given object class and all
; parent classes in reverce order.
;_________________________________________________________________________________________

proc Create, .class
begin
        push    eax ecx

        mov     ecx, [.class]
        stdcall GetMem, [ecx+TObjectClass.dataSize]
        mov     ebx, eax
        mov     [eax+TObject.ptrClass], ecx

        lea     eax, [eax+TObject.mxAccess]
        stdcall MutexCreate, 0, eax

        push    0

.loop:
        cmp     [ecx+TObjectClass.procCreate], 0
        je      .parent

        push    [ecx+TObjectClass.procCreate]

.parent:
        mov     ecx, [ecx+TObjectClass.ptrParent]
        test    ecx, ecx
        jnz     .loop

.loop2:
        pop     ecx
        jecxz   .endcreate

        push    ebx
        stdcall ecx, ebx
        pop     ebx
        jmp     .loop2

.endcreate:
        lea     eax, [ebx+TObject.mxAccess]
        stdcall MutexRelease, eax
        pop     ecx eax
        return
endp



;_________________________________________________________________________________________
;
; proc Destroy, .obj - destroys the object instance.
;
; Arguments:
;   .obj - pointer to TObject descendent object.
;
; Returns:
;   nothing.
;
; This procedure calls procDestroy for the given object class and all
; parent classes. Note that the memory is freed only by the last
; destroy handled from CObject class.
;_________________________________________________________________________________________

proc Destroy, .obj
begin
        push    eax ebx

        mov     ebx, [.obj]
        test    ebx, ebx
        jz      .error

        stdcall _LockObject, [.obj]

        mov     ebx, [ebx+TObject.ptrClass]

.loop:
        cmp     [ebx+TObjectClass.procDestroy], 0
        je      .parent

        mov      eax, [ebx+TObjectClass.procDestroy]

        push    ebx
        stdcall [ebx+TObjectClass.procDestroy], [.obj]
        pop     ebx

.parent:
        mov     ebx, [ebx+TObjectClass.ptrParent]
        test    ebx, ebx
        jnz     .loop

        mov     ebx, [.obj]
        lea     eax, [ebx+TObject.mxAccess]

        mov     ebx, [ebx+TObject.ptrVar]
        test    ebx, ebx
        jz      @f
        mov     dword [ebx], 0
@@:
        stdcall MutexDestroy, eax
        stdcall FreeMem, [.obj]
        clc
        pop     ebx eax
        return

.error:
        stdcall _UnlockObject, [.obj]
        stc
        pop     ebx eax
        return
endp




;_________________________________________________________________________________________
;
; proc Get, .obj, .paramID - returns the value of given parameter
;
; Arguments:
;   .obj - pointer to TObject descendent object.
;   .paramID - ID number of the parameter being read.
; Returns:
;   CF=0; eax = parameter value.
;   CF=1; the parameter is unknown and can not be retrived.
;
; This procedure calls procGet for the given object class and
; if the procedure returns CF=1; tries to call the parents procedure
; procGet, until the value is retrived, or the root level of inheritance
; is reached.
;_________________________________________________________________________________________

proc Get, .obj, .paramID
begin
        push    ecx


        stdcall _LockObject, [.obj]

        mov     ecx, [.obj]
.loop0:
        stc
        jecxz   .finish

.loop:
        mov     ecx, [ecx]      ; TObject.ptrClass = TObjectClass.ptrParent = 0
        jecxz   .finish

        cmp     [ecx+TObjectClass.procGetParam], 0
        je      .loop0

        push    ecx
        stdcall [ecx+TObjectClass.procGetParam], [.obj], [.paramID]
        pop     ecx
        jc      .loop

.finish:
        stdcall _UnlockObject, [.obj]
        pop     ecx
        return
endp



;_________________________________________________________________________________________
;
; proc Set, .obj, .paramID - sets the value of given parameter
;
; Arguments:
;   .obj - pointer to TObject descendent object.
;   .paramID - ID number of the parameter being read.
;   .value   - value of the parameter that should be set.
; Returns:
;   CF=0 - the value is successfully set.
;   CF=1; the value is not set, because the parameter is unknown.
;
; This procedure calls procSet for the given object class and
; if the procedure returns CF=1; tries to call the parents procedures
; procSet, until the value is set, or the root level of inheritance
; is reached.
;_________________________________________________________________________________________

proc Set, .obj, .paramID, .value
begin
        push    ecx

        stdcall _LockObject, [.obj]
        mov     ecx, [.obj]
.loop0:
        stc
        jecxz   .finish

.loop:
        mov     ecx, [ecx]      ; TObject.ptrClass = TObjectClass.ptrParent = 0
        jecxz   .finish

        cmp     [ecx+TObjectClass.procSetParam], 0
        je      .loop0

        push    ecx
        stdcall [ecx+TObjectClass.procSetParam], [.obj], [.paramID], [.value]
        pop     ecx
        jc      .loop

.finish:
        stdcall _UnlockObject, [.obj]
        pop     ecx
        return
endp





;_________________________________________________________________________________________
;
; proc ExecEvent, .obj, .event
; Arguments:
;   .obj - pointer to the TObject descendent object.
;   .event - pointer to TSysEvent descendent structure.
;_________________________________________________________________________________________

proc ExecEvent, .obj, .event
begin
        push    ecx

        stdcall _LockObject, [.obj]
        mov     ecx, [.obj]
.loop0:
        stc
        jecxz   .finish

.loop:
        mov     ecx, [ecx]      ; TObject.ptrClass = TObjectClass.ptrParent = 0
        jecxz   .finish

        cmp     [ecx+TObjectClass.procSysEventHandler], 0
        je      .loop0

        push    ecx
        stdcall [ecx+TObjectClass.procSysEventHandler], [.obj], [.event]
        pop     ecx
        jc      .loop

.finish:
        stdcall _UnlockObject, [.obj]
        pop     ecx
        return
endp




;_________________________________________________________________________________________
;
; proc IsObject, .class - returns CF=0 if the given object belongs to
;                         the given class. Else returns CF=1
;_________________________________________________________________________________________
proc IsObject   ; , .obj, .class
virtual at esp+8
  .obj dd ?
  .class dd ?
end virtual
begin
        push    ecx
        lea     ecx, [.obj]

.loop:
        stc
        mov     ecx, [ecx]      ; TObject.ptrClass = TObjectClass.ptrParent = 0
        jecxz   .finish

        cmp     ecx, [.class]   ; the first cmp will always fail because ecx contains pointer to obj that can't be equal to a class.
        jne     .loop

.finish:
        pop     ecx
        retn 8
endp



;_________________________________________________________________________________________
;
; Executes a method of given class.
; This procedure have arbitrary count of arguments
; it calls in chain procExecCmd the classes and passes
; a pointer to the arguments in esi.
; It first calls the procExecCmd of the childs and then of the parents.
; If some class have 0 in [procExecCmd] this class is skiped and
; the execution continues on its parent.
; If there is no proper handler back to the root, then the procedure
; returns CF=1
;_________________________________________________________________________________________

proc __Exec ;, .obj, .method, .argcount, ..
begin
virtual at ebp+8
  .obj dd ?
  .method dd ?
  .argcount dd ?
  .arguments:
end virtual
        push    ebp
        mov     ebp, esp        ; now ebp+8 points to the arguments.

        push    ecx ebx

        xor     ebx, ebx
        cmp     [.argcount], 0
        je      @f
        lea     ebx, [.arguments]
@@:
        mov     ecx, [.obj]

.loop0:
        stc
        jecxz   .exit

.loop:
        mov     ecx, [ecx]      ; TObject.ptrClass = TObjectClass.ptrParent = 0
        jecxz   .exit

        cmp     [ecx+TObjectClass.procExecCmd], 0
        je      .loop0

        push    ecx ebx
        stdcall [ecx+TObjectClass.procExecCmd], [.obj], [.method]
        pop     ebx ecx
        jc      .loop

.exit:
        pop     ebx ecx

        ; experimental return from procedure with arbitrary count of arguments.
        ; with keeping all registers unchanged.
        mov     esp, ebp
        push    ecx
        mov     ebp, [.argcount]
        lea     ebp, [esp+8+4*ebp+12]      ; the place where the return address should be placed. (Exec have 3 more arguments, including .argcount)
        mov     ecx, [esp+8]               ; return address
        mov     [ebp], ecx                 ; move the return address to the proper place.
        pop     ecx                        ; restore ecx
        pop     esp                        ; old value of ebp
        xchg    esp, ebp                   ; restore ebp and set esp to the proper value
        retn
endp




proc _LockObject, .obj
begin
        push    eax

        mov     eax, [.obj]
        lea     eax, [eax+TObject.mxAccess]
        stdcall WaitForMutex, eax, mxTimeout
        jc      .stop

        pop     eax
        return

.stop:
        int3
        pop     eax
        return

endp




proc _UnlockObject, .obj
begin
        pushf
        push    eax

        mov     eax, [.obj]
        lea     eax, [eax+TObject.mxAccess]
        stdcall MutexRelease, eax

        pop     eax
        popf
        return
endp





endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/progutils.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Common OS independent programming utilities.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________
module "Programming utilities"

macro JumpList [id, target] {
  forward
        dw id, target - $ - 2
  common
        dd 0
}

macro JumpTable [id, target] {
if ~ msg eq
      call JumpTo
      JumpList msg, target
end if
}


;------------------------------------------------------
; proc JumpTo
; Searches for the message in the message table.
; Arguments:
;   ebx - message number to search in the table.
; Returns:
;   This procedure doesn't returns. It simply
;   jumps to the address from table or imediately
;   after the table if the message is not found.
;   in both cases esi = eip
; Changes:
;   eax, ecx
;------------------------------------------------------
proc JumpTo
begin
        pop     ecx             ; get table address, remove return address from the stack and save the value of esi.
.loop:
        mov     eax, [ecx]
        lea     ecx, [ecx+4]
        test    eax,eax
        jz      .exit

        cmp     bx, ax
        jne     .loop

        sar     eax, 16
        add     ecx, eax
.exit:
        jmp     ecx
endp

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































Deleted freshlib/gui/sysevents.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Defines constants and structures for system events of FreshLib
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________
module "System events library"

seMouseMove        = $0001
seMouseEnter       = $0002
seMouseLeave       = $0003
seMouseBtnPress    = $0004
seMouseBtnRelease  = $0005
seMouseBtnClick    = $0006
seMouseBtnDblClick = $0007
seTimer            = $0008
seKbdKeyPress      = $0009
seKbdKeyRelease    = $000a
seKbdStatusChanged = $000b
seKbdChar          = $000c

seScroll           = $000d


sePaint            = $0100
seCloseRequest     = $0101

seFocusIn          = $0102
seFocusOut         = $0103

seMoveResize       = $0104


struct TSysEvent
  .event  dd  ?
ends


struct TMouseMoveEvent
  . TSysEvent
  .x         dd ?
  .y         dd ?
ends

mbLeft   = 0
mbMiddle = 1
mbRight  = 2

maskBtnLeft   = $0100
maskBtnMiddle = $0200
maskBtnRight  = $0400
maskShift     = $1
maskCapsLock  = $2
maskCtrl      = $4
maskAlt       = $8
maskScrLk     = $10


struct TMouseButtonEvent
  . TSysEvent
  .Button    dd ?
  .kbdStatus dd ?
  .x         dd ?   ; coordinates of the mouse pointer in the client
  .y         dd ?
ends


struct TMouseEnterEvent
  . TSysEvent
ends


; These are scan codes for the non character keys. They are OS dependent and should be used by
; their names.
include '%TargetOS%/keycodes.inc'


struct TKeyboardEvent
  . TSysEvent
  .key       dd  ?      ; 1..4 bytes UTF-8 character typed by the keyboard, or 0 if non character key is pressed/released.
  .scancode  dd  ?      ; scan code of the pressed key.
  .kbdStatus dd  ?      ; same as mouse button event - contains mouse buttons and Ctrl, Shift and Alt keys status.
ends


scTrack   = 1
scUp      = 2
scDown    = 3
scWheelUp = 4
scWheelDn = 5

scrollX = 0
scrollY = 1


struct TScrollEvent
  . TSysEvent
  .ScrollBar  dd ?      ; 0
  .ScrollCmd  dd ?      ;
  .Value      dd ?      ; Distance for scUp and scDown and position for scTrack
ends


struct TTimerEvent
  . TSysEvent
  .timer dd ?
ends


struct TPaintEvent
  . TSysEvent

  .context dd ?  ; pointer to TContext structure, properly initialized.
  .rect   RECT
ends


struct TCloseEvent
  . TSysEvent
  .reason dd ?          ; how the close was requested?
ends

cerFromUser = 0         ; user pressed X button on the window header, pressed alt+F4 from the keyboard, or choose "Close" from the title menu.
cerFromProgram = 1      ; Method Close was executed from the program.


struct TFocusInEvent
  . TSysEvent
ends

struct TFocusOutEvent
  . TSysEvent
ends


struct TMoveResizeEvent
  . TSysEvent
  .newX  dd ?
  .newY  dd ?
  .newWidth  dd ?
  .newHeight dd ?
ends



; creates and returns a string with the textual identifier of the pressed/released key.
proc CreateKeyName, .pKeyEvent
begin
        push    ebx ecx esi edi

        stdcall StrDup, .strkey
        mov     ebx, eax

        mov     edi, [.pKeyEvent]
        test    [edi+TKeyboardEvent.kbdStatus], maskCtrl
        jz      @f

        stdcall StrCharCat, ebx, 'Ctrl'
        stdcall StrCharCat, ebx, '+'
@@:
        test    [edi+TKeyboardEvent.kbdStatus], maskAlt
        jz      @f
        stdcall StrCharCat, ebx, 'Alt+'
@@:
        test    [edi+TKeyboardEvent.kbdStatus], maskShift
        jz      @f
        stdcall StrCharCat, ebx, 'Shif'
        stdcall StrCharCat, ebx, 't+'
@@:
        mov     ecx, [edi+TKeyboardEvent.key]
        jecxz   .searchlist

        cmp     ecx, ' '
        jne     @f
        mov     ecx, 'Spc'
@@:
        cmp     ecx, ' '
        jae     @f
        add     ecx, '@'
@@:
        cmp     ecx, 'a'
        jb      @f
        cmp     ecx, 'z'
        ja      @f
        xor     ecx, $20
@@:
        stdcall StrCharCat, ebx, ecx

.exitok:
        mov     eax, ebx
        clc

.finish:
        pop     edi esi ecx ebx
        return

.searchlist:
        mov     esi, __FunctionalKeyNames

.loop:
        movzx   ecx, word [esi]
        jecxz   .notfound
        cmp     ecx, [edi+TKeyboardEvent.scancode]
        je      .found
        add     esi, 4
        jmp     .loop

.found:
        movsx   eax, word [esi+2]
        add     esi, eax
        stdcall StrCat, ebx, esi
        jmp     .exitok

.notfound:
        stdcall StrDel, ebx
        xor     eax, eax
        stc
        jmp     .finish

.strkey db 'key', 0
endp


macro keynames lbl, [scancode, name] {
common
  label lbl word
forward
  local pname
        dw scancode
        dw pname - $ + 2
common
        dw 0
forward
  pname db name, 0
}


iglobal
  if used __FunctionalKeyNames
  keynames  __FunctionalKeyNames,                        \
            keyHomeNumpad,     'Home',                   \
            keyUpNumpad,       'Up',                     \
            keyPgUpNumpad,     'PgUp',                   \
            keyLeftNumpad,     'Left',                   \
            key5Numpad,        'Num5',                   \
            keyRightNumpad,    'Right',                  \
            keyEndNumpad,      'End',                    \
            keyDownNumpad,     'Down',                   \
            keyPgDnNumpad,     'PgDn',                   \
            keyInsNumpad,      'Ins',                    \
            keyDelNumpad,      'Del',                    \
            keyEnterNumpad,    'Enter',                  \
            keyNumLock,        'NumLock',                \
            keyScrollLock,     'ScrLock',                \
            keyPause,          'Pause',                  \
            keyLeft,           'Left',                   \
            keyRight,          'Right',                  \
            keyUp,             'Up',                     \
            keyDown,           'Down',                   \
            keyInsert,         'Ins',                    \
            keyDelete,         'Del',                    \
            keyHome,           'Home',                   \
            keyEnd,            'End',                    \
            keyPgUp,           'PgUp',                   \
            keyPgDown,         'PgDn',                   \
            keyF1,             'F1',                     \
            keyF2,             'F2',                     \
            keyF3,             'F3',                     \
            keyF4,             'F4',                     \
            keyF5,             'F5',                     \
            keyF6,             'F6',                     \
            keyF7,             'F7',                     \
            keyF8,             'F8',                     \
            keyF9,             'F9',                     \
            keyF10,            'F10',                    \
            keyF11,            'F11',                    \
            keyF12,            'F12',                    \
            keyCapsLock,       'CapsLock',               \
            keyShiftLeft,      'ShiftL',                 \
            keyCtrlLeft,       'CtrlL',                  \
            keyAltLeft,        'AltL',                   \
            keyAltRight,       'AltR',                   \
            keyPopupMenu,      'PopupMenu',              \
            keyShiftRight,     'ShiftR',                 \
            keyCtrlRight,      'CtrlR',                  \
            keyBackSpace,      'BackSp'
  end if
endg

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































































































































































































































































































Deleted freshlib/gui/textcaret.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Text caret control library.
;
;  Target OS: Any
;
;  Dependencies: timers.asm; graphics libraries.
;
;  Notes: Text caret have always only one instance.
;_________________________________________________________________________________________
module "Text caret library"

; the caret is shared resource and can exists only in one instance
struct TCaret
  .pWindow   dd ?
  .visible   dd ?
  .state     dd ?       ; 1 if the caret is displayed 0 if not.
  .Pos       TBounds
  .OldPos    TBounds
  .timer     dd ?
  .sync      dd ?
ends



uglobal
  if used CaretAttach
    Caret TCaret
  end if
endg

iglobal
  if used CaretTimes
    CaretTimes dd 200, 300
  end if
endg


if used CaretAttach

initialize InitCaretTimer
begin
        stdcall TimerCreate
        mov     [eax+TTimer.interval], 200
        mov     [eax+TTimer.Callback], __CaretTimerProc
        mov     [eax+TTimer.flags], tmfCallProc
        mov     [Caret.timer], eax
        return
endp


finalize DestroyCaretTimer
begin
        stdcall CaretAttach, 0
        mov     eax, [Caret.timer]
        and     [eax+TTimer.flags], not tmfRunning
        stdcall TimerDestroy, eax
        return
endp

end if


; Attaches the caret to the window, if the window needs caret.
proc CaretAttach, .pWindow
begin
        mov     eax,[.pWindow]
        cmp     eax, [Caret.pWindow]
        je      .exit

        mov     eax, -1
@@:
        xchg    [Caret.sync], eax
        test    eax, eax
        jnz     @b

        stdcall __DrawCaret, 0  ; hide the caret.

        mov     eax, [.pWindow]
        xchg    [Caret.pWindow], eax
        push    eax

        xor     eax, eax
        mov     [Caret.visible], eax
        mov     [Caret.Pos.x], eax
        mov     [Caret.Pos.y], eax
        mov     [Caret.Pos.height], eax
        mov     [Caret.Pos.width], eax

.finish:
        mov     [Caret.sync], 0
        pop     eax     ; the old window.
.exit:
        return
endp




proc CaretChange, .x, .y, .width, .height
begin
        push    eax

        mov     eax, -1
@@:
        xchg    [Caret.sync], eax
        test    eax, eax
        jnz     @b

        stdcall __DrawCaret, 0

        push    [.x] [.y]
        pop     [Caret.Pos.y] [Caret.Pos.x]

        cmp     [.width], 0
        je      .endchange

        push    [.width] [.height]
        pop     [Caret.Pos.height] [Caret.Pos.width]

        stdcall __DrawCaret, 1

.endchange:
        mov     [Caret.sync], 0

        pop     eax
        return
endp


; returns the old mode.
proc __CaretShow, .visible
begin
        mov     eax, [.visible]
        cmp     eax, [Caret.visible]       ; old vs new mode.
        je      .exit

        push    [Caret.visible]
        mov     [Caret.visible], eax

        push    ecx edx

        mov     ecx, [Caret.timer]
        mov     edx, [ecx+TTimer.flags]

        or      edx, tmfRunning
        test    eax, eax
        jnz     .timerok
        and     edx, not tmfRunning
.timerok:
        mov     [ecx+TTimer.flags], edx

        stdcall __DrawCaret, [Caret.visible]
        pop     edx ecx

        pop     eax
.exit:
        return
endp


proc CaretShow, .visible
begin
        mov     eax, -1
@@:
        xchg    [Caret.sync], eax
        test    eax, eax
        jnz     @b

        stdcall __CaretShow, [.visible]
        mov     [Caret.sync], 0

        return
endp



proc __CaretTimerProc, .timer
begin
        cmp     [Caret.pWindow], 0
        je      .exit

        mov     eax, -1
        xchg    [Caret.sync], eax
        test    eax, eax
        jnz     .exit                   ; don't wait for lock.

        cmp     [Caret.visible], 0
        je      @f
        mov     eax, 2
@@:
        stdcall __DrawCaret, eax

        mov     [Caret.sync], 0

.exit:
        return
endp



proc __DrawCaret, .operation    ; 0 - erase; 1-draw; 2-change
begin
        push    ecx esi

        mov     eax, [Caret.state]
        cmp     eax, [.operation]
        je      .exit

        cmp     [Caret.pWindow], 0
        je      .exit

        push    $ffffff

        xor     eax, 1
        mov     [Caret.state], eax

        mov     ecx, [Caret.timer]
        mov     eax, [Caret.state]
        mov     eax, [CaretTimes+4*eax]
        mov     [ecx+TTimer.interval], eax
        mov     [ecx+TTimer.value], 0

        test    eax, eax
        jnz     .draw
; clear
        push    [Caret.OldPos.height]
        push    [Caret.OldPos.width]
        push    [Caret.OldPos.y]
        push    [Caret.OldPos.x]
        jmp     .drawit

.draw:
        push    [Caret.Pos.height] [Caret.Pos.width] [Caret.Pos.y] [Caret.Pos.x]
        push    [Caret.Pos.height] [Caret.Pos.width] [Caret.Pos.y] [Caret.Pos.x]
        pop     [Caret.OldPos.x] [Caret.OldPos.y] [Caret.OldPos.width] [Caret.OldPos.height]

.drawit:
        mov     eax, [Caret.pWindow]
        stdcall AllocateContext, [eax+TWindow.handle]
        test    eax, eax
        jz      .exit

        mov     esi, eax

        stdcall SetDrawMode, esi, cmXor
        stdcall DrawFillRect, esi  ; arguments from the stack
        stdcall ReleaseContext, esi

.exit:
        pop     esi ecx
        return
endp




endmodule


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































































































































































































































































































































































Deleted freshlib/imports/Linux/_libX11.inc.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: libX11 (XLib) import library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes: Needs editing of the function arguments
;_________________________________________________________________________________________


import_proto 'libX11.so.6',                             \
        XActivateScreenSaver                    ,<NONE>,\
        XAddConnectionWatch                     ,<NONE>,\
        XAddExtension                           ,<NONE>,\
        XAddHost                                ,<NONE>,\
        XAddHosts                               ,<NONE>,\
        XAddPixel                               ,<NONE>,\
        XAddToExtensionList                     ,<NONE>,\
        XAddToSaveSet                           ,<NONE>,\
        XAllPlanes                              ,<NONE>,\
        XAllocClassHint                         ,<NONE>,\
        XAllocColor                             ,<NONE>,\
        XAllocColorCells                        ,<NONE>,\
        XAllocColorPlanes                       ,<NONE>,\
        XAllocIconSize                          ,<NONE>,\
        XAllocNamedColor                        ,<NONE>,\
        XAllocSizeHints                         ,<NONE>,\
        XAllocStandardColormap                  ,<NONE>,\
        XAllocWMHints                           ,<NONE>,\
        XAllowEvents                            ,<NONE>,\
        XAutoRepeatOff                          ,<NONE>,\
        XAutoRepeatOn                           ,<NONE>,\
        XBaseFontNameListOfFontSet              ,<NONE>,\
        XBell                                   ,<NONE>,\
        XBitmapBitOrder                         ,<NONE>,\
        XBitmapPad                              ,<NONE>,\
        XBitmapUnit                             ,<NONE>,\
        XBlackPixel                             ,<NONE>,\
        XBlackPixelOfScreen                     ,<NONE>,\
        XCellsOfScreen                          ,<NONE>,\
        XChangeActivePointerGrab                ,<NONE>,\
        XChangeGC                               ,<NONE>,\
        XChangeKeyboardControl                  ,<NONE>,\
        XChangeKeyboardMapping                  ,<NONE>,\
        XChangePointerControl                   ,<NONE>,\
        XChangeProperty                         ,<NONE>,\
        XChangeSaveSet                          ,<NONE>,\
        XChangeWindowAttributes                 ,<.display, .hwnd, .valmask, .pSetWinAttr>, \
        XCheckIfEvent                           ,<NONE>,\
        XCheckMaskEvent                         ,<NONE>,\
        XCheckTypedEvent                        ,<.display, .event_type, .pEvent>,\
        XCheckTypedWindowEvent                  ,<NONE>,\
        XCheckWindowEvent                       ,<NONE>,\
        XCirculateSubwindows                    ,<NONE>,\
        XCirculateSubwindowsDown                ,<NONE>,\
        XCirculateSubwindowsUp                  ,<NONE>,\
        XClearArea                              ,<NONE>,\
        XClearWindow                            ,<NONE>,\
        XClipBox                                ,<NONE>,\
        XCloseDisplay                           ,<NONE>,\
        XCloseIM                                ,<NONE>,\
        XCloseOM                                ,<NONE>,\
        XConfigureWindow                        ,<NONE>,\
        XConnectionNumber                       ,<NONE>,\
        XContextDependentDrawing                ,<NONE>,\
        XContextualDrawing                      ,<NONE>,\
        XConvertCase                            ,<NONE>,\
        XConvertSelection                       ,<.display, .selection, .target, .property, .requestor, .time>,\
        XCopyArea                               ,<NONE>,\
        XCopyColormapAndFree                    ,<NONE>,\
        XCopyGC                                 ,<NONE>,\
        XCopyPlane                              ,<NONE>,\
        XCreateBitmapFromData                   ,<NONE>,\
        XCreateColormap                         ,<NONE>,\
        XCreateFontCursor                       ,<NONE>,\
        XCreateFontSet                          ,<NONE>,\
        XCreateGC                               ,<NONE>,\
        XCreateGlyphCursor                      ,<NONE>,\
        XCreateIC                               ,<NONE>,\
        XCreateImage                            ,<NONE>,\
        XCreateOC                               ,<NONE>,\
        XCreatePixmap                           ,<NONE>,\
        XCreatePixmapCursor                     ,<NONE>,\
        XCreatePixmapFromBitmapData             ,<NONE>,\
        XCreateRegion                           ,<NONE>,\
        XCreateSimpleWindow                     ,<.display, .parent, .x, .y, .width, .height, .widthBorder, .clBorder, .clBackground>,\
        XCreateWindow                           ,<.display, .parent, .x, .y, .width, .height, .widthBorder, .depth, .class, .visual, .valuemask, .pAttributes>,\
        XDefaultColormap                        ,<NONE>,\
        XDefaultColormapOfScreen                ,<NONE>,\
        XDefaultDepth                           ,<NONE>,\
        XDefaultDepthOfScreen                   ,<NONE>,\
        XDefaultGC                              ,<NONE>,\
        XDefaultGCOfScreen                      ,<NONE>,\
        XDefaultRootWindow                      ,<NONE>,\
        XDefaultScreen                          ,<NONE>,\
        XDefaultScreenOfDisplay                 ,<NONE>,\
        XDefaultString                          ,<NONE>,\
        XDefaultVisual                          ,<NONE>,\
        XDefaultVisualOfScreen                  ,<NONE>,\
        XDefineCursor                           ,<NONE>,\
        XDeleteContext                          ,<NONE>,\
        XDeleteModifiermapEntry                 ,<NONE>,\
        XDeleteProperty                         ,<NONE>,\
        XDestroyIC                              ,<NONE>,\
        XDestroyImage                           ,<NONE>,\
        XDestroyOC                              ,<NONE>,\
        XDestroyRegion                          ,<NONE>,\
        XDestroySubwindows                      ,<NONE>,\
        XDestroyWindow                          ,<NONE>,\
        XDirectionalDependentDrawing            ,<NONE>,\
        XDisableAccessControl                   ,<NONE>,\
        XDisplayCells                           ,<NONE>,\
        XDisplayHeight                          ,<NONE>,\
        XDisplayHeightMM                        ,<NONE>,\
        XDisplayKeycodes                        ,<NONE>,\
        XDisplayMotionBufferSize                ,<NONE>,\
        XDisplayName                            ,<NONE>,\
        XDisplayOfIM                            ,<NONE>,\
        XDisplayOfOM                            ,<NONE>,\
        XDisplayOfScreen                        ,<NONE>,\
        XDisplayPlanes                          ,<NONE>,\
        XDisplayString                          ,<NONE>,\
        XDisplayWidth                           ,<NONE>,\
        XDisplayWidthMM                         ,<NONE>,\
        XDoesBackingStore                       ,<NONE>,\
        XDoesSaveUnders                         ,<NONE>,\
        XDrawArc                                ,<NONE>,\
        XDrawArcs                               ,<NONE>,\
        XDrawImageString                        ,<NONE>,\
        XDrawImageString16                      ,<NONE>,\
        XDrawLine                               ,<NONE>,\
        XDrawLines                              ,<NONE>,\
        XDrawPoint                              ,<NONE>,\
        XDrawPoints                             ,<NONE>,\
        XDrawRectangle                          ,<NONE>,\
        XDrawRectangles                         ,<NONE>,\
        XDrawSegments                           ,<NONE>,\
        XDrawString                             ,<NONE>,\
        XDrawString16                           ,<NONE>,\
        XDrawText                               ,<NONE>,\
        XDrawText16                             ,<NONE>,\
        XEHeadOfExtensionList                   ,<NONE>,\
        XESetBeforeFlush                        ,<NONE>,\
        XESetCloseDisplay                       ,<NONE>,\
        XESetCopyGC                             ,<NONE>,\
        XESetCreateFont                         ,<NONE>,\
        XESetCreateGC                           ,<NONE>,\
        XESetError                              ,<NONE>,\
        XESetErrorString                        ,<NONE>,\
        XESetEventToWire                        ,<NONE>,\
        XESetFlushGC                            ,<NONE>,\
        XESetFreeFont                           ,<NONE>,\
        XESetFreeGC                             ,<NONE>,\
        XESetPrintErrorValues                   ,<NONE>,\
        XESetWireToError                        ,<NONE>,\
        XESetWireToEvent                        ,<NONE>,\
        XEmptyRegion                            ,<NONE>,\
        XEnableAccessControl                    ,<NONE>,\
        XEqualRegion                            ,<NONE>,\
        XEventMaskOfScreen                      ,<NONE>,\
        XEventsQueued                           ,<NONE>,\
        XExtendedMaxRequestSize                 ,<NONE>,\
        XExtentsOfFontSet                       ,<NONE>,\
        XFetchBuffer                            ,<.display, .nbytes_return, .buffer>,\
        XFetchBytes                             ,<.display, .nbytes_return>,\
        XFetchName                              ,<.display, .window, .window_name_return>,\
        XFillArc                                ,<NONE>,\
        XFillArcs                               ,<NONE>,\
        XFillPolygon                            ,<NONE>,\
        XFillRectangle                          ,<NONE>,\
        XFillRectangles                         ,<NONE>,\
        XFilterEvent                            ,<NONE>,\
        XFindContext                            ,<NONE>,\
        XFindOnExtensionList                    ,<NONE>,\
        XFlush                                  ,<NONE>,\
        XFlushGC                                ,<NONE>,\
        XFontsOfFontSet                         ,<NONE>,\
        XForceScreenSaver                       ,<NONE>,\
        XFree                                   ,<.ptr>,\
        XFreeColormap                           ,<NONE>,\
        XFreeColors                             ,<NONE>,\
        XFreeCursor                             ,<NONE>,\
        XFreeExtensionList                      ,<NONE>,\
        XFreeFont                               ,<NONE>,\
        XFreeFontInfo                           ,<NONE>,\
        XFreeFontNames                          ,<NONE>,\
        XFreeFontPath                           ,<NONE>,\
        XFreeFontSet                            ,<NONE>,\
        XFreeGC                                 ,<NONE>,\
        XFreeModifiermap                        ,<NONE>,\
        XFreePixmap                             ,<NONE>,\
        XFreeStringList                         ,<NONE>,\
        XGContextFromGC                         ,<NONE>,\
        XGeometry                               ,<NONE>,\
        XGetAtomName                            ,<NONE>,\
        XGetAtomNames                           ,<NONE>,\
        XGetClassHint                           ,<NONE>,\
        XGetCommand                             ,<NONE>,\
        XGetDefault                             ,<NONE>,\
        XGetErrorDatabaseText                   ,<NONE>,\
        XGetErrorText                           ,<NONE>,\
        XGetFontPath                            ,<NONE>,\
        XGetFontProperty                        ,<NONE>,\
        XGetGCValues                            ,<NONE>,\
        XGetGeometry                            ,<NONE>,\
        XGetICValues                            ,<NONE>,\
        XGetIMValues                            ,<NONE>,\
        XGetIconName                            ,<NONE>,\
        XGetIconSizes                           ,<NONE>,\
        XGetImage                               ,<NONE>,\
        XGetInputFocus                          ,<NONE>,\
        XGetKeyboardControl                     ,<NONE>,\
        XGetKeyboardMapping                     ,<NONE>,\
        XGetModifierMapping                     ,<NONE>,\
        XGetMotionEvents                        ,<NONE>,\
        XGetNormalHints                         ,<NONE>,\
        XGetOCValues                            ,<NONE>,\
        XGetOMValues                            ,<NONE>,\
        XGetPixel                               ,<NONE>,\
        XGetPointerControl                      ,<NONE>,\
        XGetPointerMapping                      ,<NONE>,\
        XGetRGBColormaps                        ,<NONE>,\
        XGetScreenSaver                         ,<NONE>,\
        XGetSelectionOwner                      ,<.display, .selection>, \
        XGetSizeHints                           ,<NONE>,\
        XGetStandardColormap                    ,<NONE>,\
        XGetSubImage                            ,<NONE>,\
        XGetTextProperty                        ,<NONE>,\
        XGetTransientForHint                    ,<NONE>,\
        XGetVisualInfo                          ,<NONE>,\
        XGetWMClientMachine                     ,<NONE>,\
        XGetWMColormapWindows                   ,<NONE>,\
        XGetWMHints                             ,<NONE>,\
        XGetWMIconName                          ,<NONE>,\
        XGetWMName                              ,<NONE>,\
        XGetWMNormalHints                       ,<NONE>,\
        XGetWMProtocols                         ,<NONE>,\
        XGetWMSizeHints                         ,<NONE>,\
        XGetWindowAttributes                    ,<.display, .hwin, .pWinAttr>,\
        XGetWindowProperty                      ,<.display, .hwin, .property, .offset, .length, .delete, .req_type, .pTypeRet, .pFormatRet, .pNItemsRet, .pRemainsRet, .pDataRet>,\
        XGetZoomHints                           ,<NONE>,\
        XGrabButton                             ,<NONE>,\
        XGrabKey                                ,<NONE>,\
        XGrabKeyboard                           ,<NONE>,\
        XGrabPointer                            ,<NONE>,\
        XGrabServer                             ,<NONE>,\
        XHeightMMOfScreen                       ,<NONE>,\
        XHeightOfScreen                         ,<NONE>,\
        XIMOfIC                                 ,<NONE>,\
        XIconifyWindow                          ,<NONE>,\
        XIfEvent                                ,<NONE>,\
        XImageByteOrder                         ,<NONE>,\
        XInitExtension                          ,<NONE>,\
        XInitImage                              ,<NONE>,\
        XInitThreads                            ,<NONE>,\
        XInsertModifiermapEntry                 ,<NONE>,\
        XInstallColormap                        ,<NONE>,\
        XInternAtom                             ,<.display, .atom_name, .only_if_exists>,\
        XInternAtoms                            ,<.display, .names, .count, .only_if_exists, .atoms_return>,\
        XInternalConnectionNumbers              ,<NONE>,\
        XIntersectRegion                        ,<NONE>,\
        XKeycodeToKeysym                        ,<NONE>,\
        XKeysymToKeycode                        ,<NONE>,\
        XKeysymToString                         ,<NONE>,\
        XKillClient                             ,<NONE>,\
        XLastKnownRequestProcessed              ,<NONE>,\
        XListDepths                             ,<NONE>,\
        XListExtensions                         ,<NONE>,\
        XListFonts                              ,<NONE>,\
        XListFontsWithInfo                      ,<NONE>,\
        XListHosts                              ,<NONE>,\
        XListInstalledColormaps                 ,<NONE>,\
        XListPixmapFormats                      ,<NONE>,\
        XListProperties                         ,<NONE>,\
        XLoadFont                               ,<NONE>,\
        XLoadQueryFont                          ,<NONE>,\
        XLocaleOfFontSet                        ,<NONE>,\
        XLocaleOfIM                             ,<NONE>,\
        XLocaleOfOM                             ,<NONE>,\
        XLockDisplay                            ,<NONE>,\
        XLookupColor                            ,<NONE>,\
        XLookupKeysym                           ,<NONE>,\
        XLookupString                           ,<NONE>,\
        XLowerWindow                            ,<NONE>,\
        XMapRaised                              ,<NONE>,\
        XMapSubwindows                          ,<NONE>,\
        XMapWindow                              ,<NONE>,\
        XMaskEvent                              ,<.display, .event_mask, .pEventReturn>,\
        XMatchVisualInfo                        ,<NONE>,\
        XMaxCmapsOfScreen                       ,<NONE>,\
        XMaxRequestSize                         ,<NONE>,\
        XMinCmapsOfScreen                       ,<NONE>,\
        XMoveResizeWindow                       ,<NONE>,\
        XMoveWindow                             ,<NONE>,\
        XNewModifiermap                         ,<NONE>,\
        XNextEvent                              ,<NONE>,\
        XNextRequest                            ,<NONE>,\
        XNoOp                                   ,<NONE>,\
        XOMOfOC                                 ,<NONE>,\
        XOffsetRegion                           ,<NONE>,\
        XOpenDisplay                            ,<NONE>,\
        XOpenIM                                 ,<NONE>,\
        XOpenOM                                 ,<NONE>,\
        XParseColor                             ,<NONE>,\
        XParseGeometry                          ,<NONE>,\
        XPeekEvent                              ,<NONE>,\
        XPeekIfEvent                            ,<NONE>,\
        XPending                                ,<NONE>,\
        XPlanesOfScreen                         ,<NONE>,\
        XPointInRegion                          ,<NONE>,\
        XPolygonRegion                          ,<NONE>,\
        XProcessInternalConnection              ,<NONE>,\
        XProtocolRevision                       ,<NONE>,\
        XProtocolVersion                        ,<NONE>,\
        XPutBackEvent                           ,<NONE>,\
        XPutImage                               ,<NONE>,\
        XPutPixel                               ,<NONE>,\
        XQLength                                ,<NONE>,\
        XQueryBestCursor                        ,<NONE>,\
        XQueryBestSize                          ,<NONE>,\
        XQueryBestStipple                       ,<NONE>,\
        XQueryBestTile                          ,<NONE>,\
        XQueryColor                             ,<NONE>,\
        XQueryColors                            ,<NONE>,\
        XQueryExtension                         ,<NONE>,\
        XQueryFont                              ,<NONE>,\
        XQueryKeymap                            ,<NONE>,\
        XQueryPointer                           ,<NONE>,\
        XQueryTextExtents                       ,<NONE>,\
        XQueryTextExtents16                     ,<NONE>,\
        XQueryTree                              ,<NONE>,\
        XRaiseWindow                            ,<NONE>,\
        XReadBitmapFile                         ,<NONE>,\
        XReadBitmapFileData                     ,<NONE>,\
        XRebindKeysym                           ,<NONE>,\
        XRecolorCursor                          ,<NONE>,\
        XReconfigureWMWindow                    ,<NONE>,\
        XRectInRegion                           ,<NONE>,\
        XRefreshKeyboardMapping                 ,<NONE>,\
        XRegisterIMInstantiateCallback          ,<NONE>,\
        XRemoveConnectionWatch                  ,<NONE>,\
        XRemoveFromSaveSet                      ,<NONE>,\
        XRemoveHost                             ,<NONE>,\
        XRemoveHosts                            ,<NONE>,\
        XReparentWindow                         ,<NONE>,\
        XResetScreenSaver                       ,<NONE>,\
        XResizeWindow                           ,<NONE>,\
        XResourceManagerString                  ,<NONE>,\
        XRestackWindows                         ,<NONE>,\
        XRootWindow                             ,<NONE>,\
        XRootWindowOfScreen                     ,<NONE>,\
        XRotateBuffers                          ,<NONE>,\
        XRotateWindowProperties                 ,<NONE>,\
        XSaveContext                            ,<NONE>,\
        XScreenCount                            ,<NONE>,\
        XScreenNumberOfScreen                   ,<NONE>,\
        XScreenOfDisplay                        ,<NONE>,\
        XScreenResourceString                   ,<NONE>,\
        XSelectInput                            ,<NONE>,\
        XSendEvent                              ,<NONE>,\
        XServerVendor                           ,<NONE>,\
        XSetAccessControl                       ,<NONE>,\
        XSetAfterFunction                       ,<NONE>,\
        XSetArcMode                             ,<NONE>,\
        XSetAuthorization                       ,<NONE>,\
        XSetBackground                          ,<NONE>,\
        XSetClassHint                           ,<NONE>,\
        XSetClipMask                            ,<NONE>,\
        XSetClipOrigin                          ,<NONE>,\
        XSetClipRectangles                      ,<NONE>,\
        XSetCloseDownMode                       ,<NONE>,\
        XSetCommand                             ,<NONE>,\
        XSetDashes                              ,<NONE>,\
        XSetErrorHandler                        ,<NONE>,\
        XSetFillRule                            ,<NONE>,\
        XSetFillStyle                           ,<NONE>,\
        XSetFont                                ,<NONE>,\
        XSetFontPath                            ,<NONE>,\
        XSetForeground                          ,<NONE>,\
        XSetFunction                            ,<NONE>,\
        XSetGraphicsExposures                   ,<NONE>,\
        XSetICFocus                             ,<NONE>,\
        XSetICValues                            ,<NONE>,\
        XSetIMValues                            ,<NONE>,\
        XSetIOErrorHandler                      ,<NONE>,\
        XSetIconName                            ,<NONE>,\
        XSetIconSizes                           ,<NONE>,\
        XSetInputFocus                          ,<NONE>,\
        XSetLineAttributes                      ,<NONE>,\
        XSetLocaleModifiers                     ,<NONE>,\
        XSetModifierMapping                     ,<NONE>,\
        XSetNormalHints                         ,<NONE>,\
        XSetOCValues                            ,<NONE>,\
        XSetOMValues                            ,<NONE>,\
        XSetPlaneMask                           ,<NONE>,\
        XSetPointerMapping                      ,<NONE>,\
        XSetRGBColormaps                        ,<NONE>,\
        XSetRegion                              ,<NONE>,\
        XSetScreenSaver                         ,<NONE>,\
        XSetSelectionOwner                      ,<.display, .selection, .owner, .time>,\
        XSetSizeHints                           ,<NONE>,\
        XSetStandardColormap                    ,<NONE>,\
        XSetStandardProperties                  ,<NONE>,\
        XSetState                               ,<NONE>,\
        XSetStipple                             ,<NONE>,\
        XSetSubwindowMode                       ,<NONE>,\
        XSetTSOrigin                            ,<NONE>,\
        XSetTextProperty                        ,<NONE>,\
        XSetTile                                ,<NONE>,\
        XSetTransientForHint                    ,<NONE>,\
        XSetWMClientMachine                     ,<NONE>,\
        XSetWMColormapWindows                   ,<NONE>,\
        XSetWMHints                             ,<NONE>,\
        XSetWMIconName                          ,<NONE>,\
        XSetWMName                              ,<NONE>,\
        XSetWMNormalHints                       ,<NONE>,\
        XSetWMProperties                        ,<NONE>,\
        XSetWMProtocols                         ,<NONE>,\
        XSetWMSizeHints                         ,<NONE>,\
        XSetWindowBackground                    ,<NONE>,\
        XSetWindowBackgroundPixmap              ,<NONE>,\
        XSetWindowBorder                        ,<NONE>,\
        XSetWindowBorderPixmap                  ,<NONE>,\
        XSetWindowBorderWidth                   ,<NONE>,\
        XSetWindowColormap                      ,<NONE>,\
        XSetZoomHints                           ,<NONE>,\
        XShrinkRegion                           ,<NONE>,\
        XStoreBuffer                            ,<NONE>,\
        XStoreBytes                             ,<NONE>,\
        XStoreColor                             ,<NONE>,\
        XStoreColors                            ,<NONE>,\
        XStoreName                              ,<NONE>,\
        XStoreNamedColor                        ,<NONE>,\
        XStringListToTextProperty               ,<NONE>,\
        XStringToKeysym                         ,<NONE>,\
        XSubImage                               ,<NONE>,\
        XSubtractRegion                         ,<NONE>,\
        XSupportsLocale                         ,<NONE>,\
        XSync                                   ,<NONE>,\
        XSynchronize                            ,<NONE>,\
        XTextExtents                            ,<NONE>,\
        XTextExtents16                          ,<NONE>,\
        XTextPropertyToStringList               ,<NONE>,\
        XTextWidth                              ,<NONE>,\
        XTextWidth16                            ,<NONE>,\
        XTranslateCoordinates                   ,<NONE>,\
        XUndefineCursor                         ,<NONE>,\
        XUngrabButton                           ,<NONE>,\
        XUngrabKey                              ,<NONE>,\
        XUngrabKeyboard                         ,<NONE>,\
        XUngrabPointer                          ,<NONE>,\
        XUngrabServer                           ,<NONE>,\
        XUninstallColormap                      ,<NONE>,\
        XUnionRectWithRegion                    ,<NONE>,\
        XUnionRegion                            ,<NONE>,\
        XUnloadFont                             ,<NONE>,\
        XUnlockDisplay                          ,<NONE>,\
        XUnmapSubwindows                        ,<NONE>,\
        XUnmapWindow                            ,<NONE>,\
        XUnregisterIMInstantiateCallback        ,<NONE>,\
        XUnsetICFocus                           ,<NONE>,\
        XVaCreateNestedList                     ,<NONE>,\
        XVendorRelease                          ,<NONE>,\
        XVisualIDFromVisual                     ,<NONE>,\
        XWMGeometry                             ,<NONE>,\
        XWarpPointer                            ,<NONE>,\
        XWhitePixel                             ,<NONE>,\
        XWhitePixelOfScreen                     ,<NONE>,\
        XWidthMMOfScreen                        ,<NONE>,\
        XWidthOfScreen                          ,<NONE>,\
        XWindowEvent                            ,<.display, .hwin, .event_mask, .pEvent>,\
        XWithdrawWindow                         ,<NONE>,\
        XWriteBitmapFile                        ,<NONE>,\
        XXorRegion                              ,<NONE>,\
        XcmsAddColorSpace                       ,<NONE>,\
        XcmsAddFunctionSet                      ,<NONE>,\
        XcmsAllocColor                          ,<NONE>,\
        XcmsAllocNamedColor                     ,<NONE>,\
        XcmsCCCOfColormap                       ,<NONE>,\
        XcmsCIELabClipL                         ,<NONE>,\
        XcmsCIELabClipLab                       ,<NONE>,\
        XcmsCIELabClipab                        ,<NONE>,\
        XcmsCIELabColorSpace                    ,<NONE>,\
        XcmsCIELabQueryMaxC                     ,<NONE>,\
        XcmsCIELabQueryMaxL                     ,<NONE>,\
        XcmsCIELabQueryMaxLC                    ,<NONE>,\
        XcmsCIELabQueryMinL                     ,<NONE>,\
        XcmsCIELabToCIEXYZ                      ,<NONE>,\
        XcmsCIELabWhiteShiftColors              ,<NONE>,\
        XcmsCIELuvClipL                         ,<NONE>,\
        XcmsCIELuvClipLuv                       ,<NONE>,\
        XcmsCIELuvClipuv                        ,<NONE>,\
        XcmsCIELuvColorSpace                    ,<NONE>,\
        XcmsCIELuvQueryMaxC                     ,<NONE>,\
        XcmsCIELuvQueryMaxL                     ,<NONE>,\
        XcmsCIELuvQueryMaxLC                    ,<NONE>,\
        XcmsCIELuvQueryMinL                     ,<NONE>,\
        XcmsCIELuvToCIEuvY                      ,<NONE>,\
        XcmsCIELuvWhiteShiftColors              ,<NONE>,\
        XcmsCIEXYZColorSpace                    ,<NONE>,\
        XcmsCIEXYZToCIELab                      ,<NONE>,\
        XcmsCIEXYZToCIEuvY                      ,<NONE>,\
        XcmsCIEXYZToCIExyY                      ,<NONE>,\
        XcmsCIEXYZToRGBi                        ,<NONE>,\
        XcmsCIEuvYColorSpace                    ,<NONE>,\
        XcmsCIEuvYToCIELuv                      ,<NONE>,\
        XcmsCIEuvYToCIEXYZ                      ,<NONE>,\
        XcmsCIEuvYToTekHVC                      ,<NONE>,\
        XcmsCIExyYColorSpace                    ,<NONE>,\
        XcmsCIExyYToCIEXYZ                      ,<NONE>,\
        XcmsClientWhitePointOfCCC               ,<NONE>,\
        XcmsConvertColors                       ,<NONE>,\
        XcmsCreateCCC                           ,<NONE>,\
        XcmsDefaultCCC                          ,<NONE>,\
        XcmsDisplayOfCCC                        ,<NONE>,\
        XcmsFormatOfPrefix                      ,<NONE>,\
        XcmsFreeCCC                             ,<NONE>,\
        XcmsLinearRGBFunctionSet                ,<NONE>,\
        XcmsLookupColor                         ,<NONE>,\
        XcmsPrefixOfFormat                      ,<NONE>,\
        XcmsQueryBlack                          ,<NONE>,\
        XcmsQueryBlue                           ,<NONE>,\
        XcmsQueryColor                          ,<NONE>,\
        XcmsQueryColors                         ,<NONE>,\
        XcmsQueryGreen                          ,<NONE>,\
        XcmsQueryRed                            ,<NONE>,\
        XcmsQueryWhite                          ,<NONE>,\
        XcmsRGBColorSpace                       ,<NONE>,\
        XcmsRGBToRGBi                           ,<NONE>,\
        XcmsRGBiColorSpace                      ,<NONE>,\
        XcmsRGBiToCIEXYZ                        ,<NONE>,\
        XcmsRGBiToRGB                           ,<NONE>,\
        XcmsScreenNumberOfCCC                   ,<NONE>,\
        XcmsScreenWhitePointOfCCC               ,<NONE>,\
        XcmsSetCCCOfColormap                    ,<NONE>,\
        XcmsSetCompressionProc                  ,<NONE>,\
        XcmsSetWhiteAdjustProc                  ,<NONE>,\
        XcmsSetWhitePoint                       ,<NONE>,\
        XcmsStoreColor                          ,<NONE>,\
        XcmsStoreColors                         ,<NONE>,\
        XcmsTekHVCClipC                         ,<NONE>,\
        XcmsTekHVCClipV                         ,<NONE>,\
        XcmsTekHVCClipVC                        ,<NONE>,\
        XcmsTekHVCColorSpace                    ,<NONE>,\
        XcmsTekHVCQueryMaxC                     ,<NONE>,\
        XcmsTekHVCQueryMaxV                     ,<NONE>,\
        XcmsTekHVCQueryMaxVC                    ,<NONE>,\
        XcmsTekHVCQueryMaxVSamples              ,<NONE>,\
        XcmsTekHVCQueryMinV                     ,<NONE>,\
        XcmsTekHVCToCIEuvY                      ,<NONE>,\
        XcmsTekHVCWhiteShiftColors              ,<NONE>,\
        XcmsUNDEFINEDColorSpace                 ,<NONE>,\
        XcmsVisualOfCCC                         ,<NONE>,\
        XkbAddDeviceLedInfo                     ,<NONE>,\
        XkbAddGeomColor                         ,<NONE>,\
        XkbAddGeomDoodad                        ,<NONE>,\
        XkbAddGeomKey                           ,<NONE>,\
        XkbAddGeomKeyAlias                      ,<NONE>,\
        XkbAddGeomOutline                       ,<NONE>,\
        XkbAddGeomOverlay                       ,<NONE>,\
        XkbAddGeomOverlayKey                    ,<NONE>,\
        XkbAddGeomOverlayRow                    ,<NONE>,\
        XkbAddGeomProperty                      ,<NONE>,\
        XkbAddGeomRow                           ,<NONE>,\
        XkbAddGeomSection                       ,<NONE>,\
        XkbAddGeomShape                         ,<NONE>,\
        XkbAddKeyType                           ,<NONE>,\
        XkbAllocClientMap                       ,<NONE>,\
        XkbAllocCompatMap                       ,<NONE>,\
        XkbAllocControls                        ,<NONE>,\
        XkbAllocDeviceInfo                      ,<NONE>,\
        XkbAllocGeomColors                      ,<NONE>,\
        XkbAllocGeomDoodads                     ,<NONE>,\
        XkbAllocGeomKeyAliases                  ,<NONE>,\
        XkbAllocGeomKeys                        ,<NONE>,\
        XkbAllocGeomOutlines                    ,<NONE>,\
        XkbAllocGeomOverlayKeys                 ,<NONE>,\
        XkbAllocGeomOverlayRows                 ,<NONE>,\
        XkbAllocGeomOverlays                    ,<NONE>,\
        XkbAllocGeomPoints                      ,<NONE>,\
        XkbAllocGeomProps                       ,<NONE>,\
        XkbAllocGeomRows                        ,<NONE>,\
        XkbAllocGeomSectionDoodads              ,<NONE>,\
        XkbAllocGeomSections                    ,<NONE>,\
        XkbAllocGeomShapes                      ,<NONE>,\
        XkbAllocGeometry                        ,<NONE>,\
        XkbAllocIndicatorMaps                   ,<NONE>,\
        XkbAllocKeyboard                        ,<NONE>,\
        XkbAllocNames                           ,<NONE>,\
        XkbAllocServerMap                       ,<NONE>,\
        XkbApplyCompatMapToKey                  ,<NONE>,\
        XkbApplyVirtualModChanges               ,<NONE>,\
        XkbBell                                 ,<NONE>,\
        XkbBellEvent                            ,<NONE>,\
        XkbChangeDeviceInfo                     ,<NONE>,\
        XkbChangeEnabledControls                ,<NONE>,\
        XkbChangeKeycodeRange                   ,<NONE>,\
        XkbChangeMap                            ,<NONE>,\
        XkbChangeNames                          ,<NONE>,\
        XkbChangeTypesOfKey                     ,<NONE>,\
        XkbComputeEffectiveMap                  ,<NONE>,\
        XkbComputeRowBounds                     ,<NONE>,\
        XkbComputeSectionBounds                 ,<NONE>,\
        XkbComputeShapeBounds                   ,<NONE>,\
        XkbComputeShapeTop                      ,<NONE>,\
        XkbCopyKeyType                          ,<NONE>,\
        XkbCopyKeyTypes                         ,<NONE>,\
        XkbDeviceBell                           ,<NONE>,\
        XkbDeviceBellEvent                      ,<NONE>,\
        XkbFindOverlayForKey                    ,<NONE>,\
        XkbForceBell                            ,<NONE>,\
        XkbForceDeviceBell                      ,<NONE>,\
        XkbFreeClientMap                        ,<NONE>,\
        XkbFreeCompatMap                        ,<NONE>,\
        XkbFreeComponentList                    ,<NONE>,\
        XkbFreeControls                         ,<NONE>,\
        XkbFreeDeviceInfo                       ,<NONE>,\
        XkbFreeGeomColors                       ,<NONE>,\
        XkbFreeGeomDoodads                      ,<NONE>,\
        XkbFreeGeomKeyAliases                   ,<NONE>,\
        XkbFreeGeomKeys                         ,<NONE>,\
        XkbFreeGeomOutlines                     ,<NONE>,\
        XkbFreeGeomOverlayKeys                  ,<NONE>,\
        XkbFreeGeomOverlayRows                  ,<NONE>,\
        XkbFreeGeomOverlays                     ,<NONE>,\
        XkbFreeGeomPoints                       ,<NONE>,\
        XkbFreeGeomProperties                   ,<NONE>,\
        XkbFreeGeomRows                         ,<NONE>,\
        XkbFreeGeomSections                     ,<NONE>,\
        XkbFreeGeomShapes                       ,<NONE>,\
        XkbFreeGeometry                         ,<NONE>,\
        XkbFreeIndicatorMaps                    ,<NONE>,\
        XkbFreeKeyboard                         ,<NONE>,\
        XkbFreeNames                            ,<NONE>,\
        XkbFreeServerMap                        ,<NONE>,\
        XkbGetAutoRepeatRate                    ,<NONE>,\
        XkbGetAutoResetControls                 ,<NONE>,\
        XkbGetCompatMap                         ,<NONE>,\
        XkbGetControls                          ,<NONE>,\
        XkbGetDetectableAutoRepeat              ,<NONE>,\
        XkbGetDeviceButtonActions               ,<NONE>,\
        XkbGetDeviceInfo                        ,<NONE>,\
        XkbGetDeviceInfoChanges                 ,<NONE>,\
        XkbGetDeviceLedInfo                     ,<NONE>,\
        XkbGetGeometry                          ,<NONE>,\
        XkbGetIndicatorMap                      ,<NONE>,\
        XkbGetIndicatorState                    ,<NONE>,\
        XkbGetKeyActions                        ,<NONE>,\
        XkbGetKeyBehaviors                      ,<NONE>,\
        XkbGetKeyExplicitComponents             ,<NONE>,\
        XkbGetKeyModifierMap                    ,<NONE>,\
        XkbGetKeySyms                           ,<NONE>,\
        XkbGetKeyTypes                          ,<NONE>,\
        XkbGetKeyVirtualModMap                  ,<NONE>,\
        XkbGetKeyboard                          ,<NONE>,\
        XkbGetKeyboardByName                    ,<NONE>,\
        XkbGetMap                               ,<NONE>,\
        XkbGetMapChanges                        ,<NONE>,\
        XkbGetNamedDeviceIndicator              ,<NONE>,\
        XkbGetNamedGeometry                     ,<NONE>,\
        XkbGetNamedIndicator                    ,<NONE>,\
        XkbGetNames                             ,<NONE>,\
        XkbGetPerClientControls                 ,<NONE>,\
        XkbGetState                             ,<NONE>,\
        XkbGetUpdatedMap                        ,<NONE>,\
        XkbGetVirtualMods                       ,<NONE>,\
        XkbGetXlibControls                      ,<NONE>,\
        XkbIgnoreExtension                      ,<NONE>,\
        XkbInitCanonicalKeyTypes                ,<NONE>,\
        XkbKeyTypesForCoreSymbols               ,<NONE>,\
        XkbKeycodeToKeysym                      ,<NONE>,\
        XkbKeysymToModifiers                    ,<NONE>,\
        XkbLatchGroup                           ,<NONE>,\
        XkbLatchModifiers                       ,<NONE>,\
        XkbLibraryVersion                       ,<NONE>,\
        XkbListComponents                       ,<NONE>,\
        XkbLockGroup                            ,<NONE>,\
        XkbLockModifiers                        ,<NONE>,\
        XkbLookupKeyBinding                     ,<NONE>,\
        XkbLookupKeySym                         ,<NONE>,\
        XkbNoteControlsChanges                  ,<NONE>,\
        XkbNoteDeviceChanges                    ,<NONE>,\
        XkbNoteMapChanges                       ,<NONE>,\
        XkbNoteNameChanges                      ,<NONE>,\
        XkbOpenDisplay                          ,<NONE>,\
        XkbQueryExtension                       ,<NONE>,\
        XkbRefreshKeyboardMapping               ,<NONE>,\
        XkbResizeDeviceButtonActions            ,<NONE>,\
        XkbResizeKeyActions                     ,<NONE>,\
        XkbResizeKeySyms                        ,<NONE>,\
        XkbResizeKeyType                        ,<NONE>,\
        XkbSelectEventDetails                   ,<NONE>,\
        XkbSelectEvents                         ,<NONE>,\
        XkbSetAtomFuncs                         ,<NONE>,\
        XkbSetAutoRepeatRate                    ,<NONE>,\
        XkbSetAutoResetControls                 ,<NONE>,\
        XkbSetCompatMap                         ,<NONE>,\
        XkbSetControls                          ,<NONE>,\
        XkbSetDebuggingFlags                    ,<NONE>,\
        XkbSetDetectableAutoRepeat              ,<NONE>,\
        XkbSetDeviceButtonActions               ,<NONE>,\
        XkbSetDeviceInfo                        ,<NONE>,\
        XkbSetDeviceLedInfo                     ,<NONE>,\
        XkbSetGeometry                          ,<NONE>,\
        XkbSetIgnoreLockMods                    ,<NONE>,\
        XkbSetIndicatorMap                      ,<NONE>,\
        XkbSetMap                               ,<NONE>,\
        XkbSetNamedDeviceIndicator              ,<NONE>,\
        XkbSetNamedIndicator                    ,<NONE>,\
        XkbSetNames                             ,<NONE>,\
        XkbSetPerClientControls                 ,<NONE>,\
        XkbSetServerInternalMods                ,<NONE>,\
        XkbSetXlibControls                      ,<NONE>,\
        XkbToControl                            ,<NONE>,\
        XkbTranslateKey                         ,<NONE>,\
        XkbTranslateKeyCode                     ,<NONE>,\
        XkbTranslateKeySym                      ,<NONE>,\
        XkbUpdateActionVirtualMods              ,<NONE>,\
        XkbUpdateKeyTypeVirtualMods             ,<NONE>,\
        XkbUpdateMapFromCore                    ,<NONE>,\
        XkbUseExtension                         ,<NONE>,\
        XkbVirtualModsToReal                    ,<NONE>,\
        XkbXlibControlsImplemented              ,<NONE>,\
        XmbDrawImageString                      ,<NONE>,\
        XmbDrawString                           ,<NONE>,\
        XmbDrawText                             ,<NONE>,\
        XmbLookupString                         ,<NONE>,\
        XmbResetIC                              ,<NONE>,\
        XmbSetWMProperties                      ,<NONE>,\
        XmbTextEscapement                       ,<NONE>,\
        XmbTextExtents                          ,<NONE>,\
        XmbTextListToTextProperty               ,<NONE>,\
        XmbTextPerCharExtents                   ,<NONE>,\
        XmbTextPropertyToTextList               ,<NONE>,\
        Xpermalloc                              ,<NONE>,\
        XrmCombineDatabase                      ,<NONE>,\
        XrmCombineFileDatabase                  ,<NONE>,\
        XrmDestroyDatabase                      ,<NONE>,\
        XrmEnumerateDatabase                    ,<NONE>,\
        XrmGetDatabase                          ,<NONE>,\
        XrmGetFileDatabase                      ,<NONE>,\
        XrmGetResource                          ,<NONE>,\
        XrmGetStringDatabase                    ,<NONE>,\
        XrmInitialize                           ,<NONE>,\
        XrmLocaleOfDatabase                     ,<NONE>,\
        XrmMergeDatabases                       ,<NONE>,\
        XrmParseCommand                         ,<NONE>,\
        XrmPermStringToQuark                    ,<NONE>,\
        XrmPutFileDatabase                      ,<NONE>,\
        XrmPutLineResource                      ,<NONE>,\
        XrmPutResource                          ,<NONE>,\
        XrmPutStringResource                    ,<NONE>,\
        XrmQGetResource                         ,<NONE>,\
        XrmQGetSearchList                       ,<NONE>,\
        XrmQGetSearchResource                   ,<NONE>,\
        XrmQPutResource                         ,<NONE>,\
        XrmQPutStringResource                   ,<NONE>,\
        XrmQuarkToString                        ,<NONE>,\
        XrmSetDatabase                          ,<NONE>,\
        XrmStringToBindingQuarkList             ,<NONE>,\
        XrmStringToQuark                        ,<NONE>,\
        XrmStringToQuarkList                    ,<NONE>,\
        XrmUniqueQuark                          ,<NONE>,\
        Xutf8DrawImageString                    ,<NONE>,\
        Xutf8DrawString                         ,<NONE>,\
        Xutf8DrawText                           ,<NONE>,\
        Xutf8LookupString                       ,<NONE>,\
        Xutf8ResetIC                            ,<NONE>,\
        Xutf8SetWMProperties                    ,<NONE>,\
        Xutf8TextEscapement                     ,<NONE>,\
        Xutf8TextExtents                        ,<NONE>,\
        Xutf8TextListToTextProperty             ,<NONE>,\
        Xutf8TextPerCharExtents                 ,<NONE>,\
        Xutf8TextPropertyToTextList             ,<NONE>,\
        XwcDrawImageString                      ,<NONE>,\
        XwcDrawString                           ,<NONE>,\
        XwcDrawText                             ,<NONE>,\
        XwcFreeStringList                       ,<NONE>,\
        XwcLookupString                         ,<NONE>,\
        XwcResetIC                              ,<NONE>,\
        XwcTextEscapement                       ,<NONE>,\
        XwcTextExtents                          ,<NONE>,\
        XwcTextListToTextProperty               ,<NONE>,\
        XwcTextPerCharExtents                   ,<NONE>,\
        XwcTextPropertyToTextList               ,<NONE>,\
        XUniqueContext                          ,<NONE>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/imports/Linux/_libXft.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: libXft import library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes: Needs editing of the function arguments
;_________________________________________________________________________________________

import_proto  'libXft.so.2',         \
    XftCharExists           ,<NONE>, \
    XftCharFontSpecRender   ,<NONE>, \
    XftCharIndex            ,<NONE>, \
    XftCharSpecRender       ,<NONE>, \
    XftColorAllocName       ,<NONE>, \
    XftColorAllocValue      ,<NONE>, \
    XftColorFree            ,<NONE>, \
    XftDefaultHasRender     ,<NONE>, \
    XftDefaultSet           ,<NONE>, \
    XftDefaultSubstitute    ,<NONE>, \
    XftDrawChange           ,<NONE>, \
    XftDrawCharFontSpec     ,<NONE>, \
    XftDrawCharSpec         ,<NONE>, \
    XftDrawColormap         ,<NONE>, \
    XftDrawCreate           ,<NONE>, \
    XftDrawCreateAlpha      ,<NONE>, \
    XftDrawCreateBitmap     ,<NONE>, \
    XftDrawDestroy          ,<NONE>, \
    XftDrawDisplay          ,<NONE>, \
    XftDrawDrawable         ,<NONE>, \
    XftDrawGlyphFontSpec    ,<NONE>, \
    XftDrawGlyphSpec        ,<NONE>, \
    XftDrawGlyphs           ,<NONE>, \
    XftDrawPicture          ,<NONE>, \
    XftDrawRect             ,<NONE>, \
    XftDrawSetClip          ,<NONE>, \
    XftDrawSetClipRectangles,<NONE>, \
    XftDrawSetSubwindowMode ,<NONE>, \
    XftDrawSrcPicture       ,<NONE>, \
    XftDrawString16         ,<NONE>, \
    XftDrawString32         ,<NONE>, \
    XftDrawString8          ,<NONE>, \
    XftDrawStringUtf16      ,<NONE>, \
    XftDrawStringUtf8       ,<NONE>, \
    XftDrawVisual           ,<NONE>, \
    XftFontCheckGlyph       ,<NONE>, \
    XftFontClose            ,<NONE>, \
    XftFontCopy             ,<NONE>, \
    XftFontInfoCreate       ,<NONE>, \
    XftFontInfoDestroy      ,<NONE>, \
    XftFontInfoEqual        ,<NONE>, \
    XftFontInfoHash         ,<NONE>, \
    XftFontLoadGlyphs       ,<NONE>, \
    XftFontMatch            ,<NONE>, \
    XftFontOpen             ,<NONE>, \
    XftFontOpenInfo         ,<NONE>, \
    XftFontOpenName         ,<NONE>, \
    XftFontOpenPattern      ,<NONE>, \
    XftFontOpenXlfd         ,<NONE>, \
    XftFontUnloadGlyphs     ,<NONE>, \
    XftGetVersion           ,<NONE>, \
    XftGlyphExtents         ,<NONE>, \
    XftGlyphFontSpecRender  ,<NONE>, \
    XftGlyphRender          ,<NONE>, \
    XftGlyphSpecRender      ,<NONE>, \
    XftInit                 ,<NONE>, \
    XftInitFtLibrary        ,<NONE>, \
    XftListFonts            ,<NONE>, \
    XftLockFace             ,<NONE>, \
    XftNameParse            ,<NONE>, \
    XftNameUnparse          ,<NONE>, \
    XftTextExtents16        ,<NONE>, \
    XftTextExtents32        ,<NONE>, \
    XftTextExtents8         ,<NONE>, \
    XftTextExtentsUtf16     ,<NONE>, \
    XftTextExtentsUtf8      ,<NONE>, \
    XftTextRender16         ,<NONE>, \
    XftTextRender16BE       ,<NONE>, \
    XftTextRender16LE       ,<NONE>, \
    XftTextRender32         ,<NONE>, \
    XftTextRender32BE       ,<NONE>, \
    XftTextRender32LE       ,<NONE>, \
    XftTextRender8          ,<NONE>, \
    XftTextRenderUtf16      ,<NONE>, \
    XftTextRenderUtf8       ,<NONE>, \
    XftUnlockFace           ,<NONE>, \
    XftXlfdParse            ,<NONE>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































Deleted freshlib/imports/Linux/_libc.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: LibC import library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes: Include only small amount of exported functions.
;_________________________________________________________________________________________

import_proto 'libc.so.6',                                   \ ; LibC
  puts                                    ,<NONE>,          \
  exit                                    ,<.exit_code>,    \
  malloc                                  ,<.size>,         \
  free                                    ,<.ptr>,          \
  realloc                                 ,<.ptr, .newsize>,\
  stime                                   ,<NONE>,          \
  strerror_r                              ,<.errnum, .pBuff, .BufLen>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































Deleted freshlib/imports/Linux/_pthreads.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: libpthread (posix threads) import library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes: Needs editing of the function arguments
;_________________________________________________________________________________________

import_proto  'libpthread.so.0',          \
fork                              ,<NONE>,\
longjmp                           ,<NONE>,\
pthread_atfork                    ,<NONE>,\
pthread_attr_destroy              ,<NONE>,\
pthread_attr_getaffinity_np       ,<NONE>,\
pthread_attr_getdetachstate       ,<NONE>,\
pthread_attr_getguardsize         ,<NONE>,\
pthread_attr_getinheritsched      ,<NONE>,\
pthread_attr_getschedparam        ,<NONE>,\
pthread_attr_getschedpolicy       ,<NONE>,\
pthread_attr_getscope             ,<NONE>,\
pthread_attr_getstack             ,<NONE>,\
pthread_attr_getstackaddr         ,<NONE>,\
pthread_attr_getstacksize         ,<NONE>,\
pthread_attr_init                 ,<NONE>,\
pthread_attr_setaffinity_np       ,<NONE>,\
pthread_attr_setdetachstate       ,<NONE>,\
pthread_attr_setguardsize         ,<NONE>,\
pthread_attr_setinheritsched      ,<NONE>,\
pthread_attr_setschedparam        ,<NONE>,\
pthread_attr_setschedpolicy       ,<NONE>,\
pthread_attr_setscope             ,<NONE>,\
pthread_attr_setstack             ,<NONE>,\
pthread_attr_setstackaddr         ,<NONE>,\
pthread_attr_setstacksize         ,<NONE>,\
pthread_barrier_destroy           ,<NONE>,\
pthread_barrier_init              ,<NONE>,\
pthread_barrier_wait              ,<NONE>,\
pthread_barrierattr_destroy       ,<NONE>,\
pthread_barrierattr_getpshared    ,<NONE>,\
pthread_barrierattr_init          ,<NONE>,\
pthread_barrierattr_setpshared    ,<NONE>,\
pthread_cancel                    ,<NONE>,\
pthread_cond_broadcast            ,<NONE>,\
pthread_cond_destroy              ,<NONE>,\
pthread_cond_init                 ,<NONE>,\
pthread_cond_signal               ,<NONE>,\
pthread_cond_timedwait            ,<NONE>,\
pthread_cond_wait                 ,<NONE>,\
pthread_condattr_destroy          ,<NONE>,\
pthread_condattr_getclock         ,<NONE>,\
pthread_condattr_getpshared       ,<NONE>,\
pthread_condattr_init             ,<NONE>,\
pthread_condattr_setclock         ,<NONE>,\
pthread_condattr_setpshared       ,<NONE>,\
pthread_create                    ,<.pThreadID, .attr, .pThreadProc, .argument>,\
pthread_detach                    ,<NONE>,\
pthread_equal                     ,<NONE>,\
pthread_exit                      ,<NONE>,\
pthread_getaffinity_np            ,<NONE>,\
pthread_getattr_np                ,<NONE>,\
pthread_getconcurrency            ,<NONE>,\
pthread_getcpuclockid             ,<NONE>,\
pthread_getschedparam             ,<NONE>,\
pthread_getspecific               ,<NONE>,\
pthread_join                      ,<NONE>,\
pthread_key_create                ,<NONE>,\
pthread_key_delete                ,<NONE>,\
pthread_kill                      ,<.ThreadID, .signal>,\
pthread_kill_other_threads_np     ,<NONE>,\
pthread_mutex_consistent_np       ,<NONE>,\
pthread_mutex_destroy             ,<NONE>,\
pthread_mutex_getprioceiling      ,<NONE>,\
pthread_mutex_init                ,<NONE>,\
pthread_mutex_lock                ,<NONE>,\
pthread_mutex_setprioceiling      ,<NONE>,\
pthread_mutex_timedlock           ,<NONE>,\
pthread_mutex_trylock             ,<NONE>,\
pthread_mutex_unlock              ,<NONE>,\
pthread_mutexattr_destroy         ,<NONE>,\
pthread_mutexattr_getkind_np      ,<NONE>,\
pthread_mutexattr_getprioceiling  ,<NONE>,\
pthread_mutexattr_getprotocol     ,<NONE>,\
pthread_mutexattr_getpshared      ,<NONE>,\
pthread_mutexattr_getrobust_np    ,<NONE>,\
pthread_mutexattr_gettype         ,<NONE>,\
pthread_mutexattr_init            ,<NONE>,\
pthread_mutexattr_setkind_np      ,<NONE>,\
pthread_mutexattr_setprioceiling  ,<NONE>,\
pthread_mutexattr_setprotocol     ,<NONE>,\
pthread_mutexattr_setpshared      ,<NONE>,\
pthread_mutexattr_setrobust_np    ,<NONE>,\
pthread_mutexattr_settype         ,<NONE>,\
pthread_once                      ,<NONE>,\
pthread_rwlock_destroy            ,<NONE>,\
pthread_rwlock_init               ,<NONE>,\
pthread_rwlock_rdlock             ,<NONE>,\
pthread_rwlock_timedrdlock        ,<NONE>,\
pthread_rwlock_timedwrlock        ,<NONE>,\
pthread_rwlock_tryrdlock          ,<NONE>,\
pthread_rwlock_trywrlock          ,<NONE>,\
pthread_rwlock_unlock             ,<NONE>,\
pthread_rwlock_wrlock             ,<NONE>,\
pthread_rwlockattr_destroy        ,<NONE>,\
pthread_rwlockattr_getkind_np     ,<NONE>,\
pthread_rwlockattr_getpshared     ,<NONE>,\
pthread_rwlockattr_init           ,<NONE>,\
pthread_rwlockattr_setkind_np     ,<NONE>,\
pthread_rwlockattr_setpshared     ,<NONE>,\
pthread_self                      ,<NONE>,\
pthread_setaffinity_np            ,<NONE>,\
pthread_setcancelstate            ,<NONE>,\
pthread_setcanceltype             ,<NONE>,\
pthread_setconcurrency            ,<NONE>,\
pthread_setschedparam             ,<NONE>,\
pthread_setschedprio              ,<NONE>,\
pthread_setspecific               ,<NONE>,\
pthread_sigmask                   ,<NONE>,\
pthread_spin_destroy              ,<NONE>,\
pthread_spin_init                 ,<NONE>,\
pthread_spin_lock                 ,<NONE>,\
pthread_spin_trylock              ,<NONE>,\
pthread_spin_unlock               ,<NONE>,\
pthread_testcancel                ,<NONE>,\
pthread_timedjoin_np              ,<NONE>,\
pthread_tryjoin_np                ,<NONE>,\
pthread_yield                     ,<NONE>,\
pwrite                            ,<NONE>,\
pwrite64                          ,<NONE>,\
raise                             ,<NONE>,\
read                              ,<NONE>,\
recv                              ,<NONE>,\
recvfrom                          ,<NONE>,\
recvmsg                           ,<NONE>,\
sem_close                         ,<NONE>,\
sem_destroy                       ,<NONE>,\
sem_getvalue                      ,<NONE>,\
sem_init                          ,<NONE>,\
sem_open                          ,<NONE>,\
sem_post                          ,<NONE>,\
sem_timedwait                     ,<NONE>,\
sem_trywait                       ,<NONE>,\
sem_unlink                        ,<NONE>,\
sem_wait                          ,<NONE>,\
send                              ,<NONE>,\
sendmsg                           ,<NONE>,\
sendto                            ,<NONE>,\
sigaction                         ,<NONE>,\
siglongjmp                        ,<NONE>,\
sigwait                           ,<NONE>,\
system                            ,<NONE>,\
tcdrain                           ,<NONE>,\
vfork                             ,<NONE>,\
waitpid                           ,<NONE>,\
write                             ,<NONE>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































Deleted freshlib/imports/Linux/allimports.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Combined include of all Linux importing libraries.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

_importdata:

include '_libX11.inc'
include '_libXft.inc'
include '_libc.inc'
include '_pthreads.inc'


interpreter '/lib/ld-linux.so.2'

ImportAll

DispSize 'ELF Import data:', $-_importdata
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































Deleted freshlib/imports/Win32/allimports.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Combined import of all needed libraries
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes: Only used functions will be imported in the compiled binary.
;_________________________________________________________________________________________

 library kernel32, 'KERNEL32.DLL',\
          user32,  'USER32.DLL',  \
          gdi32,   'gdi32.dll',   \
          comctl32,'comctl32.dll',\
          comdlg32,'comdlg32.dll',\
          shell32, 'shell32.dll', \
          ole32,   'ole32.dll',   \
          advapi32,'advapi32.dll',\
          sqlite3, 'sqlite3.dll',\
          wsock32, 'wsock32.dll'


  include 'api/kernel32.inc'
  include 'api/user32.inc'
  include 'api/gdi32.inc'
  include 'api/ComCtl32.inc'
  include 'api/ComDlg32.inc'
  include 'api/Shell32.inc'
  include 'api/ole32.inc'
  include 'api/advapi32.inc'
  include 'api/sqlite3.inc'
  include 'api/wsock32.inc'

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































Deleted freshlib/imports/Win32/api/advapi32.inc.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: advapi32.dll API functions.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

import_proto advapi32,  \
    A_SHAFinal, N, <NONE>,  'A_SHAFinal',  \
    A_SHAInit, N, <NONE>,  'A_SHAInit',  \
    A_SHAUpdate, N, <NONE>,  'A_SHAUpdate',  \
    AbortSystemShutdown, A, <.lpMachineName>,  'AbortSystemShutdownA',  \
    AbortSystemShutdown, W, <.lpMachineName>,  'AbortSystemShutdownW',  \
    AccessCheck, N, <.pSecurityDescriptor, .ClientToken, .DesiredAccess, .GenericMapping, .PrivilegeSet, .PrivilegeSetLength, .GrantedAccess,  \
        .Status>,  'AccessCheck',  \
    AccessCheckAndAuditAlarm, A, <.SubsystemName, .HandleId, .ObjectTypeName, .ObjectName, .SecurityDescriptor, .DesiredAccess, .GenericMapping,  \
        .ObjectCreation, .GrantedAccess, .AccessStatus, .pfGenerateOnClose>,  'AccessCheckAndAuditAlarmA',  \
    AccessCheckAndAuditAlarm, W, <.SubsystemName, .HandleId, .ObjectTypeName, .ObjectName, .SecurityDescriptor, .DesiredAccess, .GenericMapping,  \
        .ObjectCreation, .GrantedAccess, .AccessStatus, .pfGenerateOnClose>,  'AccessCheckAndAuditAlarmW',  \
    AccessCheckByType, N, <.pSecurityDescriptor, .PrincipalSelfSid, .ClientToken, .DesiredAccess, .ObjectTypeList, .ObjectTypeListLength,  \
        .GenericMapping, .PrivilegeSet, .PrivilegeSetLength, .GrantedAccess, .AccessStatus>,  'AccessCheckByType',  \
    AccessCheckByTypeAndAuditAlarm, A, <.SubsystemName, .HandleId, .ObjectTypeName, .ObjectName, .SecurityDescriptor, .PrincipalSelfSid,  \
        .DesiredAccess, .AuditType, .Flags, .ObjectTypeList, .ObjectTypeListLength, .GenericMapping, .ObjectCreation, .GrantedAccess,  \
        .AccessStatus, .pfGenerateOnClose>,  'AccessCheckByTypeAndAuditAlarmA',  \
    AccessCheckByTypeAndAuditAlarm, W, <.SubsystemName, .HandleId, .ObjectTypeName, .ObjectName, .SecurityDescriptor, .PrincipalSelfSid,  \
        .DesiredAccess, .AuditType, .Flags, .ObjectTypeList, .ObjectTypeListLength, .GenericMapping, .ObjectCreation, .GrantedAccess,  \
        .AccessStatus, .pfGenerateOnClose>,  'AccessCheckByTypeAndAuditAlarmW',  \
    AccessCheckByTypeResultList, N, <.pSecurityDescriptor, .PrincipalSelfSid, .ClientToken, .DesiredAccess, .ObjectTypeList, .ObjectTypeListLength,  \
        .GenericMapping, .PrivilegeSet, .PrivilegeSetLength, .GrantedAccessList, .AccessStatusList>,  'AccessCheckByTypeResultList',  \
    AccessCheckByTypeResultListAndAuditAlarm, A, <.SubsystemName, .HandleId, .ObjectTypeName, .ObjectName, .SecurityDescriptor, .PrincipalSelfSid,  \
        .DesiredAccess, .AuditType, .Flags, .ObjectTypeList, .ObjectTypeListLength, .GenericMapping, .ObjectCreation, .GrantedAccess,  \
        .AccessStatusList, .pfG>,  'AccessCheckByTypeResultListAndAuditAlarmA',  \
    AccessCheckByTypeResultListAndAuditAlarmByHandle, A, <.SubsystemName, .HandleId, .ClientToken, .ObjectTypeName, .ObjectName, .SecurityDescriptor,  \
        .PrincipalSelfSid, .DesiredAccess, .AuditType, .flags, .ObjectTypeList, .ObjectTypeListLength, .GenericMapping, .ObjectCreation,  \
        .GrantedAccess, .AccessibleChildren, .paccContainer, .iChildStart, .cChildren, .rgvarChildren, .pcObtained>,  'AccessCheckByTypeResultListAndAuditAlarmByHandleA',  \
    AccessCheckByTypeResultListAndAuditAlarmByHandle, W, <.SubsystemName, .HandleId, .ClientToken, .ObjectTypeName, .ObjectName, .SecurityDescriptor,  \
        .PrincipalSelfSid, .DesiredAccess, .AuditType, .flags, .ObjectTypeList, .ObjectTypeListLength, .GenericMapping, .ObjectCreation,  \
        .GrantedAccess, .AccessibleChildren, .paccContainer, .iChildStart, .cChildren, .rgvarChildren, .pcObtained>,  'AccessCheckByTypeResultListAndAuditAlarmByHandleW',  \
    AccessCheckByTypeResultListAndAuditAlarm, W, <.SubsystemName, .HandleId, .ObjectTypeName, .ObjectName, .SecurityDescriptor, .PrincipalSelfSid,  \
        .DesiredAccess, .AuditType, .Flags, .ObjectTypeList, .ObjectTypeListLength, .GenericMapping, .ObjectCreation, .GrantedAccess,  \
        .AccessStatusList, .pfG>,  'AccessCheckByTypeResultListAndAuditAlarmW',  \
    AddAccessAllowedAce, N, <.pAcl, .dwAceRevision, .AccessMask, .pSid>,  'AddAccessAllowedAce',  \
    AddAccessAllowedAceEx, N, <.pAcl, .dwAceRevision, .AceFlags, .AccessMask, .pSid>,  'AddAccessAllowedAceEx',  \
    AddAccessAllowedObjectAce, N, <.pAcl, .dwAceRevision, .AceFlags, .AccessMask, .ObjectTypeGuid, .ByRefheritedObjectTypeGuid, .pSid,  \
      >,  'AddAccessAllowedObjectAce',  \
    AddAccessDeniedAce, N, <.pAcl, .dwAceRevision, .AccessMask, .pSid>,  'AddAccessDeniedAce',  \
    AddAccessDeniedAceEx, N, <.pAcl, .dwAceRevision, .AceFlags, .AccessMask, .pSid>,  'AddAccessDeniedAceEx',  \
    AddAccessDeniedObjectAce, N, <.pAcl, .dwAceRevision, .AceFlags, .AccessMask, .ObjectTypeGuid, .ByRefheritedObjectTypeGuid, .pSid,  \
      >,  'AddAccessDeniedObjectAce',  \
    AddAce, N, <.pAcl, .dwAceRevision, .dwStartingAceIndex, .pAceList, .nAceListLength>,  'AddAce',  \
    AddAuditAccessAce, N, <.pAcl, .dwAceRevision, .dwAccessMask, .pSid, .bAuditSuccess, .bAuditFailure>,  'AddAuditAccessAce',  \
    AddAuditAccessAceEx, N, <.pAcl, .dwAceRevision, .AceFlags, .dwAccessMask, .pSid, .bAuditSuccess, .bAuditFailure>,  'AddAuditAccessAceEx',  \
    AddAuditAccessObjectAce, N, <.pAcl, .dwAceRevision, .AceFlags, .AccessMask, .ObjectTypeGuid, .ByRefheritedObjectTypeGuid, .pSid, .bAuditSuccess,  \
        .bAuditFailure>,  'AddAuditAccessObjectAce',  \
    AddUsersToEncryptedFile, N, <.lpFileName, .pUsers>,  'AddUsersToEncryptedFile',  \
    AdjustTokenGroups, N, <.TokenHandle, .ResetToDefault, .NewState, .BufferLength, .PreviousState, .ReturnLength>,  'AdjustTokenGroups',  \
    AdjustTokenPrivileges, N, <.TokenHandle, .DisableAllPrivileges, .NewState, .BufferLength, .PreviousState, .ReturnLength>,  'AdjustTokenPrivileges',  \
    AllocateAndInitializeSid, N, <.pIdentifierAuthority, .nSubAuthorityCount, .nSubAuthority0, .nSubAuthority1, .nSubAuthority2, .nSubAuthority3,  \
        .nSubAuthority4, .nSubAuthority5, .nSubAuthority6, .nSubAuthority7, .lpPSid>,  'AllocateAndInitializeSid',  \
    AllocateLocallyUniqueId, N, <.Luid>,  'AllocateLocallyUniqueId',  \
    AreAllAccessesGranted, N, <.GrantedAccess, .DesiredAccess>,  'AreAllAccessesGranted',  \
    AreAnyAccessesGranted, N, <.GrantedAccess, .DesiredAccess>,  'AreAnyAccessesGranted',  \
    BackupEventLog, A, <.hEventLog, .lpBackupFileName>,  'BackupEventLogA',  \
    BackupEventLog, W, <.hEventLog, .lpBackupFileName>,  'BackupEventLogW',  \
    BuildExplicitAccessWithName, A, <.pExplicitAccess, .pTrusteeName, .AccessPermissions, .AccessMode, .Inheritance>,  'BuildExplicitAccessWithNameA',  \
    BuildExplicitAccessWithName, W, <.pExplicitAccess, .pTrusteeName, .AccessPermissions, .AccessMode, .Inheritance>,  'BuildExplicitAccessWithNameW',  \
    BuildImpersonateExplicitAccessWithName, A, <.pExplicitAccess, .pTrusteeName, .pTrustee, .AccessPermissions, .AccessMode, .Inheritance,  \
      >,  'BuildImpersonateExplicitAccessWithNameA',  \
    BuildImpersonateExplicitAccessWithName, W, <.pExplicitAccess, .pTrusteeName, .pTrustee, .AccessPermissions, .AccessMode, .Inheritance,  \
      >,  'BuildImpersonateExplicitAccessWithNameW',  \
    BuildImpersonateTrustee, A, <.pTrustee, .pImpersonateTrustee>,  'BuildImpersonateTrusteeA',  \
    BuildImpersonateTrustee, W, <.pTrustee, .pImpersonateTrustee>,  'BuildImpersonateTrusteeW',  \
    BuildSecurityDescriptor, A, <.pOwner, .pGroup, .cCountOfAccessEntries, .pListOfAccessEntries, .cCountOfAuditEntries, .pListOfAuditEntries,  \
        .pOldSD, .pSizeNewSD, .pNewSD>,  'BuildSecurityDescriptorA',  \
    BuildSecurityDescriptor, W, <.pOwner, .pGroup, .cCountOfAccessEntries, .pListOfAccessEntries, .cCountOfAuditEntries, .pListOfAuditEntries,  \
        .pOldSD, .pSizeNewSD, .pNewSD>,  'BuildSecurityDescriptorW',  \
    BuildTrusteeWithName, A, <.pTrustee, .pname>,  'BuildTrusteeWithNameA',  \
    BuildTrusteeWithName, W, <.pTrustee, .pname>,  'BuildTrusteeWithNameW',  \
    BuildTrusteeWithObjectsAndName, A, <.pTrustee, .pObjName, .ObjectType, .ObjectTypeName, .InheritedObjectTypeName, .name>,  'BuildTrusteeWithObjectsAndNameA',  \
    BuildTrusteeWithObjectsAndName, W, <.pTrustee, .pObjName, .ObjectType, .ObjectTypeName, .InheritedObjectTypeName, .name>,  'BuildTrusteeWithObjectsAndNameW',  \
    BuildTrusteeWithObjectsAndSid, A, <.pTrustee, .pObjSid, .pObjectGuid, .pInheritedObjectGuid, .pSid>,  'BuildTrusteeWithObjectsAndSidA',  \
    BuildTrusteeWithObjectsAndSid, W, <.pTrustee, .pObjSid, .pObjectGuid, .pInheritedObjectGuid, .pSid>,  'BuildTrusteeWithObjectsAndSidW',  \
    BuildTrusteeWithSid, A, <.pTrustee, .pSid>,  'BuildTrusteeWithSidA',  \
    BuildTrusteeWithSid, W, <.pTrustee, .pSid>,  'BuildTrusteeWithSidW',  \
    CancelOverlappedAccess, N, <NONE>,  'CancelOverlappedAccess',  \
    ChangeServiceConfig2, A, <.hService, .dwInfoLevel, .lpInfo>,  'ChangeServiceConfig2A',  \
    ChangeServiceConfig2, W, <.hService, .dwInfoLevel, .lpInfo>,  'ChangeServiceConfig2W',  \
    ChangeServiceConfig, A, <.hService, .dwServiceType, .dwStartType, .dwErrorControl, .lpBinaryPathName, .lpLoadOrderGroup, .lpdwTagId,  \
        .lpDependencies, .lpServiceStartName, .lpPassword, .lpDisplayName>,  'ChangeServiceConfigA',  \
    ChangeServiceConfig, W, <.hService, .dwServiceType, .dwStartType, .dwErrorControl, .lpBinaryPathName, .lpLoadOrderGroup, .lpdwTagId,  \
        .lpDependencies, .lpServiceStartName, .lpPassword, .lpDisplayName>,  'ChangeServiceConfigW',  \
    CheckTokenMembership, N, <.TokenHandle, .SidToCheck, .IsMember>,  'CheckTokenMembership',  \
    ClearEventLog, A, <.hEventLog, .lpBackupFileName>,  'ClearEventLogA',  \
    ClearEventLog, W, <.hEventLog, .lpBackupFileName>,  'ClearEventLogW',  \
    CloseCodeAuthzLevel, N, <NONE>,  'CloseCodeAuthzLevel',  \
    CloseEncryptedFileRaw, N, <.pvContext>,  'CloseEncryptedFileRaw',  \
    CloseEventLog, N, <.hEventLog>,  'CloseEventLog',  \
    CloseServiceHandle, N, <.hSCObject>,  'CloseServiceHandle',  \
    CloseTrace, N, <NONE>,  'CloseTrace',  \
    CommandLineFromMsiDescriptor, N, <NONE>,  'CommandLineFromMsiDescriptor',  \
    ComputeAccessTokenFromCodeAuthzLevel, N, <NONE>,  'ComputeAccessTokenFromCodeAuthzLevel',  \
    ControlService, N, <.hService, .dwControl, .lpServiceStatus>,  'ControlService',  \
    ControlTrace, A, <NONE>,  'ControlTraceA',  \
    ControlTrace, W, <NONE>,  'ControlTraceW',  \
    ConvertAccessToSecurityDescriptor, A, <NONE>,  'ConvertAccessToSecurityDescriptorA',  \
    ConvertAccessToSecurityDescriptor, W, <NONE>,  'ConvertAccessToSecurityDescriptorW',  \
    ConvertSDToStringSDRootDomain, A, <NONE>,  'ConvertSDToStringSDRootDomainA',  \
    ConvertSDToStringSDRootDomain, W, <NONE>,  'ConvertSDToStringSDRootDomainW',  \
    ConvertSecurityDescriptorToAccess, A, <NONE>,  'ConvertSecurityDescriptorToAccessA',  \
    ConvertSecurityDescriptorToAccessNamed, A, <NONE>,  'ConvertSecurityDescriptorToAccessNamedA',  \
    ConvertSecurityDescriptorToAccessNamed, W, <NONE>,  'ConvertSecurityDescriptorToAccessNamedW',  \
    ConvertSecurityDescriptorToAccess, W, <NONE>,  'ConvertSecurityDescriptorToAccessW',  \
    ConvertSecurityDescriptorToStringSecurityDescriptor, A, <.SecurityDescriptor, .RequestedStringSDRevision, .SecurityInformation, .StringSecurityDescriptor,  \
        .StringSecurityDescriptorLen>,  'ConvertSecurityDescriptorToStringSecurityDescriptorA',  \
    ConvertSecurityDescriptorToStringSecurityDescriptor, W, <.SecurityDescriptor, .RequestedStringSDRevision, .SecurityInformation, .StringSecurityDescriptor,  \
        .StringSecurityDescriptorLen>,  'ConvertSecurityDescriptorToStringSecurityDescriptorW',  \
    ConvertSidToStringSid, A, <.Sid, .StringSid>,  'ConvertSidToStringSidA',  \
    ConvertSidToStringSid, W, <.Sid, .StringSid>,  'ConvertSidToStringSidW',  \
    ConvertStringSDToSDDomain, A, <NONE>,  'ConvertStringSDToSDDomainA',  \
    ConvertStringSDToSDDomain, W, <NONE>,  'ConvertStringSDToSDDomainW',  \
    ConvertStringSDToSDRootDomain, A, <NONE>,  'ConvertStringSDToSDRootDomainA',  \
    ConvertStringSDToSDRootDomain, W, <NONE>,  'ConvertStringSDToSDRootDomainW',  \
    ConvertStringSecurityDescriptorToSecurityDescriptor, A, <.StringSecurityDescriptor, .StringSDRevision, .SecurityDescriptor, .SecurityDescriptorSize,  \
      >,  'ConvertStringSecurityDescriptorToSecurityDescriptorA',  \
    ConvertStringSecurityDescriptorToSecurityDescriptor, W, <.StringSecurityDescriptor, .StringSDRevision, .SecurityDescriptor, .SecurityDescriptorSize,  \
      >,  'ConvertStringSecurityDescriptorToSecurityDescriptorW',  \
    ConvertStringSidToSid, A, <.StringSid, .Sid>,  'ConvertStringSidToSidA',  \
    ConvertStringSidToSid, W, <.StringSid, .Sid>,  'ConvertStringSidToSidW',  \
    ConvertToAutoInheritPrivateObjectSecurity, N, <.ParentDescriptor, .CurrentSecurityDescriptor, .NewSecurityDescriptor, .ObjectType,  \
        .IsDirectoryObject, .GenericMapping>,  'ConvertToAutoInheritPrivateObjectSecurity',  \
    CopySid, N, <.nDestinationSidLength, .pDestinationSid, .pSourceSid>,  'CopySid',  \
    CreateCodeAuthzLevel, N, <NONE>,  'CreateCodeAuthzLevel',  \
    CreatePrivateObjectSecurity, N, <.ParentDescriptor, .CreatorDescriptor, .NewDescriptor, .IsDirectoryObject, .Token, .GenericMapping,  \
      >,  'CreatePrivateObjectSecurity',  \
    CreatePrivateObjectSecurityEx, N, <.ParentDescriptor, .CreatorDescriptor, .NewDescriptor, .ObjectType, .IsContainerObject, .AutoInheritFlags,  \
        .Token, .GenericMapping>,  'CreatePrivateObjectSecurityEx',  \
    CreatePrivateObjectSecurityWithMultipleInheritance, N, <NONE>,  'CreatePrivateObjectSecurityWithMultipleInheritance',  \
    CreateProcessAsUser, A, <.hToken, .lpApplicationName, .lpCommandLine, .lpProcessAttributes, .lpThreadAttributes, .bInheritHandles,  \
        .dwCreationFlags, .lpEnvironment, .lpCurrentDirectory, .lpStartupInfo, .lpProcessInformation>,  'CreateProcessAsUserA',  \
    CreateProcessAsUserSecure, N, <NONE>,  'CreateProcessAsUserSecure',  \
    CreateProcessAsUser, W, <.hToken, .lpApplicationName, .lpCommandLine, .lpProcessAttributes, .lpThreadAttributes, .bInheritHandles,  \
        .dwCreationFlags, .lpEnvironment, .lpCurrentDirectory, .lpStartupInfo, .lpProcessInformation>,  'CreateProcessAsUserW',  \
    CreateProcessWithLogon, W, <NONE>,  'CreateProcessWithLogonW',  \
    CreateRestrictedToken, N, <.ExistingTokenHandle, .Flags, .DisableSidCount, .SidsToDisable, .DeletePrivilegeCount, .PrivilegesToDelete,  \
        .RestrictedSidCount, .SidsToRestrict, .NewTokenHandle>,  'CreateRestrictedToken',  \
    CreateService, A, <.hSCManager, .lpServiceName, .lpDisplayName, .dwDesiredAccess, .dwServiceType, .dwStartType, .dwErrorControl, .lpBinaryPathName,  \
        .lpLoadOrderGroup, .lpdwTagId, .lpDependencies, .lp, .lpPassword>,  'CreateServiceA',  \
    CreateService, W, <.hSCManager, .lpServiceName, .lpDisplayName, .dwDesiredAccess, .dwServiceType, .dwStartType, .dwErrorControl, .lpBinaryPathName,  \
        .lpLoadOrderGroup, .lpdwTagId, .lpDependencies, .lp, .lpPassword>,  'CreateServiceW',  \
    CreateTraceInstanceId, N, <NONE>,  'CreateTraceInstanceId',  \
    CreateWellKnownSid, N, <NONE>,  'CreateWellKnownSid',  \
    CredDelete, A, <NONE>,  'CredDeleteA',  \
    CredDelete, W, <NONE>,  'CredDeleteW',  \
    CredEnumerate, A, <NONE>,  'CredEnumerateA',  \
    CredEnumerate, W, <NONE>,  'CredEnumerateW',  \
    CredFree, N, <NONE>,  'CredFree',  \
    CredGetSessionTypes, N, <NONE>,  'CredGetSessionTypes',  \
    CredGetTargetInfo, A, <NONE>,  'CredGetTargetInfoA',  \
    CredGetTargetInfo, W, <NONE>,  'CredGetTargetInfoW',  \
    CredIsMarshaledCredential, A, <NONE>,  'CredIsMarshaledCredentialA',  \
    CredIsMarshaledCredential, W, <NONE>,  'CredIsMarshaledCredentialW',  \
    CredMarshalCredential, A, <NONE>,  'CredMarshalCredentialA',  \
    CredMarshalCredential, W, <NONE>,  'CredMarshalCredentialW',  \
    CredProfileLoaded, N, <NONE>,  'CredProfileLoaded',  \
    CredRead, A, <NONE>,  'CredReadA',  \
    CredReadDomainCredentials, A, <NONE>,  'CredReadDomainCredentialsA',  \
    CredReadDomainCredentials, W, <NONE>,  'CredReadDomainCredentialsW',  \
    CredRead, W, <NONE>,  'CredReadW',  \
    CredRename, A, <NONE>,  'CredRenameA',  \
    CredRename, W, <NONE>,  'CredRenameW',  \
    CredUnmarshalCredential, A, <NONE>,  'CredUnmarshalCredentialA',  \
    CredUnmarshalCredential, W, <NONE>,  'CredUnmarshalCredentialW',  \
    CredWrite, A, <NONE>,  'CredWriteA',  \
    CredWriteDomainCredentials, A, <NONE>,  'CredWriteDomainCredentialsA',  \
    CredWriteDomainCredentials, W, <NONE>,  'CredWriteDomainCredentialsW',  \
    CredWrite, W, <NONE>,  'CredWriteW',  \
    CredpConvertCredential, N, <NONE>,  'CredpConvertCredential',  \
    CredpConvertTargetInfo, N, <NONE>,  'CredpConvertTargetInfo',  \
    CredpDecodeCredential, N, <NONE>,  'CredpDecodeCredential',  \
    CredpEncodeCredential, N, <NONE>,  'CredpEncodeCredential',  \
    CryptAcquireContext, A, <.phProv, .pszContainer, .pszProvider, .dwProvType, .dwFlags>,  'CryptAcquireContextA',  \
    CryptAcquireContext, W, <.phProv, .pszContainer, .pszProvider, .dwProvType, .dwFlags>,  'CryptAcquireContextW',  \
    CryptContextAddRef, N, <.hProv, .pdwReserved, .dwFlags>,  'CryptContextAddRef',  \
    CryptCreateHash, N, <.hProv, .Algid, .hKey, .dwFlags, .phHash>,  'CryptCreateHash',  \
    CryptDecrypt, N, <.hKey, .hHash, .Final, .dwFlags, .pbData, .pdwDataLen>,  'CryptDecrypt',  \
    CryptDeriveKey, N, <.hProv, .Algid, .hBaseData, .dwFlags, .phKey>,  'CryptDeriveKey',  \
    CryptDestroyHash, N, <.hHash>,  'CryptDestroyHash',  \
    CryptDestroyKey, N, <.hKey>,  'CryptDestroyKey',  \
    CryptDuplicateHash, N, <.hHash, .pdwReserved, .dwFlags, .phHash>,  'CryptDuplicateHash',  \
    CryptDuplicateKey, N, <.hKey, .pdwReserved, .dwFlags, .phKey>,  'CryptDuplicateKey',  \
    CryptEncrypt, N, <.hKey, .hHash, .Final, .dwFlags, .pbData, .pdwDataLen, .dwBufLen>,  'CryptEncrypt',  \
    CryptEnumProviderTypes, A, <.dwIndex, .pdwReserved, .dwFlags, .pdwProvType, .pszTypeName, .pcbTypeName>,  'CryptEnumProviderTypesA',  \
    CryptEnumProviderTypes, W, <.dwIndex, .pdwReserved, .dwFlags, .pdwProvType, .pszTypeName, .pcbTypeName>,  'CryptEnumProviderTypesW',  \
    CryptEnumProviders, A, <.dwIndex, .pdwReserved, .dwFlags, .pdwProvType, .pszProvName, .pcbProvName>,  'CryptEnumProvidersA',  \
    CryptEnumProviders, W, <.dwIndex, .pdwReserved, .dwFlags, .pdwProvType, .pszProvName, .pcbProvName>,  'CryptEnumProvidersW',  \
    CryptExportKey, N, <.hKey, .hExpKey, .dwBlobType, .dwFlags, .pbData, .pdwDataLen>,  'CryptExportKey',  \
    CryptGenKey, N, <.hProv, .Algid, .dwFlags, .phKey>,  'CryptGenKey',  \
    CryptGenRandom, N, <.hProv, .dwLen, .pbBuffer>,  'CryptGenRandom',  \
    CryptGetDefaultProvider, A, <.dwProvType, .pdwReserved, .dwFlags, .pszProvName, .pcbProvName>,  'CryptGetDefaultProviderA',  \
    CryptGetDefaultProvider, W, <.dwProvType, .pdwReserved, .dwFlags, .pszProvName, .pcbProvName>,  'CryptGetDefaultProviderW',  \
    CryptGetHashParam, N, <.hHash, .dwParam, .pbData, .pdwDataLen, .dwFlags>,  'CryptGetHashParam',  \
    CryptGetKeyParam, N, <.hKey, .dwParam, .pbData, .pdwDataLen, .dwFlags>,  'CryptGetKeyParam',  \
    CryptGetProvParam, N, <.hProv, .dwParam, .pbData, .pdwDataLen, .dwFlags>,  'CryptGetProvParam',  \
    CryptGetUserKey, N, <.hProv, .dwKeySpec, .phUserKey>,  'CryptGetUserKey',  \
    CryptHashData, N, <.hHash, .pbData, .dwDataLen, .dwFlags>,  'CryptHashData',  \
    CryptHashSessionKey, N, <.hHash, .hKey, .dwFlags>,  'CryptHashSessionKey',  \
    CryptImportKey, N, <.hProv, .pbData, .dwDataLen, .hPubKey, .dwFlags, .phKey>,  'CryptImportKey',  \
    CryptReleaseContext, N, <.hProv, .dwFlags>,  'CryptReleaseContext',  \
    CryptSetHashParam, N, <.hHash, .dwParam, .pbData, .dwFlags>,  'CryptSetHashParam',  \
    CryptSetKeyParam, N, <.hKey, .dwParam, .pbData, .dwFlags>,  'CryptSetKeyParam',  \
    CryptSetProvParam, N, <.hProv, .dwParam, .pbData, .dwFlags>,  'CryptSetProvParam',  \
    CryptSetProvider, A, <.pszProvName, .dwProvType>,  'CryptSetProviderA',  \
    CryptSetProviderEx, A, <.pszProvName, .dwProvType, .pdwReserved, .dwFlags>,  'CryptSetProviderExA',  \
    CryptSetProviderEx, W, <.pszProvName, .dwProvType, .pdwReserved, .dwFlags>,  'CryptSetProviderExW',  \
    CryptSetProvider, W, <.pszProvName, .dwProvType>,  'CryptSetProviderW',  \
    CryptSignHash, A, <.hHash, .dwKeySpec, .sDescription, .dwFlags, .pbSignature, .pdwSigLen>,  'CryptSignHashA',  \
    CryptSignHash, W, <.hHash, .dwKeySpec, .sDescription, .dwFlags, .pbSignature, .pdwSigLen>,  'CryptSignHashW',  \
    CryptVerifySignature, A, <.hHash, .pbSignature, .dwSigLen, .hPubKey, .sDescription, .dwFlags>,  'CryptVerifySignatureA',  \
    CryptVerifySignature, W, <.hHash, .pbSignature, .dwSigLen, .hPubKey, .sDescription, .dwFlags>,  'CryptVerifySignatureW',  \
    DecryptFile, A, <.lpFileName, .dwReserved>,  'DecryptFileA',  \
    DecryptFile, W, <.lpFileName, .dwReserved>,  'DecryptFileW',  \
    DeleteAce, N, <.pAcl, .dwAceIndex>,  'DeleteAce',  \
    DeleteService, N, <.hService>,  'DeleteService',  \
    DeregisterEventSource, N, <.hEventLog>,  'DeregisterEventSource',  \
    DestroyPrivateObjectSecurity, N, <.ObjectDescriptor>,  'DestroyPrivateObjectSecurity',  \
    DuplicateEncryptionInfoFile, N, <NONE>,  'DuplicateEncryptionInfoFile',  \
    DuplicateToken, N, <.ExistingTokenHandle, .ImpersonationLevel, .DuplicateTokenHandle>,  'DuplicateToken',  \
    DuplicateTokenEx, N, <.hExistingToken, .dwDesiredAccess, .lpTokenAttributes, .ImpersonationLevel, .TokenType, .phNewToken>,  'DuplicateTokenEx',  \
    ElfBackupEventLogFile, A, <NONE>,  'ElfBackupEventLogFileA',  \
    ElfBackupEventLogFile, W, <NONE>,  'ElfBackupEventLogFileW',  \
    ElfChangeNotify, N, <NONE>,  'ElfChangeNotify',  \
    ElfClearEventLogFile, A, <NONE>,  'ElfClearEventLogFileA',  \
    ElfClearEventLogFile, W, <NONE>,  'ElfClearEventLogFileW',  \
    ElfCloseEventLog, N, <NONE>,  'ElfCloseEventLog',  \
    ElfDeregisterEventSource, N, <NONE>,  'ElfDeregisterEventSource',  \
    ElfFlushEventLog, N, <NONE>,  'ElfFlushEventLog',  \
    ElfNumberOfRecords, N, <NONE>,  'ElfNumberOfRecords',  \
    ElfOldestRecord, N, <NONE>,  'ElfOldestRecord',  \
    ElfOpenBackupEventLog, A, <NONE>,  'ElfOpenBackupEventLogA',  \
    ElfOpenBackupEventLog, W, <NONE>,  'ElfOpenBackupEventLogW',  \
    ElfOpenEventLog, A, <NONE>,  'ElfOpenEventLogA',  \
    ElfOpenEventLog, W, <NONE>,  'ElfOpenEventLogW',  \
    ElfReadEventLog, A, <NONE>,  'ElfReadEventLogA',  \
    ElfReadEventLog, W, <NONE>,  'ElfReadEventLogW',  \
    ElfRegisterEventSource, A, <NONE>,  'ElfRegisterEventSourceA',  \
    ElfRegisterEventSource, W, <NONE>,  'ElfRegisterEventSourceW',  \
    ElfReportEvent, A, <NONE>,  'ElfReportEventA',  \
    ElfReportEvent, W, <NONE>,  'ElfReportEventW',  \
    EnableTrace, N, <NONE>,  'EnableTrace',  \
    EncryptFile, A, <.lpFileName>,  'EncryptFileA',  \
    EncryptFile, W, <.lpFileName>,  'EncryptFileW',  \
    EncryptedFileKeyInfo, N, <NONE>,  'EncryptedFileKeyInfo',  \
    EncryptionDisable, N, <.DirPath, .Disable>,  'EncryptionDisable',  \
    EnumDependentServices, A, <.hService, .dwServiceState, .lpServices, .cbBufSize, .pcbBytesNeeded, .lpServicesReturned>,  'EnumDependentServicesA',  \
    EnumDependentServices, W, <.hService, .dwServiceState, .lpServices, .cbBufSize, .pcbBytesNeeded, .lpServicesReturned>,  'EnumDependentServicesW',  \
    EnumServiceGroup, W, <NONE>,  'EnumServiceGroupW',  \
    EnumServicesStatus, A, <.hSCManager, .dwServiceType, .dwServiceState, .lpServices, .cbBufSize, .pcbBytesNeeded, .lpServicesReturned,  \
        .lpResumeHandle>,  'EnumServicesStatusA',  \
    EnumServicesStatusEx, A, <.hSCManager, .InfoLevel, .dwServiceType, .dwServiceState, .lpServices, .cbBufSize, .pcbBytesNeeded, .lpServicesReturned,  \
        .lpResumeHandle, .pszGroupName>,  'EnumServicesStatusExA',  \
    EnumServicesStatusEx, W, <.hSCManager, .InfoLevel, .dwServiceType, .dwServiceState, .lpServices, .cbBufSize, .pcbBytesNeeded, .lpServicesReturned,  \
        .lpResumeHandle, .pszGroupName>,  'EnumServicesStatusExW',  \
    EnumServicesStatus, W, <.hSCManager, .dwServiceType, .dwServiceState, .lpServices, .cbBufSize, .pcbBytesNeeded, .lpServicesReturned,  \
        .lpResumeHandle>,  'EnumServicesStatusW',  \
    EnumerateTraceGuids, N, <NONE>,  'EnumerateTraceGuids',  \
    EqualDomainSid, N, <NONE>,  'EqualDomainSid',  \
    EqualPrefixSid, N, <.pSid1, .pSid2>,  'EqualPrefixSid',  \
    EqualSid, N, <.pSid1, .pSid2>,  'EqualSid',  \
    FileEncryptionStatus, A, <.lpFileName, .lpStatus>,  'FileEncryptionStatusA',  \
    FileEncryptionStatus, W, <.lpFileName, .lpStatus>,  'FileEncryptionStatusW',  \
    FindFirstFreeAce, N, <.pAcl, .pAce>,  'FindFirstFreeAce',  \
    FlushTrace, A, <NONE>,  'FlushTraceA',  \
    FlushTrace, W, <NONE>,  'FlushTraceW',  \
    FreeEncryptedFileKeyInfo, N, <NONE>,  'FreeEncryptedFileKeyInfo',  \
    FreeEncryptionCertificateHashList, N, <.pHashes>,  'FreeEncryptionCertificateHashList',  \
    FreeInheritedFromArray, N, <.pInheritArray, .AceCnt, .pfnArray>,  'FreeInheritedFromArray',  \
    FreeSid, N, <.pSid>,  'FreeSid',  \
    GetAccessPermissionsForObject, A, <NONE>,  'GetAccessPermissionsForObjectA',  \
    GetAccessPermissionsForObject, W, <NONE>,  'GetAccessPermissionsForObjectW',  \
    GetAce, N, <.pAcl, .dwAceIndex, .pAce>,  'GetAce',  \
    GetAclInformation, N, <.pAcl, .pAclInformation, .nAclInformationLength, .dwAclInformationClass>,  'GetAclInformation',  \
    GetAuditedPermissionsFromAcl, A, <.pAcl, .pTrustee, .pSuccessfulAuditedRights, .pFailedAuditRights>,  'GetAuditedPermissionsFromAclA',  \
    GetAuditedPermissionsFromAcl, W, <.pAcl, .pTrustee, .pSuccessfulAuditedRights, .pFailedAuditRights>,  'GetAuditedPermissionsFromAclW',  \
    GetCurrentHwProfile, A, <.lpHwProfileInfo>,  'GetCurrentHwProfileA',  \
    GetCurrentHwProfile, W, <.lpHwProfileInfo>,  'GetCurrentHwProfileW',  \
    GetEffectiveRightsFromAcl, A, <.pAcl, .pTrustee, .pAccessRights>,  'GetEffectiveRightsFromAclA',  \
    GetEffectiveRightsFromAcl, W, <.pAcl, .pTrustee, .pAccessRights>,  'GetEffectiveRightsFromAclW',  \
    GetEventLogInformation, N, <.hEventLog, .dwInfoLevel, .lpBuffer, .cbBufSize, .pcbBytesNeeded>,  'GetEventLogInformation',  \
    GetExplicitEntriesFromAcl, A, <.pAcl, .pcCountOfExplicitEntries, .pListOfExplicitEntries>,  'GetExplicitEntriesFromAclA',  \
    GetExplicitEntriesFromAcl, W, <.pAcl, .pcCountOfExplicitEntries, .pListOfExplicitEntries>,  'GetExplicitEntriesFromAclW',  \
    GetFileSecurity, A, <.lpFileName, .RequestedInformation, .pSecurityDescriptor, .nLength, .lpnLengthNeeded>,  'GetFileSecurityA',  \
    GetFileSecurity, W, <.lpFileName, .RequestedInformation, .pSecurityDescriptor, .nLength, .lpnLengthNeeded>,  'GetFileSecurityW',  \
    GetInformationCodeAuthzLevel, W, <NONE>,  'GetInformationCodeAuthzLevelW',  \
    GetInformationCodeAuthzPolicy, W, <NONE>,  'GetInformationCodeAuthzPolicyW',  \
    GetInheritanceSource, A, <.pObjectName, .ObjectType, .SecurityInfo, .Container, .ObjectTypeGuid, .pAcl, .pfnArray, .pGenericMapping,  \
        .pInheritArray>,  'GetInheritanceSourceA',  \
    GetInheritanceSource, W, <.pObjectName, .ObjectType, .SecurityInfo, .Container, .ObjectTypeGuid, .pAcl, .pfnArray, .pGenericMapping,  \
        .pInheritArray>,  'GetInheritanceSourceW',  \
    GetKernelObjectSecurity, N, <.Handle, .RequestedInformation, .pSecurityDescriptor, .nLength, .lpnLengthNeeded>,  'GetKernelObjectSecurity',  \
    GetLengthSid, N, <.pSid>,  'GetLengthSid',  \
    GetLocalManagedApplicationData, N, <NONE>,  'GetLocalManagedApplicationData',  \
    GetLocalManagedApplications, N, <NONE>,  'GetLocalManagedApplications',  \
    GetManagedApplicationCategories, N, <NONE>,  'GetManagedApplicationCategories',  \
    GetManagedApplications, N, <NONE>,  'GetManagedApplications',  \
    GetMultipleTrustee, A, <.pTrustee>,  'GetMultipleTrusteeA',  \
    GetMultipleTrusteeOperation, A, <.pTrustee>,  'GetMultipleTrusteeOperationA',  \
    GetMultipleTrusteeOperation, W, <.pTrustee>,  'GetMultipleTrusteeOperationW',  \
    GetMultipleTrustee, W, <.pTrustee>,  'GetMultipleTrusteeW',  \
    GetNamedSecurityInfo, A, <.pObjectName, .ObjectType, .SecurityInfo, .ppsidOwner, .ppsidGroup, .ppDacl, .ppSacl, .ppSecurityDescriptor,  \
      >,  'GetNamedSecurityInfoA',  \
    GetNamedSecurityInfoEx, A, <NONE>,  'GetNamedSecurityInfoExA',  \
    GetNamedSecurityInfoEx, W, <NONE>,  'GetNamedSecurityInfoExW',  \
    GetNamedSecurityInfo, W, <.pObjectName, .ObjectType, .SecurityInfo, .ppsidOwner, .ppsidGroup, .ppDacl, .ppSacl, .ppSecurityDescriptor,  \
      >,  'GetNamedSecurityInfoW',  \
    GetNumberOfEventLogRecords, N, <.hEventLog, .NumberOfRecords>,  'GetNumberOfEventLogRecords',  \
    GetOldestEventLogRecord, N, <.hEventLog, .OldestRecord>,  'GetOldestEventLogRecord',  \
    GetOverlappedAccessResults, N, <NONE>,  'GetOverlappedAccessResults',  \
    GetPrivateObjectSecurity, N, <.ObjectDescriptor, .SecurityInformation, .ResultantDescriptor, .DescriptorLength, .ReturnLength>,  'GetPrivateObjectSecurity',  \
    GetSecurityDescriptorControl, N, <.pSecurityDescriptor, .pControl, .lpdwRevision>,  'GetSecurityDescriptorControl',  \
    GetSecurityDescriptorDacl, N, <.pSecurityDescriptor, .lpbDaclPresent, .pDacl, .lpbDaclDefaulted>,  'GetSecurityDescriptorDacl',  \
    GetSecurityDescriptorGroup, N, <.pSecurityDescriptor, .pGroup, .lpbGroupDefaulted>,  'GetSecurityDescriptorGroup',  \
    GetSecurityDescriptorLength, N, <.pSecurityDescriptor>,  'GetSecurityDescriptorLength',  \
    GetSecurityDescriptorOwner, N, <.pSecurityDescriptor, .pOwner, .lpbOwnerDefaulted>,  'GetSecurityDescriptorOwner',  \
    GetSecurityDescriptorRMControl, N, <.SecurityDescriptor, .RMControl>,  'GetSecurityDescriptorRMControl',  \
    GetSecurityDescriptorSacl, N, <.pSecurityDescriptor, .lpbSaclPresent, .pSacl, .lpbSaclDefaulted>,  'GetSecurityDescriptorSacl',  \
    GetSecurityInfo, N, <.Handle, .ObjectType, .SecurityInfo, .ppsidOwner, .ppsidGroup, .ppDacl, .ppSacl, .ppSecurityDescriptor>,  'GetSecurityInfo',  \
    GetSecurityInfoEx, A, <NONE>,  'GetSecurityInfoExA',  \
    GetSecurityInfoEx, W, <NONE>,  'GetSecurityInfoExW',  \
    GetServiceDisplayName, A, <.hSCManager, .lpServiceName, .lpDisplayName, .lpcchBuffer>,  'GetServiceDisplayNameA',  \
    GetServiceDisplayName, W, <.hSCManager, .lpServiceName, .lpDisplayName, .lpcchBuffer>,  'GetServiceDisplayNameW',  \
    GetServiceKeyName, A, <.hSCManager, .lpDisplayName, .lpServiceName, .lpcchBuffer>,  'GetServiceKeyNameA',  \
    GetServiceKeyName, W, <.hSCManager, .lpDisplayName, .lpServiceName, .lpcchBuffer>,  'GetServiceKeyNameW',  \
    GetSidIdentifierAuthority, N, <.pSid>,  'GetSidIdentifierAuthority',  \
    GetSidLengthRequired, N, <.nSubAuthorityCount>,  'GetSidLengthRequired',  \
    GetSidSubAuthority, N, <.pSid, .nSubAuthority>,  'GetSidSubAuthority',  \
    GetSidSubAuthorityCount, N, <.pSid>,  'GetSidSubAuthorityCount',  \
    GetTokenInformation, N, <.TokenHandle, .TokenInformationClass, .TokenInformation, .TokenInformationLength, .ReturnLength>,  'GetTokenInformation',  \
    GetTraceEnableFlags, N, <NONE>,  'GetTraceEnableFlags',  \
    GetTraceEnableLevel, N, <NONE>,  'GetTraceEnableLevel',  \
    GetTraceLoggerHandle, N, <NONE>,  'GetTraceLoggerHandle',  \
    GetTrusteeForm, A, <.pTrustee>,  'GetTrusteeFormA',  \
    GetTrusteeForm, W, <.pTrustee>,  'GetTrusteeFormW',  \
    GetTrusteeName, A, <.pTrustee>,  'GetTrusteeNameA',  \
    GetTrusteeName, W, <.pTrustee>,  'GetTrusteeNameW',  \
    GetTrusteeType, A, <.pTrustee>,  'GetTrusteeTypeA',  \
    GetTrusteeType, W, <.pTrustee>,  'GetTrusteeTypeW',  \
    GetUserName, A, <.lpBuffer, .nSize>,  'GetUserNameA',  \
    GetUserName, W, <.lpBuffer, .nSize>,  'GetUserNameW',  \
    GetWindowsAccountDomainSid, N, <NONE>,  'GetWindowsAccountDomainSid',  \
    I_ScGetCurrentGroupState, W, <NONE>,  'I_ScGetCurrentGroupStateW',  \
    I_ScIsSecurityProcess, N, <NONE>,  'I_ScIsSecurityProcess',  \
    I_ScPnPGetServiceName, N, <NONE>,  'I_ScPnPGetServiceName',  \
    I_ScSendTSMessage, N, <NONE>,  'I_ScSendTSMessage',  \
    I_ScSetServiceBits, A, <NONE>,  'I_ScSetServiceBitsA',  \
    I_ScSetServiceBits, W, <NONE>,  'I_ScSetServiceBitsW',  \
    IdentifyCodeAuthzLevel, W, <NONE>,  'IdentifyCodeAuthzLevelW',  \
    ImpersonateAnonymousToken, N, <.ThreadHandle>,  'ImpersonateAnonymousToken',  \
    ImpersonateLoggedOnUser, N, <.hToken>,  'ImpersonateLoggedOnUser',  \
    ImpersonateNamedPipeClient, N, <.hNamedPipe>,  'ImpersonateNamedPipeClient',  \
    ImpersonateSelf, N, <.ImpersonationLevel>,  'ImpersonateSelf',  \
    InitializeAcl, N, <.pAcl, .nAclLength, .dwAclRevision>,  'InitializeAcl',  \
    InitializeSecurityDescriptor, N, <.pSecurityDescriptor, .dwRevision>,  'InitializeSecurityDescriptor',  \
    InitializeSid, N, <.Sid, .pIdentifierAuthority, .nSubAuthorityCount>,  'InitializeSid',  \
    InitiateSystemShutdown, A, <.lpMachineName, .lpMessage, .dwTimeout, .bForceAppsClosed, .bRebootAfterShutdown>,  'InitiateSystemShutdownA',  \
    InitiateSystemShutdownEx, A, <.lpMachineName, .lpMessage, .dwTimeout, .bForceAppsClosed, .bRebootAfterShutdown, .dwReason>,  'InitiateSystemShutdownExA',  \
    InitiateSystemShutdownEx, W, <.lpMachineName, .lpMessage, .dwTimeout, .bForceAppsClosed, .bRebootAfterShutdown, .dwReason>,  'InitiateSystemShutdownExW',  \
    InitiateSystemShutdown, W, <.lpMachineName, .lpMessage, .dwTimeout, .bForceAppsClosed, .bRebootAfterShutdown>,  'InitiateSystemShutdownW',  \
    InstallApplication, N, <NONE>,  'InstallApplication',  \
    IsTextUnicode, N, <.lpBuffer, .cb, .lpi>,  'IsTextUnicode',  \
    IsTokenRestricted, N, <.TokenHandle>,  'IsTokenRestricted',  \
    IsTokenUntrusted, N, <NONE>,  'IsTokenUntrusted',  \
    IsValidAcl, N, <.pAcl>,  'IsValidAcl',  \
    IsValidSecurityDescriptor, N, <.pSecurityDescriptor>,  'IsValidSecurityDescriptor',  \
    IsValidSid, N, <.pSid>,  'IsValidSid',  \
    IsWellKnownSid, N, <NONE>,  'IsWellKnownSid',  \
    LockServiceDatabase, N, <.hSCManager>,  'LockServiceDatabase',  \
    LogonUser, A, <.lpszUsername, .lpszDomain, .lpszPassword, .dwLogonType, .dwLogonProvider, .phToken>,  'LogonUserA',  \
    LogonUserEx, A, <NONE>,  'LogonUserExA',  \
    LogonUserEx, W, <NONE>,  'LogonUserExW',  \
    LogonUser, W, <.lpszUsername, .lpszDomain, .lpszPassword, .dwLogonType, .dwLogonProvider, .phToken>,  'LogonUserW',  \
    LookupAccountName, A, <.lpSystemName, .lpAccountName, .Sid, .cbSid, .ReferencedDomainName, .cbReferencedDomainName, .peUse>,  'LookupAccountNameA',  \
    LookupAccountName, W, <.lpSystemName, .lpAccountName, .Sid, .cbSid, .ReferencedDomainName, .cbReferencedDomainName, .peUse>,  'LookupAccountNameW',  \
    LookupAccountSid, A, <.lpSystemName, .Sid, .Name, .cbName, .ReferencedDomainName, .cbReferencedDomainName, .peUse>,  'LookupAccountSidA',  \
    LookupAccountSid, W, <.lpSystemName, .Sid, .Name, .cbName, .ReferencedDomainName, .cbReferencedDomainName, .peUse>,  'LookupAccountSidW',  \
    LookupPrivilegeDisplayName, A, <.lpSystemName, .lpName, .lpDisplayName, .cbDisplayName, .lpLanguageID>,  'LookupPrivilegeDisplayNameA',  \
    LookupPrivilegeDisplayName, W, <.lpSystemName, .lpName, .lpDisplayName, .cbDisplayName, .lpLanguageID>,  'LookupPrivilegeDisplayNameW',  \
    LookupPrivilegeName, A, <.lpSystemName, .lpLuid, .lpName, .cbName>,  'LookupPrivilegeNameA',  \
    LookupPrivilegeName, W, <.lpSystemName, .lpLuid, .lpName, .cbName>,  'LookupPrivilegeNameW',  \
    LookupPrivilegeValue, A, <.lpSystemName, .lpName, .lpLuid>,  'LookupPrivilegeValueA',  \
    LookupPrivilegeValue, W, <.lpSystemName, .lpName, .lpLuid>,  'LookupPrivilegeValueW',  \
    LookupSecurityDescriptorParts, A, <.pOwner, .pGroup, .cCountOfAccessEntries, .pListOfAccessEntries, .cCountOfAuditEntries, .pListOfAuditEntries,  \
        .pSD>,  'LookupSecurityDescriptorPartsA',  \
    LookupSecurityDescriptorParts, W, <.pOwner, .pGroup, .cCountOfAccessEntries, .pListOfAccessEntries, .cCountOfAuditEntries, .pListOfAuditEntries,  \
        .pSD>,  'LookupSecurityDescriptorPartsW',  \
    LsaAddAccountRights, N, <.PolicyHandle, .AccountSid, .UserRights, .CountOfRights>,  'LsaAddAccountRights',  \
    LsaAddPrivilegesToAccount, N, <NONE>,  'LsaAddPrivilegesToAccount',  \
    LsaClearAuditLog, N, <NONE>,  'LsaClearAuditLog',  \
    LsaClose, N, <.ObjectHandle>,  'LsaClose',  \
    LsaCreateAccount, N, <NONE>,  'LsaCreateAccount',  \
    LsaCreateSecret, N, <NONE>,  'LsaCreateSecret',  \
    LsaCreateTrustedDomain, N, <NONE>,  'LsaCreateTrustedDomain',  \
    LsaCreateTrustedDomainEx, N, <.PolicyHandle, .TrustedDomainInformation, .AuthenticationInformation, .DesiredAccess, .TrustedDomainHandle,  \
      >,  'LsaCreateTrustedDomainEx',  \
    LsaDelete, N, <NONE>,  'LsaDelete',  \
    LsaDeleteTrustedDomain, N, <.PolicyHandle, .TrustedDomainSid>,  'LsaDeleteTrustedDomain',  \
    LsaEnumerateAccountRights, N, <.PolicyHandle, .AccountSid, .UserRights, .CountOfRights>,  'LsaEnumerateAccountRights',  \
    LsaEnumerateAccounts, N, <NONE>,  'LsaEnumerateAccounts',  \
    LsaEnumerateAccountsWithUserRight, N, <.PolicyHandle, .UserRights, .EnumerationBuffer, .CountReturned>,  'LsaEnumerateAccountsWithUserRight',  \
    LsaEnumeratePrivileges, N, <NONE>,  'LsaEnumeratePrivileges',  \
    LsaEnumeratePrivilegesOfAccount, N, <NONE>,  'LsaEnumeratePrivilegesOfAccount',  \
    LsaEnumerateTrustedDomains, N, <.PolicyHandle, .EnumerationContext, .buffer, .PreferedMaximumLength, .CountReturned>,  'LsaEnumerateTrustedDomains',  \
    LsaEnumerateTrustedDomainsEx, N, <.PolicyHandle, .EnumerationContext, .buffer, .PreferedMaximumLength, .CountReturned>,  'LsaEnumerateTrustedDomainsEx',  \
    LsaFreeMemory, N, <.buffer>,  'LsaFreeMemory',  \
    LsaGetQuotasForAccount, N, <NONE>,  'LsaGetQuotasForAccount',  \
    LsaGetRemoteUserName, N, <NONE>,  'LsaGetRemoteUserName',  \
    LsaGetSystemAccessAccount, N, <NONE>,  'LsaGetSystemAccessAccount',  \
    LsaGetUserName, N, <NONE>,  'LsaGetUserName',  \
    LsaICLookupNames, N, <NONE>,  'LsaICLookupNames',  \
    LsaICLookupNamesWithCreds, N, <NONE>,  'LsaICLookupNamesWithCreds',  \
    LsaICLookupSids, N, <NONE>,  'LsaICLookupSids',  \
    LsaICLookupSidsWithCreds, N, <NONE>,  'LsaICLookupSidsWithCreds',  \
    LsaLookupNames, N, <.PolicyHandle, .count, .Names, .ReferencedDomains, .Sids>,  'LsaLookupNames',  \
    LsaLookupNames2, N, <NONE>,  'LsaLookupNames2',  \
    LsaLookupPrivilegeDisplayName, N, <NONE>,  'LsaLookupPrivilegeDisplayName',  \
    LsaLookupPrivilegeName, N, <NONE>,  'LsaLookupPrivilegeName',  \
    LsaLookupPrivilegeValue, N, <NONE>,  'LsaLookupPrivilegeValue',  \
    LsaLookupSids, N, <.PolicyHandle, .count, .Sids, .ReferencedDomains, .Names>,  'LsaLookupSids',  \
    LsaNtStatusToWinError, N, <.Status>,  'LsaNtStatusToWinError',  \
    LsaOpenAccount, N, <NONE>,  'LsaOpenAccount',  \
    LsaOpenPolicy, N, <.SystemName, .ObjectAttributes, .DesiredAccess, .PolicyHandle>,  'LsaOpenPolicy',  \
    LsaOpenPolicySce, N, <NONE>,  'LsaOpenPolicySce',  \
    LsaOpenSecret, N, <NONE>,  'LsaOpenSecret',  \
    LsaOpenTrustedDomain, N, <NONE>,  'LsaOpenTrustedDomain',  \
    LsaOpenTrustedDomainByName, N, <.PolicyHandle, .TrustedDomainName, .DesiredAccess, .TrustedDomainHandle>,  'LsaOpenTrustedDomainByName',  \
    LsaQueryDomainInformationPolicy, N, <.PolicyHandle, .InformationClass, .buffer>,  'LsaQueryDomainInformationPolicy',  \
    LsaQueryForestTrustInformation, N, <NONE>,  'LsaQueryForestTrustInformation',  \
    LsaQueryInfoTrustedDomain, N, <NONE>,  'LsaQueryInfoTrustedDomain',  \
    LsaQueryInformationPolicy, N, <.PolicyHandle, .InformationClass, .buffer>,  'LsaQueryInformationPolicy',  \
    LsaQuerySecret, N, <NONE>,  'LsaQuerySecret',  \
    LsaQuerySecurityObject, N, <NONE>,  'LsaQuerySecurityObject',  \
    LsaQueryTrustedDomainInfo, N, <.PolicyHandle, .TrustedDomainSid, .InformationClass, .buffer>,  'LsaQueryTrustedDomainInfo',  \
    LsaQueryTrustedDomainInfoByName, N, <.PolicyHandle, .TrustedDomainName, .InformationClass, .buffer>,  'LsaQueryTrustedDomainInfoByName',  \
    LsaRemoveAccountRights, N, <.PolicyHandle, .AccountSid, .AllRights, .UserRights, .CountOfRights>,  'LsaRemoveAccountRights',  \
    LsaRemovePrivilegesFromAccount, N, <NONE>,  'LsaRemovePrivilegesFromAccount',  \
    LsaRetrievePrivateData, N, <.PolicyHandle, .KeyName, .PrivateData>,  'LsaRetrievePrivateData',  \
    LsaSetDomainInformationPolicy, N, <.PolicyHandle, .InformationClass, .buffer>,  'LsaSetDomainInformationPolicy',  \
    LsaSetForestTrustInformation, N, <NONE>,  'LsaSetForestTrustInformation',  \
    LsaSetInformationPolicy, N, <.PolicyHandle, .InformationClass, .buffer>,  'LsaSetInformationPolicy',  \
    LsaSetInformationTrustedDomain, N, <NONE>,  'LsaSetInformationTrustedDomain',  \
    LsaSetQuotasForAccount, N, <NONE>,  'LsaSetQuotasForAccount',  \
    LsaSetSecret, N, <NONE>,  'LsaSetSecret',  \
    LsaSetSecurityObject, N, <NONE>,  'LsaSetSecurityObject',  \
    LsaSetSystemAccessAccount, N, <NONE>,  'LsaSetSystemAccessAccount',  \
    LsaSetTrustedDomainInfoByName, N, <.PolicyHandle, .TrustedDomainName, .InformationClass, .buffer>,  'LsaSetTrustedDomainInfoByName',  \
    LsaSetTrustedDomainInformation, N, <.PolicyHandle, .TrustedDomainSid, .InformationClass, .buffer>,  'LsaSetTrustedDomainInformation',  \
    LsaStorePrivateData, N, <.PolicyHandle, .KeyName, .PrivateData>,  'LsaStorePrivateData',  \
    MD4Final, N, <NONE>,  'MD4Final',  \
    MD4Init, N, <NONE>,  'MD4Init',  \
    MD4Update, N, <NONE>,  'MD4Update',  \
    MD5Final, N, <NONE>,  'MD5Final',  \
    MD5Init, N, <NONE>,  'MD5Init',  \
    MD5Update, N, <NONE>,  'MD5Update',  \
    MSChapSrvChangePassword, N, <NONE>,  'MSChapSrvChangePassword',  \
    MSChapSrvChangePassword2, N, <NONE>,  'MSChapSrvChangePassword2',  \
    MakeAbsoluteSD, N, <.pSelfRelativeSecurityDescriptor, .pAbsoluteSecurityDescriptor, .lpdwAbsoluteSecurityDescriptorSize, .pDacl, .lpdwDaclSize,  \
        .pSacl, .lpdwSaclSize, .pOwner, .lpdwOwnerSize, .pPrimaryGroup, .lpdwPrimaryGroupSize>,  'MakeAbsoluteSD',  \
    MakeAbsoluteSD2, N, <.pSelfRelativeSecurityDescriptor, .lpdwBufferSize>,  'MakeAbsoluteSD2',  \
    MakeSelfRelativeSD, N, <.pAbsoluteSecurityDescriptor, .pSelfRelativeSecurityDescriptor, .lpdwBufferLength>,  'MakeSelfRelativeSD',  \
    MapGenericMask, N, <.AccessMask, .GenericMapping>,  'MapGenericMask',  \
    NotifyBootConfigStatus, N, <.BootAcceptable>,  'NotifyBootConfigStatus',  \
    NotifyChangeEventLog, N, <.hEventLog, .hEvent>,  'NotifyChangeEventLog',  \
    ObjectCloseAuditAlarm, A, <.SubsystemName, .HandleId, .GenerateOnClose>,  'ObjectCloseAuditAlarmA',  \
    ObjectCloseAuditAlarm, W, <.SubsystemName, .HandleId, .GenerateOnClose>,  'ObjectCloseAuditAlarmW',  \
    ObjectDeleteAuditAlarm, A, <.SubsystemName, .HandleId, .GenerateOnClose>,  'ObjectDeleteAuditAlarmA',  \
    ObjectDeleteAuditAlarm, W, <.SubsystemName, .HandleId, .GenerateOnClose>,  'ObjectDeleteAuditAlarmW',  \
    ObjectOpenAuditAlarm, A, <.SubsystemName, .HandleId, .ObjectTypeName, .ObjectName, .pSecurityDescriptor, .ClientToken, .DesiredAccess,  \
        .GrantedAccess, .Privileges, .ObjectCreation, .AccessGranted, .GenerateOnClose>,  'ObjectOpenAuditAlarmA',  \
    ObjectOpenAuditAlarm, W, <.SubsystemName, .HandleId, .ObjectTypeName, .ObjectName, .pSecurityDescriptor, .ClientToken, .DesiredAccess,  \
        .GrantedAccess, .Privileges, .ObjectCreation, .AccessGranted, .GenerateOnClose>,  'ObjectOpenAuditAlarmW',  \
    ObjectPrivilegeAuditAlarm, A, <.SubsystemName, .HandleId, .ClientToken, .DesiredAccess, .Privileges, .AccessGranted>,  'ObjectPrivilegeAuditAlarmA',  \
    ObjectPrivilegeAuditAlarm, W, <.SubsystemName, .HandleId, .ClientToken, .DesiredAccess, .Privileges, .AccessGranted>,  'ObjectPrivilegeAuditAlarmW',  \
    OpenBackupEventLog, A, <.lpUNCServerName, .lpFileName>,  'OpenBackupEventLogA',  \
    OpenBackupEventLog, W, <.lpUNCServerName, .lpFileName>,  'OpenBackupEventLogW',  \
    OpenEncryptedFileRaw, A, <.lpFileName, .ulFlags, .pvContext>,  'OpenEncryptedFileRawA',  \
    OpenEncryptedFileRaw, W, <.lpFileName, .ulFlags, .pvContext>,  'OpenEncryptedFileRawW',  \
    OpenEventLog, A, <.lpUNCServerName, .lpSourceName>,  'OpenEventLogA',  \
    OpenEventLog, W, <.lpUNCServerName, .lpSourceName>,  'OpenEventLogW',  \
    OpenProcessToken, N, <.ProcessHandle, .DesiredAccess, .TokenHandle>,  'OpenProcessToken',  \
    OpenSCManager, A, <.lpMachineName, .lpDatabaseName, .dwDesiredAccess>,  'OpenSCManagerA',  \
    OpenSCManager, W, <.lpMachineName, .lpDatabaseName, .dwDesiredAccess>,  'OpenSCManagerW',  \
    OpenService, A, <.hSCManager, .lpServiceName, .dwDesiredAccess>,  'OpenServiceA',  \
    OpenService, W, <.hSCManager, .lpServiceName, .dwDesiredAccess>,  'OpenServiceW',  \
    OpenThreadToken, N, <.ThreadHandle, .DesiredAccess, .OpenAsSelf, .TokenHandle>,  'OpenThreadToken',  \
    OpenTrace, A, <NONE>,  'OpenTraceA',  \
    OpenTrace, W, <NONE>,  'OpenTraceW',  \
    PrivilegeCheck, N, <.ClientToken, .RequiredPrivileges, .pfResult>,  'PrivilegeCheck',  \
    PrivilegedServiceAuditAlarm, A, <.SubsystemName, .ServiceName, .ClientToken, .Privileges, .AccessGranted>,  'PrivilegedServiceAuditAlarmA',  \
    PrivilegedServiceAuditAlarm, W, <.SubsystemName, .ServiceName, .ClientToken, .Privileges, .AccessGranted>,  'PrivilegedServiceAuditAlarmW',  \
    ProcessIdleTasks, N, <NONE>,  'ProcessIdleTasks',  \
    ProcessTrace, N, <NONE>,  'ProcessTrace',  \
    QueryAllTraces, A, <NONE>,  'QueryAllTracesA',  \
    QueryAllTraces, W, <NONE>,  'QueryAllTracesW',  \
    QueryRecoveryAgentsOnEncryptedFile, N, <.lpFileName, .pRecoveryAgents>,  'QueryRecoveryAgentsOnEncryptedFile',  \
    QueryServiceConfig2, A, <.hService, .dwInfoLevel, .lpBuffer, .cbBufSize, .pcbBytesNeeded>,  'QueryServiceConfig2A',  \
    QueryServiceConfig2, W, <.hService, .dwInfoLevel, .lpBuffer, .cbBufSize, .pcbBytesNeeded>,  'QueryServiceConfig2W',  \
    QueryServiceConfig, A, <.hService, .lpServiceConfig, .cbBufSize, .pcbBytesNeeded>,  'QueryServiceConfigA',  \
    QueryServiceConfig, W, <.hService, .lpServiceConfig, .cbBufSize, .pcbBytesNeeded>,  'QueryServiceConfigW',  \
    QueryServiceLockStatus, A, <.hSCManager, .lpLockStatus, .cbBufSize, .pcbBytesNeeded>,  'QueryServiceLockStatusA',  \
    QueryServiceLockStatus, W, <.hSCManager, .lpLockStatus, .cbBufSize, .pcbBytesNeeded>,  'QueryServiceLockStatusW',  \
    QueryServiceObjectSecurity, N, <.hService, .dwSecurityInformation, .lpSecurityDescriptor, .cbBufSize, .pcbBytesNeeded>,  'QueryServiceObjectSecurity',  \
    QueryServiceStatus, N, <.hService, .lpServiceStatus>,  'QueryServiceStatus',  \
    QueryServiceStatusEx, N, <.hService, .InfoLevel, .lpBuffer, .cbBufSize, .pcbBytesNeeded>,  'QueryServiceStatusEx',  \
    QueryTrace, A, <NONE>,  'QueryTraceA',  \
    QueryTrace, W, <NONE>,  'QueryTraceW',  \
    QueryUsersOnEncryptedFile, N, <.lpFileName, .pUsers>,  'QueryUsersOnEncryptedFile',  \
    QueryWindows31FilesMigration, N, <NONE>,  'QueryWindows31FilesMigration',  \
    ReadEncryptedFileRaw, N, <.pfExportCallback, .pvCallbackContext, .pvContext>,  'ReadEncryptedFileRaw',  \
    ReadEventLog, A, <.hEventLog, .dwReadFlags, .dwRecordOffset, .lpBuffer, .nNumberOfBytesToRead, .pnBytesRead, .pnMinNumberOfBytesNeeded,  \
      >,  'ReadEventLogA',  \
    ReadEventLog, W, <.hEventLog, .dwReadFlags, .dwRecordOffset, .lpBuffer, .nNumberOfBytesToRead, .pnBytesRead, .pnMinNumberOfBytesNeeded,  \
      >,  'ReadEventLogW',  \
    RegCloseKey, N, <.hKey>,  'RegCloseKey',  \
    RegConnectRegistry, A, <.lpMachineName, .hKey, .phkResult>,  'RegConnectRegistryA',  \
    RegConnectRegistry, W, <.lpMachineName, .hKey, .phkResult>,  'RegConnectRegistryW',  \
    RegCreateKey, A, <.hKey, .lpSubKey, .phkResult>,  'RegCreateKeyA',  \
    RegCreateKeyEx, A, <.hKey, .lpSubKey, .Reserved, .lpClass, .dwOptions, .samDesired, .lpSecurityAttributes, .phkResult, .lpdwDisposition,  \
      >,  'RegCreateKeyExA',  \
    RegCreateKeyEx, W, <.hKey, .lpSubKey, .Reserved, .lpClass, .dwOptions, .samDesired, .lpSecurityAttributes, .phkResult, .lpdwDisposition,  \
      >,  'RegCreateKeyExW',  \
    RegCreateKey, W, <.hKey, .lpSubKey, .phkResult>,  'RegCreateKeyW',  \
    RegDeleteKey, A, <.hKey, .lpSubKey>,  'RegDeleteKeyA',  \
    RegDeleteKey, W, <.hKey, .lpSubKey>,  'RegDeleteKeyW',  \
    RegDeleteValue, A, <.hKey, .lpValueName>,  'RegDeleteValueA',  \
    RegDeleteValue, W, <.hKey, .lpValueName>,  'RegDeleteValueW',  \
    RegDisablePredefinedCache, N, <VOID>,  'RegDisablePredefinedCache',  \
    RegDisablePredefinedCacheEx, N, <NONE>,  'RegDisablePredefinedCacheEx',  \
    RegEnumKey, A, <.hKey, .dwIndex, .lpName, .cbName>,  'RegEnumKeyA',  \
    RegEnumKeyEx, A, <.hKey, .dwIndex, .lpName, .lpcbName, .lpReserved, .lpClass, .lpcbClass, .lpftLastWriteTime>,  'RegEnumKeyExA',  \
    RegEnumKeyEx, W, <.hKey, .dwIndex, .lpName, .lpcbName, .lpReserved, .lpClass, .lpcbClass, .lpftLastWriteTime>,  'RegEnumKeyExW',  \
    RegEnumKey, W, <.hKey, .dwIndex, .lpName, .cbName>,  'RegEnumKeyW',  \
    RegEnumValue, A, <.hKey, .dwIndex, .lpValueName, .lpcbValueName, .lpReserved, .lpType, .lpData, .lpcbData>,  'RegEnumValueA',  \
    RegEnumValue, W, <.hKey, .dwIndex, .lpValueName, .lpcbValueName, .lpReserved, .lpType, .lpData, .lpcbData>,  'RegEnumValueW',  \
    RegFlushKey, N, <.hKey>,  'RegFlushKey',  \
    RegGetKeySecurity, N, <.hKey, .SecurityInformation, .pSecurityDescriptor, .lpcbSecurityDescriptor>,  'RegGetKeySecurity',  \
    RegLoadKey, A, <.hKey, .lpSubKey, .lpFile>,  'RegLoadKeyA',  \
    RegLoadKey, W, <.hKey, .lpSubKey, .lpFile>,  'RegLoadKeyW',  \
    RegNotifyChangeKeyValue, N, <.hKey, .bWatchSubtree, .dwNotifyFilter, .hEvent, .fAsynchronus>,  'RegNotifyChangeKeyValue',  \
    RegOpenCurrentUser, N, <.samDesired, .phkResult>,  'RegOpenCurrentUser',  \
    RegOpenKey, A, <.hKey, .lpSubKey, .phkResult>,  'RegOpenKeyA',  \
    RegOpenKeyEx, A, <.hKey, .lpSubKey, .ulOptions, .samDesired, .phkResult>,  'RegOpenKeyExA',  \
    RegOpenKeyEx, W, <.hKey, .lpSubKey, .ulOptions, .samDesired, .phkResult>,  'RegOpenKeyExW',  \
    RegOpenKey, W, <.hKey, .lpSubKey, .phkResult>,  'RegOpenKeyW',  \
    RegOpenUserClassesRoot, N, <.hToken, .dwOptions, .samDesired, .phkResult>,  'RegOpenUserClassesRoot',  \
    RegOverridePredefKey, N, <.hKey, .hNewHKey>,  'RegOverridePredefKey',  \
    RegQueryInfoKey, A, <.hKey, .lpClass, .lpcbClass, .lpReserved, .lpcSubKeys, .lpcbMaxSubKeyLen, .lpcbMaxClassLen, .lpcValues, .lpcbMaxValueNameLen,  \
        .lpcbMaxValueLen, .lpcbSecurityDescriptor, .lpftLastWriteTime>,  'RegQueryInfoKeyA',  \
    RegQueryInfoKey, W, <.hKey, .lpClass, .lpcbClass, .lpReserved, .lpcSubKeys, .lpcbMaxSubKeyLen, .lpcbMaxClassLen, .lpcValues, .lpcbMaxValueNameLen,  \
        .lpcbMaxValueLen, .lpcbSecurityDescriptor, .lpftLastWriteTime>,  'RegQueryInfoKeyW',  \
    RegQueryMultipleValues, A, <.hKey, .val_list, .num_vals, .lpValueBuf, .ldwTotsize>,  'RegQueryMultipleValuesA',  \
    RegQueryMultipleValues, W, <.hKey, .val_list, .num_vals, .lpValueBuf, .ldwTotsize>,  'RegQueryMultipleValuesW',  \
    RegQueryValue, A, <.hKey, .lpSubKey, .lpValue, .lpcbValue>,  'RegQueryValueA',  \
    RegQueryValueEx, A, <.hKey, .lpValueName, .lpReserved, .lpType, .lpData, .lpcbData>,  'RegQueryValueExA',  \
    RegQueryValueEx, W, <.hKey, .lpValueName, .lpReserved, .lpType, .lpData, .lpcbData>,  'RegQueryValueExW',  \
    RegQueryValue, W, <.hKey, .lpSubKey, .lpValue, .lpcbValue>,  'RegQueryValueW',  \
    RegReplaceKey, A, <.hKey, .lpSubKey, .lpNewFile, .lpOldFile>,  'RegReplaceKeyA',  \
    RegReplaceKey, W, <.hKey, .lpSubKey, .lpNewFile, .lpOldFile>,  'RegReplaceKeyW',  \
    RegRestoreKey, A, <.hKey, .lpFile, .dwFlags>,  'RegRestoreKeyA',  \
    RegRestoreKey, W, <.hKey, .lpFile, .dwFlags>,  'RegRestoreKeyW',  \
    RegSaveKey, A, <.hKey, .lpFile, .lpSecurityAttributes>,  'RegSaveKeyA',  \
    RegSaveKeyEx, A, <NONE>,  'RegSaveKeyExA',  \
    RegSaveKeyEx, W, <NONE>,  'RegSaveKeyExW',  \
    RegSaveKey, W, <.hKey, .lpFile, .lpSecurityAttributes>,  'RegSaveKeyW',  \
    RegSetKeySecurity, N, <.hKey, .SecurityInformation, .pSecurityDescriptor>,  'RegSetKeySecurity',  \
    RegSetValue, A, <.hKey, .lpSubKey, .dwType, .lpData, .cbData>,  'RegSetValueA',  \
    RegSetValueEx, A, <.hKey, .lpValueName, .Reserved, .dwType, .lpData, .cbData>,  'RegSetValueExA',  \
    RegSetValueEx, W, <.hKey, .lpValueName, .Reserved, .dwType, .lpData, .cbData>,  'RegSetValueExW',  \
    RegSetValue, W, <.hKey, .lpSubKey, .dwType, .lpData, .cbData>,  'RegSetValueW',  \
    RegUnLoadKey, A, <.hKey, .lpSubKey>,  'RegUnLoadKeyA',  \
    RegUnLoadKey, W, <.hKey, .lpSubKey>,  'RegUnLoadKeyW',  \
    RegisterEventSource, A, <.lpUNCServerName, .lpSourceName>,  'RegisterEventSourceA',  \
    RegisterEventSource, W, <.lpUNCServerName, .lpSourceName>,  'RegisterEventSourceW',  \
    RegisterIdleTask, N, <NONE>,  'RegisterIdleTask',  \
    RegisterServiceCtrlHandler, A, <.lpServiceName, .lpHandlerProc>,  'RegisterServiceCtrlHandlerA',  \
    RegisterServiceCtrlHandlerEx, A, <.lpServiceName, .lpHandlerProc, .lpContext>,  'RegisterServiceCtrlHandlerExA',  \
    RegisterServiceCtrlHandlerEx, W, <.lpServiceName, .lpHandlerProc, .lpContext>,  'RegisterServiceCtrlHandlerExW',  \
    RegisterServiceCtrlHandler, W, <.lpServiceName, .lpHandlerProc>,  'RegisterServiceCtrlHandlerW',  \
    RegisterTraceGuids, A, <NONE>,  'RegisterTraceGuidsA',  \
    RegisterTraceGuids, W, <NONE>,  'RegisterTraceGuidsW',  \
    RemoveTraceCallback, N, <NONE>,  'RemoveTraceCallback',  \
    RemoveUsersFromEncryptedFile, N, <.lpFileName, .pHashes>,  'RemoveUsersFromEncryptedFile',  \
    ReportEvent, A, <.hEventLog, .wType, .wCategory, .dwEventID, .lpUserSid, .wNumStrings, .dwDataSize, .lpStrings, .lpRawData>,  'ReportEventA',  \
    ReportEvent, W, <.hEventLog, .wType, .wCategory, .dwEventID, .lpUserSid, .wNumStrings, .dwDataSize, .lpStrings, .lpRawData>,  'ReportEventW',  \
    RevertToSelf, N, <VOID>,  'RevertToSelf',  \
    SaferCloseLevel, N, <NONE>,  'SaferCloseLevel',  \
    SaferComputeTokenFromLevel, N, <NONE>,  'SaferComputeTokenFromLevel',  \
    SaferCreateLevel, N, <NONE>,  'SaferCreateLevel',  \
    SaferGetLevelInformation, N, <NONE>,  'SaferGetLevelInformation',  \
    SaferGetPolicyInformation, N, <NONE>,  'SaferGetPolicyInformation',  \
    SaferIdentifyLevel, N, <NONE>,  'SaferIdentifyLevel',  \
    SaferRecordEventLogEntry, N, <NONE>,  'SaferRecordEventLogEntry',  \
    SaferSetLevelInformation, N, <NONE>,  'SaferSetLevelInformation',  \
    SaferSetPolicyInformation, N, <NONE>,  'SaferSetPolicyInformation',  \
    SaferiChangeRegistryScope, N, <NONE>,  'SaferiChangeRegistryScope',  \
    SaferiCompareTokenLevels, N, <NONE>,  'SaferiCompareTokenLevels',  \
    SaferiIsExecutableFileType, N, <NONE>,  'SaferiIsExecutableFileType',  \
    SaferiPopulateDefaultsInRegistry, N, <NONE>,  'SaferiPopulateDefaultsInRegistry',  \
    SaferiRecordEventLogEntry, N, <NONE>,  'SaferiRecordEventLogEntry',  \
    SaferiReplaceProcessThreadTokens, N, <NONE>,  'SaferiReplaceProcessThreadTokens',  \
    SaferiSearchMatchingHashRules, N, <NONE>,  'SaferiSearchMatchingHashRules',  \
    SetAclInformation, N, <.pAcl, .pAclInformation, .nAclInformationLength, .dwAclInformationClass>,  'SetAclInformation',  \
    SetEntriesInAccessList, A, <NONE>,  'SetEntriesInAccessListA',  \
    SetEntriesInAccessList, W, <NONE>,  'SetEntriesInAccessListW',  \
    SetEntriesInAcl, A, <.cCountOfExplicitEntries, .pListOfExplicitEntries, .OldAcl, .NewAcl>,  'SetEntriesInAclA',  \
    SetEntriesInAcl, W, <.cCountOfExplicitEntries, .pListOfExplicitEntries, .OldAcl, .NewAcl>,  'SetEntriesInAclW',  \
    SetEntriesInAuditList, A, <NONE>,  'SetEntriesInAuditListA',  \
    SetEntriesInAuditList, W, <NONE>,  'SetEntriesInAuditListW',  \
    SetFileSecurity, A, <.lpFileName, .SecurityInformation, .pSecurityDescriptor>,  'SetFileSecurityA',  \
    SetFileSecurity, W, <.lpFileName, .SecurityInformation, .pSecurityDescriptor>,  'SetFileSecurityW',  \
    SetInformationCodeAuthzLevel, W, <NONE>,  'SetInformationCodeAuthzLevelW',  \
    SetInformationCodeAuthzPolicy, W, <NONE>,  'SetInformationCodeAuthzPolicyW',  \
    SetKernelObjectSecurity, N, <.Handle, .SecurityInformation, .SecurityDescriptor>,  'SetKernelObjectSecurity',  \
    SetNamedSecurityInfo, A, <.pObjectName, .ObjectType, .SecurityInfo, .psidOwner, .psidGroup, .pDacl, .pSacl>,  'SetNamedSecurityInfoA',  \
    SetNamedSecurityInfoEx, A, <NONE>,  'SetNamedSecurityInfoExA',  \
    SetNamedSecurityInfoEx, W, <NONE>,  'SetNamedSecurityInfoExW',  \
    SetNamedSecurityInfo, W, <.pObjectName, .ObjectType, .SecurityInfo, .psidOwner, .psidGroup, .pDacl, .pSacl>,  'SetNamedSecurityInfoW',  \
    SetPrivateObjectSecurity, N, <.SecurityInformation, .ModificationDescriptor, .ObjectsSecurityDescriptor, .GenericMapping, .Token,  \
      >,  'SetPrivateObjectSecurity',  \
    SetPrivateObjectSecurityEx, N, <.SecurityInformation, .ModificationDescriptor, .ObjectsSecurityDescriptor, .AutoInheritFlags, .GenericMapping,  \
        .Token>,  'SetPrivateObjectSecurityEx',  \
    SetSecurityDescriptorControl, N, <.pSecurityDescriptor, .ControlBitsOfInterest, .ControlBitsToSet>,  'SetSecurityDescriptorControl',  \
    SetSecurityDescriptorDacl, N, <.pSecurityDescriptor, .bDaclPresent, .pDacl, .bDaclDefaulted>,  'SetSecurityDescriptorDacl',  \
    SetSecurityDescriptorGroup, N, <.pSecurityDescriptor, .pGroup, .bGroupDefaulted>,  'SetSecurityDescriptorGroup',  \
    SetSecurityDescriptorOwner, N, <.pSecurityDescriptor, .pOwner, .bOwnerDefaulted>,  'SetSecurityDescriptorOwner',  \
    SetSecurityDescriptorRMControl, N, <.SecurityDescriptor, .RMControl>,  'SetSecurityDescriptorRMControl',  \
    SetSecurityDescriptorSacl, N, <.pSecurityDescriptor, .bSaclPresent, .pSacl, .bSaclDefaulted>,  'SetSecurityDescriptorSacl',  \
    SetSecurityInfo, N, <.handle, .ObjectType, .SecurityInfo, .psidOwner, .psidGroup, .pDacl, .pSacl>,  'SetSecurityInfo',  \
    SetSecurityInfoEx, A, <NONE>,  'SetSecurityInfoExA',  \
    SetSecurityInfoEx, W, <NONE>,  'SetSecurityInfoExW',  \
    SetServiceBits, N, <.hServiceStatus, .dwServiceBits, .bSetBitsOn, .bUpdateImmediately>,  'SetServiceBits',  \
    SetServiceObjectSecurity, N, <.hService, .dwSecurityInformation, .lpSecurityDescriptor>,  'SetServiceObjectSecurity',  \
    SetServiceStatus, N, <.hServiceStatus, .lpServiceStatus>,  'SetServiceStatus',  \
    SetThreadToken, N, <.Thread, .Token>,  'SetThreadToken',  \
    SetTokenInformation, N, <.TokenHandle, .TokenInformationClass, .TokenInformation, .TokenInformationLength>,  'SetTokenInformation',  \
    SetTraceCallback, N, <NONE>,  'SetTraceCallback',  \
    SetUserFileEncryptionKey, N, <.pEncryptionCertificate>,  'SetUserFileEncryptionKey',  \
    StartService, A, <.hService, .dwNumServiceArgs, .lpServiceArgVectors>,  'StartServiceA',  \
    StartServiceCtrlDispatcher, A, <.lpServiceStartTable>,  'StartServiceCtrlDispatcherA',  \
    StartServiceCtrlDispatcher, W, <.lpServiceStartTable>,  'StartServiceCtrlDispatcherW',  \
    StartService, W, <.hService, .dwNumServiceArgs, .lpServiceArgVectors>,  'StartServiceW',  \
    StartTrace, A, <NONE>,  'StartTraceA',  \
    StartTrace, W, <NONE>,  'StartTraceW',  \
    StopTrace, A, <NONE>,  'StopTraceA',  \
    StopTrace, W, <NONE>,  'StopTraceW',  \
    SynchronizeWindows31FilesAndWindowsNTRegistry, N, <NONE>,  'SynchronizeWindows31FilesAndWindowsNTRegistry',  \
    SystemFunction001, N, <NONE>,  'SystemFunction001',  \
    SystemFunction002, N, <NONE>,  'SystemFunction002',  \
    SystemFunction003, N, <NONE>,  'SystemFunction003',  \
    SystemFunction004, N, <NONE>,  'SystemFunction004',  \
    SystemFunction005, N, <NONE>,  'SystemFunction005',  \
    SystemFunction006, N, <NONE>,  'SystemFunction006',  \
    SystemFunction007, N, <NONE>,  'SystemFunction007',  \
    SystemFunction008, N, <NONE>,  'SystemFunction008',  \
    SystemFunction009, N, <NONE>,  'SystemFunction009',  \
    SystemFunction010, N, <NONE>,  'SystemFunction010',  \
    SystemFunction011, N, <NONE>,  'SystemFunction011',  \
    SystemFunction012, N, <NONE>,  'SystemFunction012',  \
    SystemFunction013, N, <NONE>,  'SystemFunction013',  \
    SystemFunction014, N, <NONE>,  'SystemFunction014',  \
    SystemFunction015, N, <NONE>,  'SystemFunction015',  \
    SystemFunction016, N, <NONE>,  'SystemFunction016',  \
    SystemFunction017, N, <NONE>,  'SystemFunction017',  \
    SystemFunction018, N, <NONE>,  'SystemFunction018',  \
    SystemFunction019, N, <NONE>,  'SystemFunction019',  \
    SystemFunction020, N, <NONE>,  'SystemFunction020',  \
    SystemFunction021, N, <NONE>,  'SystemFunction021',  \
    SystemFunction022, N, <NONE>,  'SystemFunction022',  \
    SystemFunction023, N, <NONE>,  'SystemFunction023',  \
    SystemFunction024, N, <NONE>,  'SystemFunction024',  \
    SystemFunction025, N, <NONE>,  'SystemFunction025',  \
    SystemFunction026, N, <NONE>,  'SystemFunction026',  \
    SystemFunction027, N, <NONE>,  'SystemFunction027',  \
    SystemFunction028, N, <NONE>,  'SystemFunction028',  \
    SystemFunction029, N, <NONE>,  'SystemFunction029',  \
    SystemFunction030, N, <NONE>,  'SystemFunction030',  \
    SystemFunction031, N, <NONE>,  'SystemFunction031',  \
    SystemFunction032, N, <NONE>,  'SystemFunction032',  \
    SystemFunction033, N, <NONE>,  'SystemFunction033',  \
    SystemFunction034, N, <NONE>,  'SystemFunction034',  \
    SystemFunction035, N, <NONE>,  'SystemFunction035',  \
    SystemFunction036, N, <NONE>,  'SystemFunction036',  \
    SystemFunction040, N, <NONE>,  'SystemFunction040',  \
    SystemFunction041, N, <NONE>,  'SystemFunction041',  \
    TraceEvent, N, <NONE>,  'TraceEvent',  \
    TraceEventInstance, N, <NONE>,  'TraceEventInstance',  \
    TraceMessage, N, <NONE>,  'TraceMessage',  \
    TraceMessageVa, N, <NONE>,  'TraceMessageVa',  \
    TreeResetNamedSecurityInfo, A, <.pObjectName, .ObjectType, .SecurityInfo, .pOwner, .pGroup, .pDacl, .pSacl, .KeepExplicit, .fnProgress,  \
        .ProgressInvokeSetting, .Args>,  'TreeResetNamedSecurityInfoA',  \
    TreeResetNamedSecurityInfo, W, <.pObjectName, .ObjectType, .SecurityInfo, .pOwner, .pGroup, .pDacl, .pSacl, .KeepExplicit, .fnProgress,  \
        .ProgressInvokeSetting, .Args>,  'TreeResetNamedSecurityInfoW',  \
    TrusteeAccessToObject, A, <NONE>,  'TrusteeAccessToObjectA',  \
    TrusteeAccessToObject, W, <NONE>,  'TrusteeAccessToObjectW',  \
    UninstallApplication, N, <NONE>,  'UninstallApplication',  \
    UnlockServiceDatabase, N, <.ScLock>,  'UnlockServiceDatabase',  \
    UnregisterIdleTask, N, <NONE>,  'UnregisterIdleTask',  \
    UnregisterTraceGuids, N, <NONE>,  'UnregisterTraceGuids',  \
    UpdateTrace, A, <NONE>,  'UpdateTraceA',  \
    UpdateTrace, W, <NONE>,  'UpdateTraceW',  \
    WdmWmiServiceMain, N, <NONE>,  'WdmWmiServiceMain',  \
    WmiCloseBlock, N, <NONE>,  'WmiCloseBlock',  \
    WmiCloseTraceWithCursor, N, <NONE>,  'WmiCloseTraceWithCursor',  \
    WmiConvertTimestamp, N, <NONE>,  'WmiConvertTimestamp',  \
    WmiDevInstToInstanceName, A, <NONE>,  'WmiDevInstToInstanceNameA',  \
    WmiDevInstToInstanceName, W, <NONE>,  'WmiDevInstToInstanceNameW',  \
    WmiEnumerateGuids, N, <NONE>,  'WmiEnumerateGuids',  \
    WmiExecuteMethod, A, <NONE>,  'WmiExecuteMethodA',  \
    WmiExecuteMethod, W, <NONE>,  'WmiExecuteMethodW',  \
    WmiFileHandleToInstanceName, A, <NONE>,  'WmiFileHandleToInstanceNameA',  \
    WmiFileHandleToInstanceName, W, <NONE>,  'WmiFileHandleToInstanceNameW',  \
    WmiFreeBuffer, N, <NONE>,  'WmiFreeBuffer',  \
    WmiGetFirstTraceOffset, N, <NONE>,  'WmiGetFirstTraceOffset',  \
    WmiGetNextEvent, N, <NONE>,  'WmiGetNextEvent',  \
    WmiGetTraceHeader, N, <NONE>,  'WmiGetTraceHeader',  \
    WmiMofEnumerateResources, A, <NONE>,  'WmiMofEnumerateResourcesA',  \
    WmiMofEnumerateResources, W, <NONE>,  'WmiMofEnumerateResourcesW',  \
    WmiNotificationRegistration, A, <NONE>,  'WmiNotificationRegistrationA',  \
    WmiNotificationRegistration, W, <NONE>,  'WmiNotificationRegistrationW',  \
    WmiOpenBlock, N, <NONE>,  'WmiOpenBlock',  \
    WmiOpenTraceWithCursor, N, <NONE>,  'WmiOpenTraceWithCursor',  \
    WmiParseTraceEvent, N, <NONE>,  'WmiParseTraceEvent',  \
    WmiQueryAllData, A, <NONE>,  'WmiQueryAllDataA',  \
    WmiQueryAllDataMultiple, A, <NONE>,  'WmiQueryAllDataMultipleA',  \
    WmiQueryAllDataMultiple, W, <NONE>,  'WmiQueryAllDataMultipleW',  \
    WmiQueryAllData, W, <NONE>,  'WmiQueryAllDataW',  \
    WmiQueryGuidInformation, N, <NONE>,  'WmiQueryGuidInformation',  \
    WmiQuerySingleInstance, A, <NONE>,  'WmiQuerySingleInstanceA',  \
    WmiQuerySingleInstanceMultiple, A, <NONE>,  'WmiQuerySingleInstanceMultipleA',  \
    WmiQuerySingleInstanceMultiple, W, <NONE>,  'WmiQuerySingleInstanceMultipleW',  \
    WmiQuerySingleInstance, W, <NONE>,  'WmiQuerySingleInstanceW',  \
    WmiReceiveNotifications, A, <NONE>,  'WmiReceiveNotificationsA',  \
    WmiReceiveNotifications, W, <NONE>,  'WmiReceiveNotificationsW',  \
    WmiSetSingleInstance, A, <NONE>,  'WmiSetSingleInstanceA',  \
    WmiSetSingleInstance, W, <NONE>,  'WmiSetSingleInstanceW',  \
    WmiSetSingleItem, A, <NONE>,  'WmiSetSingleItemA',  \
    WmiSetSingleItem, W, <NONE>,  'WmiSetSingleItemW',  \
    Wow64Win32ApiEntry, N, <NONE>,  'Wow64Win32ApiEntry',  \
    WriteEncryptedFileRaw, N, <.pfImportCallback, .pvCallbackContext, .pvContext>,  'WriteEncryptedFileRaw'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/imports/Win32/api/comctl32.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: comctl32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto comctl32,  \
    AddMRUString, W, <NONE>,  'AddMRUStringW',  \
    CreateMRUList, W, <NONE>,  'CreateMRUListW',  \
    CreateMappedBitmap, N, <.hInstance, .idBitmap, .wFlags, .lpColorMap, .ByValumMaps>,  'CreateMappedBitmap',  \
    CreatePropertySheetPage, A, <.lpcpropsheetpagea>,  'CreatePropertySheetPageA',  \
    CreatePropertySheetPage, W, <.lpcpropsheetpagea>,  'CreatePropertySheetPageW',  \
    CreateStatusWindow, A, <.dwStyle, .lpszText, .hWndParent, .wID>,  'CreateStatusWindowA',  \
    CreateStatusWindow, W, <.dwStyle, .lpszText, .hWndParent, .wID>,  'CreateStatusWindowW',  \
    CreateToolbar, N, <NONE>,  'CreateToolbar',  \
    CreateToolbarEx, N, <.hWndParent, .dwStyle, .wID, .nBitmaps, .hBMInst, .wBMID, .lpButtons, .iNumButtons, .dxButton, .dyButton, .dxBitmap, .dyBitmap, .uStructSize>,  'CreateToolbarEx',  \
    CreateUpDownControl, N, <.dwStyle, .x, .y, .cx, .cy, .hParent, .nID, .hInst, .hBuddy, .nUpper, .nLower, .nPos>,  'CreateUpDownControl',  \
    DPA_Create, N, <NONE>,  'DPA_Create',  \
    DPA_DeleteAllPtrs, N, <NONE>,  'DPA_DeleteAllPtrs',  \
    DPA_DeletePtr, N, <NONE>,  'DPA_DeletePtr',  \
    DPA_Destroy, N, <NONE>,  'DPA_Destroy',  \
    DPA_DestroyCallback, N, <NONE>,  'DPA_DestroyCallback',  \
    DPA_EnumCallback, N, <NONE>,  'DPA_EnumCallback',  \
    DPA_GetPtr, N, <NONE>,  'DPA_GetPtr',  \
    DPA_InsertPtr, N, <NONE>,  'DPA_InsertPtr',  \
    DPA_Search, N, <NONE>,  'DPA_Search',  \
    DPA_SetPtr, N, <NONE>,  'DPA_SetPtr',  \
    DPA_Sort, N, <NONE>,  'DPA_Sort',  \
    DSA_Create, N, <NONE>,  'DSA_Create',  \
    DSA_DeleteAllItems, N, <NONE>,  'DSA_DeleteAllItems',  \
    DSA_Destroy, N, <NONE>,  'DSA_Destroy',  \
    DSA_DestroyCallback, N, <NONE>,  'DSA_DestroyCallback',  \
    DSA_GetItemPtr, N, <NONE>,  'DSA_GetItemPtr',  \
    DSA_InsertItem, N, <NONE>,  'DSA_InsertItem',  \
    DefSubclassProc, N, <NONE>,  'DefSubclassProc',  \
    DestroyPropertySheetPage, N, <.hpropsheetpage>,  'DestroyPropertySheetPage',  \
    DllGetVersion, N, <NONE>,  'DllGetVersion',  \
    DllInstall, N, <.bInstall, .pszCmdLine>,  'DllInstall',  \
    DrawInsert, N, <.handParent, .hLB, .nItem>,  'DrawInsert',  \
    DrawStatusText, A, <.hDC, .lprc, .pszText, .uFlags>,  'DrawStatusTextA',  \
    DrawStatusText, W, <.hDC, .lprc, .pszText, .uFlags>,  'DrawStatusTextW',  \
    EnumMRUList, W, <NONE>,  'EnumMRUListW',  \
    FlatSB_EnableScrollBar, N, <.hwnd, .ByValt, .uint>,  'FlatSB_EnableScrollBar',  \
    FlatSB_GetScrollInfo, N, <.hwnd, .code, .lpscrollinfo>,  'FlatSB_GetScrollInfo',  \
    FlatSB_GetScrollPos, N, <.hwnd, .code>,  'FlatSB_GetScrollPos',  \
    FlatSB_GetScrollProp, N, <.hwnd, .propIndex, .lpint>,  'FlatSB_GetScrollProp',  \
    FlatSB_GetScrollRange, N, <.hwnd, .code, .lpint>,  'FlatSB_GetScrollRange',  \
    FlatSB_SetScrollInfo, N, <.hwnd, .code, .lpscrollinfo, .fRedraw>,  'FlatSB_SetScrollInfo',  \
    FlatSB_SetScrollPos, N, <.hwnd, .code, .pos, .fRedraw>,  'FlatSB_SetScrollPos',  \
    FlatSB_SetScrollProp, N, <.hwnd, .index, .newValue, .bool>,  'FlatSB_SetScrollProp',  \
    FlatSB_SetScrollRange, N, <.hwnd, .code, .min, .max, .fRedraw>,  'FlatSB_SetScrollRange',  \
    FlatSB_ShowScrollBar, N, <.hwnd, .code, .bool>,  'FlatSB_ShowScrollBar',  \
    FreeMRUList, N, <NONE>,  'FreeMRUList',  \
    GetEffectiveClientRect, N, <.hWnd, .lprc, .lpInfo>,  'GetEffectiveClientRect',  \
    GetMUILanguage, N, <VOID>,  'GetMUILanguage',  \
    ImageList_Add, N, <.himl, .hbmImage, .hbmMask>,  'ImageList_Add',  \
    ImageList_AddIcon, N, <NONE>,  'ImageList_AddIcon',  \
    ImageList_AddMasked, N, <.himl, .hbmImage, .crMask>,  'ImageList_AddMasked',  \
    ImageList_BeginDrag, N, <.himlTrack, .iTrack, .dxHotspot, .dyHotspot>,  'ImageList_BeginDrag',  \
    ImageList_Copy, N, <.himlDst, .iDst, .himlSrc, .iSrc, .uFlags>,  'ImageList_Copy',  \
    ImageList_Create, N, <.cx, .cy, .flags, .cInitial, .cGrow>,  'ImageList_Create',  \
    ImageList_Destroy, N, <.himl>,  'ImageList_Destroy',  \
    ImageList_DragEnter, N, <.hwndLock, .x, .y>,  'ImageList_DragEnter',  \
    ImageList_DragLeave, N, <.hWndOwner>,  'ImageList_DragLeave',  \
    ImageList_DragMove, N, <.x, .y>,  'ImageList_DragMove',  \
    ImageList_DragShowNolock, N, <.fBoolean>,  'ImageList_DragShowNolock',  \
    ImageList_Draw, N, <.himl, .i, .hdcDst, .x, .y, .fStyle>,  'ImageList_Draw',  \
    ImageList_DrawEx, N, <.himl, .i, .hdcDst, .x, .y, .dx, .dy, .rgbBk, .rgbFg, .fStyle>,  'ImageList_DrawEx',  \
    ImageList_DrawIndirect, N, <.pimldp>,  'ImageList_DrawIndirect',  \
    ImageList_Duplicate, N, <.himl>,  'ImageList_Duplicate',  \
    ImageList_EndDrag, N, <VOID>,  'ImageList_EndDrag',  \
    ImageList_GetBkColor, N, <.himl>,  'ImageList_GetBkColor',  \
    ImageList_GetDragImage, N, <.ppt, .pptHotspot>,  'ImageList_GetDragImage',  \
    ImageList_GetFlags, N, <NONE>,  'ImageList_GetFlags',  \
    ImageList_GetIcon, N, <.himl, .i, .flags>,  'ImageList_GetIcon',  \
    ImageList_GetIconSize, N, <.himl, .cx, .cy>,  'ImageList_GetIconSize',  \
    ImageList_GetImageCount, N, <.himl>,  'ImageList_GetImageCount',  \
    ImageList_GetImageInfo, N, <.himl, .i, .pImageInfo>,  'ImageList_GetImageInfo',  \
    ImageList_GetImageRect, N, <NONE>,  'ImageList_GetImageRect',  \
    ImageList_LoadImage, A, <.hInst, .lpszbmp, .cx, .cGrow, .crMask, .uType, .uFlags>,  'ImageList_LoadImageA',  \
    ImageList_LoadImage, W, <.hInst, .lpszbmp, .cx, .cGrow, .crMask, .uType, .uFlags>,  'ImageList_LoadImageW',  \
    ImageList_Merge, N, <.himl1, .i1, .himl2, .i2, .dx, .dy>,  'ImageList_Merge',  \
    ImageList_Read, N, <.pstm>,  'ImageList_Read',  \
    ImageList_Remove, N, <.himl, .i>,  'ImageList_Remove',  \
    ImageList_Replace, N, <.himl, .i, .hbmImage, .hbmMask>,  'ImageList_Replace',  \
    ImageList_ReplaceIcon, N, <.himl, .i, .hicon>,  'ImageList_ReplaceIcon',  \
    ImageList_SetBkColor, N, <.himl, .clrBk>,  'ImageList_SetBkColor',  \
    ImageList_SetDragCursorImage, N, <.himlDrag, .iDrag, .dxHotspot, .dyHotspot>,  'ImageList_SetDragCursorImage',  \
    ImageList_SetFilter, N, <NONE>,  'ImageList_SetFilter',  \
    ImageList_SetFlags, N, <NONE>,  'ImageList_SetFlags',  \
    ImageList_SetIconSize, N, <.himl, .cx, .cy>,  'ImageList_SetIconSize',  \
    ImageList_SetImageCount, N, <.himl, .uNewCount>,  'ImageList_SetImageCount',  \
    ImageList_SetOverlayImage, N, <.himl, .iImage, .iOverlay>,  'ImageList_SetOverlayImage',  \
    ImageList_Write, N, <.himl, .pstm>,  'ImageList_Write',  \
    InitCommonControls, N, <VOID>,  'InitCommonControls',  \
    InitCommonControlsEx, N, <.pIcce>,  'InitCommonControlsEx',  \
    InitMUILanguage, N, <.uiLang>,  'InitMUILanguage',  \
    InitializeFlatSB, N, <.hwnd>,  'InitializeFlatSB',  \
    LBItemFromPt, N, <.hLB, .pt, .bAutoScroll>,  'LBItemFromPt',  \
    MakeDragList, N, <.hLB>,  'MakeDragList',  \
    MenuHelp, N, <.uMsg, .wParam, .lParam, .hMainMenu, .hInst, .hwndStatus, .lpwIDs>,  'MenuHelp',  \
    PropertySheet, A, <.lpcpropsheetheadera>,  'PropertySheetA',  \
    PropertySheet, W, <.lpcpropsheetheadera>,  'PropertySheetW',  \
    RemoveWindowSubclass, N, <NONE>,  'RemoveWindowSubclass',  \
    SetWindowSubclass, N, <NONE>,  'SetWindowSubclass',  \
    ShowHideMenuCtl, N, <.hWnd, .uFlags, .lpInfo>,  'ShowHideMenuCtl',  \
    Str_SetPtr, W, <NONE>,  'Str_SetPtrW',  \
    UninitializeFlatSB, N, <.hwnd>,  'UninitializeFlatSB',  \
    _TrackMouseEvent, N, <NONE>,  '_TrackMouseEvent'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































Deleted freshlib/imports/Win32/api/comdlg32.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: comdlg32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto comdlg32,  \
    ChooseColor, A, <.pChoosecolor>,  'ChooseColorA',  \
    ChooseColor, W, <.pChoosecolor>,  'ChooseColorW',  \
    ChooseFont, A, <.pChoosefont>,  'ChooseFontA',  \
    ChooseFont, W, <.pChoosefont>,  'ChooseFontW',  \
    CommDlgExtendedError, N, <VOID>,  'CommDlgExtendedError',  \
    FindText, A, <.pFindreplace>,  'FindTextA',  \
    FindText, W, <.pFindreplace>,  'FindTextW',  \
    GetFileTitle, A, <.lpszFile, .lpszTitle, .cbBuf>,  'GetFileTitleA',  \
    GetFileTitle, W, <.lpszFile, .lpszTitle, .cbBuf>,  'GetFileTitleW',  \
    GetOpenFileName, A, <.pOpenfilename>,  'GetOpenFileNameA',  \
    GetOpenFileName, W, <.pOpenfilename>,  'GetOpenFileNameW',  \
    GetSaveFileName, A, <.pOpenfilename>,  'GetSaveFileNameA',  \
    GetSaveFileName, W, <.pOpenfilename>,  'GetSaveFileNameW',  \
    LoadAlterBitmap, N, <NONE>,  'LoadAlterBitmap',  \
    PageSetupDlg, A, <.pPagesetupdlg>,  'PageSetupDlgA',  \
    PageSetupDlg, W, <.pPagesetupdlg>,  'PageSetupDlgW',  \
    PrintDlg, A, <.pPrintdlg>,  'PrintDlgA',  \
    PrintDlgEx, A, <.TLPPRINTDLGEXA>,  'PrintDlgExA',  \
    PrintDlgEx, W, <.TLPPRINTDLGEXA>,  'PrintDlgExW',  \
    PrintDlg, W, <.pPrintdlg>,  'PrintDlgW',  \
    ReplaceText, A, <.pFindreplace>,  'ReplaceTextA',  \
    ReplaceText, W, <.pFindreplace>,  'ReplaceTextW',  \
    Ssync_ANSI_UNICODE_Struct_For_WO, W, <NONE>,  'Ssync_ANSI_UNICODE_Struct_For_WOW',  \
    WantArrows, N, <NONE>,  'WantArrows',  \
    dwLBSubclass, N, <NONE>,  'dwLBSubclass',  \
    dwOKSubclass, N, <NONE>,  'dwOKSubclass'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































Deleted freshlib/imports/Win32/api/crtdll.inc.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
;   crtdll.dll API calls (ASCII)
import_proto crtdll,  \
    _CIacos, N, <NONE>,  '_CIacos',  \
    _CIasin, N, <NONE>,  '_CIasin',  \
    _CIatan, N, <NONE>,  '_CIatan',  \
    _CIatan2, N, <NONE>,  '_CIatan2',  \
    _CIcos, N, <NONE>,  '_CIcos',  \
    _CIcosh, N, <NONE>,  '_CIcosh',  \
    _CIexp, N, <NONE>,  '_CIexp',  \
    _CIfmod, N, <NONE>,  '_CIfmod',  \
    _CIlog, N, <NONE>,  '_CIlog',  \
    _CIlog10, N, <NONE>,  '_CIlog10',  \
    _CIpow, N, <NONE>,  '_CIpow',  \
    _CIsin, N, <NONE>,  '_CIsin',  \
    _CIsinh, N, <NONE>,  '_CIsinh',  \
    _CIsqrt, N, <NONE>,  '_CIsqrt',  \
    _CItan, N, <NONE>,  '_CItan',  \
    _CItanh, N, <NONE>,  '_CItanh',  \
    _HUGE_dll, N, <NONE>,  '_HUGE_dll',  \
    _XcptFilter, N, <NONE>,  '_XcptFilter',  \
    __GetMainArgs, N, <NONE>,  '__GetMainArgs',  \
    __argc_dll, N, <NONE>,  '__argc_dll',  \
    __argv_dll, N, <NONE>,  '__argv_dll',  \
    __dllonexit, N, <NONE>,  '__dllonexit',  \
    __doserrno, N, <NONE>,  '__doserrno',  \
    __fpecode, N, <NONE>,  '__fpecode',  \
    __isascii, N, <NONE>,  '__isascii',  \
    __iscsym, N, <NONE>,  '__iscsym',  \
    __iscsymf, N, <NONE>,  '__iscsymf',  \
    __mb_cur_max_dll, N, <NONE>,  '__mb_cur_max_dll',  \
    __pxcptinfoptrs, N, <NONE>,  '__pxcptinfoptrs',  \
    __threadhandle, N, <NONE>,  '__threadhandle',  \
    __threadid, N, <NONE>,  '__threadid',  \
    __toascii, N, <NONE>,  '__toascii',  \
    _abnormal_termination, N, <NONE>,  '_abnormal_termination',  \
    _access, N, <NONE>,  '_access',  \
    _acmdln_dll, N, <NONE>,  '_acmdln_dll',  \
    _aexit_rtn_dll, N, <NONE>,  '_aexit_rtn_dll',  \
    _amsg_exit, N, <NONE>,  '_amsg_exit',  \
    _assert, N, <NONE>,  '_assert',  \
    _basemajor_dll, N, <NONE>,  '_basemajor_dll',  \
    _baseminor_dll, N, <NONE>,  '_baseminor_dll',  \
    _baseversion_dll, N, <NONE>,  '_baseversion_dll',  \
    _beep, N, <NONE>,  '_beep',  \
    _beginthread, N, <NONE>,  '_beginthread',  \
    _c_exit, N, <NONE>,  '_c_exit',  \
    _cabs, N, <NONE>,  '_cabs',  \
    _cexit, N, <NONE>,  '_cexit',  \
    _cgets, N, <NONE>,  '_cgets',  \
    _chdir, N, <NONE>,  '_chdir',  \
    _chdrive, N, <NONE>,  '_chdrive',  \
    _chgsign, N, <NONE>,  '_chgsign',  \
    _chmod, N, <NONE>,  '_chmod',  \
    _chsize, N, <NONE>,  '_chsize',  \
    _clearfp, N, <NONE>,  '_clearfp',  \
    _commit, N, <NONE>,  '_commit',  \
    _commode_dll, N, <NONE>,  '_commode_dll',  \
    _control87, N, <NONE>,  '_control87',  \
    _controlfp, N, <NONE>,  '_controlfp',  \
    _copysign, N, <NONE>,  '_copysign',  \
    _cprintf, N, <NONE>,  '_cprintf',  \
    _cpumode_dll, N, <NONE>,  '_cpumode_dll',  \
    _cputs, N, <NONE>,  '_cputs',  \
    _cscanf, N, <NONE>,  '_cscanf',  \
    _ctype, N, <NONE>,  '_ctype',  \
    _cwait, N, <NONE>,  '_cwait',  \
    _daylight_dll, N, <NONE>,  '_daylight_dll',  \
    _dup, N, <NONE>,  '_dup',  \
    _dup2, N, <NONE>,  '_dup2',  \
    _ecvt, N, <NONE>,  '_ecvt',  \
    _endthread, N, <NONE>,  '_endthread',  \
    _environ_dll, N, <NONE>,  '_environ_dll',  \
    _eof, N, <NONE>,  '_eof',  \
    _errno, N, <NONE>,  '_errno',  \
    _except_handler2, N, <NONE>,  '_except_handler2',  \
    _execl, N, <NONE>,  '_execl',  \
    _execle, N, <NONE>,  '_execle',  \
    _execlp, N, <NONE>,  '_execlp',  \
    _execlpe, N, <NONE>,  '_execlpe',  \
    _execv, N, <NONE>,  '_execv',  \
    _execve, N, <NONE>,  '_execve',  \
    _execvp, N, <NONE>,  '_execvp',  \
    _execvpe, N, <NONE>,  '_execvpe',  \
    _exit, N, <NONE>,  '_exit',  \
    _expand, N, <NONE>,  '_expand',  \
    _fcloseall, N, <NONE>,  '_fcloseall',  \
    _fcvt, N, <NONE>,  '_fcvt',  \
    _fdopen, N, <NONE>,  '_fdopen',  \
    _fgetchar, N, <NONE>,  '_fgetchar',  \
    _fgetwchar, N, <NONE>,  '_fgetwchar',  \
    _filbuf, N, <NONE>,  '_filbuf',  \
    _fileinfo_dll, N, <NONE>,  '_fileinfo_dll',  \
    _filelength, N, <NONE>,  '_filelength',  \
    _fileno, N, <NONE>,  '_fileno',  \
    _findclose, N, <NONE>,  '_findclose',  \
    _findfirst, N, <NONE>,  '_findfirst',  \
    _findnext, N, <NONE>,  '_findnext',  \
    _finite, N, <NONE>,  '_finite',  \
    _flsbuf, N, <NONE>,  '_flsbuf',  \
    _flushall, N, <NONE>,  '_flushall',  \
    _fmode_dll, N, <NONE>,  '_fmode_dll',  \
    _fpclass, N, <NONE>,  '_fpclass',  \
    _fpieee_flt, N, <NONE>,  '_fpieee_flt',  \
    _fpreset, N, <NONE>,  '_fpreset',  \
    _fputchar, N, <NONE>,  '_fputchar',  \
    _fputwchar, N, <NONE>,  '_fputwchar',  \
    _fsopen, N, <NONE>,  '_fsopen',  \
    _fstat, N, <NONE>,  '_fstat',  \
    _ftime, N, <NONE>,  '_ftime',  \
    _ftol, N, <NONE>,  '_ftol',  \
    _fullpath, N, <NONE>,  '_fullpath',  \
    _futime, N, <NONE>,  '_futime',  \
    _gcvt, N, <NONE>,  '_gcvt',  \
    _get_osfhandle, N, <NONE>,  '_get_osfhandle',  \
    _getch, N, <NONE>,  '_getch',  \
    _getche, N, <NONE>,  '_getche',  \
    _getcwd, N, <NONE>,  '_getcwd',  \
    _getdcwd, N, <NONE>,  '_getdcwd',  \
    _getdiskfree, N, <NONE>,  '_getdiskfree',  \
    _getdllprocaddr, N, <NONE>,  '_getdllprocaddr',  \
    _getdrive, N, <NONE>,  '_getdrive',  \
    _getdrives, N, <NONE>,  '_getdrives',  \
    _getpid, N, <NONE>,  '_getpid',  \
    _getsystime, N, <NONE>,  '_getsystime',  \
    _getw, N, <NONE>,  '_getw',  \
    _global_unwind2, N, <NONE>,  '_global_unwind2',  \
    _heapchk, N, <NONE>,  '_heapchk',  \
    _heapmin, N, <NONE>,  '_heapmin',  \
    _heapset, N, <NONE>,  '_heapset',  \
    _heapwalk, N, <NONE>,  '_heapwalk',  \
    _hypot, N, <NONE>,  '_hypot',  \
    _initterm, N, <NONE>,  '_initterm',  \
    _iob, N, <NONE>,  '_iob',  \
    _isatty, N, <NONE>,  '_isatty',  \
    _isctype, N, <NONE>,  '_isctype',  \
    _ismbbalnum, N, <NONE>,  '_ismbbalnum',  \
    _ismbbalpha, N, <NONE>,  '_ismbbalpha',  \
    _ismbbgraph, N, <NONE>,  '_ismbbgraph',  \
    _ismbbkalnum, N, <NONE>,  '_ismbbkalnum',  \
    _ismbbkana, N, <NONE>,  '_ismbbkana',  \
    _ismbbkpunct, N, <NONE>,  '_ismbbkpunct',  \
    _ismbblead, N, <NONE>,  '_ismbblead',  \
    _ismbbprint, N, <NONE>,  '_ismbbprint',  \
    _ismbbpunct, N, <NONE>,  '_ismbbpunct',  \
    _ismbbtrail, N, <NONE>,  '_ismbbtrail',  \
    _ismbcalpha, N, <NONE>,  '_ismbcalpha',  \
    _ismbcdigit, N, <NONE>,  '_ismbcdigit',  \
    _ismbchira, N, <NONE>,  '_ismbchira',  \
    _ismbckata, N, <NONE>,  '_ismbckata',  \
    _ismbcl0, N, <NONE>,  '_ismbcl0',  \
    _ismbcl1, N, <NONE>,  '_ismbcl1',  \
    _ismbcl2, N, <NONE>,  '_ismbcl2',  \
    _ismbclegal, N, <NONE>,  '_ismbclegal',  \
    _ismbclower, N, <NONE>,  '_ismbclower',  \
    _ismbcprint, N, <NONE>,  '_ismbcprint',  \
    _ismbcspace, N, <NONE>,  '_ismbcspace',  \
    _ismbcsymbol, N, <NONE>,  '_ismbcsymbol',  \
    _ismbcupper, N, <NONE>,  '_ismbcupper',  \
    _ismbslead, N, <NONE>,  '_ismbslead',  \
    _ismbstrail, N, <NONE>,  '_ismbstrail',  \
    _isnan, N, <NONE>,  '_isnan',  \
    _itoa, N, <NONE>,  '_itoa',  \
    _itow, N, <NONE>,  '_itow',  \
    _j0, N, <NONE>,  '_j0',  \
    _j1, N, <NONE>,  '_j1',  \
    _jn, N, <NONE>,  '_jn',  \
    _kbhit, N, <NONE>,  '_kbhit',  \
    _lfind, N, <NONE>,  '_lfind',  \
    _loaddll, N, <NONE>,  '_loaddll',  \
    _local_unwind2, N, <NONE>,  '_local_unwind2',  \
    _locking, N, <NONE>,  '_locking',  \
    _logb, N, <NONE>,  '_logb',  \
    _lrotl, N, <NONE>,  '_lrotl',  \
    _lrotr, N, <NONE>,  '_lrotr',  \
    _lsearch, N, <NONE>,  '_lsearch',  \
    _ltoa, N, <NONE>,  '_ltoa',  \
    _ltow, N, <NONE>,  '_ltow',  \
    _makepath, N, <NONE>,  '_makepath',  \
    _matherr, N, <NONE>,  '_matherr',  \
    _mbbtombc, N, <NONE>,  '_mbbtombc',  \
    _mbbtype, N, <NONE>,  '_mbbtype',  \
    _mbccpy, N, <NONE>,  '_mbccpy',  \
    _mbcjistojms, N, <NONE>,  '_mbcjistojms',  \
    _mbcjmstojis, N, <NONE>,  '_mbcjmstojis',  \
    _mbclen, N, <NONE>,  '_mbclen',  \
    _mbctohira, N, <NONE>,  '_mbctohira',  \
    _mbctokata, N, <NONE>,  '_mbctokata',  \
    _mbctolower, N, <NONE>,  '_mbctolower',  \
    _mbctombb, N, <NONE>,  '_mbctombb',  \
    _mbctoupper, N, <NONE>,  '_mbctoupper',  \
    _mbctype, N, <NONE>,  '_mbctype',  \
    _mbsbtype, N, <NONE>,  '_mbsbtype',  \
    _mbscat, N, <NONE>,  '_mbscat',  \
    _mbschr, N, <NONE>,  '_mbschr',  \
    _mbscmp, N, <NONE>,  '_mbscmp',  \
    _mbscpy, N, <NONE>,  '_mbscpy',  \
    _mbscspn, N, <NONE>,  '_mbscspn',  \
    _mbsdec, N, <NONE>,  '_mbsdec',  \
    _mbsdup, N, <NONE>,  '_mbsdup',  \
    _mbsicmp, N, <NONE>,  '_mbsicmp',  \
    _mbsinc, N, <NONE>,  '_mbsinc',  \
    _mbslen, N, <NONE>,  '_mbslen',  \
    _mbslwr, N, <NONE>,  '_mbslwr',  \
    _mbsnbcat, N, <NONE>,  '_mbsnbcat',  \
    _mbsnbcmp, N, <NONE>,  '_mbsnbcmp',  \
    _mbsnbcnt, N, <NONE>,  '_mbsnbcnt',  \
    _mbsnbcpy, N, <NONE>,  '_mbsnbcpy',  \
    _mbsnbicmp, N, <NONE>,  '_mbsnbicmp',  \
    _mbsnbset, N, <NONE>,  '_mbsnbset',  \
    _mbsncat, N, <NONE>,  '_mbsncat',  \
    _mbsnccnt, N, <NONE>,  '_mbsnccnt',  \
    _mbsncmp, N, <NONE>,  '_mbsncmp',  \
    _mbsncpy, N, <NONE>,  '_mbsncpy',  \
    _mbsnextc, N, <NONE>,  '_mbsnextc',  \
    _mbsnicmp, N, <NONE>,  '_mbsnicmp',  \
    _mbsninc, N, <NONE>,  '_mbsninc',  \
    _mbsnset, N, <NONE>,  '_mbsnset',  \
    _mbspbrk, N, <NONE>,  '_mbspbrk',  \
    _mbsrchr, N, <NONE>,  '_mbsrchr',  \
    _mbsrev, N, <NONE>,  '_mbsrev',  \
    _mbsset, N, <NONE>,  '_mbsset',  \
    _mbsspn, N, <NONE>,  '_mbsspn',  \
    _mbsspnp, N, <NONE>,  '_mbsspnp',  \
    _mbsstr, N, <NONE>,  '_mbsstr',  \
    _mbstok, N, <NONE>,  '_mbstok',  \
    _mbstrlen, N, <NONE>,  '_mbstrlen',  \
    _mbsupr, N, <NONE>,  '_mbsupr',  \
    _memccpy, N, <NONE>,  '_memccpy',  \
    _memicmp, N, <NONE>,  '_memicmp',  \
    _mkdir, N, <NONE>,  '_mkdir',  \
    _mktemp, N, <NONE>,  '_mktemp',  \
    _msize, N, <NONE>,  '_msize',  \
    _nextafter, N, <NONE>,  '_nextafter',  \
    _onexit, N, <NONE>,  '_onexit',  \
    _open_osfhandle, N, <NONE>,  '_open_osfhandle',  \
    _osmajor_dll, N, <NONE>,  '_osmajor_dll',  \
    _osminor_dll, N, <NONE>,  '_osminor_dll',  \
    _osmode_dll, N, <NONE>,  '_osmode_dll',  \
    _osver_dll, N, <NONE>,  '_osver_dll',  \
    _osversion_dll, N, <NONE>,  '_osversion_dll',  \
    _pclose, N, <NONE>,  '_pclose',  \
    _pctype_dll, N, <NONE>,  '_pctype_dll',  \
    _pgmptr_dll, N, <NONE>,  '_pgmptr_dll',  \
    _pipe, N, <NONE>,  '_pipe',  \
    _popen, N, <NONE>,  '_popen',  \
    _purecall, N, <NONE>,  '_purecall',  \
    _putch, N, <NONE>,  '_putch',  \
    _putenv, N, <NONE>,  '_putenv',  \
    _putw, N, <NONE>,  '_putw',  \
    _pwctype_dll, N, <NONE>,  '_pwctype_dll',  \
    _rmdir, N, <NONE>,  '_rmdir',  \
    _rmtmp, N, <NONE>,  '_rmtmp',  \
    _rotl, N, <NONE>,  '_rotl',  \
    _rotr, N, <NONE>,  '_rotr',  \
    _scalb, N, <NONE>,  '_scalb',  \
    _searchenv, N, <NONE>,  '_searchenv',  \
    _seterrormode, N, <NONE>,  '_seterrormode',  \
    _setjmp, N, <NONE>,  '_setjmp',  \
    _setmode, N, <NONE>,  '_setmode',  \
    _setsystime, N, <NONE>,  '_setsystime',  \
    _sleep, N, <NONE>,  '_sleep',  \
    _snprintf, N, <NONE>,  '_snprintf',  \
    _snwprintf, N, <NONE>,  '_snwprintf',  \
    _sopen, N, <NONE>,  '_sopen',  \
    _spawnl, N, <NONE>,  '_spawnl',  \
    _spawnle, N, <NONE>,  '_spawnle',  \
    _spawnlp, N, <NONE>,  '_spawnlp',  \
    _spawnlpe, N, <NONE>,  '_spawnlpe',  \
    _spawnv, N, <NONE>,  '_spawnv',  \
    _spawnve, N, <NONE>,  '_spawnve',  \
    _spawnvp, N, <NONE>,  '_spawnvp',  \
    _spawnvpe, N, <NONE>,  '_spawnvpe',  \
    _splitpath, N, <NONE>,  '_splitpath',  \
    _stat, N, <NONE>,  '_stat',  \
    _statusfp, N, <NONE>,  '_statusfp',  \
    _strcmpi, N, <NONE>,  '_strcmpi',  \
    _strdate, N, <NONE>,  '_strdate',  \
    _strdec, N, <NONE>,  '_strdec',  \
    _strdup, N, <NONE>,  '_strdup',  \
    _strerror, N, <NONE>,  '_strerror',  \
    _stricmp, N, <NONE>,  '_stricmp',  \
    _stricoll, N, <NONE>,  '_stricoll',  \
    _strinc, N, <NONE>,  '_strinc',  \
    _strlwr, N, <NONE>,  '_strlwr',  \
    _strncnt, N, <NONE>,  '_strncnt',  \
    _strnextc, N, <NONE>,  '_strnextc',  \
    _strnicmp, N, <NONE>,  '_strnicmp',  \
    _strninc, N, <NONE>,  '_strninc',  \
    _strnset, N, <NONE>,  '_strnset',  \
    _strrev, N, <NONE>,  '_strrev',  \
    _strset, N, <NONE>,  '_strset',  \
    _strspnp, N, <NONE>,  '_strspnp',  \
    _strtime, N, <NONE>,  '_strtime',  \
    _strupr, N, <NONE>,  '_strupr',  \
    _swab, N, <NONE>,  '_swab',  \
    _sys_errlist, N, <NONE>,  '_sys_errlist',  \
    _sys_nerr_dll, N, <NONE>,  '_sys_nerr_dll',  \
    _tell, N, <NONE>,  '_tell',  \
    _tempnam, N, <NONE>,  '_tempnam',  \
    _timezone_dll, N, <NONE>,  '_timezone_dll',  \
    _tolower, N, <NONE>,  '_tolower',  \
    _toupper, N, <NONE>,  '_toupper',  \
    _tzname, N, <NONE>,  '_tzname',  \
    _tzset, N, <NONE>,  '_tzset',  \
    _ultoa, N, <NONE>,  '_ultoa',  \
    _ultow, N, <NONE>,  '_ultow',  \
    _umask, N, <NONE>,  '_umask',  \
    _ungetch, N, <NONE>,  '_ungetch',  \
    _unlink, N, <NONE>,  '_unlink',  \
    _unloaddll, N, <NONE>,  '_unloaddll',  \
    _utime, N, <NONE>,  '_utime',  \
    _vsnprintf, N, <NONE>,  '_vsnprintf',  \
    _vsnwprintf, N, <NONE>,  '_vsnwprintf',  \
    _wcsdup, N, <NONE>,  '_wcsdup',  \
    _wcsicmp, N, <NONE>,  '_wcsicmp',  \
    _wcsicoll, N, <NONE>,  '_wcsicoll',  \
    _wcslwr, N, <NONE>,  '_wcslwr',  \
    _wcsnicmp, N, <NONE>,  '_wcsnicmp',  \
    _wcsnset, N, <NONE>,  '_wcsnset',  \
    _wcsrev, N, <NONE>,  '_wcsrev',  \
    _wcsset, N, <NONE>,  '_wcsset',  \
    _wcsupr, N, <NONE>,  '_wcsupr',  \
    _winmajor_dll, N, <NONE>,  '_winmajor_dll',  \
    _winminor_dll, N, <NONE>,  '_winminor_dll',  \
    _winver_dll, N, <NONE>,  '_winver_dll',  \
    _wtoi, N, <NONE>,  '_wtoi',  \
    _wtol, N, <NONE>,  '_wtol',  \
    _y0, N, <NONE>,  '_y0',  \
    _y1, N, <NONE>,  '_y1',  \
    _yn, N, <NONE>,  '_yn',  \
    abort, N, <NONE>,  'abort',  \
    abs, N, <NONE>,  'abs',  \
    acos, N, <NONE>,  'acos',  \
    asctime, N, <NONE>,  'asctime',  \
    asin, N, <NONE>,  'asin',  \
    atan, N, <NONE>,  'atan',  \
    atan2, N, <NONE>,  'atan2',  \
    atexit, N, <NONE>,  'atexit',  \
    atof, N, <NONE>,  'atof',  \
    atoi, N, <NONE>,  'atoi',  \
    atol, N, <NONE>,  'atol',  \
    bsearch, N, <NONE>,  'bsearch',  \
    calloc, N, <NONE>,  'calloc',  \
    ceil, N, <NONE>,  'ceil',  \
    clearerr, N, <NONE>,  'clearerr',  \
    clock, N, <NONE>,  'clock',  \
    cos, N, <NONE>,  'cos',  \
    cosh, N, <NONE>,  'cosh',  \
    ctime, N, <NONE>,  'ctime',  \
    difftime, N, <NONE>,  'difftime',  \
    func_div, N, <NONE>,  'div',  \
    exit, N, <NONE>,  'exit',  \
    exp, N, <NONE>,  'exp',  \
    func_fabs, N, <NONE>,  'fabs',  \
    fclose, N, <NONE>,  'fclose',  \
    feof, N, <NONE>,  'feof',  \
    ferror, N, <NONE>,  'ferror',  \
    fflush, N, <NONE>,  'fflush',  \
    fgetc, N, <NONE>,  'fgetc',  \
    fgetpos, N, <NONE>,  'fgetpos',  \
    fgets, N, <NONE>,  'fgets',  \
    fgetwc, N, <NONE>,  'fgetwc',  \
    floor, N, <NONE>,  'floor',  \
    fmod, N, <NONE>,  'fmod',  \
    fopen, N, <NONE>,  'fopen',  \
    fprintf, N, <NONE>,  'fprintf',  \
    fputc, N, <NONE>,  'fputc',  \
    fputs, N, <NONE>,  'fputs',  \
    fputwc, N, <NONE>,  'fputwc',  \
    fread, N, <NONE>,  'fread',  \
    free, N, <.TM_aKey>,  'free',  \
    freopen, N, <NONE>,  'freopen',  \
    frexp, N, <NONE>,  'frexp',  \
    fscanf, N, <NONE>,  'fscanf',  \
    fseek, N, <NONE>,  'fseek',  \
    fsetpos, N, <NONE>,  'fsetpos',  \
    ftell, N, <NONE>,  'ftell',  \
    fwprintf, N, <NONE>,  'fwprintf',  \
    fwrite, N, <NONE>,  'fwrite',  \
    fwscanf, N, <NONE>,  'fwscanf',  \
    getc, N, <NONE>,  'getc',  \
    getchar, N, <NONE>,  'getchar',  \
    getenv, N, <NONE>,  'getenv',  \
    gets, N, <NONE>,  'gets',  \
    gmtime, N, <NONE>,  'gmtime',  \
    hread, N, <.hFile, .lpBuffer, .lBytes>,  'hread',  \
    hwrite, N, <.hFile, .lpBuffer, .lBytes>,  'hwrite',  \
    is_wctype, N, <NONE>,  'is_wctype',  \
    isalnum, N, <NONE>,  'isalnum',  \
    isalpha, N, <NONE>,  'isalpha',  \
    iscntrl, N, <NONE>,  'iscntrl',  \
    isdigit, N, <NONE>,  'isdigit',  \
    isgraph, N, <NONE>,  'isgraph',  \
    isleadbyte, N, <NONE>,  'isleadbyte',  \
    islower, N, <NONE>,  'islower',  \
    isprint, N, <NONE>,  'isprint',  \
    ispunct, N, <NONE>,  'ispunct',  \
    isspace, N, <NONE>,  'isspace',  \
    isupper, N, <NONE>,  'isupper',  \
    iswalnum, N, <NONE>,  'iswalnum',  \
    iswalpha, N, <NONE>,  'iswalpha',  \
    iswascii, N, <NONE>,  'iswascii',  \
    iswcntrl, N, <NONE>,  'iswcntrl',  \
    iswctype, N, <NONE>,  'iswctype',  \
    iswdigit, N, <NONE>,  'iswdigit',  \
    iswgraph, N, <NONE>,  'iswgraph',  \
    iswlower, N, <NONE>,  'iswlower',  \
    iswprint, N, <NONE>,  'iswprint',  \
    iswpunct, N, <NONE>,  'iswpunct',  \
    iswspace, N, <NONE>,  'iswspace',  \
    iswupper, N, <NONE>,  'iswupper',  \
    iswxdigit, N, <NONE>,  'iswxdigit',  \
    isxdigit, N, <NONE>,  'isxdigit',  \
    labs, N, <NONE>,  'labs',  \
    lclose, N, <.hFile>,  'lclose',  \
    lcreat, N, <.lpPathName, .iAttribute>,  'lcreat',  \
    ldexp, N, <NONE>,  'ldexp',  \
    ldiv, N, <NONE>,  'ldiv',  \
    llseek, N, <.hFile, .lOffset, .iOrigin>,  'llseek',  \
    localeconv, N, <NONE>,  'localeconv',  \
    localtime, N, <NONE>,  'localtime',  \
    log, N, <NONE>,  'log',  \
    log10, N, <NONE>,  'log10',  \
    longjmp, N, <NONE>,  'longjmp',  \
    lopen, N, <.lpPathName, .iReadWrite>,  'lopen',  \
    malloc, N, <NONE>,  'malloc',  \
    mblen, N, <NONE>,  'mblen',  \
    mbstowcs, N, <NONE>,  'mbstowcs',  \
    mbtowc, N, <NONE>,  'mbtowc',  \
    memchr, N, <NONE>,  'memchr',  \
    memcmp, N, <NONE>,  'memcmp',  \
    memcpy, N, <NONE>,  'memcpy',  \
    memmove, N, <.pVoid, .FunctionCall>,  'memmove',  \
    memset, N, <NONE>,  'memset',  \
    mktime, N, <NONE>,  'mktime',  \
    modf, N, <NONE>,  'modf',  \
    perror, N, <NONE>,  'perror',  \
    pow, N, <NONE>,  'pow',  \
    printf, N, <NONE>,  'printf',  \
    putc, N, <NONE>,  'putc',  \
    putchar, N, <NONE>,  'putchar',  \
    puts, N, <NONE>,  'puts',  \
    qsort, N, <NONE>,  'qsort',  \
    raise, N, <NONE>,  'raise',  \
    rand, N, <NONE>,  'rand',  \
    realloc, N, <NONE>,  'realloc',  \
    remove, N, <NONE>,  'remove',  \
    rename, N, <NONE>,  'rename',  \
    rewind, N, <NONE>,  'rewind',  \
    scanf, N, <NONE>,  'scanf',  \
    setbuf, N, <NONE>,  'setbuf',  \
    setlocale, N, <NONE>,  'setlocale',  \
    setvbuf, N, <NONE>,  'setvbuf',  \
    signal, N, <NONE>,  'signal',  \
    sin, N, <NONE>,  'sin',  \
    sinh, N, <NONE>,  'sinh',  \
    sprintf, N, <NONE>,  'sprintf',  \
    sqrt, N, <NONE>,  'sqrt',  \
    srand, N, <NONE>,  'srand',  \
    sscanf, N, <NONE>,  'sscanf',  \
    strcat, N, <NONE>,  'strcat',  \
    strchr, N, <.lpStart, .wMatch>,  'strchr',  \
    strcmp, N, <NONE>,  'strcmp',  \
    strcoll, N, <NONE>,  'strcoll',  \
    crt_strcpy, N, <NONE>,  'strcpy',  \
    strcspn, N, <.lpStr, .lpSet>,  'strcspn',  \
    strerror, N, <NONE>,  'strerror',  \
    strftime, N, <NONE>,  'strftime',  \
    crt_strlen, N, <NONE>,  'strlen',  \
    strncat, N, <.psz1, .psz2, .cchMax>,  'strncat',  \
    strncmp, N, <NONE>,  'strncmp',  \
    strncpy, N, <NONE>,  'strncpy',  \
    strpbrk, N, <.psz, .pszSet>,  'strpbrk',  \
    strrchr, N, <.lpStart, .lpEnd, .wMatch>,  'strrchr',  \
    strspn, N, <.psz, .pszSet>,  'strspn',  \
    strstr, N, <.lpFirst, .lpSrch>,  'strstr',  \
    strtod, N, <NONE>,  'strtod',  \
    strtok, N, <NONE>,  'strtok',  \
    strtol, N, <NONE>,  'strtol',  \
    strtoul, N, <NONE>,  'strtoul',  \
    strxfrm, N, <NONE>,  'strxfrm',  \
    swprintf, N, <NONE>,  'swprintf',  \
    swscanf, N, <NONE>,  'swscanf',  \
    system, N, <NONE>,  'system',  \
    tan, N, <NONE>,  'tan',  \
    tanh, N, <NONE>,  'tanh',  \
    time, N, <NONE>,  'time',  \
    tmpfile, N, <NONE>,  'tmpfile',  \
    tmpnam, N, <NONE>,  'tmpnam',  \
    tolower, N, <NONE>,  'tolower',  \
    toupper, N, <NONE>,  'toupper',  \
    towlower, N, <NONE>,  'towlower',  \
    towupper, N, <NONE>,  'towupper',  \
    ungetc, N, <NONE>,  'ungetc',  \
    ungetwc, N, <NONE>,  'ungetwc',  \
    vfprintf, N, <NONE>,  'vfprintf',  \
    vfwprintf, N, <NONE>,  'vfwprintf',  \
    vprintf, N, <NONE>,  'vprintf',  \
    vsprintf, N, <NONE>,  'vsprintf',  \
    vswprintf, N, <NONE>,  'vswprintf',  \
    vwprintf, N, <NONE>,  'vwprintf',  \
    wcscat, N, <NONE>,  'wcscat',  \
    wcschr, N, <NONE>,  'wcschr',  \
    wcscmp, N, <NONE>,  'wcscmp',  \
    wcscoll, N, <NONE>,  'wcscoll',  \
    wcscpy, N, <NONE>,  'wcscpy',  \
    wcscspn, N, <NONE>,  'wcscspn',  \
    wcsftime, N, <NONE>,  'wcsftime',  \
    wcslen, N, <NONE>,  'wcslen',  \
    wcsncat, N, <NONE>,  'wcsncat',  \
    wcsncmp, N, <NONE>,  'wcsncmp',  \
    wcsncpy, N, <NONE>,  'wcsncpy',  \
    wcspbrk, N, <NONE>,  'wcspbrk',  \
    wcsrchr, N, <NONE>,  'wcsrchr',  \
    wcsspn, N, <NONE>,  'wcsspn',  \
    wcsstr, N, <NONE>,  'wcsstr',  \
    wcstod, N, <NONE>,  'wcstod',  \
    wcstok, N, <NONE>,  'wcstok',  \
    wcstol, N, <NONE>,  'wcstol',  \
    wcstombs, N, <NONE>,  'wcstombs',  \
    wcstoul, N, <NONE>,  'wcstoul',  \
    wcsxfrm, N, <NONE>,  'wcsxfrm',  \
    wctomb, N, <NONE>,  'wctomb',  \
    wprintf, N, <NONE>,  'wprintf',  \
    wscanf, N, <NONE>,  'wscanf'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/imports/Win32/api/gdi32.inc.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: gdi32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto gdi32,  \
    AbortDoc, N, <.hdc>,  'AbortDoc',  \
    AbortPath, N, <.hdc>,  'AbortPath',  \
    AddFontMemResourceEx, N, <.pvoid, .dword, .pDword>,  'AddFontMemResourceEx',  \
    AddFontResource, A, <.lpFileName>,  'AddFontResourceA',  \
    AddFontResourceEx, A, <.lpcstr, .dword>,  'AddFontResourceExA',  \
    AddFontResourceEx, W, <.lpcstr, .dword>,  'AddFontResourceExW',  \
    AddFontResourceTracking, N, <NONE>,  'AddFontResourceTracking',  \
    AddFontResource, W, <.lpFileName>,  'AddFontResourceW',  \
    AngleArc, N, <.hdc, .x, .y, .dwRadius, .eStartAngle, .eSweepAngle>,  'AngleArc',  \
    AnimatePalette, N, <.hPalette, .wStartIndex, .wNumEntries, .lpPaletteColors>,  'AnimatePalette',  \
    AnyLinkedFonts, N, <NONE>,  'AnyLinkedFonts',  \
    Arc, N, <.hdc, .X1, .Y1, .X2, .Y2, .X3, .Y3, .X4, .Y4>,  'Arc',  \
    ArcTo, N, <.hdc, .X1, .Y1, .X2, .Y2, .X3, .Y3, .X4, .Y4>,  'ArcTo',  \
    BRUSHOBJ_hGetColorTransform, N, <NONE>,  'BRUSHOBJ_hGetColorTransform',  \
    BRUSHOBJ_pvAllocRbrush, N, <NONE>,  'BRUSHOBJ_pvAllocRbrush',  \
    BRUSHOBJ_pvGetRbrush, N, <NONE>,  'BRUSHOBJ_pvGetRbrush',  \
    BRUSHOBJ_ulGetBrushColor, N, <NONE>,  'BRUSHOBJ_ulGetBrushColor',  \
    BeginPath, N, <.hdc>,  'BeginPath',  \
    BitBlt, N, <.hDestDC, .x, .y, .nWidth, .nHeight, .hSrcDC, .xSrc, .ySrc, .dwRop>,  'BitBlt',  \
    CLIPOBJ_bEnum, N, <NONE>,  'CLIPOBJ_bEnum',  \
    CLIPOBJ_cEnumStart, N, <NONE>,  'CLIPOBJ_cEnumStart',  \
    CLIPOBJ_ppoGetPath, N, <NONE>,  'CLIPOBJ_ppoGetPath',  \
    CancelDC, N, <.hdc>,  'CancelDC',  \
    CheckColorsInGamut, N, <.hdc, .lpv, .lpv2, .dw>,  'CheckColorsInGamut',  \
    ChoosePixelFormat, N, <.hDC, .pPixelFormatDescriptor>,  'ChoosePixelFormat',  \
    Chord, N, <.hdc, .X1, .Y1, .X2, .Y2, .X3, .Y3, .X4, .Y4>,  'Chord',  \
    ClearBitmapAttributes, N, <NONE>,  'ClearBitmapAttributes',  \
    ClearBrushAttributes, N, <NONE>,  'ClearBrushAttributes',  \
    CloseEnhMetaFile, N, <.hdc>,  'CloseEnhMetaFile',  \
    CloseFigure, N, <.hdc>,  'CloseFigure',  \
    CloseMetaFile, N, <.hMF>,  'CloseMetaFile',  \
    ColorCorrectPalette, N, <.hdc, .hpalette, .dword>,  'ColorCorrectPalette',  \
    ColorMatchToTarget, N, <.hdc, .hdc2, .dw>,  'ColorMatchToTarget',  \
    CombineRgn, N, <.hDestRgn, .hSrcRgn1, .hSrcRgn2, .nCombineMode>,  'CombineRgn',  \
    CombineTransform, N, <.lpxformResult, .lpxform1, .lpxform2>,  'CombineTransform',  \
    CopyEnhMetaFile, A, <.hemfSrc, .lpszFile>,  'CopyEnhMetaFileA',  \
    CopyEnhMetaFile, W, <.hemfSrc, .lpszFile>,  'CopyEnhMetaFileW',  \
    CopyMetaFile, A, <.hMF, .lpFileName>,  'CopyMetaFileA',  \
    CopyMetaFile, W, <.hMF, .lpFileName>,  'CopyMetaFileW',  \
    CreateBitmap, N, <.nWidth, .nHeight, .nPlanes, .nBitCount, .lpBits>,  'CreateBitmap',  \
    CreateBitmapIndirect, N, <.lpBitmap>,  'CreateBitmapIndirect',  \
    CreateBrushIndirect, N, <.lpLogBrush>,  'CreateBrushIndirect',  \
    CreateColorSpace, A, <.lplogcolorspace>,  'CreateColorSpaceA',  \
    CreateColorSpace, W, <.lplogcolorspace>,  'CreateColorSpaceW',  \
    CreateCompatibleBitmap, N, <.hdc, .nWidth, .nHeight>,  'CreateCompatibleBitmap',  \
    CreateCompatibleDC, N, <.hdc>,  'CreateCompatibleDC',  \
    CreateDC, A, <.lpDriverName, .lpDeviceName, .lpOutput, .lpInitData>,  'CreateDCA',  \
    CreateDC, W, <.lpDriverName, .lpDeviceName, .lpOutput, .lpInitData>,  'CreateDCW',  \
    CreateDIBPatternBrush, N, <.hPackedDIB, .wUsage>,  'CreateDIBPatternBrush',  \
    CreateDIBPatternBrushPt, N, <.lpPackedDIB, .iUsage>,  'CreateDIBPatternBrushPt',  \
    CreateDIBSection, N, <.hDC, .pBitmapInfo, .iUsage, .pVarBits, .hSection, .dwOffset>,  'CreateDIBSection',  \
    CreateDIBitmap, N, <.hdc, .lpInfoHeader, .dwUsage, .lpInitBits, .lpInitInfo, .wUsage>,  'CreateDIBitmap',  \
    CreateDiscardableBitmap, N, <.hdc, .nWidth, .nHeight>,  'CreateDiscardableBitmap',  \
    CreateEllipticRgn, N, <.X1, .Y1, .X2, .Y2>,  'CreateEllipticRgn',  \
    CreateEllipticRgnIndirect, N, <.lpRect>,  'CreateEllipticRgnIndirect',  \
    CreateEnhMetaFile, A, <.hdcRef, .lpFileName, .lpRect, .lpDescription>,  'CreateEnhMetaFileA',  \
    CreateEnhMetaFile, W, <.hdcRef, .lpFileName, .lpRect, .lpDescription>,  'CreateEnhMetaFileW',  \
    CreateFont, A, <.height, .width, .escapement, .orientation, .weight, .italic, .underline, .strikeout, .charset, .OutputPrecision, .ClipPrecision, .quality, .PitchAndFamily, .Face>,  'CreateFontA',  \
    CreateFontIndirect, A, <.lpLogFont>,  'CreateFontIndirectA',  \
    CreateFontIndirectEx, A, <.ENUMLOGFONTEXDVA>,  'CreateFontIndirectExA',  \
    CreateFontIndirectEx, W, <.ENUMLOGFONTEXDVA>,  'CreateFontIndirectExW',  \
    CreateFontIndirect, W, <.lpLogFont>,  'CreateFontIndirectW',  \
    CreateFont, W, <.height, .width, .escapement, .orientation, .weight, .italic, .underline, .strikeout, .charset, .OutputPrecision, .ClipPrecision, .quality, .PitchAndFamily, .Face>,  'CreateFontW',  \
    CreateHalftonePalette, N, <.hdc>,  'CreateHalftonePalette',  \
    CreateHatchBrush, N, <.nIndex, .crColor>,  'CreateHatchBrush',  \
    CreateIC, A, <.lpDriverName, .lpDeviceName, .lpOutput, .lpInitData>,  'CreateICA',  \
    CreateIC, W, <.lpDriverName, .lpDeviceName, .lpOutput, .lpInitData>,  'CreateICW',  \
    CreateMetaFile, A, <.lpString>,  'CreateMetaFileA',  \
    CreateMetaFile, W, <.lpString>,  'CreateMetaFileW',  \
    CreatePalette, N, <.lpLogPalette>,  'CreatePalette',  \
    CreatePatternBrush, N, <.hBitmap>,  'CreatePatternBrush',  \
    CreatePen, N, <.nPenStyle, .nWidth, .crColor>,  'CreatePen',  \
    CreatePenIndirect, N, <.lpLogPen>,  'CreatePenIndirect',  \
    CreatePolyPolygonRgn, N, <.lpPoint, .lpPolyCounts, .nCount, .nPolyFillMode>,  'CreatePolyPolygonRgn',  \
    CreatePolygonRgn, N, <.lpPoint, .nCount, .nPolyFillMode>,  'CreatePolygonRgn',  \
    CreateRectRgn, N, <.X1, .Y1, .X2, .Y2>,  'CreateRectRgn',  \
    CreateRectRgnIndirect, N, <.lpRect>,  'CreateRectRgnIndirect',  \
    CreateRoundRectRgn, N, <.X1, .Y1, .X2, .Y2, .X3, .Y3>,  'CreateRoundRectRgn',  \
    CreateScalableFontResource, A, <.fHidden, .lpszResourceFile, .lpszFontFile, .lpszCurrentPath>,  'CreateScalableFontResourceA',  \
    CreateScalableFontResource, W, <.fHidden, .lpszResourceFile, .lpszFontFile, .lpszCurrentPath>,  'CreateScalableFontResourceW',  \
    CreateSolidBrush, N, <.crColor>,  'CreateSolidBrush',  \
    DPtoLP, N, <.hdc, .lpPoint, .nCount>,  'DPtoLP',  \
    DdEntry0, N, <NONE>,  'DdEntry0',  \
    DdEntry1, N, <NONE>,  'DdEntry1',  \
    DdEntry10, N, <NONE>,  'DdEntry10',  \
    DdEntry11, N, <NONE>,  'DdEntry11',  \
    DdEntry12, N, <NONE>,  'DdEntry12',  \
    DdEntry13, N, <NONE>,  'DdEntry13',  \
    DdEntry14, N, <NONE>,  'DdEntry14',  \
    DdEntry15, N, <NONE>,  'DdEntry15',  \
    DdEntry16, N, <NONE>,  'DdEntry16',  \
    DdEntry17, N, <NONE>,  'DdEntry17',  \
    DdEntry18, N, <NONE>,  'DdEntry18',  \
    DdEntry19, N, <NONE>,  'DdEntry19',  \
    DdEntry2, N, <NONE>,  'DdEntry2',  \
    DdEntry20, N, <NONE>,  'DdEntry20',  \
    DdEntry21, N, <NONE>,  'DdEntry21',  \
    DdEntry22, N, <NONE>,  'DdEntry22',  \
    DdEntry23, N, <NONE>,  'DdEntry23',  \
    DdEntry24, N, <NONE>,  'DdEntry24',  \
    DdEntry25, N, <NONE>,  'DdEntry25',  \
    DdEntry26, N, <NONE>,  'DdEntry26',  \
    DdEntry27, N, <NONE>,  'DdEntry27',  \
    DdEntry28, N, <NONE>,  'DdEntry28',  \
    DdEntry29, N, <NONE>,  'DdEntry29',  \
    DdEntry3, N, <NONE>,  'DdEntry3',  \
    DdEntry30, N, <NONE>,  'DdEntry30',  \
    DdEntry31, N, <NONE>,  'DdEntry31',  \
    DdEntry32, N, <NONE>,  'DdEntry32',  \
    DdEntry33, N, <NONE>,  'DdEntry33',  \
    DdEntry34, N, <NONE>,  'DdEntry34',  \
    DdEntry35, N, <NONE>,  'DdEntry35',  \
    DdEntry36, N, <NONE>,  'DdEntry36',  \
    DdEntry37, N, <NONE>,  'DdEntry37',  \
    DdEntry38, N, <NONE>,  'DdEntry38',  \
    DdEntry39, N, <NONE>,  'DdEntry39',  \
    DdEntry4, N, <NONE>,  'DdEntry4',  \
    DdEntry40, N, <NONE>,  'DdEntry40',  \
    DdEntry41, N, <NONE>,  'DdEntry41',  \
    DdEntry42, N, <NONE>,  'DdEntry42',  \
    DdEntry43, N, <NONE>,  'DdEntry43',  \
    DdEntry44, N, <NONE>,  'DdEntry44',  \
    DdEntry45, N, <NONE>,  'DdEntry45',  \
    DdEntry46, N, <NONE>,  'DdEntry46',  \
    DdEntry47, N, <NONE>,  'DdEntry47',  \
    DdEntry48, N, <NONE>,  'DdEntry48',  \
    DdEntry49, N, <NONE>,  'DdEntry49',  \
    DdEntry5, N, <NONE>,  'DdEntry5',  \
    DdEntry50, N, <NONE>,  'DdEntry50',  \
    DdEntry51, N, <NONE>,  'DdEntry51',  \
    DdEntry52, N, <NONE>,  'DdEntry52',  \
    DdEntry53, N, <NONE>,  'DdEntry53',  \
    DdEntry54, N, <NONE>,  'DdEntry54',  \
    DdEntry55, N, <NONE>,  'DdEntry55',  \
    DdEntry56, N, <NONE>,  'DdEntry56',  \
    DdEntry6, N, <NONE>,  'DdEntry6',  \
    DdEntry7, N, <NONE>,  'DdEntry7',  \
    DdEntry8, N, <NONE>,  'DdEntry8',  \
    DdEntry9, N, <NONE>,  'DdEntry9',  \
    DeleteColorSpace, N, <.hcolorspace>,  'DeleteColorSpace',  \
    DeleteDC, N, <.hdc>,  'DeleteDC',  \
    DeleteEnhMetaFile, N, <.hemf>,  'DeleteEnhMetaFile',  \
    DeleteMetaFile, N, <.hMF>,  'DeleteMetaFile',  \
    DeleteObject, N, <.hObject>,  'DeleteObject',  \
    DescribePixelFormat, N, <.hDC, .n, .un, .lpPixelFormatDescriptor>,  'DescribePixelFormat',  \
    DeviceCapabilitiesEx, A, <NONE>,  'DeviceCapabilitiesExA',  \
    DeviceCapabilitiesEx, W, <NONE>,  'DeviceCapabilitiesExW',  \
    DrawEscape, N, <.hdc, .nEscape, .cbInput, .lpszInData>,  'DrawEscape',  \
    Ellipse, N, <.hdc, .X1, .Y1, .X2, .Y2>,  'Ellipse',  \
    EnableEUDC, N, <NONE>,  'EnableEUDC',  \
    EndDoc, N, <.hDC>,  'EndDoc',  \
    EndFormPage, N, <.hdc>,  'EndFormPage',  \
    EndPage, N, <.hdc>,  'EndPage',  \
    EndPath, N, <.hdc>,  'EndPath',  \
    EngAcquireSemaphore, N, <NONE>,  'EngAcquireSemaphore',  \
    EngAlphaBlend, N, <NONE>,  'EngAlphaBlend',  \
    EngAssociateSurface, N, <NONE>,  'EngAssociateSurface',  \
    EngBitBlt, N, <NONE>,  'EngBitBlt',  \
    EngCheckAbort, N, <NONE>,  'EngCheckAbort',  \
    EngComputeGlyphSet, N, <NONE>,  'EngComputeGlyphSet',  \
    EngCopyBits, N, <NONE>,  'EngCopyBits',  \
    EngCreateBitmap, N, <NONE>,  'EngCreateBitmap',  \
    EngCreateClip, N, <NONE>,  'EngCreateClip',  \
    EngCreateDeviceBitmap, N, <NONE>,  'EngCreateDeviceBitmap',  \
    EngCreateDeviceSurface, N, <NONE>,  'EngCreateDeviceSurface',  \
    EngCreatePalette, N, <NONE>,  'EngCreatePalette',  \
    EngCreateSemaphore, N, <NONE>,  'EngCreateSemaphore',  \
    EngDeleteClip, N, <NONE>,  'EngDeleteClip',  \
    EngDeletePalette, N, <NONE>,  'EngDeletePalette',  \
    EngDeletePath, N, <NONE>,  'EngDeletePath',  \
    EngDeleteSemaphore, N, <NONE>,  'EngDeleteSemaphore',  \
    EngDeleteSurface, N, <NONE>,  'EngDeleteSurface',  \
    EngEraseSurface, N, <NONE>,  'EngEraseSurface',  \
    EngFillPath, N, <NONE>,  'EngFillPath',  \
    EngFindResource, N, <NONE>,  'EngFindResource',  \
    EngFreeModule, N, <NONE>,  'EngFreeModule',  \
    EngGetCurrentCodePage, N, <NONE>,  'EngGetCurrentCodePage',  \
    EngGetDriverName, N, <NONE>,  'EngGetDriverName',  \
    EngGetPrinterDataFileName, N, <NONE>,  'EngGetPrinterDataFileName',  \
    EngGradientFill, N, <NONE>,  'EngGradientFill',  \
    EngLineTo, N, <NONE>,  'EngLineTo',  \
    EngLoadModule, N, <NONE>,  'EngLoadModule',  \
    EngLockSurface, N, <NONE>,  'EngLockSurface',  \
    EngMarkBandingSurface, N, <NONE>,  'EngMarkBandingSurface',  \
    EngMultiByteToUnicodeN, N, <NONE>,  'EngMultiByteToUnicodeN',  \
    EngMultiByteToWideChar, N, <NONE>,  'EngMultiByteToWideChar',  \
    EngPaint, N, <NONE>,  'EngPaint',  \
    EngPlgBlt, N, <NONE>,  'EngPlgBlt',  \
    EngQueryEMFInfo, N, <NONE>,  'EngQueryEMFInfo',  \
    EngQueryLocalTime, N, <NONE>,  'EngQueryLocalTime',  \
    EngReleaseSemaphore, N, <NONE>,  'EngReleaseSemaphore',  \
    EngStretchBlt, N, <NONE>,  'EngStretchBlt',  \
    EngStretchBltROP, N, <NONE>,  'EngStretchBltROP',  \
    EngStrokeAndFillPath, N, <NONE>,  'EngStrokeAndFillPath',  \
    EngStrokePath, N, <NONE>,  'EngStrokePath',  \
    EngTextOut, N, <NONE>,  'EngTextOut',  \
    EngTransparentBlt, N, <NONE>,  'EngTransparentBlt',  \
    EngUnicodeToMultiByteN, N, <NONE>,  'EngUnicodeToMultiByteN',  \
    EngUnlockSurface, N, <NONE>,  'EngUnlockSurface',  \
    EngWideCharToMultiByte, N, <NONE>,  'EngWideCharToMultiByte',  \
    EnumEnhMetaFile, N, <.hdc, .hemf, .lpEnhMetaFunc, .lpData, .lpRect>,  'EnumEnhMetaFile',  \
    EnumFontFamilies, A, <.hdc, .lpszFamily, .lpEnumFontFamProc, .lParam>,  'EnumFontFamiliesA',  \
    EnumFontFamiliesEx, A, <.hdc, .lpLogFont, .lpEnumFontProc, .lParam, .dw>,  'EnumFontFamiliesExA',  \
    EnumFontFamiliesEx, W, <.hdc, .lpLogFont, .lpEnumFontProc, .lParam, .dw>,  'EnumFontFamiliesExW',  \
    EnumFontFamilies, W, <.hdc, .lpszFamily, .lpEnumFontFamProc, .lParam>,  'EnumFontFamiliesW',  \
    EnumFonts, A, <.hDC, .lpsz, .lpFontEnumProc, .lParam>,  'EnumFontsA',  \
    EnumFonts, W, <.hDC, .lpsz, .lpFontEnumProc, .lParam>,  'EnumFontsW',  \
    EnumICMProfiles, A, <.hdc, .icmEnumProc, .lParam>,  'EnumICMProfilesA',  \
    EnumICMProfiles, W, <.hdc, .icmEnumProc, .lParam>,  'EnumICMProfilesW',  \
    EnumMetaFile, N, <.hDC, .hMetafile, .lpMFEnumProc, .lParam>,  'EnumMetaFile',  \
    EnumObjects, N, <.hDC, .n, .lpGOBJEnumProc, .lpVoid>,  'EnumObjects',  \
    EqualRgn, N, <.hSrcRgn1, .hSrcRgn2>,  'EqualRgn',  \
    Escape, N, <.hdc, .nEscape, .nCount, .lpInData, .lpOutData>,  'Escape',  \
    EudcLoadLink, W, <NONE>,  'EudcLoadLinkW',  \
    EudcUnloadLink, W, <NONE>,  'EudcUnloadLinkW',  \
    ExcludeClipRect, N, <.hdc, .X1, .Y1, .X2, .Y2>,  'ExcludeClipRect',  \
    ExtCreatePen, N, <.dwPenStyle, .dwWidth, .lplb, .dwStyleCount, .lpStyle>,  'ExtCreatePen',  \
    ExtCreateRegion, N, <.lpXform, .nCount, .lpRgnData>,  'ExtCreateRegion',  \
    ExtEscape, N, <.hdc, .nEscape, .cbInput, .lpszInData, .cbOutput, .lpszOutData>,  'ExtEscape',  \
    ExtFloodFill, N, <.hdc, .x, .y, .crColor, .wFillType>,  'ExtFloodFill',  \
    ExtSelectClipRgn, N, <.hdc, .hRgn, .fnMode>,  'ExtSelectClipRgn',  \
    ExtTextOut, A, <.hdc, .x, .y, .wOptions, .lpRect, .lpString, .nCount, .lpDx>,  'ExtTextOutA',  \
    ExtTextOut, W, <.hdc, .x, .y, .wOptions, .lpRect, .lpString, .nCount, .lpDx>,  'ExtTextOutW',  \
    FONTOBJ_cGetAllGlyphHandles, N, <NONE>,  'FONTOBJ_cGetAllGlyphHandles',  \
    FONTOBJ_cGetGlyphs, N, <NONE>,  'FONTOBJ_cGetGlyphs',  \
    FONTOBJ_pQueryGlyphAttrs, N, <NONE>,  'FONTOBJ_pQueryGlyphAttrs',  \
    FONTOBJ_pfdg, N, <NONE>,  'FONTOBJ_pfdg',  \
    FONTOBJ_pifi, N, <NONE>,  'FONTOBJ_pifi',  \
    FONTOBJ_pvTrueTypeFontFile, N, <NONE>,  'FONTOBJ_pvTrueTypeFontFile',  \
    FONTOBJ_pxoGetXform, N, <NONE>,  'FONTOBJ_pxoGetXform',  \
    FONTOBJ_vGetInfo, N, <NONE>,  'FONTOBJ_vGetInfo',  \
    FillPath, N, <.hdc>,  'FillPath',  \
    FillRgn, N, <.hdc, .hRgn, .hBrush>,  'FillRgn',  \
    FixBrushOrgEx, N, <.hDC, .n1, .n2, .lpPoint>,  'FixBrushOrgEx',  \
    FlattenPath, N, <.hdc>,  'FlattenPath',  \
    FloodFill, N, <.hdc, .x, .y, .crColor>,  'FloodFill',  \
    FontIsLinked, N, <NONE>,  'FontIsLinked',  \
    FrameRgn, N, <.hdc, .hRgn, .hBrush, .nWidth, .nHeight>,  'FrameRgn',  \
    GdiAddFontResource, W, <NONE>,  'GdiAddFontResourceW',  \
    GdiAddGlsBounds, N, <NONE>,  'GdiAddGlsBounds',  \
    GdiAddGlsRecord, N, <NONE>,  'GdiAddGlsRecord',  \
    GdiAlphaBlend, N, <NONE>,  'GdiAlphaBlend',  \
    GdiArtificialDecrementDriver, N, <NONE>,  'GdiArtificialDecrementDriver',  \
    GdiCleanCacheDC, N, <NONE>,  'GdiCleanCacheDC',  \
    GdiComment, N, <.hdc, .cbSize, .lpData>,  'GdiComment',  \
    GdiConsoleTextOut, N, <NONE>,  'GdiConsoleTextOut',  \
    GdiConvertAndCheckDC, N, <NONE>,  'GdiConvertAndCheckDC',  \
    GdiConvertBitmap, N, <NONE>,  'GdiConvertBitmap',  \
    GdiConvertBitmapV5, N, <NONE>,  'GdiConvertBitmapV5',  \
    GdiConvertBrush, N, <NONE>,  'GdiConvertBrush',  \
    GdiConvertDC, N, <NONE>,  'GdiConvertDC',  \
    GdiConvertEnhMetaFile, N, <NONE>,  'GdiConvertEnhMetaFile',  \
    GdiConvertFont, N, <NONE>,  'GdiConvertFont',  \
    GdiConvertMetaFilePict, N, <NONE>,  'GdiConvertMetaFilePict',  \
    GdiConvertPalette, N, <NONE>,  'GdiConvertPalette',  \
    GdiConvertRegion, N, <NONE>,  'GdiConvertRegion',  \
    GdiConvertToDevmode, W, <NONE>,  'GdiConvertToDevmodeW',  \
    GdiCreateLocalEnhMetaFile, N, <NONE>,  'GdiCreateLocalEnhMetaFile',  \
    GdiCreateLocalMetaFilePict, N, <NONE>,  'GdiCreateLocalMetaFilePict',  \
    GdiDeleteLocalDC, N, <NONE>,  'GdiDeleteLocalDC',  \
    GdiDeleteSpoolFileHandle, N, <NONE>,  'GdiDeleteSpoolFileHandle',  \
    GdiDescribePixelFormat, N, <NONE>,  'GdiDescribePixelFormat',  \
    GdiDllInitialize, N, <NONE>,  'GdiDllInitialize',  \
    GdiDrawStream, N, <NONE>,  'GdiDrawStream',  \
    GdiEndDocEMF, N, <NONE>,  'GdiEndDocEMF',  \
    GdiEndPageEMF, N, <NONE>,  'GdiEndPageEMF',  \
    GdiEntry1, N, <NONE>,  'GdiEntry1',  \
    GdiEntry10, N, <NONE>,  'GdiEntry10',  \
    GdiEntry11, N, <NONE>,  'GdiEntry11',  \
    GdiEntry12, N, <NONE>,  'GdiEntry12',  \
    GdiEntry13, N, <NONE>,  'GdiEntry13',  \
    GdiEntry14, N, <NONE>,  'GdiEntry14',  \
    GdiEntry15, N, <NONE>,  'GdiEntry15',  \
    GdiEntry16, N, <NONE>,  'GdiEntry16',  \
    GdiEntry2, N, <NONE>,  'GdiEntry2',  \
    GdiEntry3, N, <NONE>,  'GdiEntry3',  \
    GdiEntry4, N, <NONE>,  'GdiEntry4',  \
    GdiEntry5, N, <NONE>,  'GdiEntry5',  \
    GdiEntry6, N, <NONE>,  'GdiEntry6',  \
    GdiEntry7, N, <NONE>,  'GdiEntry7',  \
    GdiEntry8, N, <NONE>,  'GdiEntry8',  \
    GdiEntry9, N, <NONE>,  'GdiEntry9',  \
    GdiFixUpHandle, N, <NONE>,  'GdiFixUpHandle',  \
    GdiFlush, N, <VOID>,  'GdiFlush',  \
    GdiFullscreenControl, N, <NONE>,  'GdiFullscreenControl',  \
    GdiGetBatchLimit, N, <VOID>,  'GdiGetBatchLimit',  \
    GdiGetBitmapBitsSize, N, <NONE>,  'GdiGetBitmapBitsSize',  \
    GdiGetCharDimensions, N, <NONE>,  'GdiGetCharDimensions',  \
    GdiGetCodePage, N, <NONE>,  'GdiGetCodePage',  \
    GdiGetDC, N, <NONE>,  'GdiGetDC',  \
    GdiGetDevmodeForPage, N, <NONE>,  'GdiGetDevmodeForPage',  \
    GdiGetLocalBrush, N, <NONE>,  'GdiGetLocalBrush',  \
    GdiGetLocalDC, N, <NONE>,  'GdiGetLocalDC',  \
    GdiGetLocalFont, N, <NONE>,  'GdiGetLocalFont',  \
    GdiGetPageCount, N, <NONE>,  'GdiGetPageCount',  \
    GdiGetPageHandle, N, <NONE>,  'GdiGetPageHandle',  \
    GdiGetSpoolFileHandle, N, <NONE>,  'GdiGetSpoolFileHandle',  \
    GdiGetSpoolMessage, N, <NONE>,  'GdiGetSpoolMessage',  \
    GdiGradientFill, N, <NONE>,  'GdiGradientFill',  \
    GdiInitSpool, N, <NONE>,  'GdiInitSpool',  \
    GdiInitializeLanguagePack, N, <NONE>,  'GdiInitializeLanguagePack',  \
    GdiIsMetaFileDC, N, <NONE>,  'GdiIsMetaFileDC',  \
    GdiIsMetaPrintDC, N, <NONE>,  'GdiIsMetaPrintDC',  \
    GdiIsPlayMetafileDC, N, <NONE>,  'GdiIsPlayMetafileDC',  \
    GdiPlayDCScript, N, <NONE>,  'GdiPlayDCScript',  \
    GdiPlayEMF, N, <NONE>,  'GdiPlayEMF',  \
    GdiPlayJournal, N, <NONE>,  'GdiPlayJournal',  \
    GdiPlayPageEMF, N, <NONE>,  'GdiPlayPageEMF',  \
    GdiPlayPrivatePageEMF, N, <NONE>,  'GdiPlayPrivatePageEMF',  \
    GdiPlayScript, N, <NONE>,  'GdiPlayScript',  \
    GdiPrinterThunk, N, <NONE>,  'GdiPrinterThunk',  \
    GdiProcessSetup, N, <NONE>,  'GdiProcessSetup',  \
    GdiQueryFonts, N, <NONE>,  'GdiQueryFonts',  \
    GdiQueryTable, N, <NONE>,  'GdiQueryTable',  \
    GdiRealizationInfo, N, <NONE>,  'GdiRealizationInfo',  \
    GdiReleaseDC, N, <NONE>,  'GdiReleaseDC',  \
    GdiReleaseLocalDC, N, <NONE>,  'GdiReleaseLocalDC',  \
    GdiResetDCEMF, N, <NONE>,  'GdiResetDCEMF',  \
    GdiSetAttrs, N, <NONE>,  'GdiSetAttrs',  \
    GdiSetBatchLimit, N, <.dwLimit>,  'GdiSetBatchLimit',  \
    GdiSetLastError, N, <NONE>,  'GdiSetLastError',  \
    GdiSetPixelFormat, N, <NONE>,  'GdiSetPixelFormat',  \
    GdiSetServerAttr, N, <NONE>,  'GdiSetServerAttr',  \
    GdiStartDocEMF, N, <NONE>,  'GdiStartDocEMF',  \
    GdiStartPageEMF, N, <NONE>,  'GdiStartPageEMF',  \
    GdiSwapBuffers, N, <NONE>,  'GdiSwapBuffers',  \
    GdiTransparentBlt, N, <NONE>,  'GdiTransparentBlt',  \
    GdiValidateHandle, N, <NONE>,  'GdiValidateHandle',  \
    GetArcDirection, N, <.hdc>,  'GetArcDirection',  \
    GetAspectRatioFilterEx, N, <.hdc, .lpAspectRatio>,  'GetAspectRatioFilterEx',  \
    GetBitmapAttributes, N, <NONE>,  'GetBitmapAttributes',  \
    GetBitmapBits, N, <.hBitmap, .dwCount, .lpBits>,  'GetBitmapBits',  \
    GetBitmapDimensionEx, N, <.hBitmap, .lpDimension>,  'GetBitmapDimensionEx',  \
    GetBkColor, N, <.hdc>,  'GetBkColor',  \
    GetBkMode, N, <.hdc>,  'GetBkMode',  \
    GetBoundsRect, N, <.hdc, .lprcBounds, .flags>,  'GetBoundsRect',  \
    GetBrushAttributes, N, <NONE>,  'GetBrushAttributes',  \
    GetBrushOrgEx, N, <.hDC, .lpPoint>,  'GetBrushOrgEx',  \
    GetCharABCWidths, A, <.hdc, .uFirstChar, .uLastChar, .lpabc>,  'GetCharABCWidthsA',  \
    GetCharABCWidthsFloat, A, <.hdc, .iFirstChar, .iLastChar, .lpABCF>,  'GetCharABCWidthsFloatA',  \
    GetCharABCWidthsFloat, W, <.hdc, .iFirstChar, .iLastChar, .lpABCF>,  'GetCharABCWidthsFloatW',  \
    GetCharABCWidthsI, N, <.hdc, .uint, .lpword, .lpabc>,  'GetCharABCWidthsI',  \
    GetCharABCWidths, W, <.hdc, .uFirstChar, .uLastChar, .lpabc>,  'GetCharABCWidthsW',  \
    GetCharWidth32, A, <.hdc, .iFirstChar, .iLastChar, .lpBuffer>,  'GetCharWidth32A',  \
    GetCharWidth32, W, <.hdc, .iFirstChar, .iLastChar, .lpBuffer>,  'GetCharWidth32W',  \
    GetCharWidth, A, <.hdc, .wFirstChar, .wLastChar, .lpBuffer>,  'GetCharWidthA',  \
    GetCharWidthFloat, A, <.hdc, .iFirstChar, .iLastChar, .pxBuffer>,  'GetCharWidthFloatA',  \
    GetCharWidthFloat, W, <.hdc, .iFirstChar, .iLastChar, .pxBuffer>,  'GetCharWidthFloatW',  \
    GetCharWidthI, N, <.hdc, .uint, .lpword, .lpint>,  'GetCharWidthI',  \
    GetCharWidthInfo, N, <NONE>,  'GetCharWidthInfo',  \
    GetCharWidth, W, <.hdc, .wFirstChar, .wLastChar, .lpBuffer>,  'GetCharWidthW',  \
    GetCharacterPlacement, A, <.hdc, .lpsz, .n1, .n2, .lpGcpResults, .dw>,  'GetCharacterPlacementA',  \
    GetCharacterPlacement, W, <.hdc, .lpsz, .n1, .n2, .lpGcpResults, .dw>,  'GetCharacterPlacementW',  \
    GetClipBox, N, <.hdc, .lpRect>,  'GetClipBox',  \
    GetClipRgn, N, <.hdc, .hRgn>,  'GetClipRgn',  \
    GetColorAdjustment, N, <.hdc, .lpca>,  'GetColorAdjustment',  \
    GetColorSpace, N, <.hdc>,  'GetColorSpace',  \
    GetCurrentObject, N, <.hdc, .uObjectType>,  'GetCurrentObject',  \
    GetCurrentPositionEx, N, <.hdc, .lpPoint>,  'GetCurrentPositionEx',  \
    GetDCBrushColor, N, <.hdc>,  'GetDCBrushColor',  \
    GetDCOrgEx, N, <.hdc, .lpPoint>,  'GetDCOrgEx',  \
    GetDCPenColor, N, <.hdc>,  'GetDCPenColor',  \
    GetDIBColorTable, N, <.hDC, .un1, .un2, .pRGBQuad>,  'GetDIBColorTable',  \
    GetDIBits, N, <.aHDC, .hBitmap, .nStartScan, .nNumScans, .lpBits, .lpBI, .wUsage>,  'GetDIBits',  \
    GetDeviceCaps, N, <.hdc, .nIndex>,  'GetDeviceCaps',  \
    GetDeviceGammaRamp, N, <.hdc, .lpv>,  'GetDeviceGammaRamp',  \
    GetETM, N, <NONE>,  'GetETM',  \
    GetEUDCTimeStamp, N, <NONE>,  'GetEUDCTimeStamp',  \
    GetEUDCTimeStampEx, W, <NONE>,  'GetEUDCTimeStampExW',  \
    GetEnhMetaFile, A, <.lpszMetaFile>,  'GetEnhMetaFileA',  \
    GetEnhMetaFileBits, N, <.hemf, .cbBuffer, .lpbBuffer>,  'GetEnhMetaFileBits',  \
    GetEnhMetaFileDescription, A, <.hemf, .cchBuffer, .lpszDescription>,  'GetEnhMetaFileDescriptionA',  \
    GetEnhMetaFileDescription, W, <.hemf, .cchBuffer, .lpszDescription>,  'GetEnhMetaFileDescriptionW',  \
    GetEnhMetaFileHeader, N, <.hemf, .cbBuffer, .lpemh>,  'GetEnhMetaFileHeader',  \
    GetEnhMetaFilePaletteEntries, N, <.hemf, .cEntries, .lppe>,  'GetEnhMetaFilePaletteEntries',  \
    GetEnhMetaFilePixelFormat, N, <.henhmetafile, .uint, .PIXELFORMATDESCRIPTOR>,  'GetEnhMetaFilePixelFormat',  \
    GetEnhMetaFile, W, <.lpszMetaFile>,  'GetEnhMetaFileW',  \
    GetFontAssocStatus, N, <NONE>,  'GetFontAssocStatus',  \
    GetFontData, N, <.hdc, .dwTable, .dwOffset, .lpvBuffer, .cbData>,  'GetFontData',  \
    GetFontLanguageInfo, N, <.hdc>,  'GetFontLanguageInfo',  \
    GetFontResourceInfo, W, <NONE>,  'GetFontResourceInfoW',  \
    GetFontUnicodeRanges, N, <.hdc, .LPGLYPHSET>,  'GetFontUnicodeRanges',  \
    GetGlyphIndices, A, <.hdc, .lpcstr, .ByValt, .lpword, .dword>,  'GetGlyphIndicesA',  \
    GetGlyphIndices, W, <.hdc, .lpcstr, .ByValt, .lpword, .dword>,  'GetGlyphIndicesW',  \
    GetGlyphOutline, A, <.hdc, .uChar, .fuFormat, .lpgm, .cbBuffer, .lpBuffer, .lpmat2>,  'GetGlyphOutlineA',  \
    GetGlyphOutline, W, <.hdc, .uChar, .fuFormat, .lpgm, .cbBuffer, .lpBuffer, .lpmat2>,  'GetGlyphOutlineW',  \
    GetGlyphOutlineWow, N, <NONE>,  'GetGlyphOutlineWow',  \
    GetGraphicsMode, N, <.hdc>,  'GetGraphicsMode',  \
    GetHFONT, N, <NONE>,  'GetHFONT',  \
    GetICMProfile, A, <.hdc, .dw, .lpStr>,  'GetICMProfileA',  \
    GetICMProfile, W, <.hdc, .dw, .lpStr>,  'GetICMProfileW',  \
    GetKerningPairs, A, <.hdc, .cPairs, .lpkrnpair>,  'GetKerningPairsA',  \
    GetKerningPairs, W, <.hdc, .cPairs, .lpkrnpair>,  'GetKerningPairsW',  \
    GetLayout, N, <.hdc>,  'GetLayout',  \
    GetLogColorSpace, A, <.hcolorspace, .lplogcolorspace, .dw>,  'GetLogColorSpaceA',  \
    GetLogColorSpace, W, <.hcolorspace, .lplogcolorspace, .dw>,  'GetLogColorSpaceW',  \
    GetMapMode, N, <.hdc>,  'GetMapMode',  \
    GetMetaFile, A, <.lpFileName>,  'GetMetaFileA',  \
    GetMetaFileBitsEx, N, <.hMF, .nSize, .lpvData>,  'GetMetaFileBitsEx',  \
    GetMetaFile, W, <.lpFileName>,  'GetMetaFileW',  \
    GetMetaRgn, N, <.hdc, .hRgn>,  'GetMetaRgn',  \
    GetMiterLimit, N, <.hdc, .peLimit>,  'GetMiterLimit',  \
    GetNearestColor, N, <.hdc, .crColor>,  'GetNearestColor',  \
    GetNearestPaletteIndex, N, <.hPalette, .crColor>,  'GetNearestPaletteIndex',  \
    GetObject, A, <.hObject, .nCount, .lpObject>,  'GetObjectA',  \
    GetObjectType, N, <.hgdiobj>,  'GetObjectType',  \
    GetObject, W, <.hObject, .nCount, .lpObject>,  'GetObjectW',  \
    GetOutlineTextMetrics, A, <.hdc, .cbData, .lpotm>,  'GetOutlineTextMetricsA',  \
    GetOutlineTextMetrics, W, <.hdc, .cbData, .lpotm>,  'GetOutlineTextMetricsW',  \
    GetPaletteEntries, N, <.hPalette, .wStartIndex, .wNumEntries, .lpPaletteEntries>,  'GetPaletteEntries',  \
    GetPath, N, <.hdc, .lpPoint, .lpTypes, .nSize>,  'GetPath',  \
    GetPixel, N, <.hdc, .x, .y>,  'GetPixel',  \
    GetPixelFormat, N, <.hDC>,  'GetPixelFormat',  \
    GetPolyFillMode, N, <.hdc>,  'GetPolyFillMode',  \
    GetROP2, N, <.hdc>,  'GetROP2',  \
    GetRandomRgn, N, <.hdc, .hrgn, .ByValt>,  'GetRandomRgn',  \
    GetRasterizerCaps, N, <.lpraststat, .cb>,  'GetRasterizerCaps',  \
    GetRegionData, N, <.hRgn, .dwCount, .lpRgnData>,  'GetRegionData',  \
    GetRelAbs, N, <NONE>,  'GetRelAbs',  \
    GetRgnBox, N, <.hRgn, .lpRect>,  'GetRgnBox',  \
    GetStockObject, N, <.fnObject>,  'GetStockObject',  \
    GetStretchBltMode, N, <.hdc>,  'GetStretchBltMode',  \
    GetStringBitmap, A, <NONE>,  'GetStringBitmapA',  \
    GetStringBitmap, W, <NONE>,  'GetStringBitmapW',  \
    GetSystemPaletteEntries, N, <.hdc, .wStartIndex, .wNumEntries, .lpPaletteEntries>,  'GetSystemPaletteEntries',  \
    GetSystemPaletteUse, N, <.hdc>,  'GetSystemPaletteUse',  \
    GetTextAlign, N, <.hdc>,  'GetTextAlign',  \
    GetTextCharacterExtra, N, <.hdc>,  'GetTextCharacterExtra',  \
    GetTextCharset, N, <.hdc>,  'GetTextCharset',  \
    GetTextCharsetInfo, N, <.hdc, .lpSig, .dwFlags>,  'GetTextCharsetInfo',  \
    GetTextColor, N, <.hdc>,  'GetTextColor',  \
    GetTextExtentExPoint, A, <.hdc, .lpszStr, .cchString, .nMaxExtent, .lpnFit, .alpDx, .lpSize>,  'GetTextExtentExPointA',  \
    GetTextExtentExPointI, N, <.hdc, .lpword, .ByValt, .lpint, .lpsize>,  'GetTextExtentExPointI',  \
    GetTextExtentExPoint, W, <.hdc, .lpszStr, .cchString, .nMaxExtent, .lpnFit, .alpDx, .lpSize>,  'GetTextExtentExPointW',  \
    GetTextExtentExPointWPri, N, <NONE>,  'GetTextExtentExPointWPri',  \
    GetTextExtentPoint32, A, <.hdc, .lpsz, .cbString, .lpSize>,  'GetTextExtentPoint32A',  \
    GetTextExtentPoint32, W, <.hdc, .lpsz, .cbString, .lpSize>,  'GetTextExtentPoint32W',  \
    GetTextExtentPoint, A, <.hdc, .lpszString, .cbString, .lpSize>,  'GetTextExtentPointA',  \
    GetTextExtentPointI, N, <.hdc, .lpword, .ByValt, .lpsize>,  'GetTextExtentPointI',  \
    GetTextExtentPoint, W, <.hdc, .lpszString, .cbString, .lpSize>,  'GetTextExtentPointW',  \
    GetTextFace, A, <.hdc, .nCount, .lpFacename>,  'GetTextFaceA',  \
    GetTextFaceAlias, W, <NONE>,  'GetTextFaceAliasW',  \
    GetTextFace, W, <.hdc, .nCount, .lpFacename>,  'GetTextFaceW',  \
    GetTextMetrics, A, <.hdc, .lpMetrics>,  'GetTextMetricsA',  \
    GetTextMetrics, W, <.hdc, .lpMetrics>,  'GetTextMetricsW',  \
    GetTransform, N, <NONE>,  'GetTransform',  \
    GetViewportExtEx, N, <.hdc, .lpSize>,  'GetViewportExtEx',  \
    GetViewportOrgEx, N, <.hdc, .lpPoint>,  'GetViewportOrgEx',  \
    GetWinMetaFileBits, N, <.hemf, .cbBuffer, .lpbBuffer, .fnMapMode, .hdcRef>,  'GetWinMetaFileBits',  \
    GetWindowExtEx, N, <.hdc, .lpSize>,  'GetWindowExtEx',  \
    GetWindowOrgEx, N, <.hdc, .lpPoint>,  'GetWindowOrgEx',  \
    GetWorldTransform, N, <.hdc, .lpXform>,  'GetWorldTransform',  \
    HT_Get8BPPFormatPalette, N, <NONE>,  'HT_Get8BPPFormatPalette',  \
    HT_Get8BPPMaskPalette, N, <NONE>,  'HT_Get8BPPMaskPalette',  \
    IntersectClipRect, N, <.hdc, .X1, .Y1, .X2, .Y2>,  'IntersectClipRect',  \
    InvertRgn, N, <.hdc, .hRgn>,  'InvertRgn',  \
    IsValidEnhMetaRecord, N, <NONE>,  'IsValidEnhMetaRecord',  \
    IsValidEnhMetaRecordOffExt, N, <NONE>,  'IsValidEnhMetaRecordOffExt',  \
    LPtoDP, N, <.hdc, .lpPoint, .nCount>,  'LPtoDP',  \
    LineDD, A, <.ByValt, .pLineddaproc, .lparam>,  'LineDDA',  \
    LineTo, N, <.hdc, .x, .y>,  'LineTo',  \
    MaskBlt, N, <.hdcDest, .nXDest, .nYDest, .nWidth, .nHeight, .hdcSrc, .nXSrc, .nYSrc, .hbmMask, .xMask, .yMask, .dwRop>,  'MaskBlt',  \
    MirrorRgn, N, <NONE>,  'MirrorRgn',  \
    ModifyWorldTransform, N, <.hdc, .lpXform, .iMode>,  'ModifyWorldTransform',  \
    MoveToEx, N, <.hdc, .x, .y, .lpPoint>,  'MoveToEx',  \
    NamedEscape, N, <NONE>,  'NamedEscape',  \
    OffsetClipRgn, N, <.hdc, .x, .y>,  'OffsetClipRgn',  \
    OffsetRgn, N, <.hRgn, .x, .y>,  'OffsetRgn',  \
    OffsetViewportOrgEx, N, <.hdc, .nX, .nY, .lpPoint>,  'OffsetViewportOrgEx',  \
    OffsetWindowOrgEx, N, <.hdc, .nX, .nY, .lpPoint>,  'OffsetWindowOrgEx',  \
    PATHOBJ_bEnum, N, <NONE>,  'PATHOBJ_bEnum',  \
    PATHOBJ_bEnumClipLines, N, <NONE>,  'PATHOBJ_bEnumClipLines',  \
    PATHOBJ_vEnumStart, N, <NONE>,  'PATHOBJ_vEnumStart',  \
    PATHOBJ_vEnumStartClipLines, N, <NONE>,  'PATHOBJ_vEnumStartClipLines',  \
    PATHOBJ_vGetBounds, N, <NONE>,  'PATHOBJ_vGetBounds',  \
    PaintRgn, N, <.hdc, .hRgn>,  'PaintRgn',  \
    PatBlt, N, <.hdc, .x, .y, .nWidth, .nHeight, .dwRop>,  'PatBlt',  \
    PathToRegion, N, <.hdc>,  'PathToRegion',  \
    Pie, N, <.hdc, .X1, .Y1, .X2, .Y2, .X3, .Y3, .X4, .Y4>,  'Pie',  \
    PlayEnhMetaFile, N, <.hdc, .hemf, .lpRect>,  'PlayEnhMetaFile',  \
    PlayEnhMetaFileRecord, N, <.hdc, .lpHandletable, .lpEnhMetaRecord, .nHandles>,  'PlayEnhMetaFileRecord',  \
    PlayMetaFile, N, <.hdc, .hMF>,  'PlayMetaFile',  \
    PlayMetaFileRecord, N, <.hdc, .lpHandletable, .lpMetaRecord, .nHandles>,  'PlayMetaFileRecord',  \
    PlgBlt, N, <.hdcDest, .lpPoint, .hdcSrc, .nXSrc, .nYSrc, .nWidth, .nHeight, .hbmMask, .xMask, .yMask>,  'PlgBlt',  \
    PolyBezier, N, <.hdc, .lppt, .cPoints>,  'PolyBezier',  \
    PolyBezierTo, N, <.hdc, .lppt, .cCount>,  'PolyBezierTo',  \
    PolyDraw, N, <.hdc, .lppt, .lpbTypes, .cCount>,  'PolyDraw',  \
    PolyPatBlt, N, <NONE>,  'PolyPatBlt',  \
    PolyPolygon, N, <.hdc, .lpPoint, .lpPolyCounts, .nCount>,  'PolyPolygon',  \
    PolyPolyline, N, <.hdc, .lppt, .lpdwPolyPoints, .cCount>,  'PolyPolyline',  \
    PolyTextOut, A, <.hdc, .pptxt, .cStrings>,  'PolyTextOutA',  \
    PolyTextOut, W, <.hdc, .pptxt, .cStrings>,  'PolyTextOutW',  \
    Polygon, N, <.hdc, .lpPoint, .nCount>,  'Polygon',  \
    Polyline, N, <.hdc, .lpPoint, .nCount>,  'Polyline',  \
    PolylineTo, N, <.hdc, .lppt, .cCount>,  'PolylineTo',  \
    PtInRegion, N, <.hRgn, .x, .y>,  'PtInRegion',  \
    PtVisible, N, <.hdc, .x, .y>,  'PtVisible',  \
    QueryFontAssocStatus, N, <NONE>,  'QueryFontAssocStatus',  \
    RealizePalette, N, <.hdc>,  'RealizePalette',  \
    RectInRegion, N, <.hRgn, .lpRect>,  'RectInRegion',  \
    RectVisible, N, <.hdc, .lpRect>,  'RectVisible',  \
    Rectangle, N, <.hdc, .X1, .Y1, .X2, .Y2>,  'Rectangle',  \
    RemoveFontMemResourceEx, N, <.handle>,  'RemoveFontMemResourceEx',  \
    RemoveFontResource, A, <.lpFileName>,  'RemoveFontResourceA',  \
    RemoveFontResourceEx, A, <.lpcstr, .dword, .DESIGNVECTOR>,  'RemoveFontResourceExA',  \
    RemoveFontResourceEx, W, <.lpcstr, .dword, .DESIGNVECTOR>,  'RemoveFontResourceExW',  \
    RemoveFontResourceTracking, N, <NONE>,  'RemoveFontResourceTracking',  \
    RemoveFontResource, W, <.lpFileName>,  'RemoveFontResourceW',  \
    ResetDC, A, <.hdc, .lpInitData>,  'ResetDCA',  \
    ResetDC, W, <.hdc, .lpInitData>,  'ResetDCW',  \
    ResizePalette, N, <.hPalette, .nNumEntries>,  'ResizePalette',  \
    RestoreDC, N, <.hdc, .nSavedDC>,  'RestoreDC',  \
    RoundRect, N, <.hdc, .X1, .Y1, .X2, .Y2, .X3, .Y3>,  'RoundRect',  \
    STROBJ_bEnum, N, <NONE>,  'STROBJ_bEnum',  \
    STROBJ_bEnumPositionsOnly, N, <NONE>,  'STROBJ_bEnumPositionsOnly',  \
    STROBJ_bGetAdvanceWidths, N, <NONE>,  'STROBJ_bGetAdvanceWidths',  \
    STROBJ_dwGetCodePage, N, <NONE>,  'STROBJ_dwGetCodePage',  \
    STROBJ_vEnumStart, N, <NONE>,  'STROBJ_vEnumStart',  \
    SaveDC, N, <.hdc>,  'SaveDC',  \
    ScaleViewportExtEx, N, <.hdc, .nXnum, .nXdenom, .nYnum, .nYdenom, .lpSize>,  'ScaleViewportExtEx',  \
    ScaleWindowExtEx, N, <.hdc, .nXnum, .nXdenom, .nYnum, .nYdenom, .lpSize>,  'ScaleWindowExtEx',  \
    SelectBrushLocal, N, <NONE>,  'SelectBrushLocal',  \
    SelectClipPath, N, <.hdc, .iMode>,  'SelectClipPath',  \
    SelectClipRgn, N, <.hdc, .hRgn>,  'SelectClipRgn',  \
    SelectFontLocal, N, <NONE>,  'SelectFontLocal',  \
    SelectObject, N, <.hdc, .hObject>,  'SelectObject',  \
    SelectPalette, N, <.hdc, .hPalette, .bForceBackground>,  'SelectPalette',  \
    SetAbortProc, N, <.hDC, .lpAbortProc>,  'SetAbortProc',  \
    SetArcDirection, N, <.hdc, .ArcDirection>,  'SetArcDirection',  \
    SetBitmapAttributes, N, <NONE>,  'SetBitmapAttributes',  \
    SetBitmapBits, N, <.hBitmap, .dwCount, .lpBits>,  'SetBitmapBits',  \
    SetBitmapDimensionEx, N, <.hbm, .nX, .nY, .lpSize>,  'SetBitmapDimensionEx',  \
    SetBkColor, N, <.hdc, .crColor>,  'SetBkColor',  \
    SetBkMode, N, <.hdc, .nBkMode>,  'SetBkMode',  \
    SetBoundsRect, N, <.hdc, .lprcBounds, .flags>,  'SetBoundsRect',  \
    SetBrushAttributes, N, <NONE>,  'SetBrushAttributes',  \
    SetBrushOrgEx, N, <.hdc, .nXOrg, .nYOrg, .lppt>,  'SetBrushOrgEx',  \
    SetColorAdjustment, N, <.hdc, .lpca>,  'SetColorAdjustment',  \
    SetColorSpace, N, <.hdc, .hcolorspace>,  'SetColorSpace',  \
    SetDCBrushColor, N, <.hdc, .colorref>,  'SetDCBrushColor',  \
    SetDCPenColor, N, <.hdc, .colorref>,  'SetDCPenColor',  \
    SetDIBColorTable, N, <.hDC, .un1, .un2, .pcRGBQuad>,  'SetDIBColorTable',  \
    SetDIBits, N, <.hdc, .hBitmap, .nStartScan, .nNumScans, .lpBits, .lpBI, .wUsage>,  'SetDIBits',  \
    SetDIBitsToDevice, N, <.hdc, .x, .y, .dx, .dy, .SrcX, .SrcY, .Scan, .NumScans, .Bits, .BitsInfo, .wUsage>,  'SetDIBitsToDevice',  \
    SetDeviceGammaRamp, N, <.hdc, .lpv>,  'SetDeviceGammaRamp',  \
    SetEnhMetaFileBits, N, <.cbBuffer, .lpData>,  'SetEnhMetaFileBits',  \
    SetFontEnumeration, N, <NONE>,  'SetFontEnumeration',  \
    SetGraphicsMode, N, <.hdc, .iMode>,  'SetGraphicsMode',  \
    SetICMMode, N, <.hdc, .n>,  'SetICMMode',  \
    SetICMProfile, A, <.hdc, .lpStr>,  'SetICMProfileA',  \
    SetICMProfile, W, <.hdc, .lpStr>,  'SetICMProfileW',  \
    SetLayout, N, <.hdc, .dword>,  'SetLayout',  \
    SetLayoutWidth, N, <NONE>,  'SetLayoutWidth',  \
    SetMagicColors, N, <NONE>,  'SetMagicColors',  \
    SetMapMode, N, <.hdc, .nMapMode>,  'SetMapMode',  \
    SetMapperFlags, N, <.hdc, .dwFlag>,  'SetMapperFlags',  \
    SetMetaFileBitsEx, N, <.nSize, .lpData>,  'SetMetaFileBitsEx',  \
    SetMetaRgn, N, <.hdc>,  'SetMetaRgn',  \
    SetMiterLimit, N, <.hdc, .eNewLimit, .peOldLimit>,  'SetMiterLimit',  \
    SetPaletteEntries, N, <.hPalette, .wStartIndex, .wNumEntries, .lpPaletteEntries>,  'SetPaletteEntries',  \
    SetPixel, N, <.hdc, .x, .y, .crColor>,  'SetPixel',  \
    SetPixelFormat, N, <.hDC, .n, .pcPixelFormatDescriptor>,  'SetPixelFormat',  \
    SetPixelV, N, <.hdc, .x, .y, .crColor>,  'SetPixelV',  \
    SetPolyFillMode, N, <.hdc, .nPolyFillMode>,  'SetPolyFillMode',  \
    SetROP2, N, <.hdc, .nDrawMode>,  'SetROP2',  \
    SetRectRgn, N, <.hRgn, .X1, .Y1, .X2, .Y2>,  'SetRectRgn',  \
    SetRelAbs, N, <NONE>,  'SetRelAbs',  \
    SetStretchBltMode, N, <.hdc, .nStretchMode>,  'SetStretchBltMode',  \
    SetSystemPaletteUse, N, <.hdc, .wUsage>,  'SetSystemPaletteUse',  \
    SetTextAlign, N, <.hdc, .fMode>,  'SetTextAlign',  \
    SetTextCharacterExtra, N, <.hdc, .nCharExtra>,  'SetTextCharacterExtra',  \
    SetTextColor, N, <.hdc, .crColor>,  'SetTextColor',  \
    SetTextJustification, N, <.hdc, .nBreakExtra, .nBreakCount>,  'SetTextJustification',  \
    SetViewportExtEx, N, <.hdc, .nX, .nY, .lpSize>,  'SetViewportExtEx',  \
    SetViewportOrgEx, N, <.hdc, .nX, .nY, .lpPoint>,  'SetViewportOrgEx',  \
    SetVirtualResolution, N, <NONE>,  'SetVirtualResolution',  \
    SetWinMetaFileBits, N, <.cbBuffer, .lpbBuffer, .hdcRef, .lpmfp>,  'SetWinMetaFileBits',  \
    SetWindowExtEx, N, <.hdc, .nX, .nY, .lpSize>,  'SetWindowExtEx',  \
    SetWindowOrgEx, N, <.hdc, .nX, .nY, .lpPoint>,  'SetWindowOrgEx',  \
    SetWorldTransform, N, <.hdc, .lpXform>,  'SetWorldTransform',  \
    StartDoc, A, <.hdc, .lpdi>,  'StartDocA',  \
    StartDoc, W, <.hdc, .lpdi>,  'StartDocW',  \
    StartFormPage, N, <.hdc>,  'StartFormPage',  \
    StartPage, N, <.hdc>,  'StartPage',  \
    StretchBlt, N, <.hdc, .x, .y, .nWidth, .nHeight, .hSrcDC, .xSrc, .ySrc, .nSrcWidth, .nSrcHeight, .dwRop>,  'StretchBlt',  \
    StretchDIBits, N, <.hdc, .x, .y, .dx, .dy, .SrcX, .SrcY, .wSrcWidth, .wSrcHeight, .lpBits, .lpBitsInfo, .wUsage, .dwRop>,  'StretchDIBits',  \
    StrokeAndFillPath, N, <.hdc>,  'StrokeAndFillPath',  \
    StrokePath, N, <.hdc>,  'StrokePath',  \
    SwapBuffers, N, <.hDC>,  'SwapBuffers',  \
    TextOut, A, <.hdc, .x, .y, .lpString, .nCount>,  'TextOutA',  \
    TextOut, W, <.hdc, .x, .y, .lpString, .nCount>,  'TextOutW',  \
    TranslateCharsetInfo, N, <.lpSrc, .lpcs, .dwFlags>,  'TranslateCharsetInfo',  \
    UnloadNetworkFonts, N, <NONE>,  'UnloadNetworkFonts',  \
    UnrealizeObject, N, <.hObject>,  'UnrealizeObject',  \
    UpdateColors, N, <.hdc>,  'UpdateColors',  \
    UpdateICMRegKey, A, <.dword, .lpstr, .uint>,  'UpdateICMRegKeyA',  \
    UpdateICMRegKey, W, <.dword, .lpstr, .uint>,  'UpdateICMRegKeyW',  \
    WidenPath, N, <.hdc>,  'WidenPath',  \
    XFORMOBJ_bApplyXform, N, <NONE>,  'XFORMOBJ_bApplyXform',  \
    XFORMOBJ_iGetXform, N, <NONE>,  'XFORMOBJ_iGetXform',  \
    XLATEOBJ_cGetPalette, N, <NONE>,  'XLATEOBJ_cGetPalette',  \
    XLATEOBJ_hGetColorTransform, N, <NONE>,  'XLATEOBJ_hGetColorTransform',  \
    XLATEOBJ_iXlate, N, <NONE>,  'XLATEOBJ_iXlate',  \
    XLATEOBJ_piVector, N, <NONE>,  'XLATEOBJ_piVector',  \
    bInitSystemAndFontsDirectories, W, <NONE>,  'bInitSystemAndFontsDirectoriesW',  \
    bMakePathName, W, <NONE>,  'bMakePathNameW',  \
    cGetTTFFromFOT, N, <NONE>,  'cGetTTFFromFOT',  \
    gdiPlaySpoolStream, N, <NONE>,  'gdiPlaySpoolStream'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/imports/Win32/api/kernel32.inc.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: kernel32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto kernel32,  \
    ActivateActCtx, N, <NONE>,  'ActivateActCtx',  \
    AddAtom, A, <.lpString>,  'AddAtomA',  \
    AddAtom, W, <.lpString>,  'AddAtomW',  \
    AddConsoleAlias, A, <NONE>,  'AddConsoleAliasA',  \
    AddConsoleAlias, W, <NONE>,  'AddConsoleAliasW',  \
    AddLocalAlternateComputerName, A, <NONE>,  'AddLocalAlternateComputerNameA',  \
    AddLocalAlternateComputerName, W, <NONE>,  'AddLocalAlternateComputerNameW',  \
    AddRefActCtx, N, <NONE>,  'AddRefActCtx',  \
    AddVectoredExceptionHandler, N, <NONE>,  'AddVectoredExceptionHandler',  \
    AllocConsole, N, <VOID>,  'AllocConsole',  \
    AllocateUserPhysicalPages, N, <.hProcess, .NumberOfPages, .PageArray>,  'AllocateUserPhysicalPages',  \
    AreFileApisANSI, N, <VOID>,  'AreFileApisANSI',  \
    AssignProcessToJobObject, N, <.hJob, .hProcess>,  'AssignProcessToJobObject',  \
    AttachConsole, N, <NONE>,  'AttachConsole',  \
    BackupRead, N, <.hFile, .lpBuffer, .nNumberOfBytesToRead, .lpNumberOfBytesRead, .bAbort, .bProcessSecurity, .lpContext>,  'BackupRead',  \
    BackupSeek, N, <.hFile, .dwLowBytesToSeek, .dwHighBytesToSeek, .lpdwLowByteSeeked, .lpdwHighByteSeeked, .lpContext>,  'BackupSeek',  \
    BackupWrite, N, <.hFile, .lpBuffer, .nNumberOfBytesToWrite, .lpNumberOfBytesWritten, .bAbort, .bProcessSecurity, .lpContext>,  'BackupWrite',  \
    BaseCheckAppcompatCache, N, <NONE>,  'BaseCheckAppcompatCache',  \
    BaseCleanupAppcompatCache, N, <NONE>,  'BaseCleanupAppcompatCache',  \
    BaseCleanupAppcompatCacheSupport, N, <NONE>,  'BaseCleanupAppcompatCacheSupport',  \
    BaseDumpAppcompatCache, N, <NONE>,  'BaseDumpAppcompatCache',  \
    BaseFlushAppcompatCache, N, <NONE>,  'BaseFlushAppcompatCache',  \
    BaseInitAppcompatCache, N, <NONE>,  'BaseInitAppcompatCache',  \
    BaseInitAppcompatCacheSupport, N, <NONE>,  'BaseInitAppcompatCacheSupport',  \
    BaseProcessInitPostImport, N, <NONE>,  'BaseProcessInitPostImport',  \
    BaseQueryModuleData, N, <NONE>,  'BaseQueryModuleData',  \
    BaseUpdateAppcompatCache, N, <NONE>,  'BaseUpdateAppcompatCache',  \
    BasepCheckWinSaferRestrictions, N, <NONE>,  'BasepCheckWinSaferRestrictions',  \
    Beep, N, <.dwFreq, .dwDuration>,  'Beep',  \
    BeginUpdateResource, A, <.pFileName, .bDeleteExistingResources>,  'BeginUpdateResourceA',  \
    BeginUpdateResource, W, <.pFileName, .bDeleteExistingResources>,  'BeginUpdateResourceW',  \
    BindIoCompletionCallback, N, <.FileHandle, .lFunction, .Flags>,  'BindIoCompletionCallback',  \
    BuildCommDCB, A, <.lpDef, .lpDCB>,  'BuildCommDCBA',  \
    BuildCommDCBAndTimeouts, A, <.lpDef, .lpDCB, .lpCommTimeouts>,  'BuildCommDCBAndTimeoutsA',  \
    BuildCommDCBAndTimeouts, W, <.lpDef, .lpDCB, .lpCommTimeouts>,  'BuildCommDCBAndTimeoutsW',  \
    BuildCommDCB, W, <.lpDef, .lpDCB>,  'BuildCommDCBW',  \
    CallNamedPipe, A, <.lpNamedPipeName, .lpInBuffer, .nInBufferSize, .lpOutBuffer, .nOutBufferSize, .lpBytesRead, .nTimeOut>,  'CallNamedPipeA',  \
    CallNamedPipe, W, <.lpNamedPipeName, .lpInBuffer, .nInBufferSize, .lpOutBuffer, .nOutBufferSize, .lpBytesRead, .nTimeOut>,  'CallNamedPipeW',  \
    CancelDeviceWakeupRequest, N, <.hDevice>,  'CancelDeviceWakeupRequest',  \
    CancelIo, N, <.hFile>,  'CancelIo',  \
    CancelTimerQueueTimer, N, <.TimerQueue, .Timer>,  'CancelTimerQueueTimer',  \
    CancelWaitableTimer, N, <.hTimer>,  'CancelWaitableTimer',  \
    ChangeTimerQueueTimer, N, <.TimerQueue, .Timer, .DueTime, .Period>,  'ChangeTimerQueueTimer',  \
    CheckNameLegalDOS8Dot3, A, <NONE>,  'CheckNameLegalDOS8Dot3A',  \
    CheckNameLegalDOS8Dot3, W, <NONE>,  'CheckNameLegalDOS8Dot3W',  \
    CheckRemoteDebuggerPresent, N, <NONE>,  'CheckRemoteDebuggerPresent',  \
    ClearCommBreak, N, <.nCid>,  'ClearCommBreak',  \
    ClearCommError, N, <.hFile, .lpErrors, .lpStat>,  'ClearCommError',  \
    CloseConsoleHandle, N, <NONE>,  'CloseConsoleHandle',  \
    CloseHandle, N, <.hObject>,  'CloseHandle',  \
    CloseProfileUserMapping, N, <NONE>,  'CloseProfileUserMapping',  \
    CmdBatNotification, N, <NONE>,  'CmdBatNotification',  \
    CommConfigDialog, A, <.lpszName, .hWnd, .lpCC>,  'CommConfigDialogA',  \
    CommConfigDialog, W, <.lpszName, .hWnd, .lpCC>,  'CommConfigDialogW',  \
    CompareFileTime, N, <.lpFileTime1, .lpFileTime2>,  'CompareFileTime',  \
    CompareString, A, <.Locale, .dwCmpFlags, .lpString1, .cchCount1, .lpString2, .cchCount2>,  'CompareStringA',  \
    CompareString, W, <.Locale, .dwCmpFlags, .lpString1, .cchCount1, .lpString2, .cchCount2>,  'CompareStringW',  \
    ConnectNamedPipe, N, <.hNamedPipe, .lpOverlapped>,  'ConnectNamedPipe',  \
    ConsoleMenuControl, N, <NONE>,  'ConsoleMenuControl',  \
    ContinueDebugEvent, N, <.dwProcessId, .dwThreadId, .dwContinueStatus>,  'ContinueDebugEvent',  \
    ConvertDefaultLocale, N, <.Locale>,  'ConvertDefaultLocale',  \
    ConvertFiberToThread, N, <NONE>,  'ConvertFiberToThread',  \
    ConvertThreadToFiber, N, <.lpParameter>,  'ConvertThreadToFiber',  \
    CopyFile, A, <.lpExistingFileName, .lpNewFileName, .bFailIfExists>,  'CopyFileA',  \
    CopyFileEx, A, <.lpExistingFileName, .lpNewFileName, .lpProgressRoutine, .lpData, .pbCancel, .dwCopyFlags>,  'CopyFileExA',  \
    CopyFileEx, W, <.lpExistingFileName, .lpNewFileName, .lpProgressRoutine, .lpData, .pbCancel, .dwCopyFlags>,  'CopyFileExW',  \
    CopyFile, W, <.lpExistingFileName, .lpNewFileName, .bFailIfExists>,  'CopyFileW',  \
    CopyLZFile, N, <.n1, .n2>,  'CopyLZFile',  \
    CreateActCtx, A, <NONE>,  'CreateActCtxA',  \
    CreateActCtx, W, <NONE>,  'CreateActCtxW',  \
    CreateConsoleScreenBuffer, N, <.dwDesiredAccess, .dwShareMode, .lpSecurityAttributes, .dwFlags, .lpScreenBufferData>,  'CreateConsoleScreenBuffer',  \
    CreateDirectory, A, <.lpPathName, .lpSecurityAttributes>,  'CreateDirectoryA',  \
    CreateDirectoryEx, A, <.lpTemplateDirectory, .lpNewDirectory, .lpSecurityAttributes>,  'CreateDirectoryExA',  \
    CreateDirectoryEx, W, <.lpTemplateDirectory, .lpNewDirectory, .lpSecurityAttributes>,  'CreateDirectoryExW',  \
    CreateDirectory, W, <.lpPathName, .lpSecurityAttributes>,  'CreateDirectoryW',  \
    CreateEvent, A, <.lpEventAttributes, .bManualReset, .bInitialState, .lpName>,  'CreateEventA',  \
    CreateEvent, W, <.lpEventAttributes, .bManualReset, .bInitialState, .lpName>,  'CreateEventW',  \
    CreateFiber, N, <.dwStackSize, .lpStartAddress, .lpParameter>,  'CreateFiber',  \
    CreateFiberEx, N, <NONE>,  'CreateFiberEx',  \
    CreateFile, A, <.lpFileName, .dwDesiredAccess, .dwShareMode, .lpSecurityAttributes, .dwCreationDisposition, .dwFlagsAndAttributes, .hTemplateFile>,  'CreateFileA',  \
    CreateFileMapping, A, <.hFile, .lpFileMappigAttributes, .flProtect, .dwMaximumSizeHigh, .dwMaximumSizeLow, .lpName>,  'CreateFileMappingA',  \
    CreateFileMapping, W, <.hFile, .lpFileMappigAttributes, .flProtect, .dwMaximumSizeHigh, .dwMaximumSizeLow, .lpName>,  'CreateFileMappingW',  \
    CreateFile, W, <.lpFileName, .dwDesiredAccess, .dwShareMode, .lpSecurityAttributes, .dwCreationDisposition, .dwFlagsAndAttributes, .hTemplateFile>,  'CreateFileW',  \
    CreateHardLink, A, <.lpFileName, .lpExistingFileName, .lpSecurityAttributes>,  'CreateHardLinkA',  \
    CreateHardLink, W, <.lpFileName, .lpExistingFileName, .lpSecurityAttributes>,  'CreateHardLinkW',  \
    CreateIoCompletionPort, N, <.FileHandle, .ExistingCompletionPort, .CompletionKey, .NumberOfConcurrentThreads>,  'CreateIoCompletionPort',  \
    CreateJobObject, A, <.lpJobAttributes, .lpName>,  'CreateJobObjectA',  \
    CreateJobObject, W, <.lpJobAttributes, .lpName>,  'CreateJobObjectW',  \
    CreateJobSet, N, <NONE>,  'CreateJobSet',  \
    CreateMailslot, A, <.lpName, .nMaxMessageSize, .lReadTimeout, .lpSecurityAttributes>,  'CreateMailslotA',  \
    CreateMailslot, W, <.lpName, .nMaxMessageSize, .lReadTimeout, .lpSecurityAttributes>,  'CreateMailslotW',  \
    CreateMemoryResourceNotification, N, <NONE>,  'CreateMemoryResourceNotification',  \
    CreateMutex, A, <.lpMutexAttributes, .bInitialOwner, .lpName>,  'CreateMutexA',  \
    CreateMutex, W, <.lpMutexAttributes, .bInitialOwner, .lpName>,  'CreateMutexW',  \
    CreateNamedPipe, A, <.lpName, .dwOpenMode, .dwPipeMode, .nMaxInstances, .nOutBufferSize, .nInBufferSize, .nDefaultTimeOut, .lpSecurityAttributes>,  'CreateNamedPipeA',  \
    CreateNamedPipe, W, <.lpName, .dwOpenMode, .dwPipeMode, .nMaxInstances, .nOutBufferSize, .nInBufferSize, .nDefaultTimeOut, .lpSecurityAttributes>,  'CreateNamedPipeW',  \
    CreateNlsSecurityDescriptor, N, <NONE>,  'CreateNlsSecurityDescriptor',  \
    CreatePipe, N, <.phReadPipe, .phWritePipe, .lpPipeAttributes, .nSize>,  'CreatePipe',  \
    CreateProcess, A, <.lpApplicationName, .lpCommandLine, .lpProcessAttributes, .lpThreadAttributes, .bInheritHandles, .dwCreationFlags, .lpEnvironment, .lpCurrentDriectory, .lpStartupInfo, .lpProcessInformation>,  'CreateProcessA',  \
    CreateProcessInternal, A, <NONE>,  'CreateProcessInternalA',  \
    CreateProcessInternal, W, <NONE>,  'CreateProcessInternalW',  \
    CreateProcessInternalWSecure, N, <NONE>,  'CreateProcessInternalWSecure',  \
    CreateProcess, W, <.lpApplicationName, .lpCommandLine, .lpProcessAttributes, .lpThreadAttributes, .bInheritHandles, .dwCreationFlags, .lpEnvironment, .lpCurrentDriectory, .lpStartupInfo, .lpProcessInformation>,  'CreateProcessW',  \
    CreateRemoteThread, N, <.hProcess, .lpThreadAttributes, .dwStackSize, .lpStartAddress, .lpParameter, .dwCreationFlags, .lpThreadId>,  'CreateRemoteThread',  \
    CreateSemaphore, A, <.lpSemaphoreAttributes, .lInitialCount, .lMaximumCount, .lpName>,  'CreateSemaphoreA',  \
    CreateSemaphore, W, <.lpSemaphoreAttributes, .lInitialCount, .lMaximumCount, .lpName>,  'CreateSemaphoreW',  \
    CreateSocketHandle, N, <NONE>,  'CreateSocketHandle',  \
    CreateTapePartition, N, <.hDevice, .dwPartitionMethod, .dwCount, .dwSize>,  'CreateTapePartition',  \
    CreateThread, N, <.lpThreadAttributes, .dwStackSize, .lpStartAddress, .lpParameter, .dwCreationFlags, .lpThreadId>,  'CreateThread',  \
    CreateTimerQueue, N, <VOID>,  'CreateTimerQueue',  \
    CreateTimerQueueTimer, N, <NONE>,  'CreateTimerQueueTimer',  \
    CreateToolhelp32Snapshot, N, <.dwFlags, .th32ProcessID>,  'CreateToolhelp32Snapshot',  \
    CreateVirtualBuffer, N, <NONE>,  'CreateVirtualBuffer',  \
    CreateWaitableTimer, A, <.lpTimerAttributes, .bManualReset, .lpTimerName>,  'CreateWaitableTimerA',  \
    CreateWaitableTimer, W, <.lpTimerAttributes, .bManualReset, .lpTimerName>,  'CreateWaitableTimerW',  \
    DeactivateActCtx, N, <NONE>,  'DeactivateActCtx',  \
    DebugActiveProcess, N, <.dwProcessId>,  'DebugActiveProcess',  \
    DebugActiveProcessStop, N, <NONE>,  'DebugActiveProcessStop',  \
    DebugBreak, N, <VOID>,  'DebugBreak',  \
    DebugBreakProcess, N, <NONE>,  'DebugBreakProcess',  \
    DebugSetProcessKillOnExit, N, <NONE>,  'DebugSetProcessKillOnExit',  \
    DecodePointer, N, <NONE>,  'DecodePointer',  \
    DecodeSystemPointer, N, <NONE>,  'DecodeSystemPointer',  \
    DefineDosDevice, A, <.dwFlags, .lpDeviceName, .lpTargetPath>,  'DefineDosDeviceA',  \
    DefineDosDevice, W, <.dwFlags, .lpDeviceName, .lpTargetPath>,  'DefineDosDeviceW',  \
    DelayLoadFailureHook, N, <NONE>,  'DelayLoadFailureHook',  \
    DeleteAtom, N, <.nAtom>,  'DeleteAtom',  \
    DeleteCriticalSection, N, <.lpCriticalSection>,  'DeleteCriticalSection',  \
    DeleteFiber, N, <.lpFiber>,  'DeleteFiber',  \
    DeleteFile, A, <.lpFileName>,  'DeleteFileA',  \
    DeleteFile, W, <.lpFileName>,  'DeleteFileW',  \
    DeleteTimerQueue, N, <.TimerQueue>,  'DeleteTimerQueue',  \
    DeleteTimerQueueEx, N, <.TimerQueue, .CompletionEvent>,  'DeleteTimerQueueEx',  \
    DeleteTimerQueueTimer, N, <.TimerQueue, .Timer, .CompletionEvent>,  'DeleteTimerQueueTimer',  \
    DeleteVolumeMountPoint, A, <.lpszVolumeMountPoint>,  'DeleteVolumeMountPointA',  \
    DeleteVolumeMountPoint, W, <.lpszVolumeMountPoint>,  'DeleteVolumeMountPointW',  \
    DeviceIoControl, N, <.hDevice, .dwIoControlCode, .lpInBuffer, .nInBufferSize, .lpOutBuffer, .nOutBufferSize, .lpBytesReturned, .lpOverlapped>,  'DeviceIoControl',  \
    DisableThreadLibraryCalls, N, <.hLibModule>,  'DisableThreadLibraryCalls',  \
    DisconnectNamedPipe, N, <.hNamedPipe>,  'DisconnectNamedPipe',  \
    DnsHostnameToComputerName, A, <.Hostname, .ComputerName, .nSize>,  'DnsHostnameToComputerNameA',  \
    DnsHostnameToComputerName, W, <.Hostname, .ComputerName, .nSize>,  'DnsHostnameToComputerNameW',  \
    DosDateTimeToFileTime, N, <.wFatDate, .wFatTime, .lpFileTime>,  'DosDateTimeToFileTime',  \
    DosPathToSessionPath, A, <.SessionId, .pInPath, .ppOutPath>,  'DosPathToSessionPathA',  \
    DosPathToSessionPath, W, <.SessionId, .pInPath, .ppOutPath>,  'DosPathToSessionPathW',  \
    DuplicateConsoleHandle, N, <NONE>,  'DuplicateConsoleHandle',  \
    DuplicateHandle, N, <.hSourceProcessHandle, .hSourceHandle, .hTargetProcessHandle, .lpTargetHandle, .dwDesiredAccess, .bInheritHandle, .dwOptions>,  'DuplicateHandle',  \
    EncodePointer, N, <NONE>,  'EncodePointer',  \
    EncodeSystemPointer, N, <NONE>,  'EncodeSystemPointer',  \
    EndUpdateResource, A, <.hUpdate, .fDiscard>,  'EndUpdateResourceA',  \
    EndUpdateResource, W, <.hUpdate, .fDiscard>,  'EndUpdateResourceW',  \
    EnterCriticalSection, N, <.lpCriticalSection>,  'EnterCriticalSection',  \
    EnumCalendarInfo, A, <.lpCalInfoEnumProc, .Locale, .Calendar, .CalType>,  'EnumCalendarInfoA',  \
    EnumCalendarInfoEx, A, <.lpCalInfoEnumProcEx, .Locale, .Calendar, .CalType>,  'EnumCalendarInfoExA',  \
    EnumCalendarInfoEx, W, <.lpCalInfoEnumProcEx, .Locale, .Calendar, .CalType>,  'EnumCalendarInfoExW',  \
    EnumCalendarInfo, W, <.lpCalInfoEnumProc, .Locale, .Calendar, .CalType>,  'EnumCalendarInfoW',  \
    EnumDateFormats, A, <.lpDateFmtEnumProc, .Locale, .dwFlags>,  'EnumDateFormatsA',  \
    EnumDateFormatsEx, A, <.lpDateFmtEnumProcEx, .Locale, .dwFlags>,  'EnumDateFormatsExA',  \
    EnumDateFormatsEx, W, <.lpDateFmtEnumProcEx, .Locale, .dwFlags>,  'EnumDateFormatsExW',  \
    EnumDateFormats, W, <.lpDateFmtEnumProc, .Locale, .dwFlags>,  'EnumDateFormatsW',  \
    EnumLanguageGroupLocales, A, <.lpLangGroupLocaleEnumProc, .LanguageGroup, .dwFlags, .lParam>,  'EnumLanguageGroupLocalesA',  \
    EnumLanguageGroupLocales, W, <.lpLangGroupLocaleEnumProc, .LanguageGroup, .dwFlags, .lParam>,  'EnumLanguageGroupLocalesW',  \
    EnumResourceLanguages, A, <.hModule, .lpType, .lpName, .lpEnumFunc, .lParam>,  'EnumResourceLanguagesA',  \
    EnumResourceLanguages, W, <.hModule, .lpType, .lpName, .lpEnumFunc, .lParam>,  'EnumResourceLanguagesW',  \
    EnumResourceNames, A, <.hModule, .lpType, .lpEnumFunc, .lParam>,  'EnumResourceNamesA',  \
    EnumResourceNames, W, <.hModule, .lpType, .lpEnumFunc, .lParam>,  'EnumResourceNamesW',  \
    EnumResourceTypes, A, <.hModule, .lpEnumFunc, .lParam>,  'EnumResourceTypesA',  \
    EnumResourceTypes, W, <.hModule, .lpEnumFunc, .lParam>,  'EnumResourceTypesW',  \
    EnumSystemCodePages, A, <.lpCodePageEnumProc, .dwFlags>,  'EnumSystemCodePagesA',  \
    EnumSystemCodePages, W, <.lpCodePageEnumProc, .dwFlags>,  'EnumSystemCodePagesW',  \
    EnumSystemGeoID, N, <NONE>,  'EnumSystemGeoID',  \
    EnumSystemLanguageGroups, A, <.lpLanguageGroupEnumProc, .dwFlags, .lParam>,  'EnumSystemLanguageGroupsA',  \
    EnumSystemLanguageGroups, W, <.lpLanguageGroupEnumProc, .dwFlags, .lParam>,  'EnumSystemLanguageGroupsW',  \
    EnumSystemLocales, A, <.lpLocaleEnumProc, .dwFlags>,  'EnumSystemLocalesA',  \
    EnumSystemLocales, W, <.lpLocaleEnumProc, .dwFlags>,  'EnumSystemLocalesW',  \
    EnumTimeFormats, A, <.lpTimeFmtEnumProc, .Locale, .dwFlags>,  'EnumTimeFormatsA',  \
    EnumTimeFormats, W, <.lpTimeFmtEnumProc, .Locale, .dwFlags>,  'EnumTimeFormatsW',  \
    EnumUILanguages, A, <.lpUILanguageEnumProc, .dwFlags, .lParam>,  'EnumUILanguagesA',  \
    EnumUILanguages, W, <.lpUILanguageEnumProc, .dwFlags, .lParam>,  'EnumUILanguagesW',  \
    EnumerateLocalComputerNames, A, <NONE>,  'EnumerateLocalComputerNamesA',  \
    EnumerateLocalComputerNames, W, <NONE>,  'EnumerateLocalComputerNamesW',  \
    EraseTape, N, <.hDevice, .dwEraseType, .bimmediate>,  'EraseTape',  \
    EscapeCommFunction, N, <.nCid, .nFunc>,  'EscapeCommFunction',  \
    ExitProcess, N, <.uExitCode>,  'ExitProcess',  \
    ExitThread, N, <.dwExitCode>,  'ExitThread',  \
    ExitVDM, N, <NONE>,  'ExitVDM',  \
    ExpandEnvironmentStrings, A, <.lpSrc, .lpDst, .nSize>,  'ExpandEnvironmentStringsA',  \
    ExpandEnvironmentStrings, W, <.lpSrc, .lpDst, .nSize>,  'ExpandEnvironmentStringsW',  \
    ExpungeConsoleCommandHistory, A, <NONE>,  'ExpungeConsoleCommandHistoryA',  \
    ExpungeConsoleCommandHistory, W, <NONE>,  'ExpungeConsoleCommandHistoryW',  \
    ExtendVirtualBuffer, N, <NONE>,  'ExtendVirtualBuffer',  \
    FatalAppExit, A, <.uAction, .lpMessageText>,  'FatalAppExitA',  \
    FatalAppExit, W, <.uAction, .lpMessageText>,  'FatalAppExitW',  \
    FatalExit, N, <.code>,  'FatalExit',  \
    FileTimeToDosDateTime, N, <.lpFileTime, .lpFatDate, .lpFatTime>,  'FileTimeToDosDateTime',  \
    FileTimeToLocalFileTime, N, <.lpFileTime, .lpLocalFileTime>,  'FileTimeToLocalFileTime',  \
    FileTimeToSystemTime, N, <.lpFileTime, .lpSystemTime>,  'FileTimeToSystemTime',  \
    FillConsoleOutputAttribute, N, <.hConsoleOutput, .wAttribute, .nLength, .dwWriteCoord, .lpNumberOfAttrsWritten>,  'FillConsoleOutputAttribute',  \
    FillConsoleOutputCharacter, A, <.hConsoleOutput, .cCharacter, .nLength, .dwWriteCoord, .lpNumberOfCharsWritten>,  'FillConsoleOutputCharacterA',  \
    FillConsoleOutputCharacter, W, <.hConsoleOutput, .cCharacter, .nLength, .dwWriteCoord, .lpNumberOfCharsWritten>,  'FillConsoleOutputCharacterW',  \
    FindActCtxSectionGuid, N, <NONE>,  'FindActCtxSectionGuid',  \
    FindActCtxSectionString, A, <NONE>,  'FindActCtxSectionStringA',  \
    FindActCtxSectionString, W, <NONE>,  'FindActCtxSectionStringW',  \
    FindAtom, A, <.lpString>,  'FindAtomA',  \
    FindAtom, W, <.lpString>,  'FindAtomW',  \
    FindClose, N, <.hFindFile>,  'FindClose',  \
    FindCloseChangeNotification, N, <.hChangeHandle>,  'FindCloseChangeNotification',  \
    FindFirstChangeNotification, A, <.lpPathName, .bWatchSubtree, .dwNotifyFilter>,  'FindFirstChangeNotificationA',  \
    FindFirstChangeNotification, W, <.lpPathName, .bWatchSubtree, .dwNotifyFilter>,  'FindFirstChangeNotificationW',  \
    FindFirstFile, A, <.lpFileName, .lpFindFileData>,  'FindFirstFileA',  \
    FindFirstFileEx, A, <.lpFileName, .fInfoLevelId, .lpFindFileData, .fSearchOp, .lpSearchFilter, .dwAdditionalFlags>,  'FindFirstFileExA',  \
    FindFirstFileEx, W, <.lpFileName, .fInfoLevelId, .lpFindFileData, .fSearchOp, .lpSearchFilter, .dwAdditionalFlags>,  'FindFirstFileExW',  \
    FindFirstFile, W, <.lpFileName, .lpFindFileData>,  'FindFirstFileW',  \
    FindFirstVolume, A, <.lpszVolumeName, .cchBufferLength>,  'FindFirstVolumeA',  \
    FindFirstVolumeMountPoint, A, <.lpszRootPathName, .lpszVolumeMountPoint, .cchBufferLength>,  'FindFirstVolumeMountPointA',  \
    FindFirstVolumeMountPoint, W, <.lpszRootPathName, .lpszVolumeMountPoint, .cchBufferLength>,  'FindFirstVolumeMountPointW',  \
    FindFirstVolume, W, <.lpszVolumeName, .cchBufferLength>,  'FindFirstVolumeW',  \
    FindNextChangeNotification, N, <.hChangeHandle>,  'FindNextChangeNotification',  \
    FindNextFile, A, <.hFindFile, .lpFindFileData>,  'FindNextFileA',  \
    FindNextFile, W, <.hFindFile, .lpFindFileData>,  'FindNextFileW',  \
    FindNextVolume, A, <.hFindVolume, .lpszVolumeName, .cchBufferLength>,  'FindNextVolumeA',  \
    FindNextVolumeMountPoint, A, <.hFindVolumeMountPoint, .lpszVolumeMountPoint, .cchBufferLength>,  'FindNextVolumeMountPointA',  \
    FindNextVolumeMountPoint, W, <.hFindVolumeMountPoint, .lpszVolumeMountPoint, .cchBufferLength>,  'FindNextVolumeMountPointW',  \
    FindNextVolume, W, <.hFindVolume, .lpszVolumeName, .cchBufferLength>,  'FindNextVolumeW',  \
    FindResource, A, <.hInstance, .lpName, .lpType>,  'FindResourceA',  \
    FindResourceEx, A, <.hModule, .lpType, .lpName, .wLanguage>,  'FindResourceExA',  \
    FindResourceEx, W, <.hModule, .lpType, .lpName, .wLanguage>,  'FindResourceExW',  \
    FindResource, W, <.hInstance, .lpName, .lpType>,  'FindResourceW',  \
    FindVolumeClose, N, <.hFindVolume>,  'FindVolumeClose',  \
    FindVolumeMountPointClose, N, <.hFindVolumeMountPoint>,  'FindVolumeMountPointClose',  \
    FlushConsoleInputBuffer, N, <.hConsoleInput>,  'FlushConsoleInputBuffer',  \
    FlushFileBuffers, N, <.hFile>,  'FlushFileBuffers',  \
    FlushInstructionCache, N, <.hProcess, .lpBaseAddress, .dwSize>,  'FlushInstructionCache',  \
    FlushViewOfFile, N, <.lpBaseAddress, .dwNumberOfBytesToFlush>,  'FlushViewOfFile',  \
    FoldString, A, <.dwMapFlags, .lpSrcStr, .cchSrc, .lpDestStr, .cchDest>,  'FoldStringA',  \
    FoldString, W, <.dwMapFlags, .lpSrcStr, .cchSrc, .lpDestStr, .cchDest>,  'FoldStringW',  \
    FormatMessage, A, <.dwFlags, .lpSource, .dwMessageId, .dwLanguageId, .lpBuffer, .nSize, .Arguments>,  'FormatMessageA',  \
    FormatMessage, W, <.dwFlags, .lpSource, .dwMessageId, .dwLanguageId, .lpBuffer, .nSize, .Arguments>,  'FormatMessageW',  \
    FreeConsole, N, <VOID>,  'FreeConsole',  \
    FreeEnvironmentStrings, A, <.lpsz>,  'FreeEnvironmentStringsA',  \
    FreeEnvironmentStrings, W, <.lpsz>,  'FreeEnvironmentStringsW',  \
    FreeLibrary, N, <.hLibModule>,  'FreeLibrary',  \
    FreeLibraryAndExitThread, N, <.hLibModule, .dwExitCode>,  'FreeLibraryAndExitThread',  \
    FreeResource, N, <.hResData>,  'FreeResource',  \
    FreeUserPhysicalPages, N, <.hProcess, .NumberOfPages, .PageArray>,  'FreeUserPhysicalPages',  \
    FreeVirtualBuffer, N, <NONE>,  'FreeVirtualBuffer',  \
    GenerateConsoleCtrlEvent, N, <.dwCtrlEvent, .dwProcessGroupId>,  'GenerateConsoleCtrlEvent',  \
    GetACP, N, <VOID>,  'GetACP',  \
    GetAtomName, A, <.nAtom, .lpBuffer, .nSize>,  'GetAtomNameA',  \
    GetAtomName, W, <.nAtom, .lpBuffer, .nSize>,  'GetAtomNameW',  \
    GetBinaryType, A, <.lpApplicationName, .lpBinaryType>,  'GetBinaryTypeA',  \
    GetBinaryType, W, <.lpApplicationName, .lpBinaryType>,  'GetBinaryTypeW',  \
    GetCPFileNameFromRegistry, N, <NONE>,  'GetCPFileNameFromRegistry',  \
    GetCPInfo, N, <.CodePage, .lpCPInfo>,  'GetCPInfo',  \
    GetCPInfoEx, A, <.CodePage, .dwFlags, .lpCPInfoEx>,  'GetCPInfoExA',  \
    GetCPInfoEx, W, <.CodePage, .dwFlags, .lpCPInfoEx>,  'GetCPInfoExW',  \
    GetCalendarInfo, A, <.Locale, .Calendar, .CalType, .lpCalData, .cchData, .lpValue>,  'GetCalendarInfoA',  \
    GetCalendarInfo, W, <.Locale, .Calendar, .CalType, .lpCalData, .cchData, .lpValue>,  'GetCalendarInfoW',  \
    GetComPlusPackageInstallStatus, N, <NONE>,  'GetComPlusPackageInstallStatus',  \
    GetCommConfig, N, <.hCommDev, .lpCC, .lpdwSize>,  'GetCommConfig',  \
    GetCommMask, N, <.hFile, .lpEvtMask>,  'GetCommMask',  \
    GetCommModemStatus, N, <.hFile, .lpModemStat>,  'GetCommModemStatus',  \
    GetCommProperties, N, <.hFile, .lpCommProp>,  'GetCommProperties',  \
    GetCommState, N, <.nCid, .lpDCB>,  'GetCommState',  \
    GetCommTimeouts, N, <.hFile, .lpCommTimeouts>,  'GetCommTimeouts',  \
    GetCommandLine, A, <VOID>,  'GetCommandLineA',  \
    GetCommandLine, W, <VOID>,  'GetCommandLineW',  \
    GetCompressedFileSize, A, <.lpFileName, .lpFileSizeHigh>,  'GetCompressedFileSizeA',  \
    GetCompressedFileSize, W, <.lpFileName, .lpFileSizeHigh>,  'GetCompressedFileSizeW',  \
    GetComputerName, A, <.lpBuffer, .nSize>,  'GetComputerNameA',  \
    GetComputerNameEx, A, <.NameType, .lpBuffer, .nSize>,  'GetComputerNameExA',  \
    GetComputerNameEx, W, <.NameType, .lpBuffer, .nSize>,  'GetComputerNameExW',  \
    GetComputerName, W, <.lpBuffer, .nSize>,  'GetComputerNameW',  \
    GetConsoleAlias, A, <NONE>,  'GetConsoleAliasA',  \
    GetConsoleAliasExes, A, <NONE>,  'GetConsoleAliasExesA',  \
    GetConsoleAliasExesLength, A, <NONE>,  'GetConsoleAliasExesLengthA',  \
    GetConsoleAliasExesLength, W, <NONE>,  'GetConsoleAliasExesLengthW',  \
    GetConsoleAliasExes, W, <NONE>,  'GetConsoleAliasExesW',  \
    GetConsoleAlias, W, <NONE>,  'GetConsoleAliasW',  \
    GetConsoleAliases, A, <NONE>,  'GetConsoleAliasesA',  \
    GetConsoleAliasesLength, A, <NONE>,  'GetConsoleAliasesLengthA',  \
    GetConsoleAliasesLength, W, <NONE>,  'GetConsoleAliasesLengthW',  \
    GetConsoleAliases, W, <NONE>,  'GetConsoleAliasesW',  \
    GetConsoleCP, N, <VOID>,  'GetConsoleCP',  \
    GetConsoleCharType, N, <NONE>,  'GetConsoleCharType',  \
    GetConsoleCommandHistory, A, <NONE>,  'GetConsoleCommandHistoryA',  \
    GetConsoleCommandHistoryLength, A, <NONE>,  'GetConsoleCommandHistoryLengthA',  \
    GetConsoleCommandHistoryLength, W, <NONE>,  'GetConsoleCommandHistoryLengthW',  \
    GetConsoleCommandHistory, W, <NONE>,  'GetConsoleCommandHistoryW',  \
    GetConsoleCursorInfo, N, <.hConsoleOutput, .lpConsoleCursorInfo>,  'GetConsoleCursorInfo',  \
    GetConsoleCursorMode, N, <NONE>,  'GetConsoleCursorMode',  \
    GetConsoleDisplayMode, N, <NONE>,  'GetConsoleDisplayMode',  \
    GetConsoleFontInfo, N, <NONE>,  'GetConsoleFontInfo',  \
    GetConsoleFontSize, N, <NONE>,  'GetConsoleFontSize',  \
    GetConsoleHardwareState, N, <NONE>,  'GetConsoleHardwareState',  \
    GetConsoleInputExeName, A, <NONE>,  'GetConsoleInputExeNameA',  \
    GetConsoleInputExeName, W, <NONE>,  'GetConsoleInputExeNameW',  \
    GetConsoleInputWaitHandle, N, <NONE>,  'GetConsoleInputWaitHandle',  \
    GetConsoleKeyboardLayoutName, A, <NONE>,  'GetConsoleKeyboardLayoutNameA',  \
    GetConsoleKeyboardLayoutName, W, <NONE>,  'GetConsoleKeyboardLayoutNameW',  \
    GetConsoleMode, N, <.hConsoleHandle, .lpMode>,  'GetConsoleMode',  \
    GetConsoleNlsMode, N, <NONE>,  'GetConsoleNlsMode',  \
    GetConsoleOutputCP, N, <VOID>,  'GetConsoleOutputCP',  \
    GetConsoleProcessList, N, <NONE>,  'GetConsoleProcessList',  \
    GetConsoleScreenBufferInfo, N, <.hConsoleOutput, .lpConsoleScreenBufferInfo>,  'GetConsoleScreenBufferInfo',  \
    GetConsoleSelectionInfo, N, <NONE>,  'GetConsoleSelectionInfo',  \
    GetConsoleTitle, A, <.lpConsoleTitle, .nSize>,  'GetConsoleTitleA',  \
    GetConsoleTitle, W, <.lpConsoleTitle, .nSize>,  'GetConsoleTitleW',  \
    GetConsoleWindow, N, <NONE>,  'GetConsoleWindow',  \
    GetCurrencyFormat, A, <.Locale, .dwFlags, .lpValue, .lpFormat, .lpCurrencyStr, .cchCurrency>,  'GetCurrencyFormatA',  \
    GetCurrencyFormat, W, <.Locale, .dwFlags, .lpValue, .lpFormat, .lpCurrencyStr, .cchCurrency>,  'GetCurrencyFormatW',  \
    GetCurrentActCtx, N, <NONE>,  'GetCurrentActCtx',  \
    GetCurrentConsoleFont, N, <NONE>,  'GetCurrentConsoleFont',  \
    GetCurrentDirectory, A, <.nBufferLength, .lpBuffer>,  'GetCurrentDirectoryA',  \
    GetCurrentDirectory, W, <.nBufferLength, .lpBuffer>,  'GetCurrentDirectoryW',  \
    GetCurrentProcess, N, <VOID>,  'GetCurrentProcess',  \
    GetCurrentProcessId, N, <VOID>,  'GetCurrentProcessId',  \
    GetCurrentThread, N, <VOID>,  'GetCurrentThread',  \
    GetCurrentThreadId, N, <VOID>,  'GetCurrentThreadId',  \
    GetDateFormat, A, <.Locale, .dwFlags, .lpDate, .lpFormat, .lpDateStr, .cchDate>,  'GetDateFormatA',  \
    GetDateFormat, W, <.Locale, .dwFlags, .lpDate, .lpFormat, .lpDateStr, .cchDate>,  'GetDateFormatW',  \
    GetDefaultCommConfig, A, <.lpszName, .lpCC, .lpdwSize>,  'GetDefaultCommConfigA',  \
    GetDefaultCommConfig, W, <.lpszName, .lpCC, .lpdwSize>,  'GetDefaultCommConfigW',  \
    GetDefaultSortkeySize, N, <NONE>,  'GetDefaultSortkeySize',  \
    GetDevicePowerState, N, <.hDevice, .pfOn>,  'GetDevicePowerState',  \
    GetDiskFreeSpace, A, <.lpRootPathName, .lpSectorsPerCluster, .lpBytesPerSector, .lpNumberOfFreeClusters, .lpTotalNumberOfClusters>,  'GetDiskFreeSpaceA',  \
    GetDiskFreeSpaceEx, A, <.lpDirectoryName, .lpFreeBytesAvailableToCaller, .lpTotalNumberOfBytes, .lpTotalNumberOfFreeBytes>,  'GetDiskFreeSpaceExA',  \
    GetDiskFreeSpaceEx, W, <.lpDirectoryName, .lpFreeBytesAvailableToCaller, .lpTotalNumberOfBytes, .lpTotalNumberOfFreeBytes>,  'GetDiskFreeSpaceExW',  \
    GetDiskFreeSpace, W, <.lpRootPathName, .lpSectorsPerCluster, .lpBytesPerSector, .lpNumberOfFreeClusters, .lpTotalNumberOfClusters>,  'GetDiskFreeSpaceW',  \
    GetDllDirectory, A, <NONE>,  'GetDllDirectoryA',  \
    GetDllDirectory, W, <NONE>,  'GetDllDirectoryW',  \
    GetDriveType, A, <.nDrive>,  'GetDriveTypeA',  \
    GetDriveType, W, <.nDrive>,  'GetDriveTypeW',  \
    GetEnvironmentStrings, A, <VOID>,  'GetEnvironmentStringsA',  \
    GetEnvironmentStrings, W, <VOID>,  'GetEnvironmentStringsW',  \
    GetEnvironmentVariable, A, <.lpName, .lpBuffer, .nSize>,  'GetEnvironmentVariableA',  \
    GetEnvironmentVariable, W, <.lpName, .lpBuffer, .nSize>,  'GetEnvironmentVariableW',  \
    GetExitCodeProcess, N, <.hProcess, .lpExitCode>,  'GetExitCodeProcess',  \
    GetExitCodeThread, N, <.hThread, .lpExitCode>,  'GetExitCodeThread',  \
    GetExpandedName, A, <.lpszSource, .lpszBuffer>,  'GetExpandedNameA',  \
    GetExpandedName, W, <.lpszSource, .lpszBuffer>,  'GetExpandedNameW',  \
    GetFileAttributes, A, <.lpFileName>,  'GetFileAttributesA',  \
    GetFileAttributesEx, A, <.lpFileName, .fInfoLevelId, .lpFileInformation>,  'GetFileAttributesExA',  \
    GetFileAttributesEx, W, <.lpFileName, .fInfoLevelId, .lpFileInformation>,  'GetFileAttributesExW',  \
    GetFileAttributes, W, <.lpFileName>,  'GetFileAttributesW',  \
    GetFileInformationByHandle, N, <.hFile, .lpFileInformation>,  'GetFileInformationByHandle',  \
    GetFileSize, N, <.hFile, .lpFileSizeHigh>,  'GetFileSize',  \
    GetFileSizeEx, N, <.hFile, .lpFileSize>,  'GetFileSizeEx',  \
    GetFileTime, N, <.hFile, .lpCreationTime, .lpLastAccessTime, .lpLastWriteTime>,  'GetFileTime',  \
    GetFileType, N, <.hFile>,  'GetFileType',  \
    GetFirmwareEnvironmentVariable, A, <NONE>,  'GetFirmwareEnvironmentVariableA',  \
    GetFirmwareEnvironmentVariable, W, <NONE>,  'GetFirmwareEnvironmentVariableW',  \
    GetFullPathName, A, <.lpFileName, .nBufferLength, .lpBuffer, .lpFilePart>,  'GetFullPathNameA',  \
    GetFullPathName, W, <.lpFileName, .nBufferLength, .lpBuffer, .lpFilePart>,  'GetFullPathNameW',  \
    GetGeoInfo, A, <NONE>,  'GetGeoInfoA',  \
    GetGeoInfo, W, <NONE>,  'GetGeoInfoW',  \
    GetHandleContext, N, <NONE>,  'GetHandleContext',  \
    GetHandleInformation, N, <.hObject, .lpdwFlags>,  'GetHandleInformation',  \
    GetLargestConsoleWindowSize, N, <.hConsoleOutput>,  'GetLargestConsoleWindowSize',  \
    GetLastError, N, <VOID>,  'GetLastError',  \
    GetLinguistLangSize, N, <NONE>,  'GetLinguistLangSize',  \
    GetLocalTime, N, <.lpSystemTime>,  'GetLocalTime',  \
    GetLocaleInfo, A, <.Locale, .LCType, .lpLCData, .cchData>,  'GetLocaleInfoA',  \
    GetLocaleInfo, W, <.Locale, .LCType, .lpLCData, .cchData>,  'GetLocaleInfoW',  \
    GetLogicalDriveStrings, A, <.nBufferLength, .lpBuffer>,  'GetLogicalDriveStringsA',  \
    GetLogicalDriveStrings, W, <.nBufferLength, .lpBuffer>,  'GetLogicalDriveStringsW',  \
    GetLogicalDrives, N, <VOID>,  'GetLogicalDrives',  \
    GetLogicalProcessorInformation, N, <NONE>,  'GetLogicalProcessorInformation',  \
    GetLongPathName, A, <.lpszShortPath, .lpszLongPath, .cchBuffer>,  'GetLongPathNameA',  \
    GetLongPathName, W, <.lpszShortPath, .lpszLongPath, .cchBuffer>,  'GetLongPathNameW',  \
    GetMailslotInfo, N, <.hMailslot, .lpMaxMessageSize, .lpNextSize, .lpMessageCount, .lpReadTimeout>,  'GetMailslotInfo',  \
    GetModuleFileName, A, <.hModule, .lpFileName, .nSize>,  'GetModuleFileNameA',  \
    GetModuleFileName, W, <.hModule, .lpFileName, .nSize>,  'GetModuleFileNameW',  \
    GetModuleHandle, A, <.lpModuleName>,  'GetModuleHandleA',  \
    GetModuleHandleEx, A, <NONE>,  'GetModuleHandleExA',  \
    GetModuleHandleEx, W, <NONE>,  'GetModuleHandleExW',  \
    GetModuleHandle, W, <.lpModuleName>,  'GetModuleHandleW',  \
    GetNamedPipeHandleState, A, <.hNamedPipe, .lpState, .lpCurInstances, .lpMaxCollectionCount, .lpCollectDataTimeout, .lpUserName, .nMaxUserNameSize>,  'GetNamedPipeHandleStateA',  \
    GetNamedPipeHandleState, W, <.hNamedPipe, .lpState, .lpCurInstances, .lpMaxCollectionCount, .lpCollectDataTimeout, .lpUserName, .nMaxUserNameSize>,  'GetNamedPipeHandleStateW',  \
    GetNamedPipeInfo, N, <.hNamedPipe, .lpFlags, .lpOutBufferSize, .lpInBufferSize, .lpMaxInstances>,  'GetNamedPipeInfo',  \
    GetNativeSystemInfo, N, <NONE>,  'GetNativeSystemInfo',  \
    GetNextVDMCommand, N, <NONE>,  'GetNextVDMCommand',  \
    GetNlsSectionName, N, <NONE>,  'GetNlsSectionName',  \
    GetNumaAvailableMemory, N, <NONE>,  'GetNumaAvailableMemory',  \
    GetNumaAvailableMemoryNode, N, <NONE>,  'GetNumaAvailableMemoryNode',  \
    GetNumaHighestNodeNumber, N, <NONE>,  'GetNumaHighestNodeNumber',  \
    GetNumaNodeProcessorMask, N, <NONE>,  'GetNumaNodeProcessorMask',  \
    GetNumaProcessorMap, N, <NONE>,  'GetNumaProcessorMap',  \
    GetNumaProcessorNode, N, <NONE>,  'GetNumaProcessorNode',  \
    GetNumberFormat, A, <.Locale, .dwFlags, .lpValue, .lpFormat, .lpNumberStr, .cchNumber>,  'GetNumberFormatA',  \
    GetNumberFormat, W, <.Locale, .dwFlags, .lpValue, .lpFormat, .lpNumberStr, .cchNumber>,  'GetNumberFormatW',  \
    GetNumberOfConsoleFonts, N, <NONE>,  'GetNumberOfConsoleFonts',  \
    GetNumberOfConsoleInputEvents, N, <.hConsoleInput, .lpNumberOfEvents>,  'GetNumberOfConsoleInputEvents',  \
    GetNumberOfConsoleMouseButtons, N, <.lpNumberOfMouseButtons>,  'GetNumberOfConsoleMouseButtons',  \
    GetOEMCP, N, <VOID>,  'GetOEMCP',  \
    GetOverlappedResult, N, <.hFile, .lpOverlapped, .lpNumberOfBytesTransferred, .bWait>,  'GetOverlappedResult',  \
    GetPriorityClass, N, <.hProcess>,  'GetPriorityClass',  \
    GetPrivateProfileInt, A, <.lpApplicationName, .lpKeyName, .nDefault, .lpFileName>,  'GetPrivateProfileIntA',  \
    GetPrivateProfileInt, W, <.lpApplicationName, .lpKeyName, .nDefault, .lpFileName>,  'GetPrivateProfileIntW',  \
    GetPrivateProfileSection, A, <.lpAppName, .lpReturnedString, .nSize, .lpFileName>,  'GetPrivateProfileSectionA',  \
    GetPrivateProfileSectionNames, A, <.lpszReturnBuffer, .nSize, .lpFileName>,  'GetPrivateProfileSectionNamesA',  \
    GetPrivateProfileSectionNames, W, <.lpszReturnBuffer, .nSize, .lpFileName>,  'GetPrivateProfileSectionNamesW',  \
    GetPrivateProfileSection, W, <.lpAppName, .lpReturnedString, .nSize, .lpFileName>,  'GetPrivateProfileSectionW',  \
    GetPrivateProfileString, A, <.lpApplicationName, .lpKeyName, .lpDefault, .lpReturnedString, .nSize, .lpFileName>,  'GetPrivateProfileStringA',  \
    GetPrivateProfileString, W, <.lpApplicationName, .lpKeyName, .lpDefault, .lpReturnedString, .nSize, .lpFileName>,  'GetPrivateProfileStringW',  \
    GetPrivateProfileStruct, A, <.lpszSection, .lpszKey, .lpStruct, .uSizeStruct, .szFile>,  'GetPrivateProfileStructA',  \
    GetPrivateProfileStruct, W, <.lpszSection, .lpszKey, .lpStruct, .uSizeStruct, .szFile>,  'GetPrivateProfileStructW',  \
    GetProcAddress, N, <.hModule, .lpProcName>,  'GetProcAddress',  \
    GetProcessAffinityMask, N, <.hProcess, .lpProcessAffinityMask, .SystemAffinityMask>,  'GetProcessAffinityMask',  \
    GetProcessDEPPolicy, N, <NONE>,  'GetProcessDEPPolicy',  \
    GetProcessHandleCount, N, <NONE>,  'GetProcessHandleCount',  \
    GetProcessHeap, N, <VOID>,  'GetProcessHeap',  \
    GetProcessHeaps, N, <.NumberOfHeaps, .ProcessHeaps>,  'GetProcessHeaps',  \
    GetProcessId, N, <NONE>,  'GetProcessId',  \
    GetProcessIoCounters, N, <.hProcess, .lpIoCounters>,  'GetProcessIoCounters',  \
    GetProcessPriorityBoost, N, <.hProcess, .pDisablePriorityBoost>,  'GetProcessPriorityBoost',  \
    GetProcessShutdownParameters, N, <.lpdwLevel, .lpdwFlags>,  'GetProcessShutdownParameters',  \
    GetProcessTimes, N, <.hProcess, .lpCreationTime, .lpExitTime, .lpKernelTime, .lpUserTime>,  'GetProcessTimes',  \
    GetProcessVersion, N, <.ProcessId>,  'GetProcessVersion',  \
    GetProcessWorkingSetSize, N, <.hProcess, .lpMinimumWorkingSetSize, .lpMaximumWorkingSetSize>,  'GetProcessWorkingSetSize',  \
    GetProfileInt, A, <.lpAppName, .lpKeyName, .nDefault>,  'GetProfileIntA',  \
    GetProfileInt, W, <.lpAppName, .lpKeyName, .nDefault>,  'GetProfileIntW',  \
    GetProfileSection, A, <.lpAppName, .lpReturnedString, .nSize>,  'GetProfileSectionA',  \
    GetProfileSection, W, <.lpAppName, .lpReturnedString, .nSize>,  'GetProfileSectionW',  \
    GetProfileString, A, <.lpAppName, .lpKeyName, .lpDefault, .lpReturnedString, .nSize>,  'GetProfileStringA',  \
    GetProfileString, W, <.lpAppName, .lpKeyName, .lpDefault, .lpReturnedString, .nSize>,  'GetProfileStringW',  \
    GetQueuedCompletionStatus, N, <.CompletionPort, .lpNumberOfBytesTransferred, .lpCompletionKey, .lpOverlapped, .dwMilliseconds>,  'GetQueuedCompletionStatus',  \
    GetShortPathName, A, <.lpszLongPath, .lpszShortPath, .cchBuffer>,  'GetShortPathNameA',  \
    GetShortPathName, W, <.lpszLongPath, .lpszShortPath, .cchBuffer>,  'GetShortPathNameW',  \
    GetStartupInfo, A, <.lpStartupInfo>,  'GetStartupInfoA',  \
    GetStartupInfo, W, <.lpStartupInfo>,  'GetStartupInfoW',  \
    GetStdHandle, N, <.nStdHandle>,  'GetStdHandle',  \
    GetStringType, A, <.Locale, .dwInfoType, .lpSrcStr, .cchSrc, .lpCharType>,  'GetStringTypeA',  \
    GetStringTypeEx, A, <.Locale, .dwInfoType, .lpSrcStr, .cchSrc, .lpCharType>,  'GetStringTypeExA',  \
    GetStringTypeEx, W, <.Locale, .dwInfoType, .lpSrcStr, .cchSrc, .lpCharType>,  'GetStringTypeExW',  \
    GetStringType, W, <.Locale, .dwInfoType, .lpSrcStr, .cchSrc, .lpCharType>,  'GetStringTypeW',  \
    GetSystemDEPPolicy, N, <NONE>,  'GetSystemDEPPolicy',  \
    GetSystemDefaultLCID, N, <VOID>,  'GetSystemDefaultLCID',  \
    GetSystemDefaultLangID, N, <VOID>,  'GetSystemDefaultLangID',  \
    GetSystemDefaultUILanguage, N, <VOID>,  'GetSystemDefaultUILanguage',  \
    GetSystemDirectory, A, <.lpBuffer, .nSize>,  'GetSystemDirectoryA',  \
    GetSystemDirectory, W, <.lpBuffer, .nSize>,  'GetSystemDirectoryW',  \
    GetSystemInfo, N, <.lpSystemInfo>,  'GetSystemInfo',  \
    GetSystemPowerStatus, N, <.lpSystemPowerStatus>,  'GetSystemPowerStatus',  \
    GetSystemRegistryQuota, N, <NONE>,  'GetSystemRegistryQuota',  \
    GetSystemTime, N, <.lpSystemTime>,  'GetSystemTime',  \
    GetSystemTimeAdjustment, N, <.lpTimeAdjustment, .lpTimeIncrement, .lpTimeAdjustmentDisabled>,  'GetSystemTimeAdjustment',  \
    GetSystemTimeAsFileTime, N, <.lpSystemTimeAsFileTime>,  'GetSystemTimeAsFileTime',  \
    GetSystemTimes, N, <NONE>,  'GetSystemTimes',  \
    GetSystemWindowsDirectory, A, <.lpBuffer, .uSize>,  'GetSystemWindowsDirectoryA',  \
    GetSystemWindowsDirectory, W, <.lpBuffer, .uSize>,  'GetSystemWindowsDirectoryW',  \
    GetSystemWow64Directory, A, <NONE>,  'GetSystemWow64DirectoryA',  \
    GetSystemWow64Directory, W, <NONE>,  'GetSystemWow64DirectoryW',  \
    GetTapeParameters, N, <.hDevice, .dwOperation, .lpdwSize, .lpTapeInformation>,  'GetTapeParameters',  \
    GetTapePosition, N, <.hDevice, .dwPositionType, .lpdwPartition, .lpdwOffsetLow, .lpdwOffsetHigh>,  'GetTapePosition',  \
    GetTapeStatus, N, <.hDevice>,  'GetTapeStatus',  \
    GetTempFileName, A, <.lpszPath, .lpPrefixString, .wUnique, .lpTempFileName>,  'GetTempFileNameA',  \
    GetTempFileName, W, <.lpszPath, .lpPrefixString, .wUnique, .lpTempFileName>,  'GetTempFileNameW',  \
    GetTempPath, A, <.nBufferLength, .lpBuffer>,  'GetTempPathA',  \
    GetTempPath, W, <.nBufferLength, .lpBuffer>,  'GetTempPathW',  \
    GetThreadContext, N, <.hThread, .lpContext>,  'GetThreadContext',  \
    GetThreadIOPendingFlag, N, <NONE>,  'GetThreadIOPendingFlag',  \
    GetThreadLocale, N, <VOID>,  'GetThreadLocale',  \
    GetThreadPriority, N, <.hThread>,  'GetThreadPriority',  \
    GetThreadPriorityBoost, N, <.hThread, .pDisablePriorityBoost>,  'GetThreadPriorityBoost',  \
    GetThreadSelectorEntry, N, <.hThread, .dwSelector, .lpSelectorEntry>,  'GetThreadSelectorEntry',  \
    GetThreadTimes, N, <.hThread, .lpCreationTime, .lpExitTime, .lpKernelTime, .lpUserTime>,  'GetThreadTimes',  \
    GetTickCount, N, <VOID>,  'GetTickCount',  \
    GetTimeFormat, A, <.Locale, .dwFlags, .lpTime, .lpFormat, .lpTimeStr, .cchTime>,  'GetTimeFormatA',  \
    GetTimeFormat, W, <.Locale, .dwFlags, .lpTime, .lpFormat, .lpTimeStr, .cchTime>,  'GetTimeFormatW',  \
    GetTimeZoneInformation, N, <.lpTimeZoneInformation>,  'GetTimeZoneInformation',  \
    GetUserDefaultLCID, N, <VOID>,  'GetUserDefaultLCID',  \
    GetUserDefaultLangID, N, <VOID>,  'GetUserDefaultLangID',  \
    GetUserDefaultUILanguage, N, <VOID>,  'GetUserDefaultUILanguage',  \
    GetUserGeoID, N, <NONE>,  'GetUserGeoID',  \
    GetVDMCurrentDirectories, N, <NONE>,  'GetVDMCurrentDirectories',  \
    GetVersion, N, <VOID>,  'GetVersion',  \
    GetVersionEx, A, <.lpVersionInformation>,  'GetVersionExA',  \
    GetVersionEx, W, <.lpVersionInformation>,  'GetVersionExW',  \
    GetVolumeInformation, A, <.lpRootPathName, .lpVolumeNameBuffer, .nVolumeNameSize, .lpVolumeSerialNumber, .lpMaximumComponentLength, .lpFileSystemFlags, .lpFileSystemNameBuffer, .nFileSystemNameSize>,  'GetVolumeInformationA',  \
    GetVolumeInformation, W, <.lpRootPathName, .lpVolumeNameBuffer, .nVolumeNameSize, .lpVolumeSerialNumber, .lpMaximumComponentLength, .lpFileSystemFlags, .lpFileSystemNameBuffer, .nFileSystemNameSize>,  'GetVolumeInformationW',  \
    GetVolumeNameForVolumeMountPoint, A, <.lpszVolumeMountPoint, .lpszVolumeName, .cchBufferLength>,  'GetVolumeNameForVolumeMountPointA',  \
    GetVolumeNameForVolumeMountPoint, W, <.lpszVolumeMountPoint, .lpszVolumeName, .cchBufferLength>,  'GetVolumeNameForVolumeMountPointW',  \
    GetVolumePathName, A, <.lpszFileName, .lpszVolumePathName, .cchBufferLength>,  'GetVolumePathNameA',  \
    GetVolumePathName, W, <.lpszFileName, .lpszVolumePathName, .cchBufferLength>,  'GetVolumePathNameW',  \
    GetVolumePathNamesForVolumeName, A, <NONE>,  'GetVolumePathNamesForVolumeNameA',  \
    GetVolumePathNamesForVolumeName, W, <NONE>,  'GetVolumePathNamesForVolumeNameW',  \
    GetWindowsDirectory, A, <.lpBuffer, .nSize>,  'GetWindowsDirectoryA',  \
    GetWindowsDirectory, W, <.lpBuffer, .nSize>,  'GetWindowsDirectoryW',  \
    GetWriteWatch, N, <.dwFlags, .lpBaseAddress, .dwRegionSize, .lpAddresses, .lpdwCount, .lpdwGranularity>,  'GetWriteWatch',  \
    GlobalAddAtom, A, <.lpString>,  'GlobalAddAtomA',  \
    GlobalAddAtom, W, <.lpString>,  'GlobalAddAtomW',  \
    GlobalAlloc, N, <.uFlags, .dwBytes>,  'GlobalAlloc',  \
    GlobalCompact, N, <.dwMinFree>,  'GlobalCompact',  \
    GlobalDeleteAtom, N, <.nAtom>,  'GlobalDeleteAtom',  \
    GlobalFindAtom, A, <.lpString>,  'GlobalFindAtomA',  \
    GlobalFindAtom, W, <.lpString>,  'GlobalFindAtomW',  \
    GlobalFix, N, <.hMem>,  'GlobalFix',  \
    GlobalFlags, N, <.hMem>,  'GlobalFlags',  \
    GlobalFree, N, <.hMem>,  'GlobalFree',  \
    GlobalGetAtomName, A, <.nAtom, .lpBuffer, .nSize>,  'GlobalGetAtomNameA',  \
    GlobalGetAtomName, W, <.nAtom, .lpBuffer, .nSize>,  'GlobalGetAtomNameW',  \
    GlobalHandle, N, <.wMem>,  'GlobalHandle',  \
    GlobalLock, N, <.hMem>,  'GlobalLock',  \
    GlobalMemoryStatus, N, <.lpBuffer>,  'GlobalMemoryStatus',  \
    GlobalMemoryStatusEx, N, <.lpBuffer>,  'GlobalMemoryStatusEx',  \
    GlobalReAlloc, N, <.hMem, .dwBytes, .wFlags>,  'GlobalReAlloc',  \
    GlobalSize, N, <.hMem>,  'GlobalSize',  \
    GlobalUnWire, N, <.hMem>,  'GlobalUnWire',  \
    GlobalUnfix, N, <.hMem>,  'GlobalUnfix',  \
    GlobalUnlock, N, <.hMem>,  'GlobalUnlock',  \
    GlobalWire, N, <.hMem>,  'GlobalWire',  \
    Heap32First, N, <.lphe, .th32ProcessID, .th32HeapID>,  'Heap32First',  \
    Heap32ListFirst, N, <.hSnapshot, .lphl>,  'Heap32ListFirst',  \
    Heap32ListNext, N, <.hSnapshot, .lphl>,  'Heap32ListNext',  \
    Heap32Next, N, <.lphe>,  'Heap32Next',  \
    HeapAlloc, N, <.hHeap, .dwFlags, .dwBytes>,  'HeapAlloc',  \
    HeapCompact, N, <.hHeap, .dwFlags>,  'HeapCompact',  \
    HeapCreate, N, <.flOptions, .dwInitialSize, .dwMaximumSize>,  'HeapCreate',  \
    HeapCreateTags, W, <NONE>,  'HeapCreateTagsW',  \
    HeapDestroy, N, <.hHeap>,  'HeapDestroy',  \
    HeapExtend, N, <NONE>,  'HeapExtend',  \
    HeapFree, N, <.hHeap, .dwFlags, .lpMem>,  'HeapFree',  \
    HeapLock, N, <.hHeap>,  'HeapLock',  \
    HeapQueryInformation, N, <NONE>,  'HeapQueryInformation',  \
    HeapQueryTag, W, <NONE>,  'HeapQueryTagW',  \
    HeapReAlloc, N, <.hHeap, .dwFlags, .lpMem, .dwBytes>,  'HeapReAlloc',  \
    HeapSetInformation, N, <NONE>,  'HeapSetInformation',  \
    HeapSize, N, <.hHeap, .dwFlags, .lpMem>,  'HeapSize',  \
    HeapSummary, N, <NONE>,  'HeapSummary',  \
    HeapUnlock, N, <.hHeap>,  'HeapUnlock',  \
    HeapUsage, N, <NONE>,  'HeapUsage',  \
    HeapValidate, N, <.hHeap, .dwFlags, .lpMem>,  'HeapValidate',  \
    HeapWalk, N, <.hHeap, .lpEntry>,  'HeapWalk',  \
    InitAtomTable, N, <.nSize>,  'InitAtomTable',  \
    InitializeCriticalSection, N, <.lpCriticalSection>,  'InitializeCriticalSection',  \
    InitializeCriticalSectionAndSpinCount, N, <.lpCriticalSection, .dwSpinCount>,  'InitializeCriticalSectionAndSpinCount',  \
    InitializeSListHead, N, <NONE>,  'InitializeSListHead',  \
    InterlockedCompareExchange, N, <.Destination, .Exchange, .Comperand>,  'InterlockedCompareExchange',  \
    InterlockedDecrement, N, <.lpAddend>,  'InterlockedDecrement',  \
    InterlockedExchange, N, <.Target, .Value>,  'InterlockedExchange',  \
    InterlockedExchangeAdd, N, <.Addend, .Value>,  'InterlockedExchangeAdd',  \
    InterlockedFlushSList, N, <NONE>,  'InterlockedFlushSList',  \
    InterlockedIncrement, N, <.lpAddend>,  'InterlockedIncrement',  \
    InterlockedPopEntrySList, N, <NONE>,  'InterlockedPopEntrySList',  \
    InterlockedPushEntrySList, N, <NONE>,  'InterlockedPushEntrySList',  \
    InvalidateConsoleDIBits, N, <NONE>,  'InvalidateConsoleDIBits',  \
    IsBadCodePtr, N, <.lpfn>,  'IsBadCodePtr',  \
    IsBadHugeReadPtr, N, <.lp, .ucb>,  'IsBadHugeReadPtr',  \
    IsBadHugeWritePtr, N, <.lp, .ucb>,  'IsBadHugeWritePtr',  \
    IsBadReadPtr, N, <.lp, .ucb>,  'IsBadReadPtr',  \
    IsBadStringPtr, A, <.lpsz, .ucchMax>,  'IsBadStringPtrA',  \
    IsBadStringPtr, W, <.lpsz, .ucchMax>,  'IsBadStringPtrW',  \
    IsBadWritePtr, N, <.lp, .ucb>,  'IsBadWritePtr',  \
    IsDBCSLeadByte, N, <.bTestChar>,  'IsDBCSLeadByte',  \
    IsDBCSLeadByteEx, N, <.CodePage, .TestChar>,  'IsDBCSLeadByteEx',  \
    IsDebuggerPresent, N, <VOID>,  'IsDebuggerPresent',  \
    IsProcessInJob, N, <NONE>,  'IsProcessInJob',  \
    IsProcessorFeaturePresent, N, <.ProcessorFeature>,  'IsProcessorFeaturePresent',  \
    IsSystemResumeAutomatic, N, <VOID>,  'IsSystemResumeAutomatic',  \
    IsValidCodePage, N, <.CodePage>,  'IsValidCodePage',  \
    IsValidLanguageGroup, N, <.LanguageGroup, .dwFlags>,  'IsValidLanguageGroup',  \
    IsValidLocale, N, <.Locale, .dwFlags>,  'IsValidLocale',  \
    IsValidUILanguage, N, <NONE>,  'IsValidUILanguage',  \
    IsWow64Process, N, <NONE>,  'IsWow64Process',  \
    LCMapString, A, <.Locale, .dwMapFlags, .lpSrcStr, .cchSrc, .lpDestStr, .cchDest>,  'LCMapStringA',  \
    LCMapString, W, <.Locale, .dwMapFlags, .lpSrcStr, .cchSrc, .lpDestStr, .cchDest>,  'LCMapStringW',  \
    LZClose, N, <.hfFile>,  'LZClose',  \
    LZCloseFile, N, <NONE>,  'LZCloseFile',  \
    LZCopy, N, <.hfSource, .hfDest>,  'LZCopy',  \
    LZCreateFile, W, <NONE>,  'LZCreateFileW',  \
    LZDone, N, <VOID>,  'LZDone',  \
    LZInit, N, <.hfSrc>,  'LZInit',  \
    LZOpenFile, A, <.lpszFile, .lpOf, .style>,  'LZOpenFileA',  \
    LZOpenFile, W, <.lpszFile, .lpOf, .style>,  'LZOpenFileW',  \
    LZRead, N, <.hfFile, .lpvBuf, .cbread>,  'LZRead',  \
    LZSeek, N, <.hfFile, .lOffset, .nOrigin>,  'LZSeek',  \
    LZStart, N, <VOID>,  'LZStart',  \
    LeaveCriticalSection, N, <.lpCriticalSection>,  'LeaveCriticalSection',  \
    LoadLibrary, A, <.lpLibFileName>,  'LoadLibraryA',  \
    LoadLibraryEx, A, <.lpLibFileName, .hFile, .dwFlags>,  'LoadLibraryExA',  \
    LoadLibraryEx, W, <.lpLibFileName, .hFile, .dwFlags>,  'LoadLibraryExW',  \
    LoadLibrary, W, <.lpLibFileName>,  'LoadLibraryW',  \
    LoadModule, N, <.lpModuleName, .lpParameterBlock>,  'LoadModule',  \
    LoadResource, N, <.hInstance, .hResInfo>,  'LoadResource',  \
    LocalAlloc, N, <.wFlags, .wBytes>,  'LocalAlloc',  \
    LocalCompact, N, <.uMinFree>,  'LocalCompact',  \
    LocalFileTimeToFileTime, N, <.lpLocalFileTime, .lpFileTime>,  'LocalFileTimeToFileTime',  \
    LocalFlags, N, <.hMem>,  'LocalFlags',  \
    LocalFree, N, <.hMem>,  'LocalFree',  \
    LocalHandle, N, <.wMem>,  'LocalHandle',  \
    LocalLock, N, <.hMem>,  'LocalLock',  \
    LocalReAlloc, N, <.hMem, .wBytes, .wFlags>,  'LocalReAlloc',  \
    LocalShrink, N, <.hMem, .cbNewSize>,  'LocalShrink',  \
    LocalSize, N, <.hMem>,  'LocalSize',  \
    LocalUnlock, N, <.hMem>,  'LocalUnlock',  \
    LockFile, N, <.hFile, .dwFileOffsetLow, .dwFileOffsetHigh, .nNumberOfBytesToLockLow, .nNumberOfBytesToLockHigh>,  'LockFile',  \
    LockFileEx, N, <.hFile, .dwFlags, .dwReserved, .nNumberOfBytesToLockLow, .nNumberOfBytesToLockHigh, .lpOverlapped>,  'LockFileEx',  \
    LockResource, N, <.hResData>,  'LockResource',  \
    MapUserPhysicalPages, N, <.VirtualAddress, .NumberOfPages, .PageArray>,  'MapUserPhysicalPages',  \
    MapUserPhysicalPagesScatter, N, <.VirtualAddresses, .NumberOfPages, .PageArray>,  'MapUserPhysicalPagesScatter',  \
    MapViewOfFile, N, <.hFileMappingObject, .dwDesiredAccess, .dwFileOffsetHigh, .dwFileOffsetLow, .dwNumberOfBytesToMap>,  'MapViewOfFile',  \
    MapViewOfFileEx, N, <.hFileMappingObject, .dwDesiredAccess, .dwFileOffsetHigh, .dwFileOffsetLow, .dwNumberOfBytesToMap, .lpBaseAddress>,  'MapViewOfFileEx',  \
    Module32First, A, <.hSnapshot, .lpme>,  'Module32First',  \
    Module32First, W, <.hSnapshot, .lpme>,  'Module32FirstW',  \
    Module32Next, A, <.hSnapshot, .lpme>,  'Module32Next',  \
    Module32Next, W, <.hSnapshot, .lpme>,  'Module32NextW',  \
    MoveFile, A, <.lpExistingFileName, .lpNewFileName>,  'MoveFileA',  \
    MoveFileEx, A, <.lpExistingFileName, .lpNewFileName, .dwFlags>,  'MoveFileExA',  \
    MoveFileEx, W, <.lpExistingFileName, .lpNewFileName, .dwFlags>,  'MoveFileExW',  \
    MoveFile, W, <.lpExistingFileName, .lpNewFileName>,  'MoveFileW',  \
    MoveFileWithProgress, A, <.lpExistingFileName, .lpNewFileName, .lpProgressRoutine, .lpData, .dwFlags>,  'MoveFileWithProgressA',  \
    MoveFileWithProgress, W, <.lpExistingFileName, .lpNewFileName, .lpProgressRoutine, .lpData, .dwFlags>,  'MoveFileWithProgressW',  \
    MulDiv, N, <.nNumber, .nNumerator, .nDenominator>,  'MulDiv',  \
    MultiByteToWideChar, N, <.CodePage, .dwFlags, .lpMultiByteStr, .cchMultiByte, .lpWideCharStr, .cchWideChar>,  'MultiByteToWideChar',  \
    NlsConvertIntegerToString, N, <NONE>,  'NlsConvertIntegerToString',  \
    NlsGetCacheUpdateCount, N, <NONE>,  'NlsGetCacheUpdateCount',  \
    NlsResetProcessLocale, N, <NONE>,  'NlsResetProcessLocale',  \
    NumaVirtualQueryNode, N, <NONE>,  'NumaVirtualQueryNode',  \
    OpenConsole, W, <NONE>,  'OpenConsoleW',  \
    OpenDataFile, N, <NONE>,  'OpenDataFile',  \
    OpenEvent, A, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenEventA',  \
    OpenEvent, W, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenEventW',  \
    OpenFile, N, <.lpFileName, .lpReOpenBuff, .wStyle>,  'OpenFile',  \
    OpenFileMapping, A, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenFileMappingA',  \
    OpenFileMapping, W, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenFileMappingW',  \
    OpenJobObject, A, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenJobObjectA',  \
    OpenJobObject, W, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenJobObjectW',  \
    OpenMutex, A, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenMutexA',  \
    OpenMutex, W, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenMutexW',  \
    OpenProcess, N, <.dwDesiredAccess, .bInheritHandle, .dwProcessId>,  'OpenProcess',  \
    OpenProfileUserMapping, N, <NONE>,  'OpenProfileUserMapping',  \
    OpenSemaphore, A, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenSemaphoreA',  \
    OpenSemaphore, W, <.dwDesiredAccess, .bInheritHandle, .lpName>,  'OpenSemaphoreW',  \
    OpenThread, N, <.dwDesiredAccess, .bInheritHandle, .dwThreadId>,  'OpenThread',  \
    OpenWaitableTimer, A, <.dwDesiredAccess, .bInheritHandle, .lpTimerName>,  'OpenWaitableTimerA',  \
    OpenWaitableTimer, W, <.dwDesiredAccess, .bInheritHandle, .lpTimerName>,  'OpenWaitableTimerW',  \
    OutputDebugString, A, <.lpOutputString>,  'OutputDebugStringA',  \
    OutputDebugString, W, <.lpOutputString>,  'OutputDebugStringW',  \
    PeekConsoleInput, A, <.hConsoleInput, .lpBuffer, .nLength, .lpNumberOfEventsRead>,  'PeekConsoleInputA',  \
    PeekConsoleInput, W, <.hConsoleInput, .lpBuffer, .nLength, .lpNumberOfEventsRead>,  'PeekConsoleInputW',  \
    PeekNamedPipe, N, <.hNamedPipe, .lpBuffer, .nBufferSize, .lpBytesRead, .lpTotalBytesAvail, .lpBytesLeftThisMessage>,  'PeekNamedPipe',  \
    PostQueuedCompletionStatus, N, <.CompletionPort, .dwNumberOfBytesTransferred, .dwCompletionKey, .lpOverlapped>,  'PostQueuedCompletionStatus',  \
    PrepareTape, N, <.hDevice, .dwOperation, .bimmediate>,  'PrepareTape',  \
    PrivCopyFileEx, W, <NONE>,  'PrivCopyFileExW',  \
    PrivMoveFileIdentity, W, <NONE>,  'PrivMoveFileIdentityW',  \
    Process32First, A, <.hSnapshot, .lppe>,  'Process32First',  \
    Process32First, W, <.hSnapshot, .lppe>,  'Process32FirstW',  \
    Process32Next, A, <.hSnapshot, .lppe>,  'Process32Next',  \
    Process32Next, W, <.hSnapshot, .lppe>,  'Process32NextW',  \
    ProcessIdToSessionId, N, <.dwProcessId, .pSessionId>,  'ProcessIdToSessionId',  \
    PulseEvent, N, <.hEvent>,  'PulseEvent',  \
    PurgeComm, N, <.hFile, .dwFlags>,  'PurgeComm',  \
    QueryActCtx, W, <NONE>,  'QueryActCtxW',  \
    QueryDepthSList, N, <NONE>,  'QueryDepthSList',  \
    QueryDosDevice, A, <.lpDeviceName, .lpTargetPath, .ucchMax>,  'QueryDosDeviceA',  \
    QueryDosDevice, W, <.lpDeviceName, .lpTargetPath, .ucchMax>,  'QueryDosDeviceW',  \
    QueryInformationJobObject, N, <.hJob, .JobObjectInformationClass, .lpJobObjectInformation, .cbJobObjectInformationLength, .lpReturnLength>,  'QueryInformationJobObject',  \
    QueryMemoryResourceNotification, N, <NONE>,  'QueryMemoryResourceNotification',  \
    QueryPerformanceCounter, N, <.lpPerformanceCount>,  'QueryPerformanceCounter',  \
    QueryPerformanceFrequency, N, <.lpFrequency>,  'QueryPerformanceFrequency',  \
    QueryWin31IniFilesMappedToRegistry, N, <NONE>,  'QueryWin31IniFilesMappedToRegistry',  \
    QueueUserAPC, N, <.pfnAPC, .hThread, .dwData>,  'QueueUserAPC',  \
    QueueUserWorkItem, N, <.lFunction, .Context, .Flags>,  'QueueUserWorkItem',  \
    RaiseException, N, <.dwExceptionCode, .dwExceptionFlags, .nNumberOfArguments, .lpArguments>,  'RaiseException',  \
    ReadConsole, A, <.hConsoleInput, .lpBuffer, .nNumberOfCharsToRead, .lpNumberOfCharsRead, .lpReserved>,  'ReadConsoleA',  \
    ReadConsoleInput, A, <.hConsoleInput, .lpBuffer, .nLength, .lpNumberOfEventsRead>,  'ReadConsoleInputA',  \
    ReadConsoleInputEx, A, <NONE>,  'ReadConsoleInputExA',  \
    ReadConsoleInputEx, W, <NONE>,  'ReadConsoleInputExW',  \
    ReadConsoleInput, W, <.hConsoleInput, .lpBuffer, .nLength, .lpNumberOfEventsRead>,  'ReadConsoleInputW',  \
    ReadConsoleOutput, A, <.hConsoleOutput, .lpBuffer, .dwBufferSize, .dwBufferCoord, .lpReadRegion>,  'ReadConsoleOutputA',  \
    ReadConsoleOutputAttribute, N, <.hConsoleOutput, .lpAttribute, .nLength, .dwReadCoord, .lpNumberOfAttrsRead>,  'ReadConsoleOutputAttribute',  \
    ReadConsoleOutputCharacter, A, <.hConsoleOutput, .lpCharacter, .nLength, .dwReadCoord, .lpNumberOfCharsRead>,  'ReadConsoleOutputCharacterA',  \
    ReadConsoleOutputCharacter, W, <.hConsoleOutput, .lpCharacter, .nLength, .dwReadCoord, .lpNumberOfCharsRead>,  'ReadConsoleOutputCharacterW',  \
    ReadConsoleOutput, W, <.hConsoleOutput, .lpBuffer, .dwBufferSize, .dwBufferCoord, .lpReadRegion>,  'ReadConsoleOutputW',  \
    ReadConsole, W, <.hConsoleInput, .lpBuffer, .nNumberOfCharsToRead, .lpNumberOfCharsRead, .lpReserved>,  'ReadConsoleW',  \
    ReadDirectoryChanges, W, <NONE>,  'ReadDirectoryChangesW',  \
    ReadFile, N, <.hFile, .lpBuffer, .nNumberOfBytesToRead, .lpNumberOfBytesRead, .lpOverlapped>,  'ReadFile',  \
    ReadFileEx, N, <.hFile, .lpBuffer, .nNumberOfBytesToRead, .lpOverlapped, .lpCompletionRoutine>,  'ReadFileEx',  \
    ReadFileScatter, N, <.hFile, .aSegmentArray, .nNumberOfBytesToRead, .lpReserved, .lpOverlapped>,  'ReadFileScatter',  \
    ReadProcessMemory, N, <.hProcess, .lpBaseAddress, .lpBuffer, .nSize, .lpNumberOfBytesWritten>,  'ReadProcessMemory',  \
    RegisterConsoleIME, N, <NONE>,  'RegisterConsoleIME',  \
    RegisterConsoleOS2, N, <NONE>,  'RegisterConsoleOS2',  \
    RegisterConsoleVDM, N, <NONE>,  'RegisterConsoleVDM',  \
    RegisterWaitForInputIdle, N, <NONE>,  'RegisterWaitForInputIdle',  \
    RegisterWaitForSingleObject, N, <.phNewWaitObject, .hObject, .Callback, .Context, .dwMilliseconds, .dwFlags>,  'RegisterWaitForSingleObject',  \
    RegisterWaitForSingleObjectEx, N, <.hObject, .Callback, .Context, .dwMilliseconds, .dwFlags>,  'RegisterWaitForSingleObjectEx',  \
    RegisterWowBaseHandlers, N, <NONE>,  'RegisterWowBaseHandlers',  \
    RegisterWowExec, N, <NONE>,  'RegisterWowExec',  \
    ReleaseActCtx, N, <NONE>,  'ReleaseActCtx',  \
    ReleaseMutex, N, <.hMutex>,  'ReleaseMutex',  \
    ReleaseSemaphore, N, <.hSemaphore, .lReleaseCount, .lpPreviousCount>,  'ReleaseSemaphore',  \
    RemoveDirectory, A, <.lpPathName>,  'RemoveDirectoryA',  \
    RemoveDirectory, W, <.lpPathName>,  'RemoveDirectoryW',  \
    RemoveLocalAlternateComputerName, A, <NONE>,  'RemoveLocalAlternateComputerNameA',  \
    RemoveLocalAlternateComputerName, W, <NONE>,  'RemoveLocalAlternateComputerNameW',  \
    RemoveVectoredExceptionHandler, N, <NONE>,  'RemoveVectoredExceptionHandler',  \
    ReplaceFile, A, <.lpReplacedFileName, .lpReplacementFileName, .lpBackupFileName, .dwReplaceFlags, .lpExclude, .lpReserved>,  'ReplaceFileA',  \
    ReplaceFile, W, <.lpReplacedFileName, .lpReplacementFileName, .lpBackupFileName, .dwReplaceFlags, .lpExclude, .lpReserved>,  'ReplaceFileW',  \
    RequestDeviceWakeup, N, <.hDevice>,  'RequestDeviceWakeup',  \
    RequestWakeupLatency, N, <.latency>,  'RequestWakeupLatency',  \
    ResetEvent, N, <.hEvent>,  'ResetEvent',  \
    ResetWriteWatch, N, <.lpBaseAddress, .dwRegionSize>,  'ResetWriteWatch',  \
    RestoreLastError, N, <NONE>,  'RestoreLastError',  \
    ResumeThread, N, <.hThread>,  'ResumeThread',  \
    RtlCaptureContext, N, <NONE>,  'RtlCaptureContext',  \
    RtlCaptureStackBackTrace, N, <NONE>,  'RtlCaptureStackBackTrace',  \
    RtlFillMemory, N, <.Destination, .Length, .Fill>,  'RtlFillMemory',  \
    RtlMoveMemory, N, <.dest, .source, .numBytes>,  'RtlMoveMemory',  \
    RtlUnwind, N, <NONE>,  'RtlUnwind',  \
    RtlZeroMemory, N, <.dest, .numBytes>,  'RtlZeroMemory',  \
    ScrollConsoleScreenBuffer, A, <.hConsoleOutput, .lpScrollRectangle, .lpClipRectangle, .dwDestinationOrigin, .lpFill>,  'ScrollConsoleScreenBufferA',  \
    ScrollConsoleScreenBuffer, W, <.hConsoleOutput, .lpScrollRectangle, .lpClipRectangle, .dwDestinationOrigin, .lpFill>,  'ScrollConsoleScreenBufferW',  \
    SearchPath, A, <.lpPath, .lpFileName, .lpExtension, .nBufferLength, .lpBuffer, .lpFilePart>,  'SearchPathA',  \
    SearchPath, W, <.lpPath, .lpFileName, .lpExtension, .nBufferLength, .lpBuffer, .lpFilePart>,  'SearchPathW',  \
    SetCPGlobal, N, <NONE>,  'SetCPGlobal',  \
    SetCalendarInfo, A, <.Locale, .Calendar, .CalType, .lpCalData>,  'SetCalendarInfoA',  \
    SetCalendarInfo, W, <.Locale, .Calendar, .CalType, .lpCalData>,  'SetCalendarInfoW',  \
    SetClientTimeZoneInformation, N, <NONE>,  'SetClientTimeZoneInformation',  \
    SetComPlusPackageInstallStatus, N, <NONE>,  'SetComPlusPackageInstallStatus',  \
    SetCommBreak, N, <.nCid>,  'SetCommBreak',  \
    SetCommConfig, N, <.hCommDev, .lpCC, .dwSize>,  'SetCommConfig',  \
    SetCommMask, N, <.hFile, .dwEvtMask>,  'SetCommMask',  \
    SetCommState, N, <.hCommDev, .lpDCB>,  'SetCommState',  \
    SetCommTimeouts, N, <.hFile, .lpCommTimeouts>,  'SetCommTimeouts',  \
    SetComputerName, A, <.lpComputerName>,  'SetComputerNameA',  \
    SetComputerNameEx, A, <.NameType, .lpBuffer>,  'SetComputerNameExA',  \
    SetComputerNameEx, W, <.NameType, .lpBuffer>,  'SetComputerNameExW',  \
    SetComputerName, W, <.lpComputerName>,  'SetComputerNameW',  \
    SetConsoleActiveScreenBuffer, N, <.hConsoleOutput>,  'SetConsoleActiveScreenBuffer',  \
    SetConsoleCP, N, <.wCodePageID>,  'SetConsoleCP',  \
    SetConsoleCommandHistoryMode, N, <NONE>,  'SetConsoleCommandHistoryMode',  \
    SetConsoleCtrlHandler, N, <.HandlerRoutine, .Add>,  'SetConsoleCtrlHandler',  \
    SetConsoleCursor, N, <NONE>,  'SetConsoleCursor',  \
    SetConsoleCursorInfo, N, <.hConsoleOutput, .lpConsoleCursorInfo>,  'SetConsoleCursorInfo',  \
    SetConsoleCursorMode, N, <NONE>,  'SetConsoleCursorMode',  \
    SetConsoleCursorPosition, N, <.hConsoleOutput, .dwCursorPosition>,  'SetConsoleCursorPosition',  \
    SetConsoleDisplayMode, N, <NONE>,  'SetConsoleDisplayMode',  \
    SetConsoleFont, N, <NONE>,  'SetConsoleFont',  \
    SetConsoleHardwareState, N, <NONE>,  'SetConsoleHardwareState',  \
    SetConsoleIcon, N, <NONE>,  'SetConsoleIcon',  \
    SetConsoleInputExeName, A, <NONE>,  'SetConsoleInputExeNameA',  \
    SetConsoleInputExeName, W, <NONE>,  'SetConsoleInputExeNameW',  \
    SetConsoleKeyShortcuts, N, <NONE>,  'SetConsoleKeyShortcuts',  \
    SetConsoleLocalEUDC, N, <NONE>,  'SetConsoleLocalEUDC',  \
    SetConsoleMaximumWindowSize, N, <NONE>,  'SetConsoleMaximumWindowSize',  \
    SetConsoleMenuClose, N, <NONE>,  'SetConsoleMenuClose',  \
    SetConsoleMode, N, <.hConsoleHandle, .dwMode>,  'SetConsoleMode',  \
    SetConsoleNlsMode, N, <NONE>,  'SetConsoleNlsMode',  \
    SetConsoleNumberOfCommands, A, <NONE>,  'SetConsoleNumberOfCommandsA',  \
    SetConsoleNumberOfCommands, W, <NONE>,  'SetConsoleNumberOfCommandsW',  \
    SetConsoleOS2OemFormat, N, <NONE>,  'SetConsoleOS2OemFormat',  \
    SetConsoleOutputCP, N, <.wCodePageID>,  'SetConsoleOutputCP',  \
    SetConsolePalette, N, <NONE>,  'SetConsolePalette',  \
    SetConsoleScreenBufferSize, N, <.hConsoleOutput, .dwSize>,  'SetConsoleScreenBufferSize',  \
    SetConsoleTextAttribute, N, <.hConsoleOutput, .wAttributes>,  'SetConsoleTextAttribute',  \
    SetConsoleTitle, A, <.lpConsoleTitle>,  'SetConsoleTitleA',  \
    SetConsoleTitle, W, <.lpConsoleTitle>,  'SetConsoleTitleW',  \
    SetConsoleWindowInfo, N, <.hConsoleOutput, .bAbsolute, .lpConsoleWindow>,  'SetConsoleWindowInfo',  \
    SetCriticalSectionSpinCount, N, <.lpCriticalSection, .dwSpinCount>,  'SetCriticalSectionSpinCount',  \
    SetCurrentDirectory, A, <.lpPathName>,  'SetCurrentDirectoryA',  \
    SetCurrentDirectory, W, <.lpPathName>,  'SetCurrentDirectoryW',  \
    SetDefaultCommConfig, A, <.lpszName, .lpCC, .dwSize>,  'SetDefaultCommConfigA',  \
    SetDefaultCommConfig, W, <.lpszName, .lpCC, .dwSize>,  'SetDefaultCommConfigW',  \
    SetDllDirectory, A, <NONE>,  'SetDllDirectoryA',  \
    SetDllDirectory, W, <NONE>,  'SetDllDirectoryW',  \
    SetEndOfFile, N, <.hFile>,  'SetEndOfFile',  \
    SetEnvironmentVariable, A, <.lpName, .lpValue>,  'SetEnvironmentVariableA',  \
    SetEnvironmentVariable, W, <.lpName, .lpValue>,  'SetEnvironmentVariableW',  \
    SetErrorMode, N, <.wMode>,  'SetErrorMode',  \
    SetEvent, N, <.hEvent>,  'SetEvent',  \
    SetFileApisToANSI, N, <VOID>,  'SetFileApisToANSI',  \
    SetFileApisToOEM, N, <VOID>,  'SetFileApisToOEM',  \
    SetFileAttributes, A, <.lpFileName, .dwFileAttributes>,  'SetFileAttributesA',  \
    SetFileAttributes, W, <.lpFileName, .dwFileAttributes>,  'SetFileAttributesW',  \
    SetFilePointer, N, <.hFile, .lDistanceToMove, .lpDistanceToMoveHigh, .dwMoveMethod>,  'SetFilePointer',  \
    SetFilePointerEx, N, <.hFile, .liDistanceToMove, .lpNewFilePointer, .dwMoveMethod>,  'SetFilePointerEx',  \
    SetFileShortName, A, <NONE>,  'SetFileShortNameA',  \
    SetFileShortName, W, <NONE>,  'SetFileShortNameW',  \
    SetFileTime, N, <.hFile, .lpCreationTime, .lpLastAccessTime, .lpLastWriteTime>,  'SetFileTime',  \
    SetFileValidData, N, <NONE>,  'SetFileValidData',  \
    SetFirmwareEnvironmentVariable, A, <NONE>,  'SetFirmwareEnvironmentVariableA',  \
    SetFirmwareEnvironmentVariable, W, <NONE>,  'SetFirmwareEnvironmentVariableW',  \
    SetHandleContext, N, <NONE>,  'SetHandleContext',  \
    SetHandleCount, N, <.wNumber>,  'SetHandleCount',  \
    SetHandleInformation, N, <.hObject, .dwMask, .dwFlags>,  'SetHandleInformation',  \
    SetInformationJobObject, N, <.hJob, .JobObjectInformationClass, .lpJobObjectInformation, .cbJobObjectInformationLength>,  'SetInformationJobObject',  \
    SetLastConsoleEventActive, N, <NONE>,  'SetLastConsoleEventActive',  \
    SetLastError, N, <.dwErrCode>,  'SetLastError',  \
    SetLocalPrimaryComputerName, A, <NONE>,  'SetLocalPrimaryComputerNameA',  \
    SetLocalPrimaryComputerName, W, <NONE>,  'SetLocalPrimaryComputerNameW',  \
    SetLocalTime, N, <.lpSystemTime>,  'SetLocalTime',  \
    SetLocaleInfo, A, <.Locale, .LCType, .lpLCData>,  'SetLocaleInfoA',  \
    SetLocaleInfo, W, <.Locale, .LCType, .lpLCData>,  'SetLocaleInfoW',  \
    SetMailslotInfo, N, <.hMailslot, .lReadTimeout>,  'SetMailslotInfo',  \
    SetMessageWaitingIndicator, N, <.hMsgIndicator, .ulMsgCount>,  'SetMessageWaitingIndicator',  \
    SetNamedPipeHandleState, N, <.hNamedPipe, .lpMode, .lpMaxCollectionCount, .lpCollectDataTimeout>,  'SetNamedPipeHandleState',  \
    SetPriorityClass, N, <.hProcess, .dwPriorityClass>,  'SetPriorityClass',  \
    SetProcessAffinityMask, N, <.hProcess, .dwProcessAffinityMask>,  'SetProcessAffinityMask',  \
    SetProcessDEPPolicy, N, <NONE>,  'SetProcessDEPPolicy',  \
    SetProcessPriorityBoost, N, <.hProcess, .bDisablePriorityBoost>,  'SetProcessPriorityBoost',  \
    SetProcessShutdownParameters, N, <.dwLevel, .dwFlags>,  'SetProcessShutdownParameters',  \
    SetProcessWorkingSetSize, N, <.hProcess, .dwMinimumWorkingSetSize, .dwMaximumWorkingSetSize>,  'SetProcessWorkingSetSize',  \
    SetStdHandle, N, <.nStdHandle, .nHandle>,  'SetStdHandle',  \
    SetSystemPowerState, N, <.fSuspend, .fForce>,  'SetSystemPowerState',  \
    SetSystemTime, N, <.lpSystemTime>,  'SetSystemTime',  \
    SetSystemTimeAdjustment, N, <.dwTimeAdjustment, .bTimeAdjustmentDisabled>,  'SetSystemTimeAdjustment',  \
    SetTapeParameters, N, <.hDevice, .dwOperation, .lpTapeInformation>,  'SetTapeParameters',  \
    SetTapePosition, N, <.hDevice, .dwPositionMethod, .dwPartition, .dwOffsetLow, .dwOffsetHigh, .bimmediate>,  'SetTapePosition',  \
    SetTermsrvAppInstallMode, N, <NONE>,  'SetTermsrvAppInstallMode',  \
    SetThreadAffinityMask, N, <.hThread, .dwThreadAffinityMask>,  'SetThreadAffinityMask',  \
    SetThreadContext, N, <.hThread, .lpContext>,  'SetThreadContext',  \
    SetThreadExecutionState, N, <.esFlags>,  'SetThreadExecutionState',  \
    SetThreadIdealProcessor, N, <.hThread, .dwIdealProcessor>,  'SetThreadIdealProcessor',  \
    SetThreadLocale, N, <.Locale>,  'SetThreadLocale',  \
    SetThreadPriority, N, <.hThread, .nPriority>,  'SetThreadPriority',  \
    SetThreadPriorityBoost, N, <.hThread, .bDisablePriorityBoost>,  'SetThreadPriorityBoost',  \
    SetThreadUILanguage, N, <NONE>,  'SetThreadUILanguage',  \
    SetTimeZoneInformation, N, <.lpTimeZoneInformation>,  'SetTimeZoneInformation',  \
    SetTimerQueueTimer, N, <.TimerQueue, .Callback, .Parameter, .DueTime, .Period, .PreferIo>,  'SetTimerQueueTimer',  \
    SetUnhandledExceptionFilter, N, <.lpTopLevelExceptionFilter>,  'SetUnhandledExceptionFilter',  \
    SetUserGeoID, N, <NONE>,  'SetUserGeoID',  \
    SetVDMCurrentDirectories, N, <NONE>,  'SetVDMCurrentDirectories',  \
    SetVolumeLabel, A, <.lpRootPathName, .lpVolumeName>,  'SetVolumeLabelA',  \
    SetVolumeLabel, W, <.lpRootPathName, .lpVolumeName>,  'SetVolumeLabelW',  \
    SetVolumeMountPoint, A, <.lpszVolumeMountPoint, .lpszVolumeName>,  'SetVolumeMountPointA',  \
    SetVolumeMountPoint, W, <.lpszVolumeMountPoint, .lpszVolumeName>,  'SetVolumeMountPointW',  \
    SetWaitableTimer, N, <.hTimer, .lpDueTime, .lPeriod, .pfnCompletionRoutine, .lpArgToCompletionRoutine, .fResume>,  'SetWaitableTimer',  \
    SetupComm, N, <.hFile, .dwInQueue, .dwOutQueue>,  'SetupComm',  \
    ShowConsoleCursor, N, <NONE>,  'ShowConsoleCursor',  \
    SignalObjectAndWait, N, <.hObjectToSignal, .hObjectToWaitOn, .dwMilliseconds, .bAlertable>,  'SignalObjectAndWait',  \
    SizeofResource, N, <.hInstance, .hResInfo>,  'SizeofResource',  \
    Sleep, N, <.dwMilliseconds>,  'Sleep',  \
    SleepEx, N, <.dwMilliseconds, .bAlertable>,  'SleepEx',  \
    SuspendThread, N, <.hThread>,  'SuspendThread',  \
    SwitchToFiber, N, <.lpFiber>,  'SwitchToFiber',  \
    SwitchToThread, N, <VOID>,  'SwitchToThread',  \
    SystemTimeToFileTime, N, <.lpSystemTime, .lpFileTime>,  'SystemTimeToFileTime',  \
    SystemTimeToTzSpecificLocalTime, N, <.lpTimeZoneInformation, .lpUniversalTime, .lpLocalTime>,  'SystemTimeToTzSpecificLocalTime',  \
    TerminateJobObject, N, <.hJob, .uExitCode>,  'TerminateJobObject',  \
    TerminateProcess, N, <.hProcess, .uExitCode>,  'TerminateProcess',  \
    TerminateThread, N, <.hThread, .dwExitCode>,  'TerminateThread',  \
    TermsrvAppInstallMode, N, <NONE>,  'TermsrvAppInstallMode',  \
    Thread32First, N, <.hSnapshot, .lpte>,  'Thread32First',  \
    Thread32Next, N, <.hSnapshot, .lpte>,  'Thread32Next',  \
    TlsAlloc, N, <VOID>,  'TlsAlloc',  \
    TlsFree, N, <.dwTlsIndex>,  'TlsFree',  \
    TlsGetValue, N, <.dwTlsIndex>,  'TlsGetValue',  \
    TlsSetValue, N, <.dwTlsIndex, .lpTlsValue>,  'TlsSetValue',  \
    Toolhelp32ReadProcessMemory, N, <.th32ProcessID, .lpBaseAddress, .lpBuffer, .cbRead, .lpNumberOfBytesRead>,  'Toolhelp32ReadProcessMemory',  \
    TransactNamedPipe, N, <.hNamedPipe, .lpInBuffer, .nInBufferSize, .lpOutBuffer, .nOutBufferSize, .lpBytesRead, .lpOverlapped>,  'TransactNamedPipe',  \
    TransmitCommChar, N, <.nCid, .cChar>,  'TransmitCommChar',  \
    TrimVirtualBuffer, N, <NONE>,  'TrimVirtualBuffer',  \
    TryEnterCriticalSection, N, <.lpCriticalSection>,  'TryEnterCriticalSection',  \
    TzSpecificLocalTimeToSystemTime, N, <NONE>,  'TzSpecificLocalTimeToSystemTime',  \
    UTRegister, N, <NONE>,  'UTRegister',  \
    UTUnRegister, N, <NONE>,  'UTUnRegister',  \
    UnhandledExceptionFilter, N, <.ExceptionInfo>,  'UnhandledExceptionFilter',  \
    UnlockFile, N, <.hFile, .dwFileOffsetLow, .dwFileOffsetHigh, .nNumberOfBytesToUnlockLow, .nNumberOfBytesToUnlockHigh>,  'UnlockFile',  \
    UnlockFileEx, N, <.hFile, .dwReserved, .nNumberOfBytesToUnlockLow, .nNumberOfBytesToUnlockHigh, .lpOverlapped>,  'UnlockFileEx',  \
    UnmapViewOfFile, N, <.lpBaseAddress>,  'UnmapViewOfFile',  \
    UnregisterConsoleIME, N, <NONE>,  'UnregisterConsoleIME',  \
    UnregisterWait, N, <.WaitHandle>,  'UnregisterWait',  \
    UnregisterWaitEx, N, <.WaitHandle, .CompletionEvent>,  'UnregisterWaitEx',  \
    UpdateResource, A, <.hUpdate, .lpType, .lpName, .wLanguage, .lpData, .cbData>,  'UpdateResourceA',  \
    UpdateResource, W, <.hUpdate, .lpType, .lpName, .wLanguage, .lpData, .cbData>,  'UpdateResourceW',  \
    VDMConsoleOperation, N, <NONE>,  'VDMConsoleOperation',  \
    VDMOperationStarted, N, <NONE>,  'VDMOperationStarted',  \
    ValidateLCType, N, <NONE>,  'ValidateLCType',  \
    ValidateLocale, N, <NONE>,  'ValidateLocale',  \
    VerLanguageName, A, <.wLang, .szLang, .nSize>,  'VerLanguageNameA',  \
    VerLanguageName, W, <.wLang, .szLang, .nSize>,  'VerLanguageNameW',  \
    VerSetConditionMask, N, <.ConditionMask, .TypeMask, .Condition>,  'VerSetConditionMask',  \
    VerifyConsoleIoHandle, N, <NONE>,  'VerifyConsoleIoHandle',  \
    VerifyVersionInfo, A, <.lpVersionInformation, .dwTypeMask, .dwlConditionMask>,  'VerifyVersionInfoA',  \
    VerifyVersionInfo, W, <.lpVersionInformation, .dwTypeMask, .dwlConditionMask>,  'VerifyVersionInfoW',  \
    VirtualAlloc, N, <.lpAddress, .dwSize, .flAllocationType, .flProtect>,  'VirtualAlloc',  \
    VirtualAllocEx, N, <.hProcess, .lpAddress, .dwSize, .flAllocationType, .flProtect>,  'VirtualAllocEx',  \
    VirtualBufferExceptionHandler, N, <NONE>,  'VirtualBufferExceptionHandler',  \
    VirtualFree, N, <.lpAddress, .dwSize, .dwFreeType>,  'VirtualFree',  \
    VirtualFreeEx, N, <.hProcess, .lpAddress, .dwSize, .dwFreeType>,  'VirtualFreeEx',  \
    VirtualLock, N, <.lpAddress, .dwSize>,  'VirtualLock',  \
    VirtualProtect, N, <.lpAddress, .dwSize, .flNewProtect, .lpflOldProtect>,  'VirtualProtect',  \
    VirtualProtectEx, N, <.hProcess, .lpAddress, .dwSize, .flNewProtect, .lpflOldProtect>,  'VirtualProtectEx',  \
    VirtualQuery, N, <.lpAddress, .lpBuffer, .dwLength>,  'VirtualQuery',  \
    VirtualQueryEx, N, <.hProcess, .lpAddress, .lpBuffer, .dwLength>,  'VirtualQueryEx',  \
    VirtualUnlock, N, <.lpAddress, .dwSize>,  'VirtualUnlock',  \
    WTSGetActiveConsoleSessionId, N, <NONE>,  'WTSGetActiveConsoleSessionId',  \
    WaitCommEvent, N, <.hFile, .lpEvtMask, .lpOverlapped>,  'WaitCommEvent',  \
    WaitForDebugEvent, N, <.lpDebugEvent, .dwMilliseconds>,  'WaitForDebugEvent',  \
    WaitForMultipleObjects, N, <.nCount, .lpHandles, .bWaitAll, .dwMilliseconds>,  'WaitForMultipleObjects',  \
    WaitForMultipleObjectsEx, N, <.nCount, .lpHandles, .bWaitAll, .dwMilliseconds, .bAlertable>,  'WaitForMultipleObjectsEx',  \
    WaitForSingleObject, N, <.hHandle, .dwMilliseconds>,  'WaitForSingleObject',  \
    WaitForSingleObjectEx, N, <.hHandle, .dwMilliseconds, .bAlertable>,  'WaitForSingleObjectEx',  \
    WaitNamedPipe, A, <.lpNamedPipeName, .nTimeOut>,  'WaitNamedPipeA',  \
    WaitNamedPipe, W, <.lpNamedPipeName, .nTimeOut>,  'WaitNamedPipeW',  \
    WideCharToMultiByte, N, <.CodePage, .dwFlags, .lpWideCharStr, .cchWideChar, .lpMultiByteStr, .cchMultiByte, .lpDefaultChar, .lpUsedDefaultChar>,  'WideCharToMultiByte',  \
    WinExec, N, <.lpCmdLine, .nCmdShow>,  'WinExec',  \
    WriteConsole, A, <.hConsoleOutput, .lpBuffer, .nNumberOfCharsToWrite, .lpNumberOfCharsWritten, .lpReserved>,  'WriteConsoleA',  \
    WriteConsoleInput, A, <.hConsoleInput, .lpBuffer, .nLength, .lpNumberOfEventsWritten>,  'WriteConsoleInputA',  \
    WriteConsoleInputVDM, A, <NONE>,  'WriteConsoleInputVDMA',  \
    WriteConsoleInputVDM, W, <NONE>,  'WriteConsoleInputVDMW',  \
    WriteConsoleInput, W, <.hConsoleInput, .lpBuffer, .nLength, .lpNumberOfEventsWritten>,  'WriteConsoleInputW',  \
    WriteConsoleOutput, A, <.hConsoleOutput, .lpBuffer, .dwBufferSize, .dwBufferCoord, .lpWriteRegion>,  'WriteConsoleOutputA',  \
    WriteConsoleOutputAttribute, N, <.hConsoleOutput, .lpAttribute, .nLength, .dwWriteCoord, .lpNumberOfAttrsWritten>,  'WriteConsoleOutputAttribute',  \
    WriteConsoleOutputCharacter, A, <.hConsoleOutput, .lpCharacter, .nLength, .dwWriteCoord, .lpNumberOfCharsWritten>,  'WriteConsoleOutputCharacterA',  \
    WriteConsoleOutputCharacter, W, <.hConsoleOutput, .lpCharacter, .nLength, .dwWriteCoord, .lpNumberOfCharsWritten>,  'WriteConsoleOutputCharacterW',  \
    WriteConsoleOutput, W, <.hConsoleOutput, .lpBuffer, .dwBufferSize, .dwBufferCoord, .lpWriteRegion>,  'WriteConsoleOutputW',  \
    WriteConsole, W, <.hConsoleOutput, .lpBuffer, .nNumberOfCharsToWrite, .lpNumberOfCharsWritten, .lpReserved>,  'WriteConsoleW',  \
    WriteFile, N, <.hFile, .lpBuffer, .nNumberOfBytesToWrite, .lpNumberOfBytesWritten, .lpOverlapped>,  'WriteFile',  \
    WriteFileEx, N, <.hFile, .lpBuffer, .nNumberOfBytesToWrite, .lpOverlapped, .lpCompletionRoutine>,  'WriteFileEx',  \
    WriteFileGather, N, <.hFile, .aSegmentArray, .nNumberOfBytesToWrite, .lpReserved, .lpOverlapped>,  'WriteFileGather',  \
    WritePrivateProfileSection, A, <.lpAppName, .lpString, .lpFileName>,  'WritePrivateProfileSectionA',  \
    WritePrivateProfileSection, W, <.lpAppName, .lpString, .lpFileName>,  'WritePrivateProfileSectionW',  \
    WritePrivateProfileString, A, <.lpApplicationName, .lpKeyName, .lpString, .lpFileName>,  'WritePrivateProfileStringA',  \
    WritePrivateProfileString, W, <.lpApplicationName, .lpKeyName, .lpString, .lpFileName>,  'WritePrivateProfileStringW',  \
    WritePrivateProfileStruct, A, <.lpszSection, .lpszKey, .lpStruct, .uSizeStruct, .szFile>,  'WritePrivateProfileStructA',  \
    WritePrivateProfileStruct, W, <.lpszSection, .lpszKey, .lpStruct, .uSizeStruct, .szFile>,  'WritePrivateProfileStructW',  \
    WriteProcessMemory, N, <.hProcess, .lpBaseAddress, .lpBuffer, .nSize, .lpNumberOfBytesWritten>,  'WriteProcessMemory',  \
    WriteProfileSection, A, <.lpAppName, .lpString>,  'WriteProfileSectionA',  \
    WriteProfileSection, W, <.lpAppName, .lpString>,  'WriteProfileSectionW',  \
    WriteProfileString, A, <.lpszSection, .lpszKeyName, .lpszString>,  'WriteProfileStringA',  \
    WriteProfileString, W, <.lpszSection, .lpszKeyName, .lpszString>,  'WriteProfileStringW',  \
    WriteTapemark, N, <.hDevice, .dwTapemarkType, .dwTapemarkCount, .bimmediate>,  'WriteTapemark',  \
    ZombifyActCtx, N, <NONE>,  'ZombifyActCtx',  \
    _hread, N, <NONE>,  '_hread',  \
    _hwrite, N, <NONE>,  '_hwrite',  \
    _lclose, N, <NONE>,  '_lclose',  \
    _lcreat, N, <NONE>,  '_lcreat',  \
    _llseek, N, <NONE>,  '_llseek',  \
    _lopen, N, <NONE>,  '_lopen',  \
    _lread, N, <NONE>,  '_lread',  \
    _lwrite, N, <NONE>,  '_lwrite',  \
    lstrcat, A, <.lpString1, .lpString2>,  'lstrcatA',  \
    lstrcat, W, <.lpString1, .lpString2>,  'lstrcatW',  \
    lstrcmp, A, <.lpString1, .lpString2>,  'lstrcmpA',  \
    lstrcmp, W, <.lpString1, .lpString2>,  'lstrcmpW',  \
    lstrcmpi, A, <.lpString1, .lpString2>,  'lstrcmpiA',  \
    lstrcmpi, W, <.lpString1, .lpString2>,  'lstrcmpiW',  \
    lstrcpy, A, <.lpString1, .lpString2>,  'lstrcpyA',  \
    lstrcpy, W, <.lpString1, .lpString2>,  'lstrcpyW',  \
    lstrcpyn, A, <.lpString1, .lpString2, .iMaxLength>,  'lstrcpynA',  \
    lstrcpyn, W, <.lpString1, .lpString2, .iMaxLength>,  'lstrcpynW',  \
    lstrlen, A, <.lpString>,  'lstrlenA',  \
    lstrlen, W, <.lpString>,  'lstrlenW'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/imports/Win32/api/msimg32.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: msimg32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto msimg32,  \
    AlphaBlend, N, <.hdc, .lInt, .BLENDFUNCT>,  'AlphaBlend',  \
    DllInitialize, N, <NONE>,  'DllInitialize',  \
    GradientFill, N, <.hdc, .PTRIVERTEX, .ulong, .pvoid>,  'GradientFill',  \
    TransparentBlt, N, <.hdc, .t, .uint>,  'TransparentBlt',  \
    vSetDdrawflag, N, <NONE>,  'vSetDdrawflag'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































Deleted freshlib/imports/Win32/api/odbc32.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: odbc32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

import_proto odbc32,  \
    CloseODBCPerfData, N, <NONE>,  'CloseODBCPerfData',  \
    CollectODBCPerfData, N, <NONE>,  'CollectODBCPerfData',  \
    CursorLibLockDbc, N, <NONE>,  'CursorLibLockDbc',  \
    CursorLibLockDesc, N, <NONE>,  'CursorLibLockDesc',  \
    CursorLibLockStmt, N, <NONE>,  'CursorLibLockStmt',  \
    CursorLibTransact, N, <NONE>,  'CursorLibTransact',  \
    DllBidEntryPoint, N, <NONE>,  'DllBidEntryPoint',  \
    GetODBCSharedData, N, <NONE>,  'GetODBCSharedData',  \
    LockHandle, N, <NONE>,  'LockHandle',  \
    MpHeapAlloc, N, <NONE>,  'MpHeapAlloc',  \
    MpHeapCompact, N, <NONE>,  'MpHeapCompact',  \
    MpHeapCreate, N, <NONE>,  'MpHeapCreate',  \
    MpHeapDestroy, N, <NONE>,  'MpHeapDestroy',  \
    MpHeapFree, N, <NONE>,  'MpHeapFree',  \
    MpHeapReAlloc, N, <NONE>,  'MpHeapReAlloc',  \
    MpHeapSize, N, <NONE>,  'MpHeapSize',  \
    MpHeapValidate, N, <NONE>,  'MpHeapValidate',  \
    ODBCGetTryWaitValue, N, <VOID>,  'ODBCGetTryWaitValue',  \
    ODBCInternalConnect, W, <NONE>,  'ODBCInternalConnectW',  \
    ODBCQualifyFileDSN, W, <NONE>,  'ODBCQualifyFileDSNW',  \
    ODBCSetTryWaitValue, N, <.dwValue>,  'ODBCSetTryWaitValue',  \
    OpenODBCPerfData, N, <NONE>,  'OpenODBCPerfData',  \
    PostComponentError, N, <NONE>,  'PostComponentError',  \
    PostODBCComponentError, N, <NONE>,  'PostODBCComponentError',  \
    PostODBCError, N, <NONE>,  'PostODBCError',  \
    SQLAllocConnect, N, <.henv, .phdbc>,  'SQLAllocConnect',  \
    SQLAllocEnv, N, <.phenv>,  'SQLAllocEnv',  \
    SQLAllocHandle, N, <.HandleType, .InputHandle, .OutputHandle>,  'SQLAllocHandle',  \
    SQLAllocHandleStd, N, <.fHandleType, .hInput, .phOutput>,  'SQLAllocHandleStd',  \
    SQLAllocStmt, N, <.hdbc, .phstmt>,  'SQLAllocStmt',  \
    SQLBindCol, N, <.hstmt, .icol, .fCType, .rgbValue, .cbValueMax, .pcbValue>,  'SQLBindCol',  \
    SQLBindParam, N, <.StatementHandle, .ParameterNumber, .ValueType, .ParameterType, .LengthPrecision, .ParameterScale, .ParameterValue, .StrLen_or_Ind>,  'SQLBindParam',  \
    SQLBindParameter, N, <.hstmt, .ipar, .fParamType, .fCType, .fSqlType, .cbColDef, .ibScale, .rgbValue, .cbValueMax, .pcbValue>,  'SQLBindParameter',  \
    SQLBrowseConnect, N, <.hdbc, .szConnStrIn, .cbConnStrIn, .szConnStrOut, .cbConnStrOutMax, .pcbConnStrOut>,  'SQLBrowseConnect',  \
    SQLBrowseConnect, A, <.hdbc, .szConnStrIn, .cbConnStrIn, .szConnStrOut, .cbConnStrOutMax, .pcbConnStrOut>,  'SQLBrowseConnectA',  \
    SQLBrowseConnect, W, <.hdbc, .szConnStrIn, .cbConnStrIn, .szConnStrOut, .cbConnStrOutMax, .pcbConnStrOut>,  'SQLBrowseConnectW',  \
    SQLBulkOperations, N, <.StatementHandle, .Operation>,  'SQLBulkOperations',  \
    SQLCancel, N, <.hstmt>,  'SQLCancel',  \
    SQLCloseCursor, N, <.StatementHandle>,  'SQLCloseCursor',  \
    SQLColAttribute, N, <.hstmt, .iCol, .iField, .pCharAttr, .cbCharAttrMax, .pcbCharAttr, .pNumAttr>,  'SQLColAttribute',  \
    SQLColAttribute, A, <.hstmt, .iCol, .iField, .pCharAttr, .cbCharAttrMax, .pcbCharAttr, .pNumAttr>,  'SQLColAttributeA',  \
    SQLColAttribute, W, <.hstmt, .iCol, .iField, .pCharAttr, .cbCharAttrMax, .pcbCharAttr, .pNumAttr>,  'SQLColAttributeW',  \
    SQLColAttributes, N, <.hstmt, .icol, .fDescType, .rgbDesc, .cbDescMax, .pcbDesc, .pfDesc>,  'SQLColAttributes',  \
    SQLColAttributes, A, <.hstmt, .icol, .fDescType, .rgbDesc, .cbDescMax, .pcbDesc, .pfDesc>,  'SQLColAttributesA',  \
    SQLColAttributes, W, <.hstmt, .icol, .fDescType, .rgbDesc, .cbDescMax, .pcbDesc, .pfDesc>,  'SQLColAttributesW',  \
    SQLColumnPrivileges, N, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .szColumnName, .cbColumnName>,  'SQLColumnPrivileges',  \
    SQLColumnPrivileges, A, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .szColumnName, .cbColumnName>,  'SQLColumnPrivilegesA',  \
    SQLColumnPrivileges, W, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .szColumnName, .cbColumnName>,  'SQLColumnPrivilegesW',  \
    SQLColumns, N, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .szColumnName, .cbColumnName>,  'SQLColumns',  \
    SQLColumns, A, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .szColumnName, .cbColumnName>,  'SQLColumnsA',  \
    SQLColumns, W, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .szColumnName, .cbColumnName>,  'SQLColumnsW',  \
    SQLConnect, N, <.hdbc, .szDSN, .cbDSN, .szUID, .cbUID, .szAuthStr, .cbAuthStr>,  'SQLConnect',  \
    SQLConnect, A, <.hdbc, .szDSN, .cbDSN, .szUID, .cbUID, .szAuthStr, .cbAuthStr>,  'SQLConnectA',  \
    SQLConnect, W, <.hdbc, .szDSN, .cbDSN, .szUID, .cbUID, .szAuthStr, .cbAuthStr>,  'SQLConnectW',  \
    SQLCopyDesc, N, <.SourceDescHandle, .TargetDescHandle>,  'SQLCopyDesc',  \
    SQLDataSources, N, <.henv, .fDirection, .szDSN, .cbDSNMax, .pcbDSN, .szDescription, .cbDescriptionMax, .pcbDescription>,  'SQLDataSources',  \
    SQLDataSources, A, <.henv, .fDirection, .szDSN, .cbDSNMax, .pcbDSN, .szDescription, .cbDescriptionMax, .pcbDescription>,  'SQLDataSourcesA',  \
    SQLDataSources, W, <.henv, .fDirection, .szDSN, .cbDSNMax, .pcbDSN, .szDescription, .cbDescriptionMax, .pcbDescription>,  'SQLDataSourcesW',  \
    SQLDescribeCol, N, <.hstmt, .icol, .szColName, .cbColNameMax, .pcbColName, .pfSqlType, .pcbColDef, .pibScale, .pfNullable>,  'SQLDescribeCol',  \
    SQLDescribeCol, A, <.hstmt, .icol, .szColName, .cbColNameMax, .pcbColName, .pfSqlType, .pcbColDef, .pibScale, .pfNullable>,  'SQLDescribeColA',  \
    SQLDescribeCol, W, <.hstmt, .icol, .szColName, .cbColNameMax, .pcbColName, .pfSqlType, .pcbColDef, .pibScale, .pfNullable>,  'SQLDescribeColW',  \
    SQLDescribeParam, N, <.hstmt, .ipar, .pfSqlType, .pcbParamDef, .pibScale, .pfNullable>,  'SQLDescribeParam',  \
    SQLDisconnect, N, <.hdbc>,  'SQLDisconnect',  \
    SQLDriverConnect, N, <.hdbc, .hwnd, .szConnStrIn, .cbConnStrIn, .szConnStrOut, .cbConnStrOutMax, .pcbConnStrOut, .fDriverCompletion>,  'SQLDriverConnect',  \
    SQLDriverConnect, A, <.hdbc, .hwnd, .szConnStrIn, .cbConnStrIn, .szConnStrOut, .cbConnStrOutMax, .pcbConnStrOut, .fDriverCompletion>,  'SQLDriverConnectA',  \
    SQLDriverConnect, W, <.hdbc, .hwnd, .szConnStrIn, .cbConnStrIn, .szConnStrOut, .cbConnStrOutMax, .pcbConnStrOut, .fDriverCompletion>,  'SQLDriverConnectW',  \
    SQLDrivers, N, <.henv, .fDirection, .szDriverDesc, .cbDriverDescMax, .pcbDriverDesc, .szDriverAttributes, .cbDrvrAttrMax, .pcbDrvrAttr>,  'SQLDrivers',  \
    SQLDrivers, A, <.henv, .fDirection, .szDriverDesc, .cbDriverDescMax, .pcbDriverDesc, .szDriverAttributes, .cbDrvrAttrMax, .pcbDrvrAttr>,  'SQLDriversA',  \
    SQLDrivers, W, <.henv, .fDirection, .szDriverDesc, .cbDriverDescMax, .pcbDriverDesc, .szDriverAttributes, .cbDrvrAttrMax, .pcbDrvrAttr>,  'SQLDriversW',  \
    SQLEndTran, N, <.HandleType, .handle, .CompletionType>,  'SQLEndTran',  \
    SQLError, N, <.henv, .hdbc, .hstmt, .szSqlState, .pfNativeError, .szErrorMsg, .cbErrorMsgMax, .pcbErrorMsg>,  'SQLError',  \
    SQLError, A, <.henv, .hdbc, .hstmt, .szSqlState, .pfNativeError, .szErrorMsg, .cbErrorMsgMax, .pcbErrorMsg>,  'SQLErrorA',  \
    SQLError, W, <.henv, .hdbc, .hstmt, .szSqlState, .pfNativeError, .szErrorMsg, .cbErrorMsgMax, .pcbErrorMsg>,  'SQLErrorW',  \
    SQLExecDirect, N, <.hstmt, .szSqlStr, .cbSqlStr>,  'SQLExecDirect',  \
    SQLExecDirect, A, <.hstmt, .szSqlStr, .cbSqlStr>,  'SQLExecDirectA',  \
    SQLExecDirect, W, <.hstmt, .szSqlStr, .cbSqlStr>,  'SQLExecDirectW',  \
    SQLExecute, N, <.hstmt>,  'SQLExecute',  \
    SQLExtendedFetch, N, <.hstmt, .fFetchType, .irow, .pcrow, .rgfRowStatus>,  'SQLExtendedFetch',  \
    SQLFetch, N, <.hstmt>,  'SQLFetch',  \
    SQLFetchScroll, N, <.StatementHandle, .FetchOrientation, .FetchOffset>,  'SQLFetchScroll',  \
    SQLForeignKeys, N, <.hstmt, .szPkCatalogName, .cbPkCatalogName, .szPkSchemaName, .cbPkSchemaName, .szPkTableName, .cbPkTableName, .szFkCatalogName, .cbFkCatalogName, .szFkSchemaName, .cbFkSchemaName, .szFkTableName, .cbFkTableName>,  'SQLForeignKeys',
    SQLForeignKeys, A, <.hstmt, .szPkCatalogName, .cbPkCatalogName, .szPkSchemaName, .cbPkSchemaName, .szPkTableName, .cbPkTableName, .szFkCatalogName, .cbFkCatalogName, .szFkSchemaName, .cbFkSchemaName, .szFkTableName, .cbFkTableName>,  'SQLForeignKeysA',
    SQLForeignKeys, W, <.hstmt, .szPkCatalogName, .cbPkCatalogName, .szPkSchemaName, .cbPkSchemaName, .szPkTableName, .cbPkTableName, .szFkCatalogName, .cbFkCatalogName, .szFkSchemaName, .cbFkSchemaName, .szFkTableName, .cbFkTableName>,  'SQLForeignKeysW',
    SQLFreeConnect, N, <.hdbc>,  'SQLFreeConnect',  \
    SQLFreeEnv, N, <.henv>,  'SQLFreeEnv',  \
    SQLFreeHandle, N, <.HandleType, .handle>,  'SQLFreeHandle',  \
    SQLFreeStmt, N, <.hstmt, .fOption>,  'SQLFreeStmt',  \
    SQLGetConnectAttr, N, <.ConnectionHandle, .lAttribute, .lValue, .BufferLength, .StringLength>,  'SQLGetConnectAttr',  \
    SQLGetConnectAttr, A, <.ConnectionHandle, .lAttribute, .lValue, .BufferLength, .StringLength>,  'SQLGetConnectAttrA',  \
    SQLGetConnectAttr, W, <.ConnectionHandle, .lAttribute, .lValue, .BufferLength, .StringLength>,  'SQLGetConnectAttrW',  \
    SQLGetConnectOption, N, <.hdbc, .fOption, .pvParam>,  'SQLGetConnectOption',  \
    SQLGetConnectOption, A, <.hdbc, .fOption, .pvParam>,  'SQLGetConnectOptionA',  \
    SQLGetConnectOption, W, <.hdbc, .fOption, .pvParam>,  'SQLGetConnectOptionW',  \
    SQLGetCursorName, N, <.hstmt, .szCursor, .cbCursorMax, .pcbCursor>,  'SQLGetCursorName',  \
    SQLGetCursorName, A, <.hstmt, .szCursor, .cbCursorMax, .pcbCursor>,  'SQLGetCursorNameA',  \
    SQLGetCursorName, W, <.hstmt, .szCursor, .cbCursorMax, .pcbCursor>,  'SQLGetCursorNameW',  \
    SQLGetData, N, <.hstmt, .icol, .fCType, .rgbValue, .cbValueMax, .pcbValue>,  'SQLGetData',  \
    SQLGetDescField, N, <.hdesc, .iRecord, .iField, .rgbValue, .cbValueMax, .pcbValue>,  'SQLGetDescField',  \
    SQLGetDescField, A, <.hdesc, .iRecord, .iField, .rgbValue, .cbValueMax, .pcbValue>,  'SQLGetDescFieldA',  \
    SQLGetDescField, W, <.hdesc, .iRecord, .iField, .rgbValue, .cbValueMax, .pcbValue>,  'SQLGetDescFieldW',  \
    SQLGetDescRec, N, <.hdesc, .iRecord, .szName, .cbNameMax, .pcbName, .pfType, .pfSubType, .pLength, .pPrecision, .pScale, .pNullable>,  'SQLGetDescRec',  \
    SQLGetDescRec, A, <.hdesc, .iRecord, .szName, .cbNameMax, .pcbName, .pfType, .pfSubType, .pLength, .pPrecision, .pScale, .pNullable>,  'SQLGetDescRecA',  \
    SQLGetDescRec, W, <.hdesc, .iRecord, .szName, .cbNameMax, .pcbName, .pfType, .pfSubType, .pLength, .pPrecision, .pScale, .pNullable>,  'SQLGetDescRecW',  \
    SQLGetDiagField, N, <.HandleType, .handle, .RecNumber, .DiagIdentifier, .DiagInfo, .BufferLength, .StringLength>,  'SQLGetDiagField',  \
    SQLGetDiagField, A, <.HandleType, .handle, .RecNumber, .DiagIdentifier, .DiagInfo, .BufferLength, .StringLength>,  'SQLGetDiagFieldA',  \
    SQLGetDiagField, W, <.HandleType, .handle, .RecNumber, .DiagIdentifier, .DiagInfo, .BufferLength, .StringLength>,  'SQLGetDiagFieldW',  \
    SQLGetDiagRec, N, <.fHandleType, .handle, .iRecord, .szSqlState, .pfNativeError, .szErrorMsg, .cbErrorMsgMax, .pcbErrorMsg>,  'SQLGetDiagRec',  \
    SQLGetDiagRec, A, <.fHandleType, .handle, .iRecord, .szSqlState, .pfNativeError, .szErrorMsg, .cbErrorMsgMax, .pcbErrorMsg>,  'SQLGetDiagRecA',  \
    SQLGetDiagRec, W, <.fHandleType, .handle, .iRecord, .szSqlState, .pfNativeError, .szErrorMsg, .cbErrorMsgMax, .pcbErrorMsg>,  'SQLGetDiagRecW',  \
    SQLGetEnvAttr, N, <.EnvironmentHandle, .lAttribute, .lValue, .BufferLength, .StringLength>,  'SQLGetEnvAttr',  \
    SQLGetFunctions, N, <.hdbc, .fFunction, .pfExists>,  'SQLGetFunctions',  \
    SQLGetInfo, N, <.hdbc, .fInfoType, .rgbInfoValue, .cbInfoValueMax, .pcbInfoValue>,  'SQLGetInfo',  \
    SQLGetInfo, A, <.hdbc, .fInfoType, .rgbInfoValue, .cbInfoValueMax, .pcbInfoValue>,  'SQLGetInfoA',  \
    SQLGetInfo, W, <.hdbc, .fInfoType, .rgbInfoValue, .cbInfoValueMax, .pcbInfoValue>,  'SQLGetInfoW',  \
    SQLGetStmtAttr, N, <.hstmt, .fAttribute, .rgbValue, .cbValueMax, .pcbValue>,  'SQLGetStmtAttr',  \
    SQLGetStmtAttr, A, <.hstmt, .fAttribute, .rgbValue, .cbValueMax, .pcbValue>,  'SQLGetStmtAttrA',  \
    SQLGetStmtAttr, W, <.hstmt, .fAttribute, .rgbValue, .cbValueMax, .pcbValue>,  'SQLGetStmtAttrW',  \
    SQLGetStmtOption, N, <.hstmt, .fOption, .pvParam>,  'SQLGetStmtOption',  \
    SQLGetTypeInfo, N, <.hstmt, .fSqlType>,  'SQLGetTypeInfo',  \
    SQLGetTypeInfo, A, <.hstmt, .fSqlType>,  'SQLGetTypeInfoA',  \
    SQLGetTypeInfo, W, <.hstmt, .fSqlType>,  'SQLGetTypeInfoW',  \
    SQLMoreResults, N, <.hstmt>,  'SQLMoreResults',  \
    SQLNativeSql, N, <.hdbc, .szSqlStrIn, .cbSqlStrIn, .szSqlStr, .cbSqlStrMax, .pcbSqlStr>,  'SQLNativeSql',  \
    SQLNativeSql, A, <.hdbc, .szSqlStrIn, .cbSqlStrIn, .szSqlStr, .cbSqlStrMax, .pcbSqlStr>,  'SQLNativeSqlA',  \
    SQLNativeSql, W, <.hdbc, .szSqlStrIn, .cbSqlStrIn, .szSqlStr, .cbSqlStrMax, .pcbSqlStr>,  'SQLNativeSqlW',  \
    SQLNumParams, N, <.hstmt, .pcpar>,  'SQLNumParams',  \
    SQLNumResultCols, N, <.hstmt, .pccol>,  'SQLNumResultCols',  \
    SQLParamData, N, <.hstmt, .prgbValue>,  'SQLParamData',  \
    SQLParamOptions, N, <.hstmt, .crow, .pirow>,  'SQLParamOptions',  \
    SQLPrepare, N, <.hstmt, .szSqlStr, .cbSqlStr>,  'SQLPrepare',  \
    SQLPrepare, A, <.hstmt, .szSqlStr, .cbSqlStr>,  'SQLPrepareA',  \
    SQLPrepare, W, <.hstmt, .szSqlStr, .cbSqlStr>,  'SQLPrepareW',  \
    SQLPrimaryKeys, N, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName>,  'SQLPrimaryKeys',  \
    SQLPrimaryKeys, A, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName>,  'SQLPrimaryKeysA',  \
    SQLPrimaryKeys, W, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName>,  'SQLPrimaryKeysW',  \
    SQLProcedureColumns, N, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szProcName, .cbProcName, .szColumnName, .cbColumnName>,  'SQLProcedureColumns',  \
    SQLProcedureColumns, A, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szProcName, .cbProcName, .szColumnName, .cbColumnName>,  'SQLProcedureColumnsA',  \
    SQLProcedureColumns, W, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szProcName, .cbProcName, .szColumnName, .cbColumnName>,  'SQLProcedureColumnsW',  \
    SQLProcedures, N, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szProcName, .cbProcName>,  'SQLProcedures',  \
    SQLProcedures, A, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szProcName, .cbProcName>,  'SQLProceduresA',  \
    SQLProcedures, W, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szProcName, .cbProcName>,  'SQLProceduresW',  \
    SQLPutData, N, <.hstmt, .rgbValue, .cbValue>,  'SQLPutData',  \
    SQLRowCount, N, <.hstmt, .pcrow>,  'SQLRowCount',  \
    SQLSetConnectAttr, N, <.hdbc, .fAttribute, .rgbValue, .cbValue>,  'SQLSetConnectAttr',  \
    SQLSetConnectAttr, A, <.hdbc, .fAttribute, .rgbValue, .cbValue>,  'SQLSetConnectAttrA',  \
    SQLSetConnectAttr, W, <.hdbc, .fAttribute, .rgbValue, .cbValue>,  'SQLSetConnectAttrW',  \
    SQLSetConnectOption, N, <.hdbc, .fOption, .vParam>,  'SQLSetConnectOption',  \
    SQLSetConnectOption, A, <.hdbc, .fOption, .vParam>,  'SQLSetConnectOptionA',  \
    SQLSetConnectOption, W, <.hdbc, .fOption, .vParam>,  'SQLSetConnectOptionW',  \
    SQLSetCursorName, N, <.hstmt, .szCursor, .cbCursor>,  'SQLSetCursorName',  \
    SQLSetCursorName, A, <.hstmt, .szCursor, .cbCursor>,  'SQLSetCursorNameA',  \
    SQLSetCursorName, W, <.hstmt, .szCursor, .cbCursor>,  'SQLSetCursorNameW',  \
    SQLSetDescField, N, <.DescriptorHandle, .RecNumber, .FieldIdentifier, .Value, .BufferLength>,  'SQLSetDescField',  \
    SQLSetDescField, A, <.DescriptorHandle, .RecNumber, .FieldIdentifier, .Value, .BufferLength>,  'SQLSetDescFieldA',  \
    SQLSetDescField, W, <.DescriptorHandle, .RecNumber, .FieldIdentifier, .Value, .BufferLength>,  'SQLSetDescFieldW',  \
    SQLSetDescRec, N, <.DescriptorHandle, .RecNumber, .lType, .SubType, .Length, .Precision, .kScale, .Data, .StringLength, .Indicator>,  'SQLSetDescRec',  \
    SQLSetEnvAttr, N, <.EnvironmentHandle, .lAttribute, .Value, .StringLength>,  'SQLSetEnvAttr',  \
    SQLSetParam, N, <.hstmt, .ipar, .fCType, .fSqlType, .cbParamDef, .ibScale, .rgbValue, .pcbValue>,  'SQLSetParam',  \
    SQLSetPos, N, <.hstmt, .irow, .fOption, .fLock>,  'SQLSetPos',  \
    SQLSetScrollOptions, N, <.hstmt, .fConcurrency, .crowKeyset, .crowRowset>,  'SQLSetScrollOptions',  \
    SQLSetStmtAttr, N, <.StatementHandle, .lAttribute, .Value, .StringLength>,  'SQLSetStmtAttr',  \
    SQLSetStmtAttr, A, <.StatementHandle, .lAttribute, .Value, .StringLength>,  'SQLSetStmtAttrA',  \
    SQLSetStmtAttr, W, <.StatementHandle, .lAttribute, .Value, .StringLength>,  'SQLSetStmtAttrW',  \
    SQLSetStmtOption, N, <.hstmt, .fOption, .vParam>,  'SQLSetStmtOption',  \
    SQLSpecialColumns, N, <.hstmt, .fColType, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .fScope, .fNullable>,  'SQLSpecialColumns',  \
    SQLSpecialColumns, A, <.hstmt, .fColType, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .fScope, .fNullable>,  'SQLSpecialColumnsA',  \
    SQLSpecialColumns, W, <.hstmt, .fColType, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .fScope, .fNullable>,  'SQLSpecialColumnsW',  \
    SQLStatistics, N, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .fUnique, .fAccuracy>,  'SQLStatistics',  \
    SQLStatistics, A, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .fUnique, .fAccuracy>,  'SQLStatisticsA',  \
    SQLStatistics, W, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .fUnique, .fAccuracy>,  'SQLStatisticsW',  \
    SQLTablePrivileges, N, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName>,  'SQLTablePrivileges',  \
    SQLTablePrivileges, A, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName>,  'SQLTablePrivilegesA',  \
    SQLTablePrivileges, W, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName>,  'SQLTablePrivilegesW',  \
    SQLTables, N, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .szTableType, .cbTableType>,  'SQLTables',  \
    SQLTables, A, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .szTableType, .cbTableType>,  'SQLTablesA',  \
    SQLTables, W, <.hstmt, .szCatalogName, .cbCatalogName, .szSchemaName, .cbSchemaName, .szTableName, .cbTableName, .szTableType, .cbTableType>,  'SQLTablesW',  \
    SQLTransact, N, <.henv, .hdbc, .fType>,  'SQLTransact',  \
    SearchStatusCode, N, <NONE>,  'SearchStatusCode',  \
    VFreeErrors, N, <NONE>,  'VFreeErrors',  \
    VRetrieveDriverErrorsRowCol, N, <NONE>,  'VRetrieveDriverErrorsRowCol',  \
    ValidateErrorQueue, N, <NONE>,  'ValidateErrorQueue',  \
    g_hHeapMalloc, N, <NONE>,  'g_hHeapMalloc'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































































































Deleted freshlib/imports/Win32/api/ole32.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: ole32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto ole32,  \
    BindMoniker, N, <.pmk, .grfOpt, .iidResult, .ppvResult>,  'BindMoniker',  \
    CLIPFORMAT_UserFree, N, <.pLong, .pClipformat>,  'CLIPFORMAT_UserFree',  \
    CLIPFORMAT_UserMarshal, N, <.pLong, .pChar, .pClipformat>,  'CLIPFORMAT_UserMarshal',  \
    CLIPFORMAT_UserSize, N, <.pLong, .lLong, .pClipformat>,  'CLIPFORMAT_UserSize',  \
    CLIPFORMAT_UserUnmarshal, N, <.pLong, .pChar, .pClipformat>,  'CLIPFORMAT_UserUnmarshal',  \
    CLSIDFromOle1Class, N, <NONE>,  'CLSIDFromOle1Class',  \
    CLSIDFromProgID, N, <.TSzProgID, .T>,  'CLSIDFromProgID',  \
    CLSIDFromProgIDEx, N, <.lpszProgID, .lpclsid>,  'CLSIDFromProgIDEx',  \
    CLSIDFromString, N, <.lpsz, .pclsid>,  'CLSIDFromString',  \
    CoAddRefServerProcess, N, <VOID>,  'CoAddRefServerProcess',  \
    CoAllowSetForegroundWindow, N, <.pUnk, .lpvReserved>,  'CoAllowSetForegroundWindow',  \
    CoBuildVersion, N, <VOID>,  'CoBuildVersion',  \
    CoCancelCall, N, <.dwThreadId, .ulTimeout>,  'CoCancelCall',  \
    CoCopyProxy, N, <.pProxy, .ppCopy>,  'CoCopyProxy',  \
    CoCreateFreeThreadedMarshaler, N, <.punkOuter, .ppunkMarshal>,  'CoCreateFreeThreadedMarshaler',  \
    CoCreateGuid, N, <.pguid>,  'CoCreateGuid',  \
    CoCreateInstance, N, <.rclsid, .pUnkOuter, .dwClsContext, .riid, .ppv>,  'CoCreateInstance',  \
    CoCreateInstanceEx, N, <.Clsid, .punkOuter, .dwClsCtx, .pServerInfo, .dwCount, .pResults>,  'CoCreateInstanceEx',  \
    CoCreateObjectInContext, N, <NONE>,  'CoCreateObjectInContext',  \
    CoDeactivateObject, N, <NONE>,  'CoDeactivateObject',  \
    CoDisableCallCancellation, N, <.pReserved>,  'CoDisableCallCancellation',  \
    CoDisconnectObject, N, <.pUnk, .dwReserved>,  'CoDisconnectObject',  \
    CoDosDateTimeToFileTime, N, <.nDosDate, .nDosTime, .lpFileTime>,  'CoDosDateTimeToFileTime',  \
    CoEnableCallCancellation, N, <.pReserved>,  'CoEnableCallCancellation',  \
    CoFileTimeNow, N, <.lpFileTime>,  'CoFileTimeNow',  \
    CoFileTimeToDosDateTime, N, <.lpFileTime, .lpDosDate, .lpDosTime>,  'CoFileTimeToDosDateTime',  \
    CoFreeAllLibraries, N, <VOID>,  'CoFreeAllLibraries',  \
    CoFreeLibrary, N, <.hInst>,  'CoFreeLibrary',  \
    CoFreeUnusedLibraries, N, <VOID>,  'CoFreeUnusedLibraries',  \
    CoFreeUnusedLibrariesEx, N, <NONE>,  'CoFreeUnusedLibrariesEx',  \
    CoGetApartmentID, N, <NONE>,  'CoGetApartmentID',  \
    CoGetCallContext, N, <.riid, .ppInterface>,  'CoGetCallContext',  \
    CoGetCallerTID, N, <NONE>,  'CoGetCallerTID',  \
    CoGetCancelObject, N, <.dwThreadId, .iid, .ppUnk>,  'CoGetCancelObject',  \
    CoGetClassObject, N, <.rclsid, .dwClsContext, .pvReserved, .riid, .ppv>,  'CoGetClassObject',  \
    CoGetClassVersion, N, <.pClassSpec, .pdwVersionMS, .pdwVersionLS>,  'CoGetClassVersion',  \
    CoGetComCatalog, N, <NONE>,  'CoGetComCatalog',  \
    CoGetContextToken, N, <NONE>,  'CoGetContextToken',  \
    CoGetCurrentLogicalThreadId, N, <NONE>,  'CoGetCurrentLogicalThreadId',  \
    CoGetCurrentProcess, N, <VOID>,  'CoGetCurrentProcess',  \
    CoGetDefaultContext, N, <NONE>,  'CoGetDefaultContext',  \
    CoGetInstanceFromFile, N, <.pServerInfo, .pClsid, .punkOuter, .dwClsCtx, .grfMode, .pwszName, .dwCount, .pResults>,  'CoGetInstanceFromFile',  \
    CoGetInstanceFromIStorage, N, <.pServerInfo, .pClsid, .punkOuter, .dwClsCtx, .pstg, .dwCount, .pResults>,  'CoGetInstanceFromIStorage',  \
    CoGetInterceptor, N, <NONE>,  'CoGetInterceptor',  \
    CoGetInterceptorFromTypeInfo, N, <NONE>,  'CoGetInterceptorFromTypeInfo',  \
    CoGetInterfaceAndReleaseStream, N, <.pStm, .iid, .ppv>,  'CoGetInterfaceAndReleaseStream',  \
    CoGetMalloc, N, <.dwMemContext, .ppMalloc>,  'CoGetMalloc',  \
    CoGetMarshalSizeMax, N, <.pulSize, .riid, .pUnk, .dwDestContext, .pvDestContext, .mshlflags>,  'CoGetMarshalSizeMax',  \
    CoGetObject, N, <.pszName, .pBindOptions, .riid, .ppv>,  'CoGetObject',  \
    CoGetObjectContext, N, <.riid, .ppv>,  'CoGetObjectContext',  \
    CoGetPSClsid, N, <.riid, .pClsid>,  'CoGetPSClsid',  \
    CoGetProcessIdentifier, N, <NONE>,  'CoGetProcessIdentifier',  \
    CoGetStandardMarshal, N, <.riid, .pUnk, .dwDestContext, .pvDestContext, .mshlflags, .ppMarshal>,  'CoGetStandardMarshal',  \
    CoGetState, N, <NONE>,  'CoGetState',  \
    CoGetStdMarshalEx, N, <.pUnkOuter, .smexflags, .ppUnkInner>,  'CoGetStdMarshalEx',  \
    CoGetSystemSecurityPermissions, N, <NONE>,  'CoGetSystemSecurityPermissions',  \
    CoGetTreatAsClass, N, <.clsidOld, .pClsidNew>,  'CoGetTreatAsClass',  \
    CoImpersonateClient, N, <VOID>,  'CoImpersonateClient',  \
    CoInitialize, N, <.pzReserved>,  'CoInitialize',  \
    CoInitializeEx, N, <.pvReserved, .dwCoInit>,  'CoInitializeEx',  \
    CoInitializeSecurity, N, <.pSecDesc, .cAuthSvc, .asAuthSvc, .pReserved1, .dwAuthnLevel, .dwImpLevel, .pAuthList, .dwCapabilities, .pReserved3>,  'CoInitializeSecurity',  \
    CoInitializeWO, W, <NONE>,  'CoInitializeWOW',  \
    CoInstall, N, <.pbc, .dwFlags, .pClassSpec, .pQuery, .pszCodeBase>,  'CoInstall',  \
    CoInvalidateRemoteMachineBindings, N, <NONE>,  'CoInvalidateRemoteMachineBindings',  \
    CoIsHandlerConnected, N, <.pUnk>,  'CoIsHandlerConnected',  \
    CoIsOle1Class, N, <.rclsid>,  'CoIsOle1Class',  \
    CoLoadLibrary, N, <.lpszLibName, .bAutoFree>,  'CoLoadLibrary',  \
    CoLockObjectExternal, N, <.pUnk, .fLock, .fLastUnlockReleases>,  'CoLockObjectExternal',  \
    CoMarshalHresult, N, <.pstm, .hresult>,  'CoMarshalHresult',  \
    CoMarshalInterThreadInterfaceInStream, N, <.riid, .pUnk, .ppStm>,  'CoMarshalInterThreadInterfaceInStream',  \
    CoMarshalInterface, N, <.pStm, .riid, .pUnk, .dwDestContext, .pvDestContext, .mshlflags>,  'CoMarshalInterface',  \
    CoPopServiceDomain, N, <NONE>,  'CoPopServiceDomain',  \
    CoPushServiceDomain, N, <NONE>,  'CoPushServiceDomain',  \
    CoQueryAuthenticationServices, N, <.pcAuthSvc, .asAuthSvc>,  'CoQueryAuthenticationServices',  \
    CoQueryClientBlanket, N, <.pAuthnSvc, .pAuthzSvc, .pServerPrincName, .pAuthnLevel, .pImpLevel, .pPrivs, .pCapabilities>,  'CoQueryClientBlanket',  \
    CoQueryProxyBlanket, N, <.pProxy, .pwAuthnSvc, .pAuthzSvc, .pServerPrincName, .pAuthnLevel, .pImpLevel, .pAuthInfo, .pCapabilites>,  'CoQueryProxyBlanket',  \
    CoQueryReleaseObject, N, <NONE>,  'CoQueryReleaseObject',  \
    CoReactivateObject, N, <NONE>,  'CoReactivateObject',  \
    CoRegisterChannelHook, N, <.ExtensionUuid, .pChannelHook>,  'CoRegisterChannelHook',  \
    CoRegisterClassObject, N, <.rclsid, .pUnk, .dwClsContext, .flags, .lpdwRegister>,  'CoRegisterClassObject',  \
    CoRegisterInitializeSpy, N, <NONE>,  'CoRegisterInitializeSpy',  \
    CoRegisterMallocSpy, N, <.pMallocSpy>,  'CoRegisterMallocSpy',  \
    CoRegisterMessageFilter, N, <.lpMessageFilter, .lplpMessageFilter>,  'CoRegisterMessageFilter',  \
    CoRegisterPSClsid, N, <.riid, .rclsid>,  'CoRegisterPSClsid',  \
    CoRegisterSurrogate, N, <.pSurrogate>,  'CoRegisterSurrogate',  \
    CoRegisterSurrogateEx, N, <NONE>,  'CoRegisterSurrogateEx',  \
    CoReleaseMarshalData, N, <.pStm>,  'CoReleaseMarshalData',  \
    CoReleaseServerProcess, N, <VOID>,  'CoReleaseServerProcess',  \
    CoResumeClassObjects, N, <VOID>,  'CoResumeClassObjects',  \
    CoRetireServer, N, <NONE>,  'CoRetireServer',  \
    CoRevertToSelf, N, <VOID>,  'CoRevertToSelf',  \
    CoRevokeClassObject, N, <.dwRegister>,  'CoRevokeClassObject',  \
    CoRevokeInitializeSpy, N, <NONE>,  'CoRevokeInitializeSpy',  \
    CoRevokeMallocSpy, N, <VOID>,  'CoRevokeMallocSpy',  \
    CoSetCancelObject, N, <.pUnk>,  'CoSetCancelObject',  \
    CoSetProxyBlanket, N, <.pProxy, .dwAuthnSvc, .dwAuthzSvc, .pServerPrincName, .dwAuthnLevel, .dwImpLevel, .pAuthInfo, .dwCapabilities>,  'CoSetProxyBlanket',  \
    CoSetState, N, <NONE>,  'CoSetState',  \
    CoSuspendClassObjects, N, <VOID>,  'CoSuspendClassObjects',  \
    CoSwitchCallContext, N, <.pNewObject, .ppOldObject>,  'CoSwitchCallContext',  \
    CoTaskMemAlloc, N, <.cb>,  'CoTaskMemAlloc',  \
    CoTaskMemFree, N, <.lpIDList>,  'CoTaskMemFree',  \
    CoTaskMemRealloc, N, <.pv, .cb>,  'CoTaskMemRealloc',  \
    CoTestCancel, N, <VOID>,  'CoTestCancel',  \
    CoTreatAsClass, N, <.clsidOld, .clsidNew>,  'CoTreatAsClass',  \
    CoUninitialize, N, <VOID>,  'CoUninitialize',  \
    CoUnloadingWO, W, <NONE>,  'CoUnloadingWOW',  \
    CoUnmarshalHresult, N, <.pstm, .phresult>,  'CoUnmarshalHresult',  \
    CoUnmarshalInterface, N, <.pStm, .riid, .ppv>,  'CoUnmarshalInterface',  \
    CoWaitForMultipleHandles, N, <.dwFlags, .dwTimeout, .cHandles, .pHandles, .lpdwindex>,  'CoWaitForMultipleHandles',  \
    ComPs_CStdStubBuffer_AddRef, N, <NONE>,  'ComPs_CStdStubBuffer_AddRef',  \
    ComPs_CStdStubBuffer_Connect, N, <NONE>,  'ComPs_CStdStubBuffer_Connect',  \
    ComPs_CStdStubBuffer_CountRefs, N, <NONE>,  'ComPs_CStdStubBuffer_CountRefs',  \
    ComPs_CStdStubBuffer_DebugServerQueryInterface, N, <NONE>,  'ComPs_CStdStubBuffer_DebugServerQueryInterface',  \
    ComPs_CStdStubBuffer_DebugServerRelease, N, <NONE>,  'ComPs_CStdStubBuffer_DebugServerRelease',  \
    ComPs_CStdStubBuffer_Disconnect, N, <NONE>,  'ComPs_CStdStubBuffer_Disconnect',  \
    ComPs_CStdStubBuffer_Invoke, N, <NONE>,  'ComPs_CStdStubBuffer_Invoke',  \
    ComPs_CStdStubBuffer_IsIIDSupported, N, <NONE>,  'ComPs_CStdStubBuffer_IsIIDSupported',  \
    ComPs_CStdStubBuffer_QueryInterface, N, <NONE>,  'ComPs_CStdStubBuffer_QueryInterface',  \
    ComPs_IUnknown_AddRef_Proxy, N, <NONE>,  'ComPs_IUnknown_AddRef_Proxy',  \
    ComPs_IUnknown_QueryInterface_Proxy, N, <NONE>,  'ComPs_IUnknown_QueryInterface_Proxy',  \
    ComPs_IUnknown_Release_Proxy, N, <NONE>,  'ComPs_IUnknown_Release_Proxy',  \
    ComPs_NdrCStdStubBuffer2_Release, N, <NONE>,  'ComPs_NdrCStdStubBuffer2_Release',  \
    ComPs_NdrCStdStubBuffer_Release, N, <NONE>,  'ComPs_NdrCStdStubBuffer_Release',  \
    ComPs_NdrClientCall2, N, <NONE>,  'ComPs_NdrClientCall2',  \
    ComPs_NdrClientCall2_va, N, <NONE>,  'ComPs_NdrClientCall2_va',  \
    ComPs_NdrDllCanUnloadNow, N, <NONE>,  'ComPs_NdrDllCanUnloadNow',  \
    ComPs_NdrDllGetClassObject, N, <NONE>,  'ComPs_NdrDllGetClassObject',  \
    ComPs_NdrDllRegisterProxy, N, <NONE>,  'ComPs_NdrDllRegisterProxy',  \
    ComPs_NdrDllUnregisterProxy, N, <NONE>,  'ComPs_NdrDllUnregisterProxy',  \
    ComPs_NdrStubCall2, N, <NONE>,  'ComPs_NdrStubCall2',  \
    ComPs_NdrStubForwardingFunction, N, <NONE>,  'ComPs_NdrStubForwardingFunction',  \
    CreateAntiMoniker, N, <.ppmk>,  'CreateAntiMoniker',  \
    CreateBindCtx, N, <.reserved, .ppbc>,  'CreateBindCtx',  \
    CreateClassMoniker, N, <.rclsid, .ppmk>,  'CreateClassMoniker',  \
    CreateDataAdviseHolder, N, <.ppDAHolder>,  'CreateDataAdviseHolder',  \
    CreateDataCache, N, <.pUnkOuter, .rclsid, .iid, .ppv>,  'CreateDataCache',  \
    CreateErrorInfo, N, <.pperrinfo>,  'CreateErrorInfo',  \
    CreateFileMoniker, N, <.lpszPathName, .ppmk>,  'CreateFileMoniker',  \
    CreateGenericComposite, N, <.pmkFirst, .pmkRest, .ppmkComposite>,  'CreateGenericComposite',  \
    CreateILockBytesOnHGlobal, N, <.hGlobal, .fDeleteOnRelease, .pplkbyt>,  'CreateILockBytesOnHGlobal',  \
    CreateItemMoniker, N, <.lpszDelim, .lpszItem, .ppmk>,  'CreateItemMoniker',  \
    CreateObjrefMoniker, N, <.punk, .ppmk>,  'CreateObjrefMoniker',  \
    CreateOleAdviseHolder, N, <.ppOAHolder>,  'CreateOleAdviseHolder',  \
    CreatePointerMoniker, N, <.punk, .ppmk>,  'CreatePointerMoniker',  \
    CreateStdProgressIndicator, N, <.hwndParent, .pszTitle, .pIbscCaller, .ppIbsc>,  'CreateStdProgressIndicator',  \
    CreateStreamOnHGlobal, N, <.hGlobal, .fDeleteOnRelease, .ppstm>,  'CreateStreamOnHGlobal',  \
    DcomChannelSetHResult, N, <NONE>,  'DcomChannelSetHResult',  \
    DllDebugObjectRPCHook, N, <NONE>,  'DllDebugObjectRPCHook',  \
    DllGetClassObjectWO, W, <NONE>,  'DllGetClassObjectWOW',  \
\;    DllRegisterServer, N, <VOID>,  'DllRegisterServer',  \
    DoDragDrop, N, <.pDataObj, .pDropSource, .dwOKEffects, .pdwEffect>,  'DoDragDrop',  \
    EnableHookObject, N, <NONE>,  'EnableHookObject',  \
    FmtIdToPropStgName, N, <.pfmtid, .oszName>,  'FmtIdToPropStgName',  \
    FreePropVariantArray, N, <.cVariants, .rgvars>,  'FreePropVariantArray',  \
    GetClassFile, N, <.szFilename, .pclsid>,  'GetClassFile',  \
    GetConvertStg, N, <.pStg>,  'GetConvertStg',  \
    GetDocumentBitStg, N, <NONE>,  'GetDocumentBitStg',  \
    GetErrorInfo, N, <.dwReserved, .pperrinfo>,  'GetErrorInfo',  \
    GetHGlobalFromILockBytes, N, <.plkbyt, .phglobal>,  'GetHGlobalFromILockBytes',  \
    GetHGlobalFromStream, N, <.pstm, .phglobal>,  'GetHGlobalFromStream',  \
    GetHookInterface, N, <NONE>,  'GetHookInterface',  \
    GetRunningObjectTable, N, <.reserved, .pprot>,  'GetRunningObjectTable',  \
    HACCEL_UserFree, N, <.pLong, .pHaccel>,  'HACCEL_UserFree',  \
    HACCEL_UserMarshal, N, <.pLong, .pChar, .pHaccel>,  'HACCEL_UserMarshal',  \
    HACCEL_UserSize, N, <.pLong, .lLong, .pHaccel>,  'HACCEL_UserSize',  \
    HACCEL_UserUnmarshal, N, <.pLong, .pChar, .pHaccel>,  'HACCEL_UserUnmarshal',  \
    HBITMAP_UserFree, N, <.pLong, .pHbitmap>,  'HBITMAP_UserFree',  \
    HBITMAP_UserMarshal, N, <.pLong, .pChar, .pHbitmap>,  'HBITMAP_UserMarshal',  \
    HBITMAP_UserSize, N, <.pLong, .lLong, .pHbitmap>,  'HBITMAP_UserSize',  \
    HBITMAP_UserUnmarshal, N, <.pLong, .pChar, .pHbitmap>,  'HBITMAP_UserUnmarshal',  \
    HBRUSH_UserFree, N, <NONE>,  'HBRUSH_UserFree',  \
    HBRUSH_UserMarshal, N, <NONE>,  'HBRUSH_UserMarshal',  \
    HBRUSH_UserSize, N, <NONE>,  'HBRUSH_UserSize',  \
    HBRUSH_UserUnmarshal, N, <NONE>,  'HBRUSH_UserUnmarshal',  \
    HDC_UserFree, N, <.pLong, .pHdc>,  'HDC_UserFree',  \
    HDC_UserMarshal, N, <.pLong, .pChar, .pHdc>,  'HDC_UserMarshal',  \
    HDC_UserSize, N, <.pLong, .lLong, .pHdc>,  'HDC_UserSize',  \
    HDC_UserUnmarshal, N, <.pLong, .pChar, .pHdc>,  'HDC_UserUnmarshal',  \
    HENHMETAFILE_UserFree, N, <NONE>,  'HENHMETAFILE_UserFree',  \
    HENHMETAFILE_UserMarshal, N, <NONE>,  'HENHMETAFILE_UserMarshal',  \
    HENHMETAFILE_UserSize, N, <NONE>,  'HENHMETAFILE_UserSize',  \
    HENHMETAFILE_UserUnmarshal, N, <NONE>,  'HENHMETAFILE_UserUnmarshal',  \
    HGLOBAL_UserFree, N, <.pLong, .pHglobal>,  'HGLOBAL_UserFree',  \
    HGLOBAL_UserMarshal, N, <.pLong, .pChar, .pHglobal>,  'HGLOBAL_UserMarshal',  \
    HGLOBAL_UserSize, N, <.pLong, .lLong, .pHglobal>,  'HGLOBAL_UserSize',  \
    HGLOBAL_UserUnmarshal, N, <.pLong, .pChar, .pHglobal>,  'HGLOBAL_UserUnmarshal',  \
    HICON_UserFree, N, <.pLong, .pHicon>,  'HICON_UserFree',  \
    HICON_UserMarshal, N, <.pLong, .pChar, .pHicon>,  'HICON_UserMarshal',  \
    HICON_UserSize, N, <.pLong, .llong, .pHicon>,  'HICON_UserSize',  \
    HICON_UserUnmarshal, N, <.pLong, .pChar, .pHicon>,  'HICON_UserUnmarshal',  \
    HMENU_UserFree, N, <.pLong, .pHmenu>,  'HMENU_UserFree',  \
    HMENU_UserMarshal, N, <.pLong, .pChar, .pHmenu>,  'HMENU_UserMarshal',  \
    HMENU_UserSize, N, <.pLong, .lLong, .pHmenu>,  'HMENU_UserSize',  \
    HMENU_UserUnmarshal, N, <.pLong, .pChar, .pHmenu>,  'HMENU_UserUnmarshal',  \
    HMETAFILEPICT_UserFree, N, <NONE>,  'HMETAFILEPICT_UserFree',  \
    HMETAFILEPICT_UserMarshal, N, <NONE>,  'HMETAFILEPICT_UserMarshal',  \
    HMETAFILEPICT_UserSize, N, <NONE>,  'HMETAFILEPICT_UserSize',  \
    HMETAFILEPICT_UserUnmarshal, N, <NONE>,  'HMETAFILEPICT_UserUnmarshal',  \
    HMETAFILE_UserFree, N, <NONE>,  'HMETAFILE_UserFree',  \
    HMETAFILE_UserMarshal, N, <NONE>,  'HMETAFILE_UserMarshal',  \
    HMETAFILE_UserSize, N, <NONE>,  'HMETAFILE_UserSize',  \
    HMETAFILE_UserUnmarshal, N, <NONE>,  'HMETAFILE_UserUnmarshal',  \
    HPALETTE_UserFree, N, <.pLong, .pHpalette>,  'HPALETTE_UserFree',  \
    HPALETTE_UserMarshal, N, <.pLong, .pChar, .pHpalette>,  'HPALETTE_UserMarshal',  \
    HPALETTE_UserSize, N, <.pLong, .lLong, .pHpalette>,  'HPALETTE_UserSize',  \
    HPALETTE_UserUnmarshal, N, <.pLong, .pChar, .pHpalette>,  'HPALETTE_UserUnmarshal',  \
    HWND_UserFree, N, <.pLong, .pHwnd>,  'HWND_UserFree',  \
    HWND_UserMarshal, N, <.pLong, .pChar, .pHwnd>,  'HWND_UserMarshal',  \
    HWND_UserSize, N, <.pLong, .lLong, .pHwnd>,  'HWND_UserSize',  \
    HWND_UserUnmarshal, N, <.pLong, .pChar, .pHwnd>,  'HWND_UserUnmarshal',  \
    HkOleRegisterObject, N, <NONE>,  'HkOleRegisterObject',  \
    IIDFromString, N, <.lpsz, .lpiid>,  'IIDFromString',  \
    IsAccelerator, N, <.hAccel, .cAccelEntries, .lpMsg, .lpwCmd>,  'IsAccelerator',  \
    IsEqualGUID, N, <NONE>,  'IsEqualGUID',  \
    IsValidIid, N, <NONE>,  'IsValidIid',  \
    IsValidInterface, N, <NONE>,  'IsValidInterface',  \
    IsValidPtrIn, N, <NONE>,  'IsValidPtrIn',  \
    IsValidPtrOut, N, <NONE>,  'IsValidPtrOut',  \
    MkParseDisplayName, N, <.pbc, .szUserName, .pchEaten, .ppmk>,  'MkParseDisplayName',  \
    MonikerCommonPrefixWith, N, <.pmkThis, .pmkOther, .ppmkCommon>,  'MonikerCommonPrefixWith',  \
    MonikerRelativePathTo, N, <.pmkSrc, .pmkDest, .ppmkRelPath, .dwReserved>,  'MonikerRelativePathTo',  \
    OleBuildVersion, N, <VOID>,  'OleBuildVersion',  \
    OleConvertIStorageToOLESTREAM, N, <.pstg, .lpolestream>,  'OleConvertIStorageToOLESTREAM',  \
    OleConvertIStorageToOLESTREAMEx, N, <.pstg, .cfFormat, .lWidth, .lHeight, .dwSize, .pmedium, .polestm>,  'OleConvertIStorageToOLESTREAMEx',  \
    OleConvertOLESTREAMToIStorage, N, <.lpolestream, .pstg, .ptd>,  'OleConvertOLESTREAMToIStorage',  \
    OleConvertOLESTREAMToIStorageEx, N, <.polestm, .pstg, .pcfFormat, .plwWidth, .plHeight, .pdwSize, .pmedium>,  'OleConvertOLESTREAMToIStorageEx',  \
    OleCreate, N, <.rclsid, .riid, .renderopt, .pFormatEtc, .pClientSite, .pStg, .ppvObj>,  'OleCreate',  \
    OleCreateDefaultHandler, N, <.clsid, .pUnkOuter, .riid, .lplpObj>,  'OleCreateDefaultHandler',  \
    OleCreateEmbeddingHelper, N, <.clsid, .pUnkOuter, .flags, .pCF, .riid, .lplpObj>,  'OleCreateEmbeddingHelper',  \
    OleCreateEx, N, <.rclsid, .riid, .dwFlags, .renderopt, .cFormats, .rgAdvf, .rgFormatEtc, .lpAdviseSink, .rgdwConnection, .pClientSite, .pStg, .ppvObj>,  'OleCreateEx',  \
    OleCreateFromData, N, <.pSrcDataObj, .riid, .renderopt, .pFormatEtc, .pClientSite, .pStg, .ppvObj>,  'OleCreateFromData',  \
    OleCreateFromDataEx, N, <.pSrcDataObj, .riid, .dwFlags, .renderopt, .cFormats, .rgAdvf, .rgFormatEtc, .lpAdviseSink, .rgdwConnection, .pClientSite, .pStg, .ppvObj>,  'OleCreateFromDataEx',  \
    OleCreateFromFile, N, <.rclsid, .lpszFileName, .riid, .renderopt, .lpFormatEtc, .pClientSite, .pStg, .ppvObj>,  'OleCreateFromFile',  \
    OleCreateFromFileEx, N, <.rclsid, .lpszFileName, .riid, .dwFlags, .renderopt, .cFormats, .rgAdvf, .rgFormatEtc, .lpAdviseSink, .rgdwConnection, .pClientSite, .pStg, .ppvObj>,  'OleCreateFromFileEx',  \
    OleCreateLink, N, <.pmkLinkSrc, .riid, .renderopt, .lpFormatEtc, .pClientSite, .pStg, .ppvObj>,  'OleCreateLink',  \
    OleCreateLinkEx, N, <.pmkLinkSrc, .riid, .dwFlags, .renderopt, .cFormats, .rgAdvf, .rgFormatEtc, .lpAdviseSink, .rgdwConnection, .pClientSite, .pStg, .ppvObj>,  'OleCreateLinkEx',  \
    OleCreateLinkFromData, N, <.pSrcDataObj, .riid, .renderopt, .pFormatEtc, .pClientSite, .pStg, .ppvObj>,  'OleCreateLinkFromData',  \
    OleCreateLinkFromDataEx, N, <.pSrcDataObj, .riid, .dwFlags, .renderopt, .cFormats, .rgAdvf, .rgFormatEtc, .lpAdviseSink, .rgdwConnection, .pClientSite, .pStg, .ppvObj>,  'OleCreateLinkFromDataEx',  \
    OleCreateLinkToFile, N, <.lpszFileName, .riid, .renderopt, .lpFormatEtc, .pClientSite, .pStg, .ppvObj>,  'OleCreateLinkToFile',  \
    OleCreateLinkToFileEx, N, <.lpszFileName, .riid, .dwFlags, .renderopt, .cFormats, .rgAdvf, .rgFormatEtc, .lpAdviseSink, .rgdwConnection, .pClientSite, .pStg, .ppvObj>,  'OleCreateLinkToFileEx',  \
    OleCreateMenuDescriptor, N, <.hmenuCombined, .lpMenuWidths>,  'OleCreateMenuDescriptor',  \
    OleCreateStaticFromData, N, <.pSrcDataObj, .iid, .renderopt, .pFormatEtc, .pClientSite, .pStg, .ppvObj>,  'OleCreateStaticFromData',  \
    OleDestroyMenuDescriptor, N, <.holemenu>,  'OleDestroyMenuDescriptor',  \
    OleDoAutoConvert, N, <.pStg, .pClsidNew>,  'OleDoAutoConvert',  \
    OleDraw, N, <.pUnknown, .dwAspect, .hdcDraw, .lprcBounds>,  'OleDraw',  \
    OleDuplicateData, N, <.hSrc, .cfFormat, .uiFlags>,  'OleDuplicateData',  \
    OleFlushClipboard, N, <VOID>,  'OleFlushClipboard',  \
    OleGetAutoConvert, N, <.clsidOld, .pClsidNew>,  'OleGetAutoConvert',  \
    OleGetClipboard, N, <.ppDataObj>,  'OleGetClipboard',  \
    OleGetIconOfClass, N, <.rclsid, .lpszLabel, .fUseTypeAsLabel>,  'OleGetIconOfClass',  \
    OleGetIconOfFile, N, <.lpszPath, .fUseFileAsLabel>,  'OleGetIconOfFile',  \
    OleInitialize, N, <.pvReserved>,  'OleInitialize',  \
    OleInitializeWO, W, <NONE>,  'OleInitializeWOW',  \
    OleIsCurrentClipboard, N, <.pDataObj>,  'OleIsCurrentClipboard',  \
    OleIsRunning, N, <.pObject>,  'OleIsRunning',  \
    OleLoad, N, <.pStg, .riid, .pClientSite, .ppvObj>,  'OleLoad',  \
    OleLoadFromStream, N, <.pStm, .iidInterface, .ppvObj>,  'OleLoadFromStream',  \
    OleLockRunning, N, <.pUnknown, .fLock, .fLastUnlockCloses>,  'OleLockRunning',  \
    OleMetafilePictFromIconAndLabel, N, <.hIcon, .lpszLabel, .lpszSourceFile, .iIconIndex>,  'OleMetafilePictFromIconAndLabel',  \
    OleNoteObjectVisible, N, <.pUnknown, .fVisible>,  'OleNoteObjectVisible',  \
    OleQueryCreateFromData, N, <.pSrcDataObject>,  'OleQueryCreateFromData',  \
    OleQueryLinkFromData, N, <.pSrcDataObject>,  'OleQueryLinkFromData',  \
    OleRegEnumFormatEtc, N, <.clsid, .dwDirection, .ppenum>,  'OleRegEnumFormatEtc',  \
    OleRegEnumVerbs, N, <.clsid, .ppenum>,  'OleRegEnumVerbs',  \
    OleRegGetMiscStatus, N, <.clsid, .dwAspect, .pdwStatus>,  'OleRegGetMiscStatus',  \
    OleRegGetUserType, N, <.clsid, .dwFormOfType, .pszUserType>,  'OleRegGetUserType',  \
    OleRun, N, <.pUnknown>,  'OleRun',  \
    OleSave, N, <.pPS, .pStg, .fSameAsLoad>,  'OleSave',  \
    OleSaveToStream, N, <.pPStm, .pStm>,  'OleSaveToStream',  \
    OleSetAutoConvert, N, <.clsidOld, .clsidNew>,  'OleSetAutoConvert',  \
    OleSetClipboard, N, <.pDataObj>,  'OleSetClipboard',  \
    OleSetContainedObject, N, <.pUnknown, .fContained>,  'OleSetContainedObject',  \
    OleSetMenuDescriptor, N, <.holemenu, .hwndFrame, .hwndActiveObject, .lpFrame, .lpActiveObj>,  'OleSetMenuDescriptor',  \
    OleTranslateAccelerator, N, <.lpFrame, .lpFrameInfo, .lpmsg>,  'OleTranslateAccelerator',  \
    OleUninitialize, N, <VOID>,  'OleUninitialize',  \
    OpenOrCreateStream, N, <NONE>,  'OpenOrCreateStream',  \
    ProgIDFromCLSID, N, <.clsid, .lplpszProgID>,  'ProgIDFromCLSID',  \
    PropStgNameToFmtId, N, <.oszName, .pfmtid>,  'PropStgNameToFmtId',  \
    PropSysAllocString, N, <NONE>,  'PropSysAllocString',  \
    PropSysFreeString, N, <NONE>,  'PropSysFreeString',  \
    PropVariantChangeType, N, <NONE>,  'PropVariantChangeType',  \
    PropVariantClear, N, <.pvar>,  'PropVariantClear',  \
    PropVariantCopy, N, <.pvarDest, .pvarSrc>,  'PropVariantCopy',  \
    ReadClassStg, N, <.pStg, .pclsid>,  'ReadClassStg',  \
    ReadClassStm, N, <.pStm, .pclsid>,  'ReadClassStm',  \
    ReadFmtUserTypeStg, N, <.pstg, .pcf, .lplpszUserType>,  'ReadFmtUserTypeStg',  \
    ReadOleStg, N, <NONE>,  'ReadOleStg',  \
    ReadStringStream, N, <NONE>,  'ReadStringStream',  \
    RegisterDragDrop, N, <.hwnd, .pDropTarget>,  'RegisterDragDrop',  \
    ReleaseStgMedium, N, <.lpstgmedium>,  'ReleaseStgMedium',  \
    RevokeDragDrop, N, <.hwnd>,  'RevokeDragDrop',  \
    SNB_UserFree, N, <.pLong, .pSnb>,  'SNB_UserFree',  \
    SNB_UserMarshal, N, <.pLong, .pChar, .pSnb>,  'SNB_UserMarshal',  \
    SNB_UserSize, N, <.pLong, .lLong, .pSnb>,  'SNB_UserSize',  \
    SNB_UserUnmarshal, N, <.pLong, .pChar, .pSnb>,  'SNB_UserUnmarshal',  \
    STGMEDIUM_UserFree, N, <.pLong, .pStgmedium>,  'STGMEDIUM_UserFree',  \
    STGMEDIUM_UserMarshal, N, <.pLong, .pChar, .pStgmedium>,  'STGMEDIUM_UserMarshal',  \
    STGMEDIUM_UserSize, N, <.pLong, .long, .pStgmedium>,  'STGMEDIUM_UserSize',  \
    STGMEDIUM_UserUnmarshal, N, <.pLong, .pChar, .pStgmedium>,  'STGMEDIUM_UserUnmarshal',  \
    SetConvertStg, N, <.pStg, .fConvert>,  'SetConvertStg',  \
    SetDocumentBitStg, N, <NONE>,  'SetDocumentBitStg',  \
    SetErrorInfo, N, <.dwReserved, .perrinfo>,  'SetErrorInfo',  \
    StgConvertPropertyToVariant, N, <NONE>,  'StgConvertPropertyToVariant',  \
    StgConvertVariantToProperty, N, <NONE>,  'StgConvertVariantToProperty',  \
    StgCreateDocfile, N, <.pwcsName, .grfMode, .reserved, .ppstgOpen>,  'StgCreateDocfile',  \
    StgCreateDocfileOnILockBytes, N, <.plkbyt, .grfMode, .reserved, .ppstgOpen>,  'StgCreateDocfileOnILockBytes',  \
    StgCreatePropSetStg, N, <.pStorage, .dwReserved, .ppPropSetStg>,  'StgCreatePropSetStg',  \
    StgCreatePropStg, N, <.pUnk, .fmtid, .pclsid, .grfFlags, .dwReserved, .ppPropStg>,  'StgCreatePropStg',  \
    StgCreateStorageEx, N, <.pwcsName, .grfMode, .stgfmt, .grfAttrs, .pStgOptions, .reserved, .riid, .ppObjectOpen>,  'StgCreateStorageEx',  \
    StgGetIFillLockBytesOnFile, N, <.pwcsName, .ppflb>,  'StgGetIFillLockBytesOnFile',  \
    StgGetIFillLockBytesOnILockBytes, N, <.pilb, .ppflb>,  'StgGetIFillLockBytesOnILockBytes',  \
    StgIsStorageFile, N, <.pwcsName>,  'StgIsStorageFile',  \
    StgIsStorageILockBytes, N, <.plkbyt>,  'StgIsStorageILockBytes',  \
    StgOpenAsyncDocfileOnIFillLockBytes, N, <.pflb, .grfMode, .asyncFlags, .ppstgOpen>,  'StgOpenAsyncDocfileOnIFillLockBytes',  \
    StgOpenPropStg, N, <.pUnk, .fmtid, .grfFlags, .dwReserved, .ppPropStg>,  'StgOpenPropStg',  \
    StgOpenStorage, N, <.pwcsName, .pstgPriority, .grfMode, .snbExclude, .reserved, .ppstgOpen>,  'StgOpenStorage',  \
    StgOpenStorageEx, N, <.pwcsName, .grfMode, .stgfmt, .grfAttrs, .pStgOptions, .reserved, .riid, .ppObjectOpen>,  'StgOpenStorageEx',  \
    StgOpenStorageOnHandle, N, <NONE>,  'StgOpenStorageOnHandle',  \
    StgOpenStorageOnILockBytes, N, <.plkbyt, .pstgPriority, .grfMode, .snbExclude, .reserved, .ppstgOpen>,  'StgOpenStorageOnILockBytes',  \
    StgPropertyLengthAsVariant, N, <NONE>,  'StgPropertyLengthAsVariant',  \
    StgSetTimes, N, <.lpszName, .pctime, .patime, .pmtime>,  'StgSetTimes',  \
    StringFromCLSID, N, <.rclsid, .lplpsz>,  'StringFromCLSID',  \
    StringFromGUID2, N, <.rguid, .lpsz, .cchMax>,  'StringFromGUID2',  \
    StringFromIID, N, <.rclsid, .lplpsz>,  'StringFromIID',  \
    UpdateDCOMSettings, N, <NONE>,  'UpdateDCOMSettings',  \
    UtConvertDvtd16toDvtd32, N, <NONE>,  'UtConvertDvtd16toDvtd32',  \
    UtConvertDvtd32toDvtd16, N, <NONE>,  'UtConvertDvtd32toDvtd16',  \
    UtGetDvtd16Info, N, <NONE>,  'UtGetDvtd16Info',  \
    UtGetDvtd32Info, N, <NONE>,  'UtGetDvtd32Info',  \
    WdtpInterfacePointer_UserFree, N, <NONE>,  'WdtpInterfacePointer_UserFree',  \
    WdtpInterfacePointer_UserMarshal, N, <NONE>,  'WdtpInterfacePointer_UserMarshal',  \
    WdtpInterfacePointer_UserSize, N, <NONE>,  'WdtpInterfacePointer_UserSize',  \
    WdtpInterfacePointer_UserUnmarshal, N, <NONE>,  'WdtpInterfacePointer_UserUnmarshal',  \
    WriteClassStg, N, <.pStg, .rclsid>,  'WriteClassStg',  \
    WriteClassStm, N, <.pStm, .rclsid>,  'WriteClassStm',  \
    WriteFmtUserTypeStg, N, <.pstg, .cf, .lpszUserType>,  'WriteFmtUserTypeStg',  \
    WriteOleStg, N, <NONE>,  'WriteOleStg',  \
    WriteStringStream, N, <NONE>,  'WriteStringStream'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/imports/Win32/api/shell32.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: shell32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto shell32,  \
    Activate_RunDLL, N, <NONE>,  'Activate_RunDLL',  \
    AppCompat_RunDLL, W, <NONE>,  'AppCompat_RunDLLW',  \
    CDefFolderMenu_Create, N, <NONE>,  'CDefFolderMenu_Create',  \
    CDefFolderMenu_Create2, N, <NONE>,  'CDefFolderMenu_Create2',  \
    CallCPLEntry16, N, <NONE>,  'CallCPLEntry16',  \
    CheckEscapes, A, <NONE>,  'CheckEscapesA',  \
    CheckEscapes, W, <NONE>,  'CheckEscapesW',  \
    CommandLineToArgv, W, <.lpCmdLine, .pNumArgs>,  'CommandLineToArgvW',  \
    Control_FillCache_RunDLL, A, <NONE>,  'Control_FillCache_RunDLLA',  \
    Control_FillCache_RunDLL, W, <NONE>,  'Control_FillCache_RunDLLW',  \
    Control_RunDLL, A, <NONE>,  'Control_RunDLLA',  \
    Control_RunDLLAsUser, W, <NONE>,  'Control_RunDLLAsUserW',  \
    Control_RunDLL, W, <NONE>,  'Control_RunDLLW',  \
    DAD_AutoScroll, N, <NONE>,  'DAD_AutoScroll',  \
    DAD_DragEnterEx, N, <NONE>,  'DAD_DragEnterEx',  \
    DAD_DragEnterEx2, N, <NONE>,  'DAD_DragEnterEx2',  \
    DAD_DragLeave, N, <NONE>,  'DAD_DragLeave',  \
    DAD_DragMove, N, <NONE>,  'DAD_DragMove',  \
    DAD_SetDragImage, N, <NONE>,  'DAD_SetDragImage',  \
    DAD_ShowDragImage, N, <NONE>,  'DAD_ShowDragImage',  \
    DllCanUnloadNow, N, <VOID>,  'DllCanUnloadNow',  \
    DllGetClassObject, N, <.rclsid, .riid, .ppv>,  'DllGetClassObject',  \
\;    DllGetVersion, N, <NONE>,  'DllGetVersion',  \
\;    DllInstall, N, <.bInstall, .pszCmdLine>,  'DllInstall',  \
    DllRegisterServer, N, <VOID>,  'DllRegisterServer',  \
    DllUnregisterServer, N, <VOID>,  'DllUnregisterServer',  \
    DoEnvironmentSubst, A, <.szString, .cbString>,  'DoEnvironmentSubstA',  \
    DoEnvironmentSubst, W, <.szString, .cbString>,  'DoEnvironmentSubstW',  \
    DragAcceptFiles, N, <.hwnd, .fAccept>,  'DragAcceptFiles',  \
    DragFinish, N, <.hDrop>,  'DragFinish',  \
    DragQueryFile, A, <.HDROP, .UINT, .lpStr, .ch>,  'DragQueryFileA',  \
    DragQueryFile, W, <.HDROP, .UINT, .lpStr, .ch>,  'DragQueryFileW',  \
    DragQueryFileAorW, N, <NONE>,  'DragQueryFileAorW',  \
    DragQueryPoint, N, <.HDROP, .lpPoint>,  'DragQueryPoint',  \
    DriveType, N, <NONE>,  'DriveType',  \
    DuplicateIcon, N, <.hInst, .hIcon>,  'DuplicateIcon',  \
    ExtractAssociatedIcon, A, <.hInst, .lpIconPath, .lpiIcon>,  'ExtractAssociatedIconA',  \
    ExtractAssociatedIconEx, A, <NONE>,  'ExtractAssociatedIconExA',  \
    ExtractAssociatedIconEx, W, <NONE>,  'ExtractAssociatedIconExW',  \
    ExtractAssociatedIcon, W, <.hInst, .lpIconPath, .lpiIcon>,  'ExtractAssociatedIconW',  \
    ExtractIcon, A, <.hInst, .lpszExeFileName, .nIconIndex>,  'ExtractIconA',  \
    ExtractIconEx, A, <.lpszFile, .nIconIndex, .phiconLarge, .phiconSmall, .nIcons>,  'ExtractIconExA',  \
    ExtractIconEx, W, <.lpszFile, .nIconIndex, .phiconLarge, .phiconSmall, .nIcons>,  'ExtractIconExW',  \
    ExtractIconResInfo, A, <NONE>,  'ExtractIconResInfoA',  \
    ExtractIconResInfo, W, <NONE>,  'ExtractIconResInfoW',  \
    ExtractIcon, W, <.hInst, .lpszExeFileName, .nIconIndex>,  'ExtractIconW',  \
    ExtractVersionResource16, W, <NONE>,  'ExtractVersionResource16W',  \
    FindExeDlgProc, N, <NONE>,  'FindExeDlgProc',  \
    FindExecutable, A, <.lpFile, .lpDirectory, .lpResult>,  'FindExecutableA',  \
    FindExecutable, W, <.lpFile, .lpDirectory, .lpResult>,  'FindExecutableW',  \
    FreeIconList, N, <NONE>,  'FreeIconList',  \
    GetFileNameFromBrowse, N, <NONE>,  'GetFileNameFromBrowse',  \
    ILAppendID, N, <NONE>,  'ILAppendID',  \
    ILClone, N, <NONE>,  'ILClone',  \
    ILCloneFirst, N, <NONE>,  'ILCloneFirst',  \
    ILCombine, N, <NONE>,  'ILCombine',  \
    ILCreateFromPath, A, <NONE>,  'ILCreateFromPathA',  \
    ILCreateFromPath, W, <NONE>,  'ILCreateFromPathW',  \
    ILFindChild, N, <NONE>,  'ILFindChild',  \
    ILFindLastID, N, <NONE>,  'ILFindLastID',  \
    ILFree, N, <NONE>,  'ILFree',  \
    ILGetNext, N, <NONE>,  'ILGetNext',  \
    ILGetSize, N, <NONE>,  'ILGetSize',  \
    ILIsEqual, N, <NONE>,  'ILIsEqual',  \
    ILIsParent, N, <NONE>,  'ILIsParent',  \
    ILLoadFromStream, N, <NONE>,  'ILLoadFromStream',  \
    ILRemoveLastID, N, <NONE>,  'ILRemoveLastID',  \
    ILSaveToStream, N, <NONE>,  'ILSaveToStream',  \
    InternalExtractIconList, A, <NONE>,  'InternalExtractIconListA',  \
    InternalExtractIconList, W, <NONE>,  'InternalExtractIconListW',  \
    IsLFNDrive, A, <NONE>,  'IsLFNDriveA',  \
    IsLFNDrive, W, <NONE>,  'IsLFNDriveW',  \
    IsNetDrive, N, <NONE>,  'IsNetDrive',  \
    IsUserAnAdmin, N, <NONE>,  'IsUserAnAdmin',  \
    OpenAs_RunDLL, A, <NONE>,  'OpenAs_RunDLLA',  \
    OpenAs_RunDLL, W, <NONE>,  'OpenAs_RunDLLW',  \
    OpenRegStream, N, <NONE>,  'OpenRegStream',  \
    Options_RunDLL, A, <NONE>,  'Options_RunDLLA',  \
    Options_RunDLL, W, <NONE>,  'Options_RunDLLW',  \
    PathCleanupSpec, N, <NONE>,  'PathCleanupSpec',  \
    PathGetShortPath, N, <NONE>,  'PathGetShortPath',  \
    PathIsExe, N, <NONE>,  'PathIsExe',  \
    PathIsSlow, A, <NONE>,  'PathIsSlowA',  \
    PathIsSlow, W, <NONE>,  'PathIsSlowW',  \
    PathMakeUniqueName, N, <NONE>,  'PathMakeUniqueName',  \
    PathProcessCommand, N, <NONE>,  'PathProcessCommand',  \
    PathQualify, N, <NONE>,  'PathQualify',  \
    PathResolve, N, <NONE>,  'PathResolve',  \
    PathYetAnotherMakeUniqueName, N, <NONE>,  'PathYetAnotherMakeUniqueName',  \
    PickIconDlg, N, <NONE>,  'PickIconDlg',  \
    PifMgr_CloseProperties, N, <NONE>,  'PifMgr_CloseProperties',  \
    PifMgr_GetProperties, N, <NONE>,  'PifMgr_GetProperties',  \
    PifMgr_OpenProperties, N, <NONE>,  'PifMgr_OpenProperties',  \
    PifMgr_SetProperties, N, <NONE>,  'PifMgr_SetProperties',  \
    PrintersGetCommand_RunDLL, A, <NONE>,  'PrintersGetCommand_RunDLLA',  \
    PrintersGetCommand_RunDLL, W, <NONE>,  'PrintersGetCommand_RunDLLW',  \
    ReadCabinetState, N, <NONE>,  'ReadCabinetState',  \
    RealDriveType, N, <NONE>,  'RealDriveType',  \
    RealShellExecute, A, <NONE>,  'RealShellExecuteA',  \
    RealShellExecuteEx, A, <NONE>,  'RealShellExecuteExA',  \
    RealShellExecuteEx, W, <NONE>,  'RealShellExecuteExW',  \
    RealShellExecute, W, <NONE>,  'RealShellExecuteW',  \
    RegenerateUserEnvironment, N, <NONE>,  'RegenerateUserEnvironment',  \
    RestartDialog, N, <NONE>,  'RestartDialog',  \
    RestartDialogEx, N, <NONE>,  'RestartDialogEx',  \
    SHAddFromPropSheetExtArray, N, <NONE>,  'SHAddFromPropSheetExtArray',  \
    SHAddToRecentDocs, N, <.uFlags, .pv>,  'SHAddToRecentDocs',  \
    SHAlloc, N, <NONE>,  'SHAlloc',  \
    SHAllocShared, N, <NONE>,  'SHAllocShared',  \
    SHAppBarMessage, N, <.dwMessage, .pData>,  'SHAppBarMessage',  \
    SHBindToParent, N, <.pidl, .riid, .ppv, .ppidlLast>,  'SHBindToParent',  \
    SHBrowseForFolder, A, <.lpbi>,  'SHBrowseForFolderA',  \
    SHBrowseForFolder, W, <.lpbi>,  'SHBrowseForFolderW',  \
    SHCLSIDFromString, N, <NONE>,  'SHCLSIDFromString',  \
    SHChangeNotification_Lock, N, <NONE>,  'SHChangeNotification_Lock',  \
    SHChangeNotification_Unlock, N, <NONE>,  'SHChangeNotification_Unlock',  \
    SHChangeNotify, N, <.wEventId, .uFlags, .dwItem1, .dwItem2>,  'SHChangeNotify',  \
    SHChangeNotifyDeregister, N, <NONE>,  'SHChangeNotifyDeregister',  \
    SHChangeNotifyRegister, N, <NONE>,  'SHChangeNotifyRegister',  \
    SHChangeNotifySuspendResume, N, <NONE>,  'SHChangeNotifySuspendResume',  \
    SHCloneSpecialIDList, N, <NONE>,  'SHCloneSpecialIDList',  \
    SHCoCreateInstance, N, <NONE>,  'SHCoCreateInstance',  \
    SHCreateDirectory, N, <NONE>,  'SHCreateDirectory',  \
    SHCreateDirectoryEx, A, <.hwnd, .pszPath, .psa>,  'SHCreateDirectoryExA',  \
    SHCreateDirectoryEx, W, <.hwnd, .pszPath, .psa>,  'SHCreateDirectoryExW',  \
    SHCreateFileExtractIcon, W, <NONE>,  'SHCreateFileExtractIconW',  \
    SHCreateLocalServerRunDll, N, <NONE>,  'SHCreateLocalServerRunDll',  \
    SHCreateProcessAsUser, W, <NONE>,  'SHCreateProcessAsUserW',  \
    SHCreatePropSheetExtArray, N, <NONE>,  'SHCreatePropSheetExtArray',  \
    SHCreateQueryCancelAutoPlayMoniker, N, <NONE>,  'SHCreateQueryCancelAutoPlayMoniker',  \
    SHCreateShellFolderView, N, <NONE>,  'SHCreateShellFolderView',  \
    SHCreateShellFolderViewEx, N, <NONE>,  'SHCreateShellFolderViewEx',  \
    SHCreateShellItem, N, <NONE>,  'SHCreateShellItem',  \
    SHCreateStdEnumFmtEtc, N, <NONE>,  'SHCreateStdEnumFmtEtc',  \
    SHDefExtractIcon, A, <NONE>,  'SHDefExtractIconA',  \
    SHDefExtractIcon, W, <NONE>,  'SHDefExtractIconW',  \
    SHDestroyPropSheetExtArray, N, <NONE>,  'SHDestroyPropSheetExtArray',  \
    SHDoDragDrop, N, <NONE>,  'SHDoDragDrop',  \
    SHEmptyRecycleBin, A, <.hwnd, .pszRootPath, .dwFlags>,  'SHEmptyRecycleBinA',  \
    SHEmptyRecycleBin, W, <.hwnd, .pszRootPath, .dwFlags>,  'SHEmptyRecycleBinW',  \
    SHEnableServiceObject, N, <NONE>,  'SHEnableServiceObject',  \
    SHEnumerateUnreadMailAccounts, W, <NONE>,  'SHEnumerateUnreadMailAccountsW',  \
    SHExtractIcons, W, <NONE>,  'SHExtractIconsW',  \
    SHFileOperation, A, <.lpFileOp>,  'SHFileOperationA',  \
    SHFileOperation, W, <.lpFileOp>,  'SHFileOperationW',  \
    SHFindFiles, N, <NONE>,  'SHFindFiles',  \
    SHFind_InitMenuPopup, N, <NONE>,  'SHFind_InitMenuPopup',  \
    SHFlushClipboard, N, <NONE>,  'SHFlushClipboard',  \
    SHFlushSFCache, N, <NONE>,  'SHFlushSFCache',  \
    SHFormatDrive, N, <NONE>,  'SHFormatDrive',  \
    SHFree, N, <NONE>,  'SHFree',  \
    SHFreeNameMappings, N, <.hNameMappings>,  'SHFreeNameMappings',  \
    SHFreeShared, N, <NONE>,  'SHFreeShared',  \
    SHGetAttributesFromDataObject, N, <NONE>,  'SHGetAttributesFromDataObject',  \
    SHGetDataFromIDList, A, <.psf, .pidl, .nFormat, .pv, .cb>,  'SHGetDataFromIDListA',  \
    SHGetDataFromIDList, W, <.psf, .pidl, .nFormat, .pv, .cb>,  'SHGetDataFromIDListW',  \
    SHGetDesktopFolder, N, <.ppshf>,  'SHGetDesktopFolder',  \
    SHGetDiskFreeSpace, A, <NONE>,  'SHGetDiskFreeSpaceA',  \
    SHGetDiskFreeSpaceEx, A, <.pszDirectoryName, .pulFreeBytesAvailableToCaller, .pulTotalNumberOfBytes, .pulTotalNumberOfFreeBytes>,  'SHGetDiskFreeSpaceExA',  \
    SHGetDiskFreeSpaceEx, W, <.pszDirectoryName, .pulFreeBytesAvailableToCaller, .pulTotalNumberOfBytes, .pulTotalNumberOfFreeBytes>,  'SHGetDiskFreeSpaceExW',  \
    SHGetFileInfo, A, <.pszPath, .dwFileAttributes, .psfi, .cbFileInfo, .uFlags>,  'SHGetFileInfoA',  \
    SHGetFileInfo, W, <.pszPath, .dwFileAttributes, .psfi, .cbFileInfo, .uFlags>,  'SHGetFileInfoW',  \
    SHGetFolderLocation, N, <.hwnd, .csidl, .hToken, .dwFlags, .ppidl>,  'SHGetFolderLocation',  \
    SHGetFolderPath, A, <.hwnd, .csidl, .hToken, .dwFlags, .pszPath>,  'SHGetFolderPathA',  \
    SHGetFolderPathAndSubDir, A, <NONE>,  'SHGetFolderPathAndSubDirA',  \
    SHGetFolderPathAndSubDir, W, <NONE>,  'SHGetFolderPathAndSubDirW',  \
    SHGetFolderPath, W, <.hwnd, .csidl, .hToken, .dwFlags, .pszPath>,  'SHGetFolderPathW',  \
    SHGetIconOverlayIndex, A, <.pszIconPath, .iIconIndex>,  'SHGetIconOverlayIndexA',  \
    SHGetIconOverlayIndex, W, <.pszIconPath, .iIconIndex>,  'SHGetIconOverlayIndexW',  \
    SHGetImageList, N, <NONE>,  'SHGetImageList',  \
    SHGetInstanceExplorer, N, <.ppunk>,  'SHGetInstanceExplorer',  \
    SHGetMalloc, N, <.ppMalloc>,  'SHGetMalloc',  \
    SHGetNewLinkInfo, A, <.pszLinkto, .pszDir, .pszName, .pfMustCopy, .uFlags>,  'SHGetNewLinkInfoA',  \
    SHGetNewLinkInfo, W, <.pszLinkto, .pszDir, .pszName, .pfMustCopy, .uFlags>,  'SHGetNewLinkInfoW',  \
    SHGetPathFromIDList, A, <.pidl, .pszPath>,  'SHGetPathFromIDListA',  \
    SHGetPathFromIDList, W, <.pidl, .pszPath>,  'SHGetPathFromIDListW',  \
    SHGetRealIDL, N, <NONE>,  'SHGetRealIDL',  \
    SHGetSetFolderCustomSettings, W, <NONE>,  'SHGetSetFolderCustomSettingsW',  \
    SHGetSetSettings, N, <NONE>,  'SHGetSetSettings',  \
    SHGetSettings, N, <.lpsfs, .dwMask>,  'SHGetSettings',  \
    SHGetShellStyleHInstance, N, <NONE>,  'SHGetShellStyleHInstance',  \
    SHGetSpecialFolderLocation, N, <.hwnd, .csidl, .ppidl>,  'SHGetSpecialFolderLocation',  \
    SHGetSpecialFolderPath, A, <.hwnd, .pszPath, .csidl, .fCreate>,  'SHGetSpecialFolderPathA',  \
    SHGetSpecialFolderPath, W, <.hwnd, .pszPath, .csidl, .fCreate>,  'SHGetSpecialFolderPathW',  \
    SHGetUnreadMailCount, W, <NONE>,  'SHGetUnreadMailCountW',  \
    SHHandleUpdateImage, N, <NONE>,  'SHHandleUpdateImage',  \
    SHHelpShortcuts_RunDLL, A, <NONE>,  'SHHelpShortcuts_RunDLLA',  \
    SHHelpShortcuts_RunDLL, W, <NONE>,  'SHHelpShortcuts_RunDLLW',  \
    SHILCreateFromPath, N, <NONE>,  'SHILCreateFromPath',  \
    SHInvokePrinterCommand, A, <.hwnd, .uAction, .lpBuf1, .lpBuf2, .fModal>,  'SHInvokePrinterCommandA',  \
    SHInvokePrinterCommand, W, <.hwnd, .uAction, .lpBuf1, .lpBuf2, .fModal>,  'SHInvokePrinterCommandW',  \
    SHIsFileAvailableOffline, N, <.pwszPath, .pdwStatus>,  'SHIsFileAvailableOffline',  \
    SHLimitInputEdit, N, <NONE>,  'SHLimitInputEdit',  \
    SHLoadInProc, N, <.rclsid>,  'SHLoadInProc',  \
    SHLoadNonloadedIconOverlayIdentifiers, N, <VOID>,  'SHLoadNonloadedIconOverlayIdentifiers',  \
    SHLoadOLE, N, <NONE>,  'SHLoadOLE',  \
    SHLockShared, N, <NONE>,  'SHLockShared',  \
    SHMapIDListToImageListIndexAsync, N, <NONE>,  'SHMapIDListToImageListIndexAsync',  \
    SHMapPIDLToSystemImageListIndex, N, <NONE>,  'SHMapPIDLToSystemImageListIndex',  \
    SHMultiFileProperties, N, <NONE>,  'SHMultiFileProperties',  \
    SHObjectProperties, N, <NONE>,  'SHObjectProperties',  \
    SHOpenFolderAndSelectItems, N, <NONE>,  'SHOpenFolderAndSelectItems',  \
    SHOpenPropSheet, W, <NONE>,  'SHOpenPropSheetW',  \
    SHParseDisplayName, N, <NONE>,  'SHParseDisplayName',  \
    SHPathPrepareForWrite, A, <.hwnd, .punkEnableModless, .pszPath, .dwFlags>,  'SHPathPrepareForWriteA',  \
    SHPathPrepareForWrite, W, <.hwnd, .punkEnableModless, .pszPath, .dwFlags>,  'SHPathPrepareForWriteW',  \
    SHPropStgCreate, N, <NONE>,  'SHPropStgCreate',  \
    SHPropStgReadMultiple, N, <NONE>,  'SHPropStgReadMultiple',  \
    SHPropStgWriteMultiple, N, <NONE>,  'SHPropStgWriteMultiple',  \
    SHQueryRecycleBin, A, <.pszRootPath, .pSHQueryRBInfo>,  'SHQueryRecycleBinA',  \
    SHQueryRecycleBin, W, <.pszRootPath, .pSHQueryRBInfo>,  'SHQueryRecycleBinW',  \
    SHReplaceFromPropSheetExtArray, N, <NONE>,  'SHReplaceFromPropSheetExtArray',  \
    SHRestricted, N, <NONE>,  'SHRestricted',  \
    SHRunControlPanel, N, <NONE>,  'SHRunControlPanel',  \
    SHSetInstanceExplorer, N, <NONE>,  'SHSetInstanceExplorer',  \
    SHSetLocalizedName, N, <NONE>,  'SHSetLocalizedName',  \
    SHSetUnreadMailCount, W, <NONE>,  'SHSetUnreadMailCountW',  \
    SHShellFolderView_Message, N, <NONE>,  'SHShellFolderView_Message',  \
    SHSimpleIDListFromPath, N, <NONE>,  'SHSimpleIDListFromPath',  \
    SHStartNetConnectionDialog, W, <NONE>,  'SHStartNetConnectionDialogW',  \
    SHTestTokenMembership, N, <NONE>,  'SHTestTokenMembership',  \
    SHUnlockShared, N, <NONE>,  'SHUnlockShared',  \
    SHUpdateImage, A, <NONE>,  'SHUpdateImageA',  \
    SHUpdateImage, W, <NONE>,  'SHUpdateImageW',  \
    SHUpdateRecycleBinIcon, N, <NONE>,  'SHUpdateRecycleBinIcon',  \
    SHValidateUNC, N, <NONE>,  'SHValidateUNC',  \
    SheChangeDir, A, <NONE>,  'SheChangeDirA',  \
    SheChangeDirEx, A, <NONE>,  'SheChangeDirExA',  \
    SheChangeDirEx, W, <NONE>,  'SheChangeDirExW',  \
    SheChangeDir, W, <NONE>,  'SheChangeDirW',  \
    SheConvertPath, W, <NONE>,  'SheConvertPathW',  \
    SheFullPath, A, <NONE>,  'SheFullPathA',  \
    SheFullPath, W, <NONE>,  'SheFullPathW',  \
    SheGetCurDrive, N, <NONE>,  'SheGetCurDrive',  \
    SheGetDir, A, <NONE>,  'SheGetDirA',  \
    SheGetDirEx, W, <NONE>,  'SheGetDirExW',  \
    SheGetDir, W, <NONE>,  'SheGetDirW',  \
    SheGetPathOffset, W, <NONE>,  'SheGetPathOffsetW',  \
    SheRemoveQuotes, A, <NONE>,  'SheRemoveQuotesA',  \
    SheRemoveQuotes, W, <NONE>,  'SheRemoveQuotesW',  \
    SheSetCurDrive, N, <NONE>,  'SheSetCurDrive',  \
    SheShortenPath, A, <NONE>,  'SheShortenPathA',  \
    SheShortenPath, W, <NONE>,  'SheShortenPathW',  \
    ShellAbout, A, <.hwnd, .szApp, .szOtherStuff, .hIcon>,  'ShellAboutA',  \
    ShellAbout, W, <.hwnd, .szApp, .szOtherStuff, .hIcon>,  'ShellAboutW',  \
    ShellExec_RunDLL, A, <NONE>,  'ShellExec_RunDLLA',  \
    ShellExec_RunDLL, W, <NONE>,  'ShellExec_RunDLLW',  \
    ShellExecute, A, <.hwnd, .lpOperation, .lpFile, .lpParameters, .lpDirectory, .nCmdShow>,  'ShellExecuteA',  \
    ShellExecuteEx, A, <.lpExecInfo>,  'ShellExecuteExA',  \
    ShellExecuteEx, W, <.lpExecInfo>,  'ShellExecuteExW',  \
    ShellExecute, W, <.hwnd, .lpOperation, .lpFile, .lpParameters, .lpDirectory, .nCmdShow>,  'ShellExecuteW',  \
    ShellHookProc, N, <NONE>,  'ShellHookProc',  \
    ShellMessageBox, A, <NONE>,  'ShellMessageBoxA',  \
    ShellMessageBox, W, <NONE>,  'ShellMessageBoxW',  \
    Shell_GetCachedImageIndex, N, <NONE>,  'Shell_GetCachedImageIndex',  \
    Shell_GetImageLists, N, <NONE>,  'Shell_GetImageLists',  \
    Shell_MergeMenus, N, <NONE>,  'Shell_MergeMenus',  \
    Shell_NotifyIcon, A, <.dwMessage, .lpData>,  'Shell_NotifyIconA',  \
    Shell_NotifyIcon, W, <.dwMessage, .lpData>,  'Shell_NotifyIconW',  \
    SignalFileOpen, N, <NONE>,  'SignalFileOpen',  \
    StrChr, A, <.lpStart, .wMatch>,  'StrChrA',  \
    StrChrI, A, <.lpStart, .wMatch>,  'StrChrIA',  \
    StrChrI, W, <.lpStart, .wMatch>,  'StrChrIW',  \
    StrChr, W, <.lpStart, .wMatch>,  'StrChrW',  \
    StrCmpN, A, <.lpStr1, .lpStr2, .nChar>,  'StrCmpNA',  \
    StrCmpNI, A, <.lpStr1, .lpStr2, .nChar>,  'StrCmpNIA',  \
    StrCmpNI, W, <.lpStr1, .lpStr2, .nChar>,  'StrCmpNIW',  \
    StrCmpN, W, <.lpStr1, .lpStr2, .nChar>,  'StrCmpNW',  \
    StrCpyN, A, <NONE>,  'StrCpyNA',  \
    StrCpyN, W, <NONE>,  'StrCpyNW',  \
    StrNCmp, A, <NONE>,  'StrNCmpA',  \
    StrNCmpI, A, <NONE>,  'StrNCmpIA',  \
    StrNCmpI, W, <NONE>,  'StrNCmpIW',  \
    StrNCmp, W, <NONE>,  'StrNCmpW',  \
    StrNCpy, A, <NONE>,  'StrNCpyA',  \
    StrNCpy, W, <NONE>,  'StrNCpyW',  \
    StrRChr, A, <.lpStart, .lpEnd, .wMatch>,  'StrRChrA',  \
    StrRChrI, A, <.lpStart, .lpEnd, .wMatch>,  'StrRChrIA',  \
    StrRChrI, W, <.lpStart, .lpEnd, .wMatch>,  'StrRChrIW',  \
    StrRChr, W, <.lpStart, .lpEnd, .wMatch>,  'StrRChrW',  \
    StrRStr, A, <NONE>,  'StrRStrA',  \
    StrRStrI, A, <.lpSource, .lpLast, .lpSrch>,  'StrRStrIA',  \
    StrRStrI, W, <.lpSource, .lpLast, .lpSrch>,  'StrRStrIW',  \
    StrRStr, W, <NONE>,  'StrRStrW',  \
    StrStr, A, <.lpFirst, .lpSrch>,  'StrStrA',  \
    StrStrI, A, <.lpFirst, .lpSrch>,  'StrStrIA',  \
    StrStrI, W, <.lpFirst, .lpSrch>,  'StrStrIW',  \
    StrStr, W, <.lpFirst, .lpSrch>,  'StrStrW',  \
    WOWShellExecute, N, <NONE>,  'WOWShellExecute',  \
    Win32DeleteFile, N, <NONE>,  'Win32DeleteFile',  \
    WriteCabinetState, N, <NONE>,  'WriteCabinetState'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































































































































































































































































































































































































Deleted freshlib/imports/Win32/api/sqlite3.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: sqlite3.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto sqlite3,  \
    sqliteAggregateContext, N, <.context, .nbytes>,  'sqlite3_aggregate_context',  \
    sqliteAggregateCount_OLD, N, <NONE>,  'sqlite3_aggregate_count',  \
    sqliteAutoExtension, N, <.ptrCallback>,  'sqlite3_auto_extension',  \
    sqliteBackupFinish, N, <.ptrBackup>,  'sqlite3_backup_finish',  \
    sqliteBackupInit, N, <.ptrDestDB, .ptrDestName, .ptrSourceDB, .ptrSourceName>,  'sqlite3_backup_init',  \
    sqliteBackupPageCount, N, <.ptrBackup>,  'sqlite3_backup_pagecount',  \
    sqliteBackupRemaining, N, <.ptrBackup>,  'sqlite3_backup_remaining',  \
    sqliteBackupStep, N, <.ptrBackup, .nPage>,  'sqlite3_backup_step',  \
    sqliteBindBlob, N, <.stmt, .index, .ptrData, .nbytes, .destructor>,  'sqlite3_bind_blob',  \
    sqliteBindDouble, N, <.stmt, .index, .value>,  'sqlite3_bind_double',  \
    sqliteBindInt, N, <.stmt, .index, .value>,  'sqlite3_bind_int',  \
    sqliteBindInt64, N, <.stmt, .index, .valueLo, .valueHi>,  'sqlite3_bind_int64',  \
    sqliteBindNull, N, <.stmt, .index>,  'sqlite3_bind_null',  \
    sqliteBindParameterCount, N, <.stmt>,  'sqlite3_bind_parameter_count',  \
    sqliteBindParameterIndex, N, <.stmt, .paramName>,  'sqlite3_bind_parameter_index',  \
    sqliteBindParameterName, N, <.stmt, .paramIndex>,  'sqlite3_bind_parameter_name',  \
    sqliteBindText, N, <.stmt, .index, .ptrText, .nbytes, .destructor>,  'sqlite3_bind_text',  \
    sqliteBindText16, N, <.stmt, .index, .ptrText, .nbytes, .destructor>,  'sqlite3_bind_text16',  \
    sqliteBindValue, N, <.stmt, .index, .ptrValue>,  'sqlite3_bind_value',  \
    sqliteBindZeroblob, N, <.stmt, .index, .size>,  'sqlite3_bind_zeroblob',  \
    sqliteBlobBytes, N, <.hBlob>,  'sqlite3_blob_bytes',  \
    sqliteBlobClose, N, <.hBlob>,  'sqlite3_blob_close',  \
    sqliteBlobOpen, N, <.ptrDB, .DBname, .Table, .Column, .iRow, .flags, .ptrVarBlob>,  'sqlite3_blob_open',  \
    sqliteBlobRead, N, <.hBlob, .ptrBuffer, .bytes, .iOffset>,  'sqlite3_blob_read',  \
    sqliteBlobWrite, N, <.hBlob, .ptrBuffer, .bytes, .iOffset>,  'sqlite3_blob_write',  \
    sqliteBusyHandler, N, <.ptrDB, .ptrProc, .lParam>,  'sqlite3_busy_handler',  \
    sqliteBusyTimeout, N, <.ptrDB, .time_ms>,  'sqlite3_busy_timeout',  \
    sqliteChanges, N, <.ptrDB>,  'sqlite3_changes',  \
    sqliteClearBindings, N, <.stmt>,  'sqlite3_clear_bindings',  \
    sqliteClose, N, <.ptrDatabase>,  'sqlite3_close',  \
    sqliteCollationNeeded, N, <.ptrDB, .lparam, .ptrCallback>,  'sqlite3_collation_needed',  \
    sqliteCollationNeeded16, N, <.ptrDB, .lparam, .ptrCallback>,  'sqlite3_collation_needed16',  \
    sqliteColumnBlob, N, <.stmt, .iCol>,  'sqlite3_column_blob',  \
    sqliteColumnBytes, N, <.stmt, .iCol>,  'sqlite3_column_bytes',  \
    sqliteColumnBytes16, N, <.stmt, .iCol>,  'sqlite3_column_bytes16',  \
    sqliteColumnCount, N, <.stmt>,  'sqlite3_column_count',  \
    sqliteColumnDatabaseName, N, <.stmt, .index>,  'sqlite3_column_database_name',  \
    sqliteColumnDatabaseName16, N, <.stmt, .index>,  'sqlite3_column_database_name16',  \
    sqliteColumnDeclType, N, <.stmt, .index>,  'sqlite3_column_decltype',  \
    sqliteColumnDeclType16, N, <.stmt, .index>,  'sqlite3_column_decltype16',  \
    sqliteColumnDouble, N, <.stmt, .iCol>,  'sqlite3_column_double',  \
    sqliteColumnInt, N, <.stmt, .iCol>,  'sqlite3_column_int',  \
    sqliteColumnInt64, N, <.stmt, .iCol>,  'sqlite3_column_int64',  \
    sqliteColumnName, N, <.stmt, .index>,  'sqlite3_column_name',  \
    sqliteColumnName16, N, <.stmt, .index>,  'sqlite3_column_name16',  \
    sqliteColumnOriginName, N, <.stmt, .index>,  'sqlite3_column_origin_name',  \
    sqliteColumnOriginName16, N, <.stmt, .index>,  'sqlite3_column_origin_name16',  \
    sqliteColumnTableName, N, <.stmt, .index>,  'sqlite3_column_table_name',  \
    sqliteColumnTableName16, N, <.stmt, .index>,  'sqlite3_column_table_name16',  \
    sqliteColumnText, N, <.stmt, .iCol>,  'sqlite3_column_text',  \
    sqliteColumnText16, N, <.stmt, .iCol>,  'sqlite3_column_text16',  \
    sqliteColumnType, N, <.stmt, .iCol>,  'sqlite3_column_type',  \
    sqliteColumnValue, N, <.stmt, .iCol>,  'sqlite3_column_value',  \
    sqliteCommitHook, N, <.ptrDB, .ptrHook, .lparam>,  'sqlite3_commit_hook',  \
    sqliteCompileOptionGet, N, <.N>,  'sqlite3_compileoption_get',  \
    sqliteCompileOptionUsed, N, <.ptrOptName>,  'sqlite3_compileoption_used',  \
    sqliteComplete, N, <.ptrSQL>,  'sqlite3_complete',  \
    sqliteComplete16, N, <.ptrSQL>,  'sqlite3_complete16',  \
    sqliteConfig, N, <.index, .Carguments>,  'sqlite3_config',  \
    sqliteContextDBHandle, N, <.context>,  'sqlite3_context_db_handle',  \
    sqliteCreateCollation, N, <.ptrDB, .ptrName, .eTextRep, .lparam, .procCompare>,  'sqlite3_create_collation',  \
    sqliteCreateCollation16, N, <.ptrDB, .ptrName, .eTextRep, .lparam, .procCompare>,  'sqlite3_create_collation16',  \
    sqliteCreateCollation_v2, N, <.ptrDB, .ptrName, .eTextRep, .lparam, .procCompare, .ptrDestroy>,  'sqlite3_create_collation_v2',  \
    sqliteCreateFunction, N, <.ptrDB, .ptrFunctionName, .nArg, .eTextRep, .lparam, .procFunc, .procStep, .procFinal>,  'sqlite3_create_function',  \
    sqliteCreateFunction16, N, <.ptrDB, .ptrFunctionName, .nArg, .eTextRep, .lparam, .procFunc, .procStep, .procFinal>,  'sqlite3_create_function16',  \
    sqliteCreateFunction_v2, N, <.ptrDB, .ptrFunctionName, .nArg, .eTextRep, .lparam, .procFunc, .procStep, .procFinal, .procDestroy>,  'sqlite3_create_function_v2',  \
    sqliteCreateModule, N, <.ptrDB, .ptrModuleName, .ptrVTableModule, .lparam>,  'sqlite3_create_module',  \
    sqliteCreateModule_v2, N, <.ptrDB, .ptrModuleName, .ptrVTableModule, .lparam, .procDestroy>,  'sqlite3_create_module_v2',  \
    sqliteDBConfig, N, <.ptrDB, .index, .Carguments>,  'sqlite3_db_config',  \
    sqliteDBHandle, N, <.stmt>,  'sqlite3_db_handle',  \
    sqliteDBMutex, N, <.ptrDB>,  'sqlite3_db_mutex',  \
    sqliteDBStatus, N, <.ptrDB, .index, .ptrRetCurrent, .ptrRetHighest, .flagReset>,  'sqlite3_db_status',  \
    sqliteDataCount, N, <.stmt>,  'sqlite3_data_count',  \
    sqliteDeclareVtab, N, <.ptrDB, .ptrSQL>,  'sqlite3_declare_vtab',  \
    sqliteEnableLoadExtension, N, <.ptrDB, .flagEnable>,  'sqlite3_enable_load_extension',  \
    sqliteEnableSharedCache, N, <.flagEnable>,  'sqlite3_enable_shared_cache',  \
    sqliteErrCode, N, <.ptrDB>,  'sqlite3_errcode',  \
    sqliteErrMsg, N, <.ptrDB>,  'sqlite3_errmsg',  \
    sqliteErrMsg16, N, <.ptrDB>,  'sqlite3_errmsg16',  \
    sqliteExec, N, <.ptrDB, .ptrSQL, .procCallback, .lparam, .ptrVarErrMsg>,  'sqlite3_exec',  \
    sqliteExpired, N, <VOID>,  'sqlite3_expired',  \
    sqliteExtendedErrCode, N, <.ptrDB>,  'sqlite3_extended_errcode',  \
    sqliteExtendedResultCodes, N, <.ptrDB, .flagEnable>,  'sqlite3_extended_result_codes',  \
    sqliteFileControl, N, <.ptrDB, .ptrDBName, .wparam, .lparam>,  'sqlite3_file_control',  \
    sqliteFinalize, N, <.stmt>,  'sqlite3_finalize',  \
    sqliteFree, N, <.ptrmem>,  'sqlite3_free',  \
    sqliteFreeTable, N, <.ptrVarResult>,  'sqlite3_free_table',  \
    sqliteGetAutocommit, N, <.ptrDB>,  'sqlite3_get_autocommit',  \
    sqliteGetAuxdata, N, <.context, .N>,  'sqlite3_get_auxdata',  \
    sqliteGetTable, N, <.ptrDB, .ptrSQL, .ptrVarResult, .ptrVarRows, .ptrVarColumns, .ptrVarErrorMsg>,  'sqlite3_get_table',  \
    sqliteGlobalRecover_OLD, N, <NONE>,  'sqlite3_global_recover',  \
    sqliteInitialize, N, <VOID>,  'sqlite3_initialize',  \
    sqliteInterrupt, N, <.ptrDB>,  'sqlite3_interrupt',  \
    sqliteLastInsertRowID, N, <.ptrDB>,  'sqlite3_last_insert_rowid',  \
    sqliteLibVersion, N, <VOID>,  'sqlite3_libversion',  \
    sqliteLibversionNumber, N, <VOID>,  'sqlite3_libversion_number',  \
    sqliteLimit, N, <.ptrDB, .idLimit, .newVal>,  'sqlite3_limit',  \
    sqliteLoadExtension, N, <.ptrDB, .nameDLL, .entryProc, .ptrVarErrMsg>,  'sqlite3_load_extension',  \
    sqliteLog, N, <.iErrCode, .ptrFormat, .Carguments>,  'sqlite3_log',  \
    sqliteMAlloc, N, <.size>,  'sqlite3_malloc',  \
    sqliteMemoryAlarm_OLD, N, <NONE>,  'sqlite3_memory_alarm',  \
    sqliteMemoryHighWater, N, <.flagReset>,  'sqlite3_memory_highwater',  \
    sqliteMemoryUsed, N, <VOID>,  'sqlite3_memory_used',  \
    sqliteMprintf, N, <.ptrString, .Carguments>,  'sqlite3_mprintf',  \
    sqliteMutexAlloc, N, <.type>,  'sqlite3_mutex_alloc',  \
    sqliteMutexEnter, N, <.hMutex>,  'sqlite3_mutex_enter',  \
    sqliteMutexFree, N, <.hMutex>,  'sqlite3_mutex_free',  \
    sqliteMutexLeave, N, <.hMutex>,  'sqlite3_mutex_leave',  \
    sqliteMutexTry, N, <.hMutex>,  'sqlite3_mutex_try',  \
    sqliteNextStmt, N, <.ptrDB, .stmt>,  'sqlite3_next_stmt',  \
    sqliteOSEnd, N, <VOID>,  'sqlite3_os_end',  \
    sqliteOSInit, N, <VOID>,  'sqlite3_os_init',  \
    sqliteOpen, N, <.ptrFileName, \
    .ptrVarDB>,  'sqlite3_open',  \
    sqliteOpen16, N, <.ptrFileName, .ptrVarDB>,  'sqlite3_open16',  \
    sqliteOpen_v2, N, <.ptrFileName, .ptrVarDB, .flags, .ptrVFSName>,  'sqlite3_open_v2',  \
    sqliteOverloadFunction, N, <.ptrDB, .ptrFuncName, .lparam>,  'sqlite3_overload_function',  \
    sqlitePrepare, N, <.ptrDB, .ptrSQL, .lenSQL, .ptrVarStmt, .ptrVarNext>,  'sqlite3_prepare',  \
    sqlitePrepare16, N, <.ptrDB, .ptrSQL, .lenSQL, .ptrVarStmt, .ptrVarNext>,  'sqlite3_prepare16',  \
    sqlitePrepare16_v2, N, <.ptrDB, .ptrSQL, .lenSQL, .ptrVarStmt, .ptrVarNext>,  'sqlite3_prepare16_v2',  \
    sqlitePrepare_v2, N, <.ptrDB, .ptrSQL, .lenSQL, .ptrVarStmt, .ptrVarNext>,  'sqlite3_prepare_v2',  \
    sqliteProfile, N, <.ptrDB, .procProfiler, .lparam>,  'sqlite3_profile',  \
    sqliteProgressHandler, N, <.ptrDB, .N, .procProgress, .lparam>,  'sqlite3_progress_handler',  \
    sqliteRandomness, N, <.bytes, .buffer>,  'sqlite3_randomness',  \
    sqliteReAlloc, N, <.ptrmem, .newsize>,  'sqlite3_realloc',  \
    sqliteReleaseMemory, N, <.bytes>,  'sqlite3_release_memory',  \
    sqliteReset, N, <.stmt>,  'sqlite3_reset',  \
    sqliteResetAutoExtension, N, <VOID>,  'sqlite3_reset_auto_extension',  \
    sqliteResultBlob, N, <.context, .ptrdata, .size, .procDestroy>,  'sqlite3_result_blob',  \
    sqliteResultDouble, N, <.context, .double>,  'sqlite3_result_double',  \
    sqliteResultError, N, <.context, .ptrErrMsg, .size>,  'sqlite3_result_error',  \
    sqliteResultError16, N, <.context, .ptrErrMsg, .size>,  'sqlite3_result_error16',  \
    sqliteResultErrorCode, N, <.context, .errcode>,  'sqlite3_result_error_code',  \
    sqliteResultErrorNoMem, N, <.context>,  'sqlite3_result_error_nomem',  \
    sqliteResultErrorTooBig, N, <.context>,  'sqlite3_result_error_toobig',  \
    sqliteResultInt, N, <.context, .integer>,  'sqlite3_result_int',  \
    sqliteResultInt64, N, <.context, .int64Lo, .int64Hi>,  'sqlite3_result_int64',  \
    sqliteResultNULL, N, <.context>,  'sqlite3_result_null',  \
    sqliteResultText, N, <.context, .ptrText, .size, .procDestroy>,  'sqlite3_result_text',  \
    sqliteResultText16, N, <.context, .ptrText, .size, .procDestroy>,  'sqlite3_result_text16',  \
    sqliteResultText16be, N, <.context, .ptrText, .size, .procDestroy>,  'sqlite3_result_text16be',  \
    sqliteResultText16le, N, <.context, .ptrText, .size, .procDestroy>,  'sqlite3_result_text16le',  \
    sqliteResultValue, N, <.context, .ptrValue>,  'sqlite3_result_value',  \
    sqliteResultZeroBlob, N, <.context, .size>,  'sqlite3_result_zeroblob',  \
    sqliteRollbackHook, N, <.ptrDB, .ptrHook, .lparam>,  'sqlite3_rollback_hook',  \
    sqliteRtreeGeometryCallback, N, <NONE>,  'sqlite3_rtree_geometry_callback',  \
    sqliteSQL, N, <.stmt>,  'sqlite3_sql',  \
    sqliteSetAuthorizer, N, <.ptrDB, .procAuthorizer, .lparam>,  'sqlite3_set_authorizer',  \
    sqliteSetAuxdata, N, <.context, .N, .ptrData, .procDestructor>,  'sqlite3_set_auxdata',  \
    sqliteShutdown, N, <VOID>,  'sqlite3_shutdown',  \
    sqliteSleep, N, <.sleep_ms>,  'sqlite3_sleep',  \
    sqliteSnprintf, N, <.size, .ptrBuffer, .ptrString, .Carguments>,  'sqlite3_snprintf',  \
    sqliteSoftHeapLimit, N, <.N>,  'sqlite3_soft_heap_limit',  \
    sqliteSoftHeapLimit64, N, <.sizeLo, .sizeHi>,  'sqlite3_soft_heap_limit64',  \
    sqliteSourceID, N, <VOID>,  'sqlite3_sourceid',  \
    sqliteStatus, N, <.paramIndex, .ptrVarResult, .ptrVarHighwater, .flagReset>,  'sqlite3_status',  \
    sqliteStep, N, <.stmt>,  'sqlite3_step',  \
    sqliteStmtStatus, N, <.stmt, .paramIndex, .flagReset>,  'sqlite3_stmt_status',  \
    sqliteStrnicmp, N, <.ptrStr1, .ptrStr2, .size>,  'sqlite3_strnicmp',  \
    sqliteTableColumnMetadata, N, <.ptrDB, .ptrDBName, .ptrTableName, .ptrColumnName, .ptrVarDataType, .ptrVarCollSeq, .ptrVarNotNull, .ptrVarPrimaryKey, .ptrVarAutoInc>,  'sqlite3_table_column_metadata',  \
    sqliteTestControl, N, <.opCode, .Carguments>,  'sqlite3_test_control',  \
    sqliteThreadCleanup, N, <VOID>,  'sqlite3_thread_cleanup',  \
    sqliteThreadsafe, N, <VOID>,  'sqlite3_threadsafe',  \
    sqliteTotalChanges, N, <.ptrDB>,  'sqlite3_total_changes',  \
    sqliteTrace, N, <.ptrDB, .procTrace, .lparam>,  'sqlite3_trace',  \
    sqliteTransferBindings, N, <VOID>,  'sqlite3_transfer_bindings',  \
    sqliteUpdateHook, N, <.ptrDB, .procUpdateHook, .lparam>,  'sqlite3_update_hook',  \
    sqliteUserData, N, <.context>,  'sqlite3_user_data',  \
    sqliteValueBlob, N, <.ptrValue>,  'sqlite3_value_blob',  \
    sqliteValueBytes, N, <.ptrValue>,  'sqlite3_value_bytes',  \
    sqliteValueBytes16, N, <.ptrValue>,  'sqlite3_value_bytes16',  \
    sqliteValueDouble, N, <.ptrValue>,  'sqlite3_value_double',  \
    sqliteValueInt, N, <.ptrValue>,  'sqlite3_value_int',  \
    sqliteValueInt64, N, <.ptrValue>,  'sqlite3_value_int64',  \
    sqliteValueNumericType, N, <.ptrValue>,  'sqlite3_value_numeric_type',  \
    sqliteValueText, N, <.ptrValue>,  'sqlite3_value_text',  \
    sqliteValueText16, N, <.ptrValue>,  'sqlite3_value_text16',  \
    sqliteValueText16be, N, <.ptrValue>,  'sqlite3_value_text16be',  \
    sqliteValueText16le, N, <.ptrValue>,  'sqlite3_value_text16le',  \
    sqliteValueType, N, <.ptrValue>,  'sqlite3_value_type',  \
    sqliteVersion, N, <VOID>,  'sqlite3_version',  \
    sqliteVfsFind, N, <.ptrVFSName>,  'sqlite3_vfs_find',  \
    sqliteVfsRegister, N, <.hVFS, .flagDefault>,  'sqlite3_vfs_register',  \
    sqliteVfsUnregister, N, <.hVFS>,  'sqlite3_vfs_unregister',  \
    sqliteVmprintf, N, <.ptrString, .va_list>,  'sqlite3_vmprintf',  \
    sqliteWalAutocheckpoint, N, <.ptrDB, .N>,  'sqlite3_wal_autocheckpoint',  \
    sqliteWalCheckpoint, N, <.ptrDB, .ptrDBName>,  'sqlite3_wal_checkpoint',  \
    sqliteWalHook, N, <.ptrDB, .procCommitHook, .lparam>,  'sqlite3_wal_hook',  \
    sqliteWin32_MbcsToUtf8, N, <NONE>,  'sqlite3_win32_mbcs_to_utf8'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































































































Deleted freshlib/imports/Win32/api/user32.inc.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: user32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto user32,  \
    ActivateKeyboardLayout, N, <.HKL, .flags>,  'ActivateKeyboardLayout',  \
    AdjustWindowRect, N, <.lpRect, .dwStyle, .bMenu>,  'AdjustWindowRect',  \
    AdjustWindowRectEx, N, <.lpRect, .dwStyle, .bMenu, .dwExStyle>,  'AdjustWindowRectEx',  \
    AlignRects, N, <NONE>,  'AlignRects',  \
    AllowForegroundActivation, N, <NONE>,  'AllowForegroundActivation',  \
    AllowSetForegroundWindow, N, <.dwProcessId>,  'AllowSetForegroundWindow',  \
    AnimateWindow, N, <.hwnd, .dwTime, .dwFlags>,  'AnimateWindow',  \
    AnyPopup, N, <VOID>,  'AnyPopup',  \
    AppendMenu, A, <.hMenu, .wFlags, .wIDNewItem, .lpNewItem>,  'AppendMenuA',  \
    AppendMenu, W, <.hMenu, .wFlags, .wIDNewItem, .lpNewItem>,  'AppendMenuW',  \
    ArrangeIconicWindows, N, <.hwnd>,  'ArrangeIconicWindows',  \
    AttachThreadInput, N, <.idAttach, .idAttachTo, .fAttach>,  'AttachThreadInput',  \
    BeginDeferWindowPos, N, <.nNumWindows>,  'BeginDeferWindowPos',  \
    BeginPaint, N, <.hwnd, .lpPaint>,  'BeginPaint',  \
    BlockInput, N, <.fBlockIt>,  'BlockInput',  \
    BringWindowToTop, N, <.hwnd>,  'BringWindowToTop',  \
    BroadcastSystemMessage, A, <.dw, .pdw, .un, .wParam, .lParam>,  'BroadcastSystemMessageA',  \
    BroadcastSystemMessageEx, A, <NONE>,  'BroadcastSystemMessageExA',  \
    BroadcastSystemMessageEx, W, <NONE>,  'BroadcastSystemMessageExW',  \
    BroadcastSystemMessage, W, <.dw, .pdw, .un, .wParam, .lParam>,  'BroadcastSystemMessageW',  \
    BuildReasonArray, N, <NONE>,  'BuildReasonArray',  \
    CalcMenuBar, N, <NONE>,  'CalcMenuBar',  \
    CallMsgFilter, A, <.lpMsg, .ncode>,  'CallMsgFilterA',  \
    CallMsgFilter, W, <.lpMsg, .ncode>,  'CallMsgFilterW',  \
    CallNextHookEx, N, <.hHook, .ncode, .wParam, .lParam>,  'CallNextHookEx',  \
    CallWindowProc, A, <.lpPrevWndFunc, .hWnd, .Msg, .wParam, .lParam>,  'CallWindowProcA',  \
    CallWindowProc, W, <.lpPrevWndFunc, .hWnd, .Msg, .wParam, .lParam>,  'CallWindowProcW',  \
    CascadeChildWindows, N, <NONE>,  'CascadeChildWindows',  \
    CascadeWindows, N, <.hwndParent, .wHow, .lpRect, .cKids, .lpkids>,  'CascadeWindows',  \
    ChangeClipboardChain, N, <.hwnd, .hWndNext>,  'ChangeClipboardChain',  \
    ChangeDisplaySettings, A, <.lpDevMode, .dwFlags>,  'ChangeDisplaySettingsA',  \
    ChangeDisplaySettingsEx, A, <.lpszDeviceName, .lpDevMode, .hwnd, .dwflags, .lParam>,  'ChangeDisplaySettingsExA',  \
    ChangeDisplaySettingsEx, W, <.lpszDeviceName, .lpDevMode, .hwnd, .dwflags, .lParam>,  'ChangeDisplaySettingsExW',  \
    ChangeDisplaySettings, W, <.lpDevMode, .dwFlags>,  'ChangeDisplaySettingsW',  \
    ChangeMenu, A, <.hMenu, .cmd, .lpszNewItem, .cmdInsert, .flags>,  'ChangeMenuA',  \
    ChangeMenu, W, <.hMenu, .cmd, .lpszNewItem, .cmdInsert, .flags>,  'ChangeMenuW',  \
    CharLower, A, <.lpsz>,  'CharLowerA',  \
    CharLowerBuff, A, <.lpsz, .cchLength>,  'CharLowerBuffA',  \
    CharLowerBuff, W, <.lpsz, .cchLength>,  'CharLowerBuffW',  \
    CharLower, W, <.lpsz>,  'CharLowerW',  \
    CharNext, A, <.lpsz>,  'CharNextA',  \
    CharNextEx, A, <.CodePage, .lpCurrentChar, .dwFlags>,  'CharNextExA',  \
    CharNext, W, <.lpsz>,  'CharNextW',  \
    CharPrev, A, <.lpszStart, .lpszCurrent>,  'CharPrevA',  \
    CharPrevEx, A, <.CodePage, .lpStart, .lpCurrentChar, .dwFlags>,  'CharPrevExA',  \
    CharPrev, W, <.lpszStart, .lpszCurrent>,  'CharPrevW',  \
    CharToOem, A, <.lpszSrc, .lpszDst>,  'CharToOemA',  \
    CharToOemBuff, A, <.lpszSrc, .lpszDst, .cchDstLength>,  'CharToOemBuffA',  \
    CharToOemBuff, W, <.lpszSrc, .lpszDst, .cchDstLength>,  'CharToOemBuffW',  \
    CharToOem, W, <.lpszSrc, .lpszDst>,  'CharToOemW',  \
    CharUpper, A, <.lpsz>,  'CharUpperA',  \
    CharUpperBuff, A, <.lpsz, .cchLength>,  'CharUpperBuffA',  \
    CharUpperBuff, W, <.lpsz, .cchLength>,  'CharUpperBuffW',  \
    CharUpper, W, <.lpsz>,  'CharUpperW',  \
    CheckDlgButton, N, <.hDlg, .nIDButton, .uCheck>,  'CheckDlgButton',  \
    CheckMenuItem, N, <.hMenu, .wIDCheckItem, .wCheck>,  'CheckMenuItem',  \
    CheckMenuRadioItem, N, <.hMenu, .un1, .un2, .un3, .un4>,  'CheckMenuRadioItem',  \
    CheckRadioButton, N, <.hDlg, .nIDFirstButton, .nIDLastButton, .nIDCheckButton>,  'CheckRadioButton',  \
    ChildWindowFromPoint, N, <.hWnd, .xPoint, .yPoint>,  'ChildWindowFromPoint',  \
    ChildWindowFromPointEx, N, <.hWnd, .pt, .un>,  'ChildWindowFromPointEx',  \
    CliImmSetHotKey, N, <NONE>,  'CliImmSetHotKey',  \
    ClientThreadSetup, N, <NONE>,  'ClientThreadSetup',  \
    ClientToScreen, N, <.hwnd, .lpPoint>,  'ClientToScreen',  \
    ClipCursor, N, <.lpRect>,  'ClipCursor',  \
    CloseClipboard, N, <VOID>,  'CloseClipboard',  \
    CloseDesktop, N, <.hDesktop>,  'CloseDesktop',  \
    CloseWindow, N, <.hwnd>,  'CloseWindow',  \
    CloseWindowStation, N, <.hWinSta>,  'CloseWindowStation',  \
    CopyAcceleratorTable, A, <.hAccelSrc, .lpAccelDst, .cAccelEntries>,  'CopyAcceleratorTableA',  \
    CopyAcceleratorTable, W, <.hAccelSrc, .lpAccelDst, .cAccelEntries>,  'CopyAcceleratorTableW',  \
    CopyIcon, N, <.hIcon>,  'CopyIcon',  \
    CopyImage, N, <.handle, .un1, .n1, .n2, .un2>,  'CopyImage',  \
    CopyRect, N, <.lpDestRect, .lpSourceRect>,  'CopyRect',  \
    CountClipboardFormats, N, <VOID>,  'CountClipboardFormats',  \
    CreateAcceleratorTable, A, <.lpaccl, .cEntries>,  'CreateAcceleratorTableA',  \
    CreateAcceleratorTable, W, <.lpaccl, .cEntries>,  'CreateAcceleratorTableW',  \
    CreateCaret, N, <.hwnd, .hBitmap, .nWidth, .nHeight>,  'CreateCaret',  \
    CreateCursor, N, <.hInstance, .nXhotspot, .nYhotspot, .nWidth, .nHeight, .lpANDbitPlane, .lpXORbitPlane>,  'CreateCursor',  \
    CreateDesktop, A, <.lpszDesktop, .lpszDevice, .pDevmode, .dwFlags, .dwDesiredAccess, .lpsa>,  'CreateDesktopA',  \
    CreateDesktop, W, <.lpszDesktop, .lpszDevice, .pDevmode, .dwFlags, .dwDesiredAccess, .lpsa>,  'CreateDesktopW',  \
    CreateDialogIndirectParam, A, <.hInstance, .lpTemplate, .hWndParent, .lpDialogFunc, .dwInitParam>,  'CreateDialogIndirectParamA',  \
    CreateDialogIndirectParamAor, W, <NONE>,  'CreateDialogIndirectParamAorW',  \
    CreateDialogIndirectParam, W, <.hInstance, .lpTemplate, .hWndParent, .lpDialogFunc, .dwInitParam>,  'CreateDialogIndirectParamW',  \
    CreateDialogParam, A, <.hInstance, .lpName, .hWndParent, .lpDialogFunc, .lParamInit>,  'CreateDialogParamA',  \
    CreateDialogParam, W, <.hInstance, .lpName, .hWndParent, .lpDialogFunc, .lParamInit>,  'CreateDialogParamW',  \
    CreateIcon, N, <.hInstance, .nWidth, .nHeight, .nPlanes, .nBitsPixel, .lpANDbits, .lpXORbits>,  'CreateIcon',  \
    CreateIconFromResource, N, <.presbits, .dwResSize, .fIcon, .dwVer>,  'CreateIconFromResource',  \
    CreateIconFromResourceEx, N, <.presbits, .dwResSize, .fIcon, .dwVer, .cxDesired, .cyDesired, .Flags>,  'CreateIconFromResourceEx',  \
    CreateIconIndirect, N, <.piconinfo>,  'CreateIconIndirect',  \
    CreateMDIWindow, A, <.lpClassName, .lpWindowName, .dwStyle, .x, .y, .nWidth, .nHeight, .hWndParent, .hInstance, .lParam>,  'CreateMDIWindowA',  \
    CreateMDIWindow, W, <.lpClassName, .lpWindowName, .dwStyle, .x, .y, .nWidth, .nHeight, .hWndParent, .hInstance, .lParam>,  'CreateMDIWindowW',  \
    CreateMenu, N, <VOID>,  'CreateMenu',  \
    CreatePopupMenu, N, <VOID>,  'CreatePopupMenu',  \
    CreateSystemThreads, N, <NONE>,  'CreateSystemThreads',  \
    CreateWindowEx, A, <.dwExStyle, .lpClassName, .lpWindowName, .dwStyle, .x, .y, .nWidth, .nHeight, .hWndParent, .hMenu, .hInstance, .lpParam>,  'CreateWindowExA',  \
    CreateWindowEx, W, <.dwExStyle, .lpClassName, .lpWindowName, .dwStyle, .x, .y, .nWidth, .nHeight, .hWndParent, .hMenu, .hInstance, .lpParam>,  'CreateWindowExW',  \
    CreateWindowStation, A, <.lpwinsta, .dwReserved, .dwDesiredAccess, .lpsa>,  'CreateWindowStationA',  \
    CreateWindowStation, W, <.lpwinsta, .dwReserved, .dwDesiredAccess, .lpsa>,  'CreateWindowStationW',  \
    CsrBroadcastSystemMessageEx, W, <NONE>,  'CsrBroadcastSystemMessageExW',  \
    CtxInitUser32, N, <NONE>,  'CtxInitUser32',  \
    DdeAbandonTransaction, N, <.idInst, .hConv, .idTransaction>,  'DdeAbandonTransaction',  \
    DdeAccessData, N, <.hData, .pcbDataSize>,  'DdeAccessData',  \
    DdeAddData, N, <.hData, .pSrc, .cb, .cbOff>,  'DdeAddData',  \
    DdeClientTransaction, N, <.pData, .cbData, .hConv, .hszItem, .wFmt, .wType, .dwTimeout, .pdwResult>,  'DdeClientTransaction',  \
    DdeCmpStringHandles, N, <.hsz1, .hsz2>,  'DdeCmpStringHandles',  \
    DdeConnect, N, <.idInst, .hszService, .hszTopic, .pCC>,  'DdeConnect',  \
    DdeConnectList, N, <.idInst, .hszService, .hszTopic, .hConvList, .pCC>,  'DdeConnectList',  \
    DdeCreateDataHandle, N, <.idInst, .pSrc, .cb, .cbOff, .hszItem, .wFmt, .afCmd>,  'DdeCreateDataHandle',  \
    DdeCreateStringHandle, A, <.idInst, .psz, .iCodePage>,  'DdeCreateStringHandleA',  \
    DdeCreateStringHandle, W, <.idInst, .psz, .iCodePage>,  'DdeCreateStringHandleW',  \
    DdeDisconnect, N, <.hConv>,  'DdeDisconnect',  \
    DdeDisconnectList, N, <.hConvList>,  'DdeDisconnectList',  \
    DdeEnableCallback, N, <.idInst, .hConv, .wCmd>,  'DdeEnableCallback',  \
    DdeFreeDataHandle, N, <.hData>,  'DdeFreeDataHandle',  \
    DdeFreeStringHandle, N, <.idInst, .hsz>,  'DdeFreeStringHandle',  \
    DdeGetData, N, <.hData, .pDst, .cbMax, .cbOff>,  'DdeGetData',  \
    DdeGetLastError, N, <.idInst>,  'DdeGetLastError',  \
    DdeGetQualityOfService, N, <NONE>,  'DdeGetQualityOfService',  \
    DdeImpersonateClient, N, <.hConv>,  'DdeImpersonateClient',  \
    DdeInitialize, A, <.pidInst, .pfnCallback, .afCmd, .ulRes>,  'DdeInitializeA',  \
    DdeInitialize, W, <.pidInst, .pfnCallback, .afCmd, .ulRes>,  'DdeInitializeW',  \
    DdeKeepStringHandle, N, <.idInst, .hsz>,  'DdeKeepStringHandle',  \
    DdeNameService, N, <.idInst, .hsz1, .hsz2, .afCmd>,  'DdeNameService',  \
    DdePostAdvise, N, <.idInst, .hszTopic, .hszItem>,  'DdePostAdvise',  \
    DdeQueryConvInfo, N, <.hConv, .idTransaction, .pConvInfo>,  'DdeQueryConvInfo',  \
    DdeQueryNextServer, N, <.hConvList, .hConvPrev>,  'DdeQueryNextServer',  \
    DdeQueryString, A, <.idInst, .hsz, .psz, .cchMax, .iCodePage>,  'DdeQueryStringA',  \
    DdeQueryString, W, <.idInst, .hsz, .psz, .cchMax, .iCodePage>,  'DdeQueryStringW',  \
    DdeReconnect, N, <.hConv>,  'DdeReconnect',  \
    DdeSetQualityOfService, N, <.hWndClient, .pqosNew, .pqosPrev>,  'DdeSetQualityOfService',  \
    DdeSetUserHandle, N, <.hConv, .id, .hUser>,  'DdeSetUserHandle',  \
    DdeUnaccessData, N, <.hData>,  'DdeUnaccessData',  \
    DdeUninitialize, N, <.idInst>,  'DdeUninitialize',  \
    DefDlgProc, A, <.hDlg, .wMsg, .wParam, .lParam>,  'DefDlgProcA',  \
    DefDlgProc, W, <.hDlg, .wMsg, .wParam, .lParam>,  'DefDlgProcW',  \
    DefFrameProc, A, <.hwnd, .hWndMDIClient, .wMsg, .wParam, .lParam>,  'DefFrameProcA',  \
    DefFrameProc, W, <.hwnd, .hWndMDIClient, .wMsg, .wParam, .lParam>,  'DefFrameProcW',  \
    DefMDIChildProc, A, <.hwnd, .wMsg, .wParam, .lParam>,  'DefMDIChildProcA',  \
    DefMDIChildProc, W, <.hwnd, .wMsg, .wParam, .lParam>,  'DefMDIChildProcW',  \
    DefRawInputProc, N, <NONE>,  'DefRawInputProc',  \
    DefWindowProc, A, <.hwnd, .wMsg, .wParam, .lParam>,  'DefWindowProcA',  \
    DefWindowProc, W, <.hwnd, .wMsg, .wParam, .lParam>,  'DefWindowProcW',  \
    DeferWindowPos, N, <.hWinPosInfo, .hwnd, .hWndInsertAfter, .x, .y, .cx, .cy, .wFlags>,  'DeferWindowPos',  \
    DeleteMenu, N, <.hMenu, .nPosition, .wFlags>,  'DeleteMenu',  \
    DeregisterShellHookWindow, N, <NONE>,  'DeregisterShellHookWindow',  \
    DestroyAcceleratorTable, N, <.haccel>,  'DestroyAcceleratorTable',  \
    DestroyCaret, N, <VOID>,  'DestroyCaret',  \
    DestroyCursor, N, <.hCursor>,  'DestroyCursor',  \
    DestroyIcon, N, <.hIcon>,  'DestroyIcon',  \
    DestroyMenu, N, <.hMenu>,  'DestroyMenu',  \
    DestroyReasons, N, <NONE>,  'DestroyReasons',  \
    DestroyWindow, N, <.hwnd>,  'DestroyWindow',  \
    DeviceEventWorker, N, <NONE>,  'DeviceEventWorker',  \
    DialogBoxIndirectParam, A, <.hInstance, .hDialogTemplate, .hWndParent, .lpDialogFunc, .dwInitParam>,  'DialogBoxIndirectParamA',  \
    DialogBoxIndirectParamAor, W, <NONE>,  'DialogBoxIndirectParamAorW',  \
    DialogBoxIndirectParam, W, <.hInstance, .hDialogTemplate, .hWndParent, .lpDialogFunc, .dwInitParam>,  'DialogBoxIndirectParamW',  \
    DialogBoxParam, A, <.hInstance, .lpTemplateName, .hWndParent, .lpDialogFunc, .dwInitParam>,  'DialogBoxParamA',  \
    DialogBoxParam, W, <.hInstance, .lpTemplateName, .hWndParent, .lpDialogFunc, .dwInitParam>,  'DialogBoxParamW',  \
    DisableProcessWindowsGhosting, N, <NONE>,  'DisableProcessWindowsGhosting',  \
    DispatchMessage, A, <.lpMsg>,  'DispatchMessageA',  \
    DispatchMessage, W, <.lpMsg>,  'DispatchMessageW',  \
    DisplayExitWindowsWarnings, N, <NONE>,  'DisplayExitWindowsWarnings',  \
    DlgDirList, A, <.hDlg, .lpPathSpec, .nIDListBox, .nIDStaticPath, .wFileType>,  'DlgDirListA',  \
    DlgDirListComboBox, A, <.hDlg, .lpPathSpec, .nIDComboBox, .nIDStaticPath, .wFileType>,  'DlgDirListComboBoxA',  \
    DlgDirListComboBox, W, <.hDlg, .lpPathSpec, .nIDComboBox, .nIDStaticPath, .wFileType>,  'DlgDirListComboBoxW',  \
    DlgDirList, W, <.hDlg, .lpPathSpec, .nIDListBox, .nIDStaticPath, .wFileType>,  'DlgDirListW',  \
    DlgDirSelectComboBoxEx, A, <.hWndDlg, .lpszPath, .cbPath, .idComboBox>,  'DlgDirSelectComboBoxExA',  \
    DlgDirSelectComboBoxEx, W, <.hWndDlg, .lpszPath, .cbPath, .idComboBox>,  'DlgDirSelectComboBoxExW',  \
    DlgDirSelectEx, A, <.hWndDlg, .lpszPath, .cbPath, .idListBox>,  'DlgDirSelectExA',  \
    DlgDirSelectEx, W, <.hWndDlg, .lpszPath, .cbPath, .idListBox>,  'DlgDirSelectExW',  \
    DragDetect, N, <.hWnd, .pt>,  'DragDetect',  \
    DragObject, N, <.hWnd1, .hWnd2, .un, .dw, .hCursor>,  'DragObject',  \
    DrawAnimatedRects, N, <.hwnd, .idAni, .lprcFrom, .lprcTo>,  'DrawAnimatedRects',  \
    DrawCaption, N, <.hWnd, .hDC, .pcRect, .uDCFlags>,  'DrawCaption',  \
    DrawCaptionTemp, A, <NONE>,  'DrawCaptionTempA',  \
    DrawCaptionTemp, W, <NONE>,  'DrawCaptionTempW',  \
    DrawEdge, N, <.hdc, .qrc, .edge, .grfFlags>,  'DrawEdge',  \
    DrawFocusRect, N, <.hdc, .lpRect>,  'DrawFocusRect',  \
    DrawFrame, N, <NONE>,  'DrawFrame',  \
    DrawFrameControl, N, <.hDC, .lpRect, .uFrameType, .uFrameState>,  'DrawFrameControl',  \
    DrawIcon, N, <.hdc, .x, .y, .hIcon>,  'DrawIcon',  \
    DrawIconEx, N, <.hdc, .xLeft, .yTop, .hIcon, .cxWidth, .cyWidth, .istepIfAniCur, .hbrFlickerFreeDraw, .diFlags>,  'DrawIconEx',  \
    DrawMenuBar, N, <.hwnd>,  'DrawMenuBar',  \
    DrawMenuBarTemp, N, <NONE>,  'DrawMenuBarTemp',  \
    DrawState, A, <.hDC, .hBrush, .lpDrawStateProc, .lParam, .wParam, .n1, .n2, .n3, .n4, .un>,  'DrawStateA',  \
    DrawState, W, <.hDC, .hBrush, .lpDrawStateProc, .lParam, .wParam, .n1, .n2, .n3, .n4, .un>,  'DrawStateW',  \
    DrawText, A, <.hdc, .lpStr, .nCount, .lpRect, .wFormat>,  'DrawTextA',  \
    DrawTextEx, A, <.hDC, .lpsz, .n, .lpRect, .un, .lpDrawTextParams>,  'DrawTextExA',  \
    DrawTextEx, W, <.hDC, .lpsz, .n, .lpRect, .un, .lpDrawTextParams>,  'DrawTextExW',  \
    DrawText, W, <.hdc, .lpStr, .nCount, .lpRect, .wFormat>,  'DrawTextW',  \
    EditWndProc, N, <NONE>,  'EditWndProc',  \
    EmptyClipboard, N, <VOID>,  'EmptyClipboard',  \
    EnableMenuItem, N, <.hMenu, .wIDEnableItem, .wEnable>,  'EnableMenuItem',  \
    EnableScrollBar, N, <.hwnd, .wSBflags, .wArrows>,  'EnableScrollBar',  \
    EnableWindow, N, <.hwnd, .fBoolean>,  'EnableWindow',  \
    EndDeferWindowPos, N, <.hWinPosInfo>,  'EndDeferWindowPos',  \
    EndDialog, N, <.hDlg, .nResult>,  'EndDialog',  \
    EndMenu, N, <VOID>,  'EndMenu',  \
    EndPaint, N, <.hwnd, .lpPaint>,  'EndPaint',  \
    EndTask, N, <NONE>,  'EndTask',  \
    EnterReaderModeHelper, N, <NONE>,  'EnterReaderModeHelper',  \
    EnumChildWindows, N, <.hWndParent, .lpEnumFunc, .lParam>,  'EnumChildWindows',  \
    EnumClipboardFormats, N, <.wFormat>,  'EnumClipboardFormats',  \
    EnumDesktopWindows, N, <.hDesktop, .lpfn, .lParam>,  'EnumDesktopWindows',  \
    EnumDesktops, A, <.hwinsta, .lpEnumFunc, .lParam>,  'EnumDesktopsA',  \
    EnumDesktops, W, <.hwinsta, .lpEnumFunc, .lParam>,  'EnumDesktopsW',  \
    EnumDisplayDevices, A, <.lpDevice, .iDevNum, .lpDisplayDevice, .dwFlags>,  'EnumDisplayDevicesA',  \
    EnumDisplayDevices, W, <.lpDevice, .iDevNum, .lpDisplayDevice, .dwFlags>,  'EnumDisplayDevicesW',  \
    EnumDisplayMonitors, N, <.hdc, .lprcClip, .lpfnEnum, .dwData>,  'EnumDisplayMonitors',  \
    EnumDisplaySettings, A, <.lpszDeviceName, .iModeNum, .lpDevMode>,  'EnumDisplaySettingsA',  \
    EnumDisplaySettingsEx, A, <.lpszDeviceName, .iModeNum, .lpDevMode, .dwFlags>,  'EnumDisplaySettingsExA',  \
    EnumDisplaySettingsEx, W, <.lpszDeviceName, .iModeNum, .lpDevMode, .dwFlags>,  'EnumDisplaySettingsExW',  \
    EnumDisplaySettings, W, <.lpszDeviceName, .iModeNum, .lpDevMode>,  'EnumDisplaySettingsW',  \
    EnumProps, A, <.hWnd, .lpEnumFunc>,  'EnumPropsA',  \
    EnumPropsEx, A, <.hWnd, .lpEnumFunc, .lParam>,  'EnumPropsExA',  \
    EnumPropsEx, W, <.hWnd, .lpEnumFunc, .lParam>,  'EnumPropsExW',  \
    EnumProps, W, <.hWnd, .lpEnumFunc>,  'EnumPropsW',  \
    EnumThreadWindows, N, <.dwThreadId, .lpfn, .lParam>,  'EnumThreadWindows',  \
    EnumWindowStations, A, <.lpEnumFunc, .lParam>,  'EnumWindowStationsA',  \
    EnumWindowStations, W, <.lpEnumFunc, .lParam>,  'EnumWindowStationsW',  \
    EnumWindows, N, <.lpEnumFunc, .lParam>,  'EnumWindows',  \
    EqualRect, N, <.lpRect1, .lpRect2>,  'EqualRect',  \
    ExcludeUpdateRgn, N, <.hdc, .hwnd>,  'ExcludeUpdateRgn',  \
    ExitWindowsEx, N, <.uFlags, .dwReserved>,  'ExitWindowsEx',  \
    FillRect, N, <.hdc, .lpRect, .hBrush>,  'FillRect',  \
    FindWindow, A, <.lpClassName, .lpWindowName>,  'FindWindowA',  \
    FindWindowEx, A, <.hWnd1, .hWnd2, .lpsz1, .lpsz2>,  'FindWindowExA',  \
    FindWindowEx, W, <.hWnd1, .hWnd2, .lpsz1, .lpsz2>,  'FindWindowExW',  \
    FindWindow, W, <.lpClassName, .lpWindowName>,  'FindWindowW',  \
    FlashWindow, N, <.hwnd, .bInvert>,  'FlashWindow',  \
    FlashWindowEx, N, <.pfwi>,  'FlashWindowEx',  \
    FrameRect, N, <.hdc, .lpRect, .hBrush>,  'FrameRect',  \
    FreeDDElParam, N, <.msg, .lParam>,  'FreeDDElParam',  \
    GetActiveWindow, N, <VOID>,  'GetActiveWindow',  \
    GetAltTabInfo, A, <.hwnd, .iItem, .pati, .pszItemText, .cchItemText>,  'GetAltTabInfoA',  \
    GetAltTabInfo, W, <.hwnd, .iItem, .pati, .pszItemText, .cchItemText>,  'GetAltTabInfoW',  \
    GetAncestor, N, <.hwnd, .gaFlags>,  'GetAncestor',  \
    GetAppCompatFlags, N, <NONE>,  'GetAppCompatFlags',  \
    GetAppCompatFlags2, N, <NONE>,  'GetAppCompatFlags2',  \
    GetAsyncKeyState, N, <.vKey>,  'GetAsyncKeyState',  \
    GetCapture, N, <VOID>,  'GetCapture',  \
    GetCaretBlinkTime, N, <VOID>,  'GetCaretBlinkTime',  \
    GetCaretPos, N, <.lpPoint>,  'GetCaretPos',  \
    GetClassInfo, A, <.hInstance, .lpClassName, .lpWndClass>,  'GetClassInfoA',  \
    GetClassInfoEx, A, <.hinstance, .lpcstr, .lpwndclassexa>,  'GetClassInfoExA',  \
    GetClassInfoEx, W, <.hinstance, .lpcstr, .lpwndclassexa>,  'GetClassInfoExW',  \
    GetClassInfo, W, <.hInstance, .lpClassName, .lpWndClass>,  'GetClassInfoW',  \
    GetClassLong, A, <.hwnd, .nIndex>,  'GetClassLongA',  \
    GetClassLong, W, <.hwnd, .nIndex>,  'GetClassLongW',  \
    GetClassName, A, <.hwnd, .lpClassName, .nMaxCount>,  'GetClassNameA',  \
    GetClassName, W, <.hwnd, .lpClassName, .nMaxCount>,  'GetClassNameW',  \
    GetClassWord, N, <.hwnd, .nIndex>,  'GetClassWord',  \
    GetClientRect, N, <.hwnd, .lpRect>,  'GetClientRect',  \
    GetClipCursor, N, <.lprc>,  'GetClipCursor',  \
    GetClipboardData, N, <.wFormat>,  'GetClipboardData',  \
    GetClipboardFormatName, A, <.wFormat, .lpString, .nMaxCount>,  'GetClipboardFormatNameA',  \
    GetClipboardFormatName, W, <.wFormat, .lpString, .nMaxCount>,  'GetClipboardFormatNameW',  \
    GetClipboardOwner, N, <VOID>,  'GetClipboardOwner',  \
    GetClipboardSequenceNumber, N, <VOID>,  'GetClipboardSequenceNumber',  \
    GetClipboardViewer, N, <VOID>,  'GetClipboardViewer',  \
    GetComboBoxInfo, N, <.hwndCombo, .pcbi>,  'GetComboBoxInfo',  \
    GetCursor, N, <VOID>,  'GetCursor',  \
    GetCursorFrameInfo, N, <NONE>,  'GetCursorFrameInfo',  \
    GetCursorInfo, N, <.pci>,  'GetCursorInfo',  \
    GetCursorPos, N, <.lpPoint>,  'GetCursorPos',  \
    GetDC, N, <.hwnd>,  'GetDC',  \
    GetDCEx, N, <.hwnd, .hrgnclip, .fdwOptions>,  'GetDCEx',  \
    GetDesktopWindow, N, <VOID>,  'GetDesktopWindow',  \
    GetDialogBaseUnits, N, <VOID>,  'GetDialogBaseUnits',  \
    GetDlgCtrlID, N, <.hwnd>,  'GetDlgCtrlID',  \
    GetDlgItem, N, <.hDlg, .nIDDlgItem>,  'GetDlgItem',  \
    GetDlgItemInt, N, <.hDlg, .nIDDlgItem, .lpTranslated, .bSigned>,  'GetDlgItemInt',  \
    GetDlgItemText, A, <.hDlg, .nIDDlgItem, .lpString, .nMaxCount>,  'GetDlgItemTextA',  \
    GetDlgItemText, W, <.hDlg, .nIDDlgItem, .lpString, .nMaxCount>,  'GetDlgItemTextW',  \
    GetDoubleClickTime, N, <VOID>,  'GetDoubleClickTime',  \
    GetFocus, N, <VOID>,  'GetFocus',  \
    GetForegroundWindow, N, <VOID>,  'GetForegroundWindow',  \
    GetGUIThreadInfo, N, <.idThread, .pgui>,  'GetGUIThreadInfo',  \
    GetGuiResources, N, <.hProcess, .uiFlags>,  'GetGuiResources',  \
    GetIconInfo, N, <.hIcon, .piconinfo>,  'GetIconInfo',  \
    GetInputDesktop, N, <NONE>,  'GetInputDesktop',  \
    GetInputState, N, <VOID>,  'GetInputState',  \
    GetInternalWindowPos, N, <NONE>,  'GetInternalWindowPos',  \
    GetKBCodePage, N, <VOID>,  'GetKBCodePage',  \
    GetKeyNameText, A, <.lParam, .lpBuffer, .nSize>,  'GetKeyNameTextA',  \
    GetKeyNameText, W, <.lParam, .lpBuffer, .nSize>,  'GetKeyNameTextW',  \
    GetKeyState, N, <.nVirtKey>,  'GetKeyState',  \
    GetKeyboardLayout, N, <.dwLayout>,  'GetKeyboardLayout',  \
    GetKeyboardLayoutList, N, <.nBuff, .lpList>,  'GetKeyboardLayoutList',  \
    GetKeyboardLayoutName, A, <.pwszKLID>,  'GetKeyboardLayoutNameA',  \
    GetKeyboardLayoutName, W, <.pwszKLID>,  'GetKeyboardLayoutNameW',  \
    GetKeyboardState, N, <.pbKeyState>,  'GetKeyboardState',  \
    GetKeyboardType, N, <.nTypeFlag>,  'GetKeyboardType',  \
    GetLastActivePopup, N, <.hwndOwnder>,  'GetLastActivePopup',  \
    GetLastInputInfo, N, <.plii>,  'GetLastInputInfo',  \
    GetLayeredWindowAttributes, N, <NONE>,  'GetLayeredWindowAttributes',  \
    GetListBoxInfo, N, <.hwnd>,  'GetListBoxInfo',  \
    GetMenu, N, <.hwnd>,  'GetMenu',  \
    GetMenuBarInfo, N, <.hwnd, .idObject, .idItem, .pmbi>,  'GetMenuBarInfo',  \
    GetMenuCheckMarkDimensions, N, <VOID>,  'GetMenuCheckMarkDimensions',  \
    GetMenuContextHelpId, N, <.hMenu>,  'GetMenuContextHelpId',  \
    GetMenuDefaultItem, N, <.hMenu, .fByPos, .gmdiFlags>,  'GetMenuDefaultItem',  \
    GetMenuInfo, N, <.hmenu, .LPMENUINFO>,  'GetMenuInfo',  \
    GetMenuItemCount, N, <.hMenu>,  'GetMenuItemCount',  \
    GetMenuItemID, N, <.hMenu, .nPos>,  'GetMenuItemID',  \
    GetMenuItemInfo, A, <.hMenu, .un, .fBoolean, .lpMenuItemInfo>,  'GetMenuItemInfoA',  \
    GetMenuItemInfo, W, <.hMenu, .un, .fBoolean, .lpMenuItemInfo>,  'GetMenuItemInfoW',  \
    GetMenuItemRect, N, <.hWnd, .hMenu, .uItem, .lprcItem>,  'GetMenuItemRect',  \
    GetMenuState, N, <.hMenu, .wID, .wFlags>,  'GetMenuState',  \
    GetMenuString, A, <.hMenu, .wIDItem, .lpString, .nMaxCount, .wFlags>,  'GetMenuStringA',  \
    GetMenuString, W, <.hMenu, .wIDItem, .lpString, .nMaxCount, .wFlags>,  'GetMenuStringW',  \
    GetMessage, A, <.lpMsg, .hwnd, .wMsgFilterMin, .wMsgFilterMax>,  'GetMessageA',  \
    GetMessageExtraInfo, N, <VOID>,  'GetMessageExtraInfo',  \
    GetMessagePos, N, <VOID>,  'GetMessagePos',  \
    GetMessageTime, N, <VOID>,  'GetMessageTime',  \
    GetMessage, W, <.lpMsg, .hwnd, .wMsgFilterMin, .wMsgFilterMax>,  'GetMessageW',  \
    GetMonitorInfo, A, <.hMonitor, .lpmi>,  'GetMonitorInfoA',  \
    GetMonitorInfo, W, <.hMonitor, .lpmi>,  'GetMonitorInfoW',  \
    GetMouseMovePointsEx, N, <.cbSize, .lppt, .lpptBuf, .nBufPoints, .resolution>,  'GetMouseMovePointsEx',  \
    GetNextDlgGroupItem, N, <.hDlg, .hCtl, .bPrevious>,  'GetNextDlgGroupItem',  \
    GetNextDlgTabItem, N, <.hDlg, .hCtl, .bPrevious>,  'GetNextDlgTabItem',  \
    GetOpenClipboardWindow, N, <VOID>,  'GetOpenClipboardWindow',  \
    GetParent, N, <.hwnd>,  'GetParent',  \
    GetPriorityClipboardFormat, N, <.lpPriorityList, .nCount>,  'GetPriorityClipboardFormat',  \
    GetProcessDefaultLayout, N, <.pdwDefaultLayout>,  'GetProcessDefaultLayout',  \
    GetProcessWindowStation, N, <VOID>,  'GetProcessWindowStation',  \
    GetProgmanWindow, N, <NONE>,  'GetProgmanWindow',  \
    GetProp, A, <.hwnd, .lpString>,  'GetPropA',  \
    GetProp, W, <.hwnd, .lpString>,  'GetPropW',  \
    GetQueueStatus, N, <.fuFlags>,  'GetQueueStatus',  \
    GetRawInputBuffer, N, <NONE>,  'GetRawInputBuffer',  \
    GetRawInputData, N, <NONE>,  'GetRawInputData',  \
    GetRawInputDeviceInfo, A, <NONE>,  'GetRawInputDeviceInfoA',  \
    GetRawInputDeviceInfo, W, <NONE>,  'GetRawInputDeviceInfoW',  \
    GetRawInputDeviceList, N, <NONE>,  'GetRawInputDeviceList',  \
    GetReasonTitleFromReasonCode, N, <NONE>,  'GetReasonTitleFromReasonCode',  \
    GetRegisteredRawInputDevices, N, <NONE>,  'GetRegisteredRawInputDevices',  \
    GetScrollBarInfo, N, <.hwnd, .idObject, .psbi>,  'GetScrollBarInfo',  \
    GetScrollInfo, N, <.hWnd, .n, .lpScrollInfo>,  'GetScrollInfo',  \
    GetScrollPos, N, <.hwnd, .nBar>,  'GetScrollPos',  \
    GetScrollRange, N, <.hwnd, .nBar, .lpMinPos, .lpMaxPos>,  'GetScrollRange',  \
    GetShellWindow, N, <NONE>,  'GetShellWindow',  \
    GetSubMenu, N, <.hMenu, .nPos>,  'GetSubMenu',  \
    GetSysColor, N, <.nSysColor>,  'GetSysColor',  \
    GetSysColorBrush, N, <.nSysColor>,  'GetSysColorBrush',  \
    GetSystemMenu, N, <.hwnd, .fBoolean>,  'GetSystemMenu',  \
    GetSystemMetrics, N, <.nIndex>,  'GetSystemMetrics',  \
    GetTabbedTextExtent, A, <.hdc, .lpString, .nCount, .nTabPositions, .lpnTabStopPositions>,  'GetTabbedTextExtentA',  \
    GetTabbedTextExtent, W, <.hdc, .lpString, .nCount, .nTabPositions, .lpnTabStopPositions>,  'GetTabbedTextExtentW',  \
    GetTaskmanWindow, N, <NONE>,  'GetTaskmanWindow',  \
    GetThreadDesktop, N, <.dwThread>,  'GetThreadDesktop',  \
    GetTitleBarInfo, N, <.hwnd, .pti>,  'GetTitleBarInfo',  \
    GetTopWindow, N, <.hwnd>,  'GetTopWindow',  \
    GetUpdateRect, N, <.hwnd, .lpRect, .bErase>,  'GetUpdateRect',  \
    GetUpdateRgn, N, <.hwnd, .hRgn, .fErase>,  'GetUpdateRgn',  \
    GetUserObjectInformation, A, <.hObj, .nIndex, .pvInfo, .nLength, .lpnLengthNeeded>,  'GetUserObjectInformationA',  \
    GetUserObjectInformation, W, <.hObj, .nIndex, .pvInfo, .nLength, .lpnLengthNeeded>,  'GetUserObjectInformationW',  \
    GetUserObjectSecurity, N, <.hObj, .pSIRequested, .pSd, .nLength, .lpnLengthNeeded>,  'GetUserObjectSecurity',  \
    GetWinStationInfo, N, <NONE>,  'GetWinStationInfo',  \
    GetWindow, N, <.hwnd, .wCmd>,  'GetWindow',  \
    GetWindowContextHelpId, N, <.hWnd>,  'GetWindowContextHelpId',  \
    GetWindowDC, N, <.hwnd>,  'GetWindowDC',  \
    GetWindowInfo, N, <.hwnd, .pwi>,  'GetWindowInfo',  \
    GetWindowLong, A, <.hwnd, .nIndex>,  'GetWindowLongA',  \
    GetWindowLong, W, <.hwnd, .nIndex>,  'GetWindowLongW',  \
    GetWindowModuleFileName, A, <.hwnd, .pszFileName, .cchFileNameMax>,  'GetWindowModuleFileNameA',  \
    GetWindowModuleFileName, W, <.hwnd, .pszFileName, .cchFileNameMax>,  'GetWindowModuleFileNameW',  \
    GetWindowPlacement, N, <.hwnd, .lpwndpl>,  'GetWindowPlacement',  \
    GetWindowRect, N, <.hwnd, .lpRect>,  'GetWindowRect',  \
    GetWindowRgn, N, <.hWnd, .hRgn>,  'GetWindowRgn',  \
    GetWindowRgnBox, N, <NONE>,  'GetWindowRgnBox',  \
    GetWindowText, A, <.hwnd, .lpString, .cch>,  'GetWindowTextA',  \
    GetWindowTextLength, A, <.hwnd>,  'GetWindowTextLengthA',  \
    GetWindowTextLength, W, <.hwnd>,  'GetWindowTextLengthW',  \
    GetWindowText, W, <.hwnd, .lpString, .cch>,  'GetWindowTextW',  \
    GetWindowThreadProcessId, N, <.hwnd, .lpdwProcessId>,  'GetWindowThreadProcessId',  \
    GetWindowWord, N, <.hwnd, .nIndex>,  'GetWindowWord',  \
    GrayString, A, <.hDC, .hBrush, .lpOutputFunc, .lpData, .nCount, .X, .Y, .nWidth, .nHeight>,  'GrayStringA',  \
    GrayString, W, <.hDC, .hBrush, .lpOutputFunc, .lpData, .nCount, .X, .Y, .nWidth, .nHeight>,  'GrayStringW',  \
    HideCaret, N, <.hwnd>,  'HideCaret',  \
    HiliteMenuItem, N, <.hwnd, .hMenu, .wIDHiliteItem, .wHilite>,  'HiliteMenuItem',  \
    IMPGetIME, A, <.hwnd, .LPIMEPROA>,  'IMPGetIMEA',  \
    IMPGetIME, W, <.hwnd, .LPIMEPROA>,  'IMPGetIMEW',  \
    IMPQueryIME, A, <.LPIMEPROA>,  'IMPQueryIMEA',  \
    IMPQueryIME, W, <.LPIMEPROA>,  'IMPQueryIMEW',  \
    IMPSetIME, A, <.hwnd, .LPIMEPROA>,  'IMPSetIMEA',  \
    IMPSetIME, W, <.hwnd, .LPIMEPROA>,  'IMPSetIMEW',  \
    ImpersonateDdeClientWindow, N, <.hWndClient, .hWndServer>,  'ImpersonateDdeClientWindow',  \
    InSendMessage, N, <VOID>,  'InSendMessage',  \
    InSendMessageEx, N, <.lpReserved>,  'InSendMessageEx',  \
    InflateRect, N, <.lpRect, .x, .y>,  'InflateRect',  \
    InitializeLpkHooks, N, <NONE>,  'InitializeLpkHooks',  \
    InitializeWin32EntryTable, N, <NONE>,  'InitializeWin32EntryTable',  \
    InsertMenu, A, <.hMenu, .nPosition, .wFlags, .wIDNewItem, .lpNewItem>,  'InsertMenuA',  \
    InsertMenuItem, A, <.hMenu, .uItem, .bool, .ByRef>,  'InsertMenuItemA',  \
    InsertMenuItem, W, <.hMenu, .uItem, .bool, .ByRef>,  'InsertMenuItemW',  \
    InsertMenu, W, <.hMenu, .nPosition, .wFlags, .wIDNewItem, .lpNewItem>,  'InsertMenuW',  \
    InternalGetWindowText, N, <NONE>,  'InternalGetWindowText',  \
    IntersectRect, N, <.lpDestRect, .lpSrc1Rect, .lpSrc2Rect>,  'IntersectRect',  \
    InvalidateRect, N, <.hwnd, .lpRect, .fBoolean>,  'InvalidateRect',  \
    InvalidateRgn, N, <.hwnd, .hRgn, .bErase>,  'InvalidateRgn',  \
    InvertRect, N, <.hdc, .lpRect>,  'InvertRect',  \
    IsCharAlpha, A, <.cChar>,  'IsCharAlphaA',  \
    IsCharAlphaNumeric, A, <.cChar>,  'IsCharAlphaNumericA',  \
    IsCharAlphaNumeric, W, <.cChar>,  'IsCharAlphaNumericW',  \
    IsCharAlpha, W, <.cChar>,  'IsCharAlphaW',  \
    IsCharLower, A, <.cChar>,  'IsCharLowerA',  \
    IsCharLower, W, <.cChar>,  'IsCharLowerW',  \
    IsCharUpper, A, <.cChar>,  'IsCharUpperA',  \
    IsCharUpper, W, <.cChar>,  'IsCharUpperW',  \
    IsChild, N, <.hWndParent, .hwnd>,  'IsChild',  \
    IsClipboardFormatAvailable, N, <.wFormat>,  'IsClipboardFormatAvailable',  \
    IsDialogMessage, A, <.hDlg, .lpMsg>,  'IsDialogMessageA',  \
    IsDialogMessage, W, <.hDlg, .lpMsg>,  'IsDialogMessageW',  \
    IsDlgButtonChecked, N, <.hDlg, .nIDButton>,  'IsDlgButtonChecked',  \
    IsGUIThread, N, <NONE>,  'IsGUIThread',  \
    IsHungAppWindow, N, <NONE>,  'IsHungAppWindow',  \
    IsIconic, N, <.hwnd>,  'IsIconic',  \
    IsMenu, N, <.hMenu>,  'IsMenu',  \
    IsRectEmpty, N, <.lpRect>,  'IsRectEmpty',  \
    IsServerSideWindow, N, <NONE>,  'IsServerSideWindow',  \
    IsWinEventHookInstalled, N, <NONE>,  'IsWinEventHookInstalled',  \
    IsWindow, N, <.hwnd>,  'IsWindow',  \
    IsWindowEnabled, N, <.hwnd>,  'IsWindowEnabled',  \
    IsWindowInDestroy, N, <NONE>,  'IsWindowInDestroy',  \
    IsWindowUnicode, N, <.hwnd>,  'IsWindowUnicode',  \
    IsWindowVisible, N, <.hwnd>,  'IsWindowVisible',  \
    IsZoomed, N, <.hwnd>,  'IsZoomed',  \
    KillSystemTimer, N, <NONE>,  'KillSystemTimer',  \
    KillTimer, N, <.hwnd, .nIDEvent>,  'KillTimer',  \
    LoadAccelerators, A, <.hInstance, .lpTableName>,  'LoadAcceleratorsA',  \
    LoadAccelerators, W, <.hInstance, .lpTableName>,  'LoadAcceleratorsW',  \
    LoadBitmap, A, <.hInstance, .lpBitmapName>,  'LoadBitmapA',  \
    LoadBitmap, W, <.hInstance, .lpBitmapName>,  'LoadBitmapW',  \
    LoadCursor, A, <.hInstance, .lpCursorName>,  'LoadCursorA',  \
    LoadCursorFromFile, A, <.lpFileName>,  'LoadCursorFromFileA',  \
    LoadCursorFromFile, W, <.lpFileName>,  'LoadCursorFromFileW',  \
    LoadCursor, W, <.hInstance, .lpCursorName>,  'LoadCursorW',  \
    LoadIcon, A, <.hInstance, .lpIconName>,  'LoadIconA',  \
    LoadIcon, W, <.hInstance, .lpIconName>,  'LoadIconW',  \
    LoadImage, A, <.hInst, .lpsz, .uType, .n1, .n2, .uFlags>,  'LoadImageA',  \
    LoadImage, W, <.hInst, .lpsz, .uType, .n1, .n2, .uFlags>,  'LoadImageW',  \
    LoadKeyboardLayout, A, <.pwszKLID, .flags>,  'LoadKeyboardLayoutA',  \
    LoadKeyboardLayoutEx, N, <NONE>,  'LoadKeyboardLayoutEx',  \
    LoadKeyboardLayout, W, <.pwszKLID, .flags>,  'LoadKeyboardLayoutW',  \
    LoadLocalFonts, N, <NONE>,  'LoadLocalFonts',  \
    LoadMenu, A, <.hInstance, .lpString>,  'LoadMenuA',  \
    LoadMenuIndirect, A, <.lpMenuTemplate>,  'LoadMenuIndirectA',  \
    LoadMenuIndirect, W, <.lpMenuTemplate>,  'LoadMenuIndirectW',  \
    LoadMenu, W, <.hInstance, .lpString>,  'LoadMenuW',  \
    LoadRemoteFonts, N, <NONE>,  'LoadRemoteFonts',  \
    LoadString, A, <.hInstance, .wID, .lpBuffer, .nBufferMax>,  'LoadStringA',  \
    LoadString, W, <.hInstance, .wID, .lpBuffer, .nBufferMax>,  'LoadStringW',  \
    LockSetForegroundWindow, N, <.uLockCode>,  'LockSetForegroundWindow',  \
    LockWindowStation, N, <NONE>,  'LockWindowStation',  \
    LockWindowUpdate, N, <.hwndLock>,  'LockWindowUpdate',  \
    LockWorkStation, N, <VOID>,  'LockWorkStation',  \
    LookupIconIdFromDirectory, N, <.presbits, .fIcon>,  'LookupIconIdFromDirectory',  \
    LookupIconIdFromDirectoryEx, N, <.presbits, .fIcon, .cxDesired, .cyDesired, .Flags>,  'LookupIconIdFromDirectoryEx',  \
    MBToWCSEx, N, <NONE>,  'MBToWCSEx',  \
    MB_GetString, N, <NONE>,  'MB_GetString',  \
    MapDialogRect, N, <.hDlg, .lpRect>,  'MapDialogRect',  \
    MapVirtualKey, A, <.wCode, .wMapType>,  'MapVirtualKeyA',  \
    MapVirtualKeyEx, A, <.uCode, .uMapType, .dwhkl>,  'MapVirtualKeyExA',  \
    MapVirtualKeyEx, W, <.uCode, .uMapType, .dwhkl>,  'MapVirtualKeyExW',  \
    MapVirtualKey, W, <.wCode, .wMapType>,  'MapVirtualKeyW',  \
    MapWindowPoints, N, <.hwndFrom, .hwndTo, .lppt, .cPoints>,  'MapWindowPoints',  \
    MenuItemFromPoint, N, <.hWnd, .hMenu, .ptScreen>,  'MenuItemFromPoint',  \
    MenuWindowProc, A, <NONE>,  'MenuWindowProcA',  \
    MenuWindowProc, W, <NONE>,  'MenuWindowProcW',  \
    MessageBeep, N, <.wType>,  'MessageBeep',  \
    MessageBox, A, <.hwnd, .lpText, .lpCaption, .wType>,  'MessageBoxA',  \
    MessageBoxEx, A, <.hwnd, .lpText, .lpCaption, .wType, .wLanguageId>,  'MessageBoxExA',  \
    MessageBoxEx, W, <.hwnd, .lpText, .lpCaption, .wType, .wLanguageId>,  'MessageBoxExW',  \
    MessageBoxIndirect, A, <.lpMsgBoxParams>,  'MessageBoxIndirectA',  \
    MessageBoxIndirect, W, <.lpMsgBoxParams>,  'MessageBoxIndirectW',  \
    MessageBoxTimeout, A, <NONE>,  'MessageBoxTimeoutA',  \
    MessageBoxTimeout, W, <NONE>,  'MessageBoxTimeoutW',  \
    MessageBox, W, <.hwnd, .lpText, .lpCaption, .wType>,  'MessageBoxW',  \
    ModifyMenu, A, <.hMenu, .nPosition, .wFlags, .wIDNewItem, .lpString>,  'ModifyMenuA',  \
    ModifyMenu, W, <.hMenu, .nPosition, .wFlags, .wIDNewItem, .lpString>,  'ModifyMenuW',  \
    MonitorFromPoint, N, <.pt, .dwFlags>,  'MonitorFromPoint',  \
    MonitorFromRect, N, <.lprc, .dwFlags>,  'MonitorFromRect',  \
    MonitorFromWindow, N, <.hwnd, .dwFlags>,  'MonitorFromWindow',  \
    MoveWindow, N, <.hwnd, .x, .y, .nWidth, .nHeight, .fBoolean>,  'MoveWindow',  \
    MsgWaitForMultipleObjects, N, <.nCount, .pHandles, .fWaitAll, .dwMilliseconds, .dwWakeMask>,  'MsgWaitForMultipleObjects',  \
    MsgWaitForMultipleObjectsEx, N, <.nCount, .pHandles, .dwMilliseconds, .dwWakeMask, .dwFlags>,  'MsgWaitForMultipleObjectsEx',  \
    NotifyWinEvent, N, <.lEvent, .hwnd, .idObject, .idChild>,  'NotifyWinEvent',  \
    OemKeyScan, N, <.wOemChar>,  'OemKeyScan',  \
    OemToChar, A, <.lpszSrc, .lpszDst>,  'OemToCharA',  \
    OemToCharBuff, A, <.lpszSrc, .lpszDst, .cchDstLength>,  'OemToCharBuffA',  \
    OemToCharBuff, W, <.lpszSrc, .lpszDst, .cchDstLength>,  'OemToCharBuffW',  \
    OemToChar, W, <.lpszSrc, .lpszDst>,  'OemToCharW',  \
    OffsetRect, N, <.lpRect, .x, .y>,  'OffsetRect',  \
    OpenClipboard, N, <.hwnd>,  'OpenClipboard',  \
    OpenDesktop, A, <.lpszDesktop, .dwFlags, .fInherit, .dwDesiredAccess>,  'OpenDesktopA',  \
    OpenDesktop, W, <.lpszDesktop, .dwFlags, .fInherit, .dwDesiredAccess>,  'OpenDesktopW',  \
    OpenIcon, N, <.hwnd>,  'OpenIcon',  \
    OpenInputDesktop, N, <.dwFlags, .fInherit, .dwDesiredAccess>,  'OpenInputDesktop',  \
    OpenWindowStation, A, <.lpszWinSta, .fInherit, .dwDesiredAccess>,  'OpenWindowStationA',  \
    OpenWindowStation, W, <.lpszWinSta, .fInherit, .dwDesiredAccess>,  'OpenWindowStationW',  \
    PackDDElParam, N, <.msg, .uiLo, .uiHi>,  'PackDDElParam',  \
    PaintDesktop, N, <.hdc>,  'PaintDesktop',  \
    PaintMenuBar, N, <NONE>,  'PaintMenuBar',  \
    PeekMessage, A, <.lpMsg, .hwnd, .wMsgFilterMin, .wMsgFilterMax, .wRemoveMsg>,  'PeekMessageA',  \
    PeekMessage, W, <.lpMsg, .hwnd, .wMsgFilterMin, .wMsgFilterMax, .wRemoveMsg>,  'PeekMessageW',  \
    PostMessage, A, <.hwnd, .wMsg, .wParam, .lParam>,  'PostMessageA',  \
    PostMessage, W, <.hwnd, .wMsg, .wParam, .lParam>,  'PostMessageW',  \
    PostQuitMessage, N, <.nExitCode>,  'PostQuitMessage',  \
    PostThreadMessage, A, <.idThread, .msg, .wParam, .lParam>,  'PostThreadMessageA',  \
    PostThreadMessage, W, <.idThread, .msg, .wParam, .lParam>,  'PostThreadMessageW',  \
    PrintWindow, N, <.hWnd, .hdcBlt, .nFlags>,  'PrintWindow',  \
    PrivateExtractIconEx, A, <NONE>,  'PrivateExtractIconExA',  \
    PrivateExtractIconEx, W, <NONE>,  'PrivateExtractIconExW',  \
    PrivateExtractIcons, A, <NONE>,  'PrivateExtractIconsA',  \
    PrivateExtractIcons, W, <NONE>,  'PrivateExtractIconsW',  \
    PrivateSetDbgTag, N, <NONE>,  'PrivateSetDbgTag',  \
    PrivateSetRipFlags, N, <NONE>,  'PrivateSetRipFlags',  \
    PtInRect, N, <.lpRect, .x, .y>,  'PtInRect',  \
    QuerySendMessage, N, <NONE>,  'QuerySendMessage',  \
    QueryUserCounters, N, <NONE>,  'QueryUserCounters',  \
    RealChildWindowFromPoint, N, <.hwndParent, .ptParentClientCoords>,  'RealChildWindowFromPoint',  \
    RealGetWindowClass, A, <.hwnd, .pszType, .cchType>,  'RealGetWindowClassA',  \
    RealGetWindowClass, W, <.hwnd, .pszType, .cchType>,  'RealGetWindowClassW',  \
    ReasonCodeNeedsBugID, N, <NONE>,  'ReasonCodeNeedsBugID',  \
    ReasonCodeNeedsComment, N, <NONE>,  'ReasonCodeNeedsComment',  \
    RecordShutdownReason, N, <NONE>,  'RecordShutdownReason',  \
    RedrawWindow, N, <.hwnd, .lprcUpdate, .hrgnUpdate, .fuRedraw>,  'RedrawWindow',  \
    RegisterClass, A, <.Class>,  'RegisterClassA',  \
    RegisterClassEx, A, <.pcWndClassEx>,  'RegisterClassExA',  \
    RegisterClassEx, W, <.pcWndClassEx>,  'RegisterClassExW',  \
    RegisterClass, W, <.Class>,  'RegisterClassW',  \
    RegisterClipboardFormat, A, <.lpString>,  'RegisterClipboardFormatA',  \
    RegisterClipboardFormat, W, <.lpString>,  'RegisterClipboardFormatW',  \
    RegisterDeviceNotification, A, <.hRecipient, .NotificationFilter, .Flags>,  'RegisterDeviceNotificationA',  \
    RegisterDeviceNotification, W, <.hRecipient, .NotificationFilter, .Flags>,  'RegisterDeviceNotificationW',  \
    RegisterHotKey, N, <.hwnd, .id, .fsModifiers, .vk>,  'RegisterHotKey',  \
    RegisterLogonProcess, N, <NONE>,  'RegisterLogonProcess',  \
    RegisterMessagePumpHook, N, <NONE>,  'RegisterMessagePumpHook',  \
    RegisterRawInputDevices, N, <NONE>,  'RegisterRawInputDevices',  \
    RegisterServicesProcess, N, <NONE>,  'RegisterServicesProcess',  \
    RegisterShellHookWindow, N, <NONE>,  'RegisterShellHookWindow',  \
    RegisterSystemThread, N, <NONE>,  'RegisterSystemThread',  \
    RegisterTasklist, N, <NONE>,  'RegisterTasklist',  \
    RegisterUserApiHook, N, <NONE>,  'RegisterUserApiHook',  \
    RegisterWindowMessage, A, <.lpString>,  'RegisterWindowMessageA',  \
    RegisterWindowMessage, W, <.lpString>,  'RegisterWindowMessageW',  \
    ReleaseCapture, N, <VOID>,  'ReleaseCapture',  \
    ReleaseDC, N, <.hwnd, .hdc>,  'ReleaseDC',  \
    RemoveMenu, N, <.hMenu, .nPosition, .wFlags>,  'RemoveMenu',  \
    RemoveProp, A, <.hwnd, .lpString>,  'RemovePropA',  \
    RemoveProp, W, <.hwnd, .lpString>,  'RemovePropW',  \
    ReplyMessage, N, <.lReply>,  'ReplyMessage',  \
    ResolveDesktopForWO, W, <NONE>,  'ResolveDesktopForWOW',  \
    ReuseDDElParam, N, <.lParam, .msgIn, .msgOut, .uiLo, .uiHi>,  'ReuseDDElParam',  \
    ScreenToClient, N, <.hwnd, .lpPoint>,  'ScreenToClient',  \
    ScrollChildren, N, <NONE>,  'ScrollChildren',  \
    ScrollDC, N, <.hdc, .dx, .dy, .lprcScroll, .lprcClip, .hrgnUpdate, .lprcUpdate>,  'ScrollDC',  \
    ScrollWindow, N, <.hWnd, .XAmount, .YAmount, .lpRect, .lpClipRect>,  'ScrollWindow',  \
    ScrollWindowEx, N, <.hwnd, .dx, .dy, .lprcScroll, .lprcClip, .hrgnUpdate, .lprcUpdate, .fuScroll>,  'ScrollWindowEx',  \
    SendDlgItemMessage, A, <.hDlg, .nIDDlgItem, .wMsg, .wParam, .lParam>,  'SendDlgItemMessageA',  \
    SendDlgItemMessage, W, <.hDlg, .nIDDlgItem, .wMsg, .wParam, .lParam>,  'SendDlgItemMessageW',  \
    SendIMEMessageEx, A, <.hwnd, .lparam>,  'SendIMEMessageExA',  \
    SendIMEMessageEx, W, <.hwnd, .lparam>,  'SendIMEMessageExW',  \
    SendInput, N, <.cInputs, .pInputs, .cbSize>,  'SendInput',  \
    SendMessage, A, <.hwnd, .wMsg, .wParam, .lParam>,  'SendMessageA',  \
    SendMessageCallback, A, <.hwnd, .wMsg, .wParam, .lParam, .lpResultCallBack, .dwData>,  'SendMessageCallbackA',  \
    SendMessageCallback, W, <.hwnd, .wMsg, .wParam, .lParam, .lpResultCallBack, .dwData>,  'SendMessageCallbackW',  \
    SendMessageTimeout, A, <.hwnd, .msg, .wParam, .lParam, .fuFlags, .uTimeout, .lpdwResult>,  'SendMessageTimeoutA',  \
    SendMessageTimeout, W, <.hwnd, .msg, .wParam, .lParam, .fuFlags, .uTimeout, .lpdwResult>,  'SendMessageTimeoutW',  \
    SendMessage, W, <.hwnd, .wMsg, .wParam, .lParam>,  'SendMessageW',  \
    SendNotifyMessage, A, <.hwnd, .msg, .wParam, .lParam>,  'SendNotifyMessageA',  \
    SendNotifyMessage, W, <.hwnd, .msg, .wParam, .lParam>,  'SendNotifyMessageW',  \
    SetActiveWindow, N, <.hwnd>,  'SetActiveWindow',  \
    SetCapture, N, <.hwnd>,  'SetCapture',  \
    SetCaretBlinkTime, N, <.wMSeconds>,  'SetCaretBlinkTime',  \
    SetCaretPos, N, <.x, .y>,  'SetCaretPos',  \
    SetClassLong, A, <.hwnd, .nIndex, .dwNewLong>,  'SetClassLongA',  \
    SetClassLong, W, <.hwnd, .nIndex, .dwNewLong>,  'SetClassLongW',  \
    SetClassWord, N, <.hwnd, .nIndex, .wNewWord>,  'SetClassWord',  \
    SetClipboardData, N, <.uFormat, .hMem>,  'SetClipboardData',  \
    SetClipboardViewer, N, <.hwnd>,  'SetClipboardViewer',  \
    SetConsoleReserveKeys, N, <NONE>,  'SetConsoleReserveKeys',  \
    SetCursor, N, <.hCursor>,  'SetCursor',  \
    SetCursorContents, N, <NONE>,  'SetCursorContents',  \
    SetCursorPos, N, <.x, .y>,  'SetCursorPos',  \
    SetDebugErrorLevel, N, <.dwLevel>,  'SetDebugErrorLevel',  \
    SetDeskWallpaper, N, <NONE>,  'SetDeskWallpaper',  \
    SetDlgItemInt, N, <.hDlg, .nIDDlgItem, .wValue, .bSigned>,  'SetDlgItemInt',  \
    SetDlgItemText, A, <.hDlg, .nIDDlgItem, .lpString>,  'SetDlgItemTextA',  \
    SetDlgItemText, W, <.hDlg, .nIDDlgItem, .lpString>,  'SetDlgItemTextW',  \
    SetDoubleClickTime, N, <.wCount>,  'SetDoubleClickTime',  \
    SetFocus, N, <.hwnd>,  'SetFocus',  \
    SetForegroundWindow, N, <.hwnd>,  'SetForegroundWindow',  \
    SetInternalWindowPos, N, <NONE>,  'SetInternalWindowPos',  \
    SetKeyboardState, N, <.lppbKeyState>,  'SetKeyboardState',  \
    SetLastErrorEx, N, <.dwErrCode, .dwType>,  'SetLastErrorEx',  \
    SetLayeredWindowAttributes, N, <.hwnd, .crKey, .bAlpha, .dwFlags>,  'SetLayeredWindowAttributes',  \
    SetLogonNotifyWindow, N, <NONE>,  'SetLogonNotifyWindow',  \
    SetMenu, N, <.hwnd, .hMenu>,  'SetMenu',  \
    SetMenuContextHelpId, N, <.hMenu, .dw>,  'SetMenuContextHelpId',  \
    SetMenuDefaultItem, N, <.hMenu, .uItem, .fByPos>,  'SetMenuDefaultItem',  \
    SetMenuInfo, N, <.hmenu, .LPCMENUINFO>,  'SetMenuInfo',  \
    SetMenuItemBitmaps, N, <.hMenu, .nPosition, .wFlags, .hBitmapUnchecked, .hBitmapChecked>,  'SetMenuItemBitmaps',  \
    SetMenuItemInfo, A, <.hMenu, .un, .fBoolean, .lpcMenuItemInfo>,  'SetMenuItemInfoA',  \
    SetMenuItemInfo, W, <.hMenu, .un, .fBoolean, .lpcMenuItemInfo>,  'SetMenuItemInfoW',  \
    SetMessageExtraInfo, N, <.lParam>,  'SetMessageExtraInfo',  \
    SetMessageQueue, N, <.cMessagesMax>,  'SetMessageQueue',  \
    SetParent, N, <.hWndChild, .hWndNewParent>,  'SetParent',  \
    SetProcessDefaultLayout, N, <.dwDefaultLayout>,  'SetProcessDefaultLayout',  \
    SetProcessWindowStation, N, <.hWinSta>,  'SetProcessWindowStation',  \
    SetProgmanWindow, N, <NONE>,  'SetProgmanWindow',  \
    SetProp, A, <.hwnd, .lpString, .hData>,  'SetPropA',  \
    SetProp, W, <.hwnd, .lpString, .hData>,  'SetPropW',  \
    SetRect, N, <.lpRect, .X1, .Y1, .X2, .Y2>,  'SetRect',  \
    SetRectEmpty, N, <.lpRect>,  'SetRectEmpty',  \
    SetScrollInfo, N, <.hWnd, .n, .lpcScrollInfo, .bool>,  'SetScrollInfo',  \
    SetScrollPos, N, <.hwnd, .nBar, .nPos, .fBoolean>,  'SetScrollPos',  \
    SetScrollRange, N, <.hwnd, .nBar, .nMinPos, .nMaxPos, .bRedraw>,  'SetScrollRange',  \
    SetShellWindow, N, <NONE>,  'SetShellWindow',  \
    SetShellWindowEx, N, <NONE>,  'SetShellWindowEx',  \
    SetSysColors, N, <.nChanges, .lpSysColor, .lpColorValues>,  'SetSysColors',  \
    SetSysColorsTemp, N, <NONE>,  'SetSysColorsTemp',  \
    SetSystemCursor, N, <.hcur, .id>,  'SetSystemCursor',  \
    SetSystemMenu, N, <NONE>,  'SetSystemMenu',  \
    SetSystemTimer, N, <NONE>,  'SetSystemTimer',  \
    SetTaskmanWindow, N, <NONE>,  'SetTaskmanWindow',  \
    SetThreadDesktop, N, <.hDesktop>,  'SetThreadDesktop',  \
    SetTimer, N, <.hWnd, .nIDEvent, .uElapse, .lpTimerFunc>,  'SetTimer',  \
    SetUserObjectInformation, A, <.hObj, .nIndex, .pvInfo, .nLength>,  'SetUserObjectInformationA',  \
    SetUserObjectInformation, W, <.hObj, .nIndex, .pvInfo, .nLength>,  'SetUserObjectInformationW',  \
    SetUserObjectSecurity, N, <.hObj, .pSIRequested, .pSd>,  'SetUserObjectSecurity',  \
    SetWinEventHook, N, <.eventMin, .eventMax, .hmodWinEventProc, .pfnWinEventProc, .idProcess, .idThread, .dwFlags>,  'SetWinEventHook',  \
    SetWindowContextHelpId, N, <.hWnd, .dw>,  'SetWindowContextHelpId',  \
    SetWindowLong, A, <.hwnd, .nIndex, .dwNewLong>,  'SetWindowLongA',  \
    SetWindowLong, W, <.hwnd, .nIndex, .dwNewLong>,  'SetWindowLongW',  \
    SetWindowPlacement, N, <.hwnd, .lpwndpl>,  'SetWindowPlacement',  \
    SetWindowPos, N, <.hwnd, .hWndInsertAfter, .x, .y, .cx, .cy, .wFlags>,  'SetWindowPos',  \
    SetWindowRgn, N, <.hWnd, .hRgn, .bRedraw>,  'SetWindowRgn',  \
    SetWindowStationUser, N, <NONE>,  'SetWindowStationUser',  \
    SetWindowText, A, <.hwnd, .lpString>,  'SetWindowTextA',  \
    SetWindowText, W, <.hwnd, .lpString>,  'SetWindowTextW',  \
    SetWindowWord, N, <.hwnd, .nIndex, .wNewWord>,  'SetWindowWord',  \
    SetWindowsHook, A, <.nFilterType, .pfnFilterProc>,  'SetWindowsHookA',  \
    SetWindowsHookEx, A, <.idHook, .lpfn, .hmod, .dwThreadId>,  'SetWindowsHookExA',  \
    SetWindowsHookEx, W, <.idHook, .lpfn, .hmod, .dwThreadId>,  'SetWindowsHookExW',  \
    SetWindowsHook, W, <.nFilterType, .pfnFilterProc>,  'SetWindowsHookW',  \
    ShowCaret, N, <.hwnd>,  'ShowCaret',  \
    ShowCursor, N, <.bShow>,  'ShowCursor',  \
    ShowOwnedPopups, N, <.hwnd, .fBoolean>,  'ShowOwnedPopups',  \
    ShowScrollBar, N, <.hwnd, .wBar, .bShow>,  'ShowScrollBar',  \
    ShowStartGlass, N, <NONE>,  'ShowStartGlass',  \
    ShowWindow, N, <.hwnd, .nCmdShow>,  'ShowWindow',  \
    ShowWindowAsync, N, <.hWnd, .nCmdShow>,  'ShowWindowAsync',  \
    SoftModalMessageBox, N, <NONE>,  'SoftModalMessageBox',  \
    SubtractRect, N, <.lprcDst, .lprcSrc1, .lprcSrc2>,  'SubtractRect',  \
    SwapMouseButton, N, <.bSwap>,  'SwapMouseButton',  \
    SwitchDesktop, N, <.hDesktop>,  'SwitchDesktop',  \
    SwitchToThisWindow, N, <NONE>,  'SwitchToThisWindow',  \
    SystemParametersInfo, A, <.uAction, .uParam, .ByRef, .fuWinIni>,  'SystemParametersInfoA',  \
    SystemParametersInfo, W, <.uAction, .uParam, .ByRef, .fuWinIni>,  'SystemParametersInfoW',  \
    TabbedTextOut, A, <.hdc, .x, .y, .lpString, .nCount, .nTabPositions, .lpnTabStopPositions, .nTabOrigin>,  'TabbedTextOutA',  \
    TabbedTextOut, W, <.hdc, .x, .y, .lpString, .nCount, .nTabPositions, .lpnTabStopPositions, .nTabOrigin>,  'TabbedTextOutW',  \
    TileChildWindows, N, <NONE>,  'TileChildWindows',  \
    TileWindows, N, <.hwndParent, .wHow, .lpRect, .cKids, .lpKids>,  'TileWindows',  \
    ToAscii, N, <.uVirtKey, .uScanCode, .lpbKeyState, .lpwTransKey, .fuState>,  'ToAscii',  \
    ToAsciiEx, N, <.uVirtKey, .uScanCode, .lpKeyState, .lpChar, .uFlags, .dwhkl>,  'ToAsciiEx',  \
    ToUnicode, N, <.wVirtKey, .wScanCode, .lpKeyState, .pwszBuff, .cchBuff, .wFlags>,  'ToUnicode',  \
    ToUnicodeEx, N, <.wVirtKey, .wScanCode, .lpKeyState, .pwszBuff, .cchBuff, .wFlags, .dwhkl>,  'ToUnicodeEx',  \
    TrackMouseEvent, N, <.lpEventTrack>,  'TrackMouseEvent',  \
    TrackPopupMenu, N, <.hMenu, .uFlags, .x, .y, .nReserved, .hwnd, .lprc>,  'TrackPopupMenu',  \
    TrackPopupMenuEx, N, <.hMenu, .un, .n1, .n2, .hWnd, .lpTPMParams>,  'TrackPopupMenuEx',  \
    TranslateAccelerator, A, <.hwnd, .hAccTable, .lpMsg>,  'TranslateAcceleratorA',  \
    TranslateAccelerator, W, <.hwnd, .hAccTable, .lpMsg>,  'TranslateAcceleratorW',  \
    TranslateMDISysAccel, N, <.hWndClient, .lpMsg>,  'TranslateMDISysAccel',  \
    TranslateMessage, N, <.lpMsg>,  'TranslateMessage',  \
    TranslateMessageEx, N, <NONE>,  'TranslateMessageEx',  \
    UnhookWinEvent, N, <.hWinEventHook>,  'UnhookWinEvent',  \
    UnhookWindowsHook, N, <.nCode, .pfnFilterProc>,  'UnhookWindowsHook',  \
    UnhookWindowsHookEx, N, <.hHook>,  'UnhookWindowsHookEx',  \
    UnionRect, N, <.lpDestRect, .lpSrc1Rect, .lpSrc2Rect>,  'UnionRect',  \
    UnloadKeyboardLayout, N, <.HKL>,  'UnloadKeyboardLayout',  \
    UnlockWindowStation, N, <NONE>,  'UnlockWindowStation',  \
    UnpackDDElParam, N, <.msg, .lParam, .puiLo, .puiHi>,  'UnpackDDElParam',  \
    UnregisterClass, A, <.lpClassName, .hInstance>,  'UnregisterClassA',  \
    UnregisterClass, W, <.lpClassName, .hInstance>,  'UnregisterClassW',  \
    UnregisterDeviceNotification, N, <.Handle>,  'UnregisterDeviceNotification',  \
    UnregisterHotKey, N, <.hwnd, .id>,  'UnregisterHotKey',  \
    UnregisterMessagePumpHook, N, <NONE>,  'UnregisterMessagePumpHook',  \
    UnregisterUserApiHook, N, <NONE>,  'UnregisterUserApiHook',  \
    UpdateLayeredWindow, N, <.hWnd, .hdcDst, .pptDst, .psize, .hdcSrc, .pptSrc, .crKey, .pblend, .dwFlags>,  'UpdateLayeredWindow',  \
    UpdatePerUserSystemParameters, N, <NONE>,  'UpdatePerUserSystemParameters',  \
    UpdateWindow, N, <.hwnd>,  'UpdateWindow',  \
    User32InitializeImmEntryTable, N, <NONE>,  'User32InitializeImmEntryTable',  \
    UserClientDllInitialize, N, <NONE>,  'UserClientDllInitialize',  \
    UserHandleGrantAccess, N, <.hUserHandle, .hJob, .bGrant>,  'UserHandleGrantAccess',  \
    UserLpkPSMTextOut, N, <NONE>,  'UserLpkPSMTextOut',  \
    UserLpkTabbedTextOut, N, <NONE>,  'UserLpkTabbedTextOut',  \
    UserRealizePalette, N, <NONE>,  'UserRealizePalette',  \
    UserRegisterWowHandlers, N, <NONE>,  'UserRegisterWowHandlers',  \
    VRipOutput, N, <NONE>,  'VRipOutput',  \
    VTagOutput, N, <NONE>,  'VTagOutput',  \
    ValidateRect, N, <.hwnd, .lpRect>,  'ValidateRect',  \
    ValidateRgn, N, <.hwnd, .hRgn>,  'ValidateRgn',  \
    VkKeyScan, A, <.cChar>,  'VkKeyScanA',  \
    VkKeyScanEx, A, <.ch, .dwhkl>,  'VkKeyScanExA',  \
    VkKeyScanEx, W, <.ch, .dwhkl>,  'VkKeyScanExW',  \
    VkKeyScan, W, <.cChar>,  'VkKeyScanW',  \
    WCSToMBEx, N, <NONE>,  'WCSToMBEx',  \
    WINNLSEnableIME, N, <.hwnd, .bool>,  'WINNLSEnableIME',  \
    WINNLSGetEnableStatus, N, <.hwnd>,  'WINNLSGetEnableStatus',  \
    WINNLSGetIMEHotkey, N, <.hwnd>,  'WINNLSGetIMEHotkey',  \
    WaitForInputIdle, N, <.hProcess, .dwMilliseconds>,  'WaitForInputIdle',  \
    WaitMessage, N, <VOID>,  'WaitMessage',  \
    Win32PoolAllocationStats, N, <NONE>,  'Win32PoolAllocationStats',  \
    WinHelp, A, <.hwnd, .lpHelpFile, .wCommand, .dwData>,  'WinHelpA',  \
    WinHelp, W, <.hwnd, .lpHelpFile, .wCommand, .dwData>,  'WinHelpW',  \
    WindowFromDC, N, <.hdc>,  'WindowFromDC',  \
    WindowFromPoint, N, <.xPoint, .yPoint>,  'WindowFromPoint',  \
    keybd_event, N, <.bVk, .bScan, .dwFlags, .dwExtraInfo>,  'keybd_event',  \
    mouse_event, N, <.dwFlags, .dx, .dy, .cButtons, .dwExtraInfo>,  'mouse_event',  \
    wsprintf, A, <.lpOut, .lpFmt, .etc>,  'wsprintfA',  \
    wsprintf, W, <.lpOut, .lpFmt, .etc>,  'wsprintfW',  \
    wvsprintf, A, <NONE>,  'wvsprintfA',  \
    wvsprintf, W, <NONE>,  'wvsprintfW'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/imports/Win32/api/wsock32.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: wsock32.dll API calls
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


import_proto wsock32,  \
    AcceptEx, N, <.sListenSocket, .sAcceptSocket, .lpOutputBuffer, .dwReceiveDataLength, .dwLocalAddressLength, .dwRemoteAddressLength, .lpdwBytesReceived, .lpOverlapped>,  'AcceptEx',  \
    EnumProtocols, A, <.lpiProtocols, .lpProtocolBuffer, .lpdwBufferLength>,  'EnumProtocolsA',  \
    EnumProtocols, W, <.lpiProtocols, .lpProtocolBuffer, .lpdwBufferLength>,  'EnumProtocolsW',  \
    GetAcceptExSockaddrs, N, <.lpOutputBuffer, .dwReceiveDataLength, .dwLocalAddressLength, .dwRemoteAddressLength, .LocalSockaddr, .LocalSockaddrLength, .RemoteSockaddr, .RemoteSockaddrLength>,  'GetAcceptExSockaddrs',  \
    GetAddressByName, A, <.dwNameSpace, .lpServiceType, .lpServiceName, .lpiProtocols, .dwResolution, .lpServiceAs, .lpCsaddrBuffer, .lpdwBufferLength, .lpAliasBuffer, .lpdwAliasBufferLength>,  'GetAddressByNameA',  \
    GetAddressByName, W, <.dwNameSpace, .lpServiceType, .lpServiceName, .lpiProtocols, .dwResolution, .lpServiceAs, .lpCsaddrBuffer, .lpdwBufferLength, .lpAliasBuffer, .lpdwAliasBufferLength>,  'GetAddressByNameW',  \
    GetNameByType, A, <.lpServiceType, .lpServiceName, .dwNameLength>,  'GetNameByTypeA',  \
    GetNameByType, W, <.lpServiceType, .lpServiceName, .dwNameLength>,  'GetNameByTypeW',  \
    GetService, A, <.dwNameSpace, .lpGuid, .lpServiceName, .dwProperties, .lpBuffer, .lpdwBufferSize, .lpServiceAs>,  'GetServiceA',  \
    GetService, W, <.dwNameSpace, .lpGuid, .lpServiceName, .dwProperties, .lpBuffer, .lpdwBufferSize, .lpServiceAs>,  'GetServiceW',  \
    GetTypeByName, A, <.lpServiceName, .lpServiceType>,  'GetTypeByNameA',  \
    GetTypeByName, W, <.lpServiceName, .lpServiceType>,  'GetTypeByNameW',  \
    MigrateWinsockConfiguration, N, <NONE>,  'MigrateWinsockConfiguration',  \
    NPLoadNameSpaces, N, <NONE>,  'NPLoadNameSpaces',  \
    SetService, A, <.dwNameSpace, .dwOperation, .dwFlags, .lpServiceInfo, .lpServiceAsyncInfo, .lpdwStatusFlags>,  'SetServiceA',  \
    SetService, W, <.dwNameSpace, .dwOperation, .dwFlags, .lpServiceInfo, .lpServiceAsyncInfo, .lpdwStatusFlags>,  'SetServiceW',  \
    TransmitFile, N, <.hSocket, .hFile, .nNumberOfBytesToWrite, .nNumberOfBytesPerSend, .lpOverlapped, .lpTransmitBuffers, .dwReserved>,  'TransmitFile',  \
    WEP, N, <NONE>,  'WEP',  \
    WSAAsyncGetHostByAddr, N, <.hWnd, .wMsg, .addr, .lLen, .lType, .buf, .buflen>,  'WSAAsyncGetHostByAddr',  \
    WSAAsyncGetHostByName, N, <.hWnd, .wMsg, .name, .buf, .buflen>,  'WSAAsyncGetHostByName',  \
    WSAAsyncGetProtoByName, N, <.hWnd, .wMsg, .name, .buf, .buflen>,  'WSAAsyncGetProtoByName',  \
    WSAAsyncGetProtoByNumber, N, <.hWnd, .wMsg, .number, .buf, .buflen>,  'WSAAsyncGetProtoByNumber',  \
    WSAAsyncGetServByName, N, <.hWnd, .wMsg, .name, .proto, .buf, .buflen>,  'WSAAsyncGetServByName',  \
    WSAAsyncGetServByPort, N, <.hWnd, .wMsg, .port, .proto, .buf, .buflen>,  'WSAAsyncGetServByPort',  \
    WSAAsyncSelect, N, <.s, .hWnd, .wMsg, .lEvent>,  'WSAAsyncSelect',  \
    WSACancelAsyncRequest, N, <.hAsyncTaskHandle>,  'WSACancelAsyncRequest',  \
    WSACancelBlockingCall, N, <VOID>,  'WSACancelBlockingCall',  \
    WSACleanup, N, <VOID>,  'WSACleanup',  \
    WSAGetLastError, N, <VOID>,  'WSAGetLastError',  \
    WSAIsBlocking, N, <VOID>,  'WSAIsBlocking',  \
    WSARecvEx, N, <.s, .buf, .lLen, .flags>,  'WSARecvEx',  \
    WSASetBlockingHook, N, <.lpBlockFunc>,  'WSASetBlockingHook',  \
    WSASetLastError, N, <.iError>,  'WSASetLastError',  \
    WSAStartup, N, <.wVersionRequired, .lpWSAData>,  'WSAStartup',  \
    WSAUnhookBlockingHook, N, <VOID>,  'WSAUnhookBlockingHook',  \
    WSApSetPostRoutine, N, <NONE>,  'WSApSetPostRoutine',  \
    __WSAFDIsSet, N, <NONE>,  '__WSAFDIsSet',  \
    accept, N, <.s, .addr, .addrlen>,  'accept',  \
    bind, N, <.s, .addr, .namelen>,  'bind',  \
    closesocket, N, <.s>,  'closesocket',  \
    connect, N, <.s, .name, .namelen>,  'connect',  \
    dn_expand, N, <NONE>,  'dn_expand',  \
    gethostbyaddr, N, <.addr, .len, .type>,  'gethostbyaddr',  \
    gethostbyname, N, <.name>,  'gethostbyname',  \
    gethostname, N, <.name, .namelen>,  'gethostname',  \
    getnetbyname, N, <NONE>,  'getnetbyname',  \
    getpeername, N, <.s, .name, .namelen>,  'getpeername',  \
    getprotobyname, N, <.name>,  'getprotobyname',  \
    getprotobynumber, N, <.number>,  'getprotobynumber',  \
    getservbyname, N, <.name, .proto>,  'getservbyname',  \
    getservbyport, N, <.port, .proto>,  'getservbyport',  \
    getsockname, N, <.s, .name, .namelen>,  'getsockname',  \
    getsockopt, N, <.s, .level, .optname, .optval, .optlen>,  'getsockopt',  \
    htonl, N, <.hostlong>,  'htonl',  \
    htons, N, <.hostshort>,  'htons',  \
    inet_addr, N, <.cp>,  'inet_addr',  \
    inet_network, N, <NONE>,  'inet_network',  \
    inet_ntoa, N, <.lIn>,  'inet_ntoa',  \
    ioctlsocket, N, <.s, .cmd, .argp>,  'ioctlsocket',  \
    listen, N, <.s, .backlog>,  'listen',  \
    ntohl, N, <.netlong>,  'ntohl',  \
    ntohs, N, <.netshort>,  'ntohs',  \
    rcmd, N, <NONE>,  'rcmd',  \
    recv, N, <.s, .buf, .lLen, .flags>,  'recv',  \
    recvfrom, N, <.s, .buf, .lLen, .flags, .from, .fromlen>,  'recvfrom',  \
    rexec, N, <NONE>,  'rexec',  \
    rresvport, N, <NONE>,  'rresvport',  \
    s_perror, N, <NONE>,  's_perror',  \
    select, N, <NONE>,  'select',  \
    send, N, <.s, .buf, .lLen, .flags>,  'send',  \
    sendto, N, <.s, .buf, .lLen, .flags, .to, .tolen>,  'sendto',  \
    sethostname, N, <NONE>,  'sethostname',  \
    setsockopt, N, <.s, .level, .optname, .optval, .optlen>,  'setsockopt',  \
    shutdown, N, <.s, .how>,  'shutdown',  \
    socket, N, <.af, .lType, .protocol>,  'socket'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































Deleted freshlib/imports/allimports.asm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Combined include of all needed import libraries.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

include '%TargetOS%/allimports.asm'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























Deleted freshlib/macros/Linux/_elf.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: ELF format macros. Used internally in _import.inc
;
;  Target OS: Linux (ELF)
;
;  Dependencies:
;
;  Notes: The form and use of these macros is somehow unsystematic.
;_________________________________________________________________________________________


macro Elf32_Sym name,value,size,bind,type,other,shndx
{
 dd name+0
 dd value+0
 dd size+0
 db (bind+0) shl 4 + (type+0)
 db other+0
 dw shndx+0
}

virtual at 0
 Elf32_Sym
 sizeof.Elf32_Sym = $
end virtual

macro Elf32_Rel offset,symbol,type
{
  dd offset+0
  dd (symbol+0) shl 8 + (type+0)
}

virtual at 0
 Elf32_Rel
 sizeof.Elf32_Rel = $
end virtual

macro Elf32_Rela offset,symbol,type,addend
{
  dd offset+0
  dd (symbol+0) shl 8 + (type+0)
  dd addend+0
}

virtual at 0
 Elf32_Rela
 sizeof.Elf32_Rela = $
end virtual

macro Elf64_Sym name,value,size,bind,type,other,shndx
{
 dd name+0
 db (bind+0) shl 4 + (type+0)
 db other+0
 dw shndx+0
 dq value+0
 dq size+0
}

virtual at 0
 Elf64_Sym
 sizeof.Elf64_Sym = $
end virtual

macro Elf64_Rel offset,symbol,type
{
  dq offset+0
  dq (symbol+0) shl 32 + (type+0)
}

virtual at 0
 Elf64_Rel
 sizeof.Elf64_Rel = $
end virtual

macro Elf64_Rela offset,symbol,type,addend
{
  dq offset+0
  dq (symbol+0) shl 32 + (type+0)
  dq addend+0
}

virtual at 0
 Elf64_Rela
 sizeof.Elf64_Rela = $
end virtual

DT_NULL    = 0
DT_NEEDED  = 1
DT_HASH    = 4
DT_STRTAB  = 5
DT_SYMTAB  = 6
DT_RELA    = 7
DT_RELASZ  = 8
DT_RELAENT = 9
DT_STRSZ   = 10
DT_SYMENT  = 11
DT_REL     = 17
DT_RELSZ   = 18
DT_RELENT  = 19

STB_LOCAL  = 0
STB_GLOBAL = 1
STB_WEAK   = 2

STT_NOTYPE  = 0
STT_OBJECT  = 1
STT_FUNC    = 2
STT_SECTION = 3
STT_FILE    = 4

R_386_NONE     = 0
R_386_32       = 1
R_386_PC32     = 2
R_386_GOT32    = 3
R_386_PLT32    = 4
R_386_COPY     = 5
R_386_GLOB_DAT = 6
R_386_JMP_SLOT = 7
R_386_RELATIVE = 8
R_386_GOTOFF   = 9
R_386_GOTPC    = 10

R_X86_64_NONE      = 0
R_X86_64_64        = 1
R_X86_64_PC32      = 2
R_X86_64_GOT32     = 3
R_X86_64_PLT32     = 4
R_X86_64_COPY      = 5
R_X86_64_GLOB_DAT  = 6
R_X86_64_JUMP_SLOT = 7
R_X86_64_RELATIVE  = 8
R_X86_64_GOTPCREL  = 9
R_X86_64_32        = 10
R_X86_64_32S       = 11
R_X86_64_16        = 12
R_X86_64_PC16      = 13
R_X86_64_8         = 14
R_X86_64_PC8       = 15
R_X86_64_DPTMOD64  = 16
R_X86_64_DTPOFF64  = 17
R_X86_64_TPOFF64   = 18
R_X86_64_TLSGD     = 19
R_X86_64_TLSLD     = 20
R_X86_64_DTPOFF32  = 21
R_X86_64_GOTTPOFF  = 22
R_X86_64_TPOFF32   = 23
R_X86_64_PC64      = 24
R_X86_64_GOTOFF64  = 25
R_X86_64_GOTPC32   = 26
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































Deleted freshlib/macros/Linux/_import.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Macros for importing functions in Linux
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


include '_elf.inc'


macro interpreter [library]
{
 db library,0
}


; creates symbols list with needed libraries.
macro import_proto library, [name, arg]
{
  common
    local str, cnt, use
    match needed,needed@dynamic \{ define needed@dynamic needed, str:cnt:use:library \}
    match ,needed@dynamic \{ define needed@dynamic str:cnt:use:library \}

  forward
    match imported, imported@dynamic \{ imported@dynamic equ imported, cnt:name \}
    match ,imported@dynamic \{ imported@dynamic equ cnt:name \}
    define name#@arg arg
}
define needed@dynamic
define imported@dynamic



macro __define_import_arguments_var [argument] {
common
  virtual at ebp+8
forward
  argument dd ?
common
  end virtual
}


macro __define_import_arguments name {
common
  if name#@arg eq VOID
    .__info.argtype=1
  else
    if name#@arg eq NONE
      .__info.argtype = 0
    else
      match A, name#@arg \{ __define_import_arguments_var A \}
      .__info.argtype = 2
    end if
  end if
}



struc def_name name {
  db `name, 0
}


macro __do_import [cntandname]
{
common
  local strtab,strsz,symtab,rel,relsz,hash
  segment dynamic readable

  match needed, needed@dynamic \{
    irp item, needed \\{
      match str:cnt:use:library, item \\\{
        cnt = 0
        if use > 0
          dd DT_NEEDED, str-strtab
        end if
      \\\}
    \\}
  \}

  dd DT_STRTAB, strtab
  dd DT_STRSZ, strsz
  dd DT_SYMTAB, symtab
  dd DT_SYMENT, sizeof.Elf32_Sym
  dd DT_REL, rel
  dd DT_RELSZ, relsz
  dd DT_RELENT, sizeof.Elf32_Rel
  dd DT_HASH, hash
  dd DT_NULL, 0

  segment readable writeable
  symtab: Elf32_Sym

forward
  match cnt:name, cntandname \{
    if used name
      local fstr
      Elf32_Sym fstr-strtab,0,0,STB_GLOBAL,STT_FUNC,0,0
      cnt = cnt + 1
    end if
  \}

common
  rel:
  local counter
  counter = 1

forward
  match cnt:name, cntandname \{
    if used name
      Elf32_Rel name, counter, R_386_32
      counter = counter + 1
    end if
  \}

common
  relsz = $-rel
  hash:
  dd 1, counter
  dd 0

  repeat counter
   if %=counter
    dd 0
   else
    dd %
   end if
  end repeat
  strtab db 0

forward
  match cnt:name, cntandname \{
    if used name
      fstr def_name name
    end if
  \}

common
  match needed, needed@dynamic \{
    irp item, needed \\{
      match str:cnt:use:library,item \\\{
        use = cnt
        if use > 0
          str db library, 0
        end if
      \\\}
    \\}
  \}
  strsz = $-strtab

forward
  match cnt:name, cntandname \{
label name dword
    if used name
       dd 0
    end if
__define_import_arguments name
  \}
}


macro ImportAll {
  match arguments, __do_import imported@dynamic \{ arguments \}
}


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































Deleted freshlib/macros/Linux/_linproc.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Linux variant or return instruction for thread procedures.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

macro thread_return {
  cret
}




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































Deleted freshlib/macros/Linux/allmacros.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Combined include of all Linux specific macros.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

include '_import.inc'
include '_linproc.inc'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































Deleted freshlib/macros/Win32/_exceptions.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Win32 exception handling macros.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

..TryLevel = 0

macro beginTry {
  common
    ptrExceptionContext equ esp+$0c
    ptrExceptionRecord  equ esp+$04

    local ..handler, ..endtry
    end@try equ ..endtry

  if defined ..handler
        ..TryLevel = ..TryLevel+1
        pushd   ..handler
        pushd   [fs:0]
        mov     [fs:0], esp
  end if

  macro onException \{
        jmp     ..endtry
    ..handler:
  \}

  macro Ignore \{
        mov     eax, [ptrExceptionContext]
        mov     [eax+CONTEXT.regEip], ..endtry
        xor     eax, eax
        retn
  \}

  macro Retry \{
        xor     eax, eax
        retn
  \}


  macro Next \{
        mov     eax, 1
        retn
  \}
}



macro endTry {
common
  label end@try
  if ..TryLevel > 0
        popd    [fs:0]
        add     esp, 4
        ..TryLevel = ..TryLevel - 1
  end if
  purge onException
  purge Ignore
  purge Next
  purge Retry
  restore end@try
  restore ptrExceptionContext
  restore ptrExceptionRecord
}




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































Deleted freshlib/macros/Win32/_export.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Win32 export sections creating macros.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

; macroinstruction for making export section

macro export dllname,[label,string]     ; strings must be sorted
 { common
    local module,addresses,names,ordinal,count
    count = 0
   forward
    count = count+1
   common
    dd 0,0,0,RVA module,1
    dd count,count,RVA addresses,RVA names,RVA ordinal
    addresses:
   forward
    dd RVA label
   common
    names:
   forward
    local name
    dd RVA name
   common
    ordinal: count = 0
   forward
    dw count
    count = count+1
   common
    module db dllname,0
   forward
    name db string,0 }
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































Deleted freshlib/macros/Win32/_import.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Win32 import macros.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes: Only import_proto should be used in portable applications. Here we have some
;         old macros that needs revision or even removing.
;_________________________________________________________________________________________

; macroinstruction for making import section
macro library [name,string] {
forward
    local _label
    if ~ name#.needed
    dd 0,0,0,RVA _label,RVA name
    end if
common
    dd 0,0,0,0,0
forward
    if ~ name#.needed
    _label db string,0
;    display 'Import from:', string, $0d, $0a
    end if
 }


macro import name,[label, string]
 { common
    name:
   forward
    if used label
     local _label
     label dd RVA _label
    end if
   common
    if $ > name
     name#.needed = FALSE
     dd 0
    else
     name#.needed = TRUE
    end if
   forward
    if used label
    _label dw 0
           db string,0
    end if
  }



macro define_import_arguments [argument] {
common
  virtual at ebp+8
forward
    argument dd ?
common
  end virtual
}

macro import_proto name, [lbl, api, arg, string] {
common
    name:
forward
    local ..lbl, ..used

    match =N, api \{ @label equ lbl\}
    match =W, api \{
      match =ascii, GlobalAPI \\{ @label equ lbl#W \\}
      match =unicode, GlobalAPI \\{ @label equ lbl \\}
      match , GlobalAPI \\{ @label equ lbl#W \\}
    \}
    match =A, api \{
      match =ascii, GlobalAPI \\{ @label equ lbl \\}
      match =unicode, GlobalAPI \\{ @label equ lbl#A \\}
      match , GlobalAPI \\{ @label equ lbl#A \\}
    \}

    ..used = 0
    if used @label
      @label dd RVA ..lbl
      ..used = 1
    end if

   if ~(arg eq NONE)
     if arg eq VOID
       .__info.argtype = 1
     else
       define_import_arguments arg
       .__info.argtype = 2
     end if
   else
     .__info.argtype = 0
   end if

   restore @label

common
    if $ > name
     name#.needed = FALSE
     dd 0
    else
     name#.needed = TRUE
    end if

forward
    if ..used
    ..lbl dw 0
          db string,0
    end if
}



macro U_library [name,string]
 { forward
     local _label
     dd 0,0,0,RVA _label,RVA name
   common
     dd 0,0,0,0,0
   forward
    _label db string,0
 }


macro U_import name,[label,string]
{ common
    name:
   forward
     local _label
     label dd RVA _label
   common
     dd 0
   forward
    _label dw 0
           db string,0
}


macro ImportLib [lib] {
forward
    local _label
    if ~ lib#.needed
      dd 0, 0, 0, RVA _label, RVA lib
    end if

common
    dd 0, 0, 0, 0, 0

forward
  if ~ lib#.needed
    _label db `lib#'.dll', 0
  end if

forward
  \include "%finc%\win32\api\"#`lib#".inc"
}


GlobalAPI equ unicode
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































Deleted freshlib/macros/Win32/_winproc.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Win32 specific macros. winproc is procedure for message handling.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes: Actually these macros are not OS dependent, but their usefulness for other
;         OS is unclear. Maybe they need some refactoring in order to be used OS
;         independently.
;_________________________________________________________________________________________

macro thread_return {
  return
}

;-----------------------------------------
; This file is part of Fresh standard
; macro library.
;-----------------------------------------


macro winproc name, [arg] {
common

  \err@endp

  macro err@endp \{
    end if
    Missing 'endwp' before the procedure.
  \}


  if ~ used name
    if defined options.ShowSkipped & options.ShowSkipped
      display 1,'Message procedure skiped: ',`name, $0d, $0a
    end if
  else

 name:
    .__info.id = 2

  if arg eq
    virtual at ebp+8
      .hwnd dd ?
      .wmsg dd ?
      .wparam dd ?
      .lparam dd ?
      .__info.argsize = 16
    end virtual
  else
    virtual at ebp+8
      forward
        arg dd ?
        if ~ defined name#arg
          ERROR! the argument `arg MUST begin with dot
        end if
      common
        .__info.argsize = $ - ebp - 8
    end virtual
  end if

  if .__info.argsize <> 16
    Error! The count of `name arguments MUST be 4 dwords.
  end if

  virtual at ebp - .__info.commonframe.size
  .__info.commonframe.begin:
}



macro ondefault {  ; begins procedure instructions
  common
    local ..msgcounter, ..msglist
    msgcounter equ ..msgcounter
    msglist equ ..msglist

    ..msgcounter = 0

    call JumpTo
    ..msglist:
    rd   .__info.msgcount
    dd   0

    .ondefault:
}


macro onmessage message {
  .#message:
  .#message#.__info.id = 3
  .#message#.__info.number = msgcounter / 4
     store word message at (msglist + msgcounter)
     store word ($ - msglist - msgcounter - 4 ) at (msglist + msgcounter + 2)
  msgcounter = msgcounter + 4
}


macro endwp {
    .__info.msgcount = msgcounter / 4
    .__info.framesize = maxsize + .__info.commonframe.size
  end if
  restore maxsize, msgcounter, msglist
  purge err@endp
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































Deleted freshlib/macros/Win32/allmacros.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Combined include of all Win32 specific macros.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

include '_winproc.inc'
include '_import.inc'
include '_export.inc'
include '_exceptions.inc'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































Deleted freshlib/macros/_datamacros.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Several data definition/manipulation macros.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

macro getfile lblname*, filename* {
  if used lblname
    lblname file filename
    .size = $ - lblname
  end if
}

macro StringTable [string] {
  forward
    local ..lbl
    dd  ..lbl
  common
    dd  0
  forward
..lbl db string, 0
}


macro IndexedStrings [lparam, string] {
  forward
    local ..lbl
    dd  ..lbl, lparam
  common
    dd  0
  forward
..lbl db string, 0
}


macro Sequence [seqname*, initvalue*] {
forward
  seqname#.current = initvalue
  macro seqname [name] \{
    name = seqname#.current
    seqname#.current = seqname#.current + 1
    if defined seqname#.display & seqname#.display
      disp iconInfo, `seqname, ' value: ', \`#name, ' = $', <name, 16>, $0d
    end if
  \}
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































Deleted freshlib/macros/_display.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Macro library for displaying compile time messages.
;
;  Target OS: Any (FASM compiler)
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

iconWarning = 1
iconError = 2
iconInfo = 3
iconFind = 4
iconNone  = 5
iconDebug = 6


macro __digit num
{
   if num < 10
    display '0'+num
   else
    display 'A'+num-10
   end if
}


macro __disp arg1, arg2
{
   if arg2 eq
    display arg1
   else
    local ..tmp
    ..tmp = arg1
    virtual at 0
     repeat 32
      if ..tmp > 0
       db ..tmp mod arg2
       ..tmp = ..tmp / arg2
      end if
     end repeat
     repeat $
      load ..tmp byte from $-%
      __digit ..tmp
     end repeat
     if $ = 0
      display '0'
     end if
    end virtual
   end if
}

macro disp [arg] { __disp arg }


macro DispSize Text, Sz {
  local size, suffix
  size = Sz;
  if defined options.ShowSizes & options.ShowSizes
    if Text eqtype "A"
      disp 3,"Sizeof [", Text, "] is: "
    else
      disp 3,"Sizeof [", `Text, "] is: "
    end if

    suffix = 'bytes'
    if Sz>10000
      size = size / 1024
      disp <size,10>, 'K',$0d,$0a
    else
      disp <size,10>, ' bytes.',$0d,$0a
    end if
  end if
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































































































































Deleted freshlib/macros/_globals.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;   Description: Macto library for global variables handling.
;
;   Target OS: Any
;
;   Dependencies:
;
;   Notes:
;_________________________________________________________________________________________

;------------------------------------------------------------------
; use "iglobal" for inserting initialized global data definitions.
;------------------------------------------------------------------
macro iglobal {
  IGlobals equ IGlobals,
  macro __IGlobalBlock \{
}


;-------------------------------------------------------------
; use 'uglobal' for inserting uninitialized global definitions.
; even when you define some data values, these variables
; will be stored as uninitialized data.
;-------------------------------------------------------------
macro uglobal {
  UGlobals equ UGlobals,
  macro __UGlobalBlock \{
}

; Use endg for ending iglobal and uglobal blocks.
endg fix }


macro IncludeIGlobals {
  macro IGlobals dummy, [n] \{
    __IGlobalBlock
    purge __IGlobalBlock
  \}
  match I, IGlobals \{
    I
  \}
}


macro IncludeUGlobals {
  macro UGlobals dummy, [n] \{
    \common
      \local begin, size
      begin = $
      virtual at $
    \forward
        __UGlobalBlock
        purge __UGlobalBlock
    \common
        size = $ - begin
      end virtual
      rb size
  \}
  match U, UGlobals \{
    U
  \}
}




macro InitStringList {
  local r,v,c
  c equ 0

  struc text [val] \{
    \common
      if ~val eqtype 1
      virtual at 0
    \forward
        db val
    \common
      .length = $
      end virtual
      end if
    rept 1 x:c+1 \\{
      c equ x
      r\\#x equ .
      v\\#x equ val
    \\}
  \}

  macro __IncludeAllStrings \{
    \common
    \local ..start, len, i, j, f, ch1, ch2
    label ..start byte
    if defined options.ShowSizes and options.ShowSizes
      disp 3, 'String data address: $', <..start, 16>, 13
    end if

    rept c x \\{
      if used r\\#x
        if ~v\\#x eqtype 1
          r\\#x db v\\#x, 0
        else
          label r\\#x byte at v\\#x
        end if
      end if
    \\}
  \}
}

;macro InitStringList {
;  local r,v,c
;  c equ 0
;  struc string [val] \{
;    \common
;    rept 1 x:c+1 \\{
;      c equ x
;      r\\#x equ .
;      v\\#x equ val
;    \\}
;  \}
;
;  macro __IncludeAllStrings \{
;    \common
;    \local ..start
;    label ..start byte
;    if defined options.ShowSizes and options.ShowSizes
;      disp 3, 'String data address: $', <..start, 16>, 13
;    end if
;    rept c x \\{
;      \\common
;      \\forward
;      \\local len, i, j, f, ch1, ch2, hash, hash2
;      if ~v\\#x eqtype 1
;        virtual at 0
;          db v\\#x, 0
;          len = $
;
;          i = 0
;          hash = 1234
;          while i<len
;            load ch1 byte from i
;            hash = hash + ch1
;            i=i+1
;          end while
;        end virtual
;
;        i = ..start
;        j = 0
;        f = 0
;        while i<=($-len)
;          j = 0
;          f = 0
;          hash2 = 1234
;          while j<len
;            load ch1 byte from i+j
;            hash2=hash2+ch1
;            if hash2>=hash
;              break
;            end if
;            j=j+1
;          end while
;
;          if hash2=hash
;            j=0
;            while j<len
;              load ch1 byte from i+j
;              virtual at 0
;                db v\\#x, 0
;                load ch2 byte from j
;              end virtual
;              if ch1 <> ch2
;                break
;              end if
;              j=j+1
;            end while
;            if (ch1 =0) & (ch2 = 0)
;              f = 1
;              break
;            end if
;          end if
;          i = i + 1
;        end while
;
;        if ~f
;          r\\#x db v\\#x, 0
;          sizeof.#r\\#x = len
;        else
;          label r\\#x byte at i
;        end if
;      else
;        label r\\#x byte at v\\#x
;      end if
;    \\}
;  \}
;}

InitStringList


macro IncludeAllGlobals {
  local begin

  begin = $
  disp 3, 'Initialized data address: $', <begin, 16>, 13
  IncludeIGlobals
  DispSize 'Initialized data', ($ - begin)

  begin = $
  __IncludeAllStrings
  DispSize 'String data', ($ - begin)

  begin = $
  IncludeUGlobals
  DispSize 'Uninitialized data', ($ - begin)
}



macro var expr {
common
  match name==value, expr \{
    if used name
      name dd value
    else
      name = 0
    end if
  \}
}



iglobal
endg

uglobal
endg
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































































































































































































































































































































































































































Deleted freshlib/macros/_stdcall.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Macros for create and call of high level procedures.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


macro locals {
  local ..locsize
  locsize equ ..locsize
  virtual at ebp - ..locsize - .__info.commonframe.size
  @@:
}


macro endl {
  rb (4 - ($- @b) and 11b) and 11b
  locsize = $ - @b
  if $-@b > maxsize
    maxsize = $-@b
  end if
  end virtual
  restore locsize
}


macro err@endp { }


macro proc name, [arg] {
  common
    \err@endp

    macro err@endp \{
      end if
      Missing 'endp' or 'endwp' before the procedure.
    \}

  if defined options.AlignCode & options.AlignCode = 1
    align 16
  end if

  name:
    .__info.id = 1
    .__info.start = $

    virtual at ebp+8
      if ~ arg eq
        forward
          arg dd ?
          if ~ defined name#arg
            ERROR! the argument `arg MUST begins with dot
          end if
        common
      end if
        .__info.argsize = $-ebp-8
    end virtual

    if ~ used name
      if defined options.ShowSkipped & options.ShowSkipped
        display 1,'Procedure skiped: ',`name, $0d, $0a
      end if
    else

    virtual at ebp - .__info.commonframe.size
    .__info.commonframe.begin:
}


macro begin {
      rb (4 - ($ - .__info.commonframe.begin) and 11b) and 11b
      .__info.commonframe.size = $ - .__info.commonframe.begin
    end virtual

    local ..maxsize
    maxsize equ ..maxsize
    ..maxsize = 0

    if .__info.framesize
      if defined options.FastEnter & options.FastEnter
        push ebp
        mov  ebp, esp
        sub  esp, .__info.framesize
      else
        enter .__info.framesize, 0
      end if
    else
      if .__info.argsize
        push ebp
        mov  ebp, esp
      end if
    end if
}


macro cret {
  if .__info.argsize | .__info.framesize
    if defined options.FastEnter & options.FastEnter
      mov   esp, ebp
      pop   ebp
    else
      leave
    end if
  end if
  retn
}


macro return {
  if .__info.argsize | .__info.framesize
    if defined options.FastEnter & options.FastEnter
      mov   esp, ebp
      pop   ebp
    else
      leave
    end if
  end if

  if .__info.argsize
    retn .__info.argsize
  else
    retn
  end if
}



macro endp {
    .__info.framesize = maxsize + .__info.commonframe.size
    .__info.codesize = $ - .__info.start
  end if
  restore maxsize
  purge err@endp
}






macro __InitInitializeEngine {
  local i,f,ci,cf
  ci equ 0
  cf equ 0

  macro initialize procname \{
    \common
    rept 1 x:ci+1 \\{
      ci equ x
      i\\#x equ procname
      proc procname
    \\}
  \}

  macro finalize procname \{
    \common
    rept 1 x:cf+1 \\{
      cf equ x
      f\\#x equ procname
      proc procname
    \\}
  \}


  macro InitializeAll \{
    \common
    rept ci x \\{
      \\forward
      if defined i\\#x
        call i\\#x
      end if
    \\}
  \}

  macro FinalizeAll \{
    \common
    rept cf x \\{
      \\reverse
      if defined f\\#x
        call f\\#x
      end if
    \\}
  \}
}

__InitInitializeEngine



;*****************************************
; Call macroses
;*****************************************

macro stdcall proc, [arg] {    ; call procedure
common
  local ..argsize
  ..argsize = 0
  if ~ arg eq
reverse
    pushd arg
    ..argsize = ..argsize + 4
common
  end if
  if defined options.CheckArguments & options.CheckArguments
    if (defined proc#.__info.argsize) & (proc#.__info.argsize <> ..argsize)
      ERROR! wrong argument count for procedure call.
    end if
  end if

  call proc
}


macro invoke proc,[arg] {   ; invoke procedure (indirect)
common
  if ~ arg eq
reverse
    pushd arg
common
  end if
  call [proc]
}


macro ccall proc,[arg]                  ; call procedure in C calling convention
 { common local ..size
   ..size = 0
   reverse
   pushd arg
   ..size = ..size+4
   common
   call proc
   add esp,..size }

macro cinvoke proc,[arg] {               ; invoke procedure (indirect)
common
    if ~ arg eq
     ccall [proc],arg
    else
     call [proc]
    end if
}

;****************************************
; INT3 break point, when first = second.
;****************************************

macro BreakEq first, second {
  local .lbl
  push  eax
  mov   eax, first
  cmp   eax, second
  pop   eax
  jne   .lbl

  int3

.lbl:
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































Deleted freshlib/macros/_struct.inc.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Macro to make complex data structures.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

macro struct name {
  macro name@struct \{ name name \}
  macro size@struct \{ sizeof.#name = $ \}
  struc name \{
}


ends fix } struct_helper


macro struct_helper {
  virtual at 0
    name@struct
    size@struct
  end virtual
  purge name@struc
  purge size@struct
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































Deleted freshlib/macros/allmacros.inc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Includes all macro libraries at once.
;
;  Target OS:
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

include '_struct.inc'
include '_stdcall.inc'
include '_display.inc'
include '_globals.inc'
include '_datamacros.inc'

include '%TargetOS%/allmacros.inc'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































Deleted freshlib/readme.txt.

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
 _______________________________________________________________________________________
|                                                                                       |
| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
|                                                                                       |
| (c)2003, 2004, 2005, 2010, 2011 Fresh developement team                               |
|_______________________________________________________________________________________|

FreshLib is standard Fresh IDE library. FreshLib contains macros, 
equates and code to allow writing of portable applications.

FreshLib is free, open source project, distributed under the terms of 
"Fresh artistic license". 
The text of the license is in the file "License.txt"

FreshLib is created and maintained by Fresh development team. Every member of the team
have some contribution to the project. Here is the list of people contributed to the
project (in order of appearance; newer first):

pelaillo
scientica (Fredrik Klasson)
tommy 	  (Tommy Lilehagen)
VeSCeRa	  (Yunus Sina Gulsen)
roticv	  (Victor Loh)
decard 	  (Mateusz Tymek)
John Found 

Special thanks to Tomasz Grysztar for creating FASM.
Tomasz also provided some really useful macros.
_________________________________________________________________________________________

For additional information about Fresh and FreshLib, look at following locations:

http://fresh.flatassembler.net	- main site of the project Fresh.
http://board.flatassembler.net	- Flat assembler message board.
_________________________________________________________________________________________

The test project for FreshLib is "TestFreshLib.fpr"
You can compile and run it as Win32, or as Linux application. 
Use Fresh IDE or compile TestLib.asm file with FASM compiler.

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































Deleted freshlib/simpledebug/Linux/debug.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: SimpleDebug library.
;
;  Target OS: Linux
;
;  Dependencies: Not dependent on other libraries.
;
;  Notes:
;_________________________________________________________________________________________



proc Output, .ptrStr
begin
        pushad

        stdcall __simpStrLength, [.ptrStr]
        mov     edx, ecx

        mov     eax, 4
        mov     ebx, 1
        mov     ecx, [.ptrStr]
        int     $80

        popad
        return
endp


macro Output string {
if defined options.DebugMode & options.DebugMode = 1
        stdcall Output, string
end if
}


proc GetTimestamp
begin
        pushad
        mov     eax, 78
        mov     ebx, _timestamp
        xor     ecx, ecx
        int     $80

        mov     eax,dword [_timestamp]
        mov     ecx,1000
        mul     ecx
        mov     ebx,eax
        mov     eax,dword [_timestamp+4]
        div     ecx
        add     eax,ebx

        mov     [esp+4*regEAX], eax
        popad
        return

endp


uglobal
  if used _timestamp
   _timestamp dq 0
  end if
endg


macro OutputEvent event {
if defined options.DebugMode & options.DebugMode
        stdcall __OutputEvent, event
end if
}

proc __OutputEvent, .pEvent
begin
        pushad
        stdcall Output, cEventLabel
        mov     esi, [.pEvent]
        mov     eax, [esi+XEvent.type]
        cmp     eax, 2
        jl      .bynumber
        cmp     eax, 35
        jg      .bynumber

        sub     eax, 2
        mov     eax, [__EventStrings+4*eax]
        stdcall Output, eax
        stdcall Output, cEventLabel1

.window:
        mov     eax, [esi+XEvent.type]
        stdcall OutputNumber, eax, 10, 3
        stdcall Output, cEventLabel2
        stdcall OutputNumber, [esi+XEvent.window], 16, 8
        stdcall Output, cEventLabel3

        popad
        return

.bynumber:
        stdcall OutputNumber, eax, 10, 3
        jmp     .window

endp

if used __OutputEvent
  cEventLabel db 'X event: "', 0
  cEventLabel1 db ' (', 0
  cEventLabel2 db ')" for window: $', 0
  cEventLabel3 db 10, 0

  ; From number 2..35
  __EventStrings:
  StringTable              \
  `KeyPress, `KeyRelease, `ButtonPress, `ButtonRelease, `MotionNotify, `EnterNotify, \
  `LeaveNotify, `FocusIn, `FocusOut, `KeymapNotify, `Expose, `GraphicsExpose, `NoExpose, \
  `VisibilityNotify, `CreateNotify, `DestroyNotify, `UnmapNotify, `MapNotify, `MapRequest, \
  `ReparentNotify, `ConfigureNotify, `ConfigureRequest, `GravityNotify, `ResizeRequest,    \
  `CirculateNotify, `CirculateRequest, `PropertyNotify, `SelectionClear, `SelectionRequest, \
  `SelectionNotify, `ColormapNotify, `ClientMessage, `MappingNotify, `LASTEvent
end if
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































Deleted freshlib/simpledebug/Win32/debug.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: SimpleDebug library.
;
;  Target OS: Win32
;
;  Dependencies: Not dependent on other libraries.
;
;  Notes:
;_________________________________________________________________________________________


uglobal
  if used debug_con_handle
    debug_con_handle dd ?
  end if
endg


iglobal
  if used cConsoleTitle
    cConsoleTitle du 'Fresh simple debug console.', 0
  end if
endg


if (defined options.DebugMode & options.DebugMode) | used Output
initialize InitDebugConsole
begin
        invoke  AllocConsole
        invoke  GetStdHandle, STD_OUTPUT_HANDLE
        mov     [debug_con_handle], eax
        invoke  SetConsoleTitle, cConsoleTitle
        return
endp
end if



proc Output, .ptrStr
.dummy dd ?
begin
        pushad

        stdcall __simpStrLength, [.ptrStr]
        lea     eax, [.dummy]
        invoke  WriteConsoleA, [debug_con_handle], [.ptrStr], ecx, eax, 0

        popad
        return
endp



proc GetTimestamp
begin
        pushad
        invoke  GetTickCount
        mov     [esp+4*regEAX], eax
        popad
        return
endp




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































Deleted freshlib/simpledebug/debug.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: SimpleDebug library. Provides simple debugging macros and code.
;
;  Target OS: Any
;
;  Dependencies: Not dependent on other libraries.
;
;  Notes: use options.DebugMode={1|0} to enable/disable debug output of this library.
;_________________________________________________________________________________________
module "Simple debug library"

SimpleDebugLoaded = 1

include "%TargetOS%/debug.asm"


macro DebugMsg msg {
common
if defined options.DebugMode & options.DebugMode
  local ..msg, ..skip

        stdcall Output, ..msg
        jmp     ..skip
  ..msg db msg, 10, 0

  label ..skip
end if
}


macro Message msg {
common
  local ..msg, ..skip

        stdcall Output, ..msg
        jmp     ..skip
  ..msg db msg, 10, 0

  label ..skip
}



proc OutputMemory, .ptr, .size
begin
        pushad

        mov     esi, [.ptr]
        mov     edx, [.size]

.loop:
        stdcall OutputNumber, esi, 16, 8
        stdcall Output, .cSimpDbgSep1

        mov     ecx, 4

.lineloop:
        stdcall OutputNumber, [esi], 16, 8
        stdcall Output, .cSimpDbgSep2
        lea     esi, [esi+4]

        sub     edx, 4
        cmp     edx, 0
        jle     .exit

        dec     ecx
        jnz     .lineloop

.exit:
        stdcall Output, .cSimpDbgNewLine

        cmp     edx, 0
        jg      .loop

        stdcall Output, .cSimpDbgNewLine

        popad
        return

.cSimpDbgSep1 db ': ',0
.cSimpDbgSep2 db '  ',0
.cSimpDbgNewLine db 13,10,0


endp

macro OutputMemory pointer, size {
if defined options.DebugMode & options.DebugMode
        stdcall OutputMemory, pointer, size
end if
}





proc OutputNumber, .number, .radix, .digits
begin
        pushad

        cld
        mov     edi, _simpdebugstr

        mov     eax, [.number]
        mov     ecx, [.radix]
        mov     esi, [.digits]

        call    __simpNumToStrUF
        xor     eax, eax
        stosd

        stdcall Output, _simpdebugstr

.exit:
        popad
        return
endp


macro OutputNumber number, radix, digits {
if defined options.DebugMode & options.DebugMode
        stdcall OutputNumber, number, radix, digits
end if
}


regEDI = 0
regESI = 1
regEBP = 2
regESP = 3
regEBX = 4
regEDX = 5
regECX = 6
regEAX = 7


proc OutputRegister, .reg, .radix
begin
        pushad

        cmp     [.reg], 7
        ja      .exit

        cld
        mov     edi, _simpdebugstr
        mov     ebx, [.reg]

        mov     eax, [.regnames+4*ebx]
        stosd

        mov     eax, [esp+4*ebx]
        mov     ecx, [.radix]
        mov     esi, 8

        call    __simpNumToStrUF
        mov     eax, $0a
        stosd

        stdcall Output, _simpdebugstr

.exit:
        popad
        return

  .regnames:
        dd      'edi='
        dd      'esi='
        dd      'ebp='
        dd      'esp='
        dd      'ebx='
        dd      'edx='
        dd      'ecx='
        dd      'eax='
endp



macro OutputRegister reg, radix {
if defined options.DebugMode & options.DebugMode
        stdcall OutputRegister, reg, radix
end if
}



uglobal
  if used _simpdebugstr
    _simpdebugstr rb 256
  end if
endg



proc __simpStrLength;, .pString
begin
        mov     ecx, [esp+4]
.scan:
        cmp     byte [ecx], 0
        lea     ecx, [ecx+1]
        jne     .scan

        stc
        sbb     ecx, [esp+4]
        retn 4
endp


;*****************************************************
; NumToStrF:
;   Converts signed integer value to string.
; NumToStrUF:
;   Converts unsigned integer value to string.
;
; edi - pointer to string buffer
; eax - Number to convert
; ecx - radix from 2 to $ff
; esi - length of the number in chars
;
; returns: edi - pointer to the end of converted num
;
; Note: Don't use 1 as radix.
;*****************************************************
proc __simpNumToStrF
begin
        test    eax,eax
        jns     NumToStrUF
        neg     eax
        mov     byte [edi],'-'
        push    esi
        dec     esi
        add     edi,esi
        push    edi
        jmp     __simpNumToStrUF.loopc
endp

proc __simpNumToStrUF
begin
        push    esi
        add     edi, esi
        push    edi
        dec     edi
.loopc:
        xor     edx,edx
        div     ecx
        xchg    al,dl
        cmp     al,$0a
        sbb     al,$69
        das
        mov     [edi],al
        dec     edi
        xchg    al,dl
        dec     esi
        jnz     .loopc
        pop     edi
        pop     esi
        return
endp



endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































































































































































































































Deleted freshlib/sqlite/sqlite.asm.

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
;-------------------------------------------------------------------
; Procedures for convenient work with SQLite database angine.
;-------------------------------------------------------------------

;-------------------------------------------------------------------
; If the file in [.ptrFileName] exists, the function opens it.
; if the file does not exists, new database is created and the
; initialization script from [.ptrInitScript] is executed on it.
;
; Returns:
;    CF: 0 - database was open successfully
;      eax = 0 - Existing database was open successfuly.
;      eax = 1 - New database was created and init script was
;                executed successfully.
;      eax = 2 - New database was created but init script exits
;                with error.
;    CF: 1 - the database could not be open. (error)
;-------------------------------------------------------------------
proc OpenOrCreate, .ptrFileName, .ptrDatabase, .ptrInitScript
   .hSQL dd ?
.ptrNext dd ?
begin
        push    esi ebx

        mov     esi, [.ptrDatabase]
        cinvoke sqliteOpen, [.ptrFileName], esi
        test    eax, eax
        jz      .openok
        stc
        pop     esi
        return

.openok:
        xor     ebx, ebx
        cinvoke sqliteExec, [esi], .sqlCheckEmpty, .AbortCallback, ebx, ebx
        cmp     eax, SQLITE_ABORT
        je      .finish

        cinvoke sqliteExec, [esi], [.ptrInitScript], -1, ebx, ebx, ebx
        inc     ebx
        test    eax, eax     ; SQLITE_OK
        jz      .finish

        inc     ebx

.finish:
        cinvoke sqliteFinalize, [.hSQL]
        mov     eax, ebx
        clc
        pop     ebx esi
        return

.AbortCallback:
        xor     eax, eax
        inc     eax
        retn

.sqlCheckEmpty db 'select * from sqlite_master',0

endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































Deleted freshlib/system/Linux/clipboard.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Clipboard management library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


if used ClipboardRead | used ClipboardWrite
  __UseClipboard = 1
else
  __UseClipboard = 0
end if



proc ClipboardRead
.result dd ?

.event XEvent

.return_type    dd ?
.return_format  dd ?
.return_items   dd ?
.return_remains dd ?
.return_data    dd ?

begin
        pushad
        mov     [.result], 0

        cinvoke XGetSelectionOwner, [hApplicationDisplay], [atomSelClipboard]
        test    eax, eax
        jz      .finish

        cinvoke XConvertSelection, [hApplicationDisplay], [atomSelClipboard], [atomUTF8], [atomUTF8], [hClipboardWindow], CurrentTime

.wait_loop:
        lea     eax, [.event]
        cinvoke XCheckTypedEvent, [hApplicationDisplay], SelectionNotify, eax
        test    eax, eax
        jz      .wait_loop

        cmp     [.event+XSelectionEvent.property], None
        je      .finish

        lea     eax, [.return_data]
        lea     ecx, [.return_remains]
        lea     edx, [.return_items]

        push    eax
        push    ecx
        push    edx

        lea     eax, [.return_format]
        lea     ecx, [.return_type]
        push    eax
        push    ecx

        push    AnyPropertyType
        push    FALSE
        push    $7fffffff
        push    0
        push    [.event+XSelectionEvent.property]
        push    [.event+XSelectionEvent.requestor]
        push    [hApplicationDisplay]
        call    [XGetWindowProperty]
        add     esp, 12*4

        mov     eax, [.return_type]
        cmp     eax, [atomUTF8]
        jne     .finish

        mov      eax, [.return_data]
        test     eax, eax
        jz       .finish

        stdcall StrDup, eax
        mov     [.result], eax

        cinvoke XFree, [.return_data]

.finish:
        popad
        mov     eax, [.result]
        return
endp



proc ClipboardWrite, .hstring
begin



        return
endp




uglobal
  var atomSelClipboard = 0
  var atomUTF8 = 0
  var hClipboardWindow = 0
endg

cAtomClipboard text 'CLIPBOARD'
cAtomUTF8 text 'UTF8_STRING'


proc __InitLinuxClipboard
begin
        cinvoke XInternAtom, [hApplicationDisplay], cAtomClipboard, FALSE
        mov     [atomSelClipboard], eax

        cinvoke XInternAtom, [hApplicationDisplay], cAtomUTF8, FALSE
        mov     [atomUTF8], eax

        cinvoke XCreateWindow, [hApplicationDisplay], [hRootWindow], 0, 0, 1, 1, 0, CopyFromParent, InputOnly, CopyFromParent, 0, 0
        mov     [hClipboardWindow], eax
        return
endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































































































































































Deleted freshlib/system/Linux/environment.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Linux environment management library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


uglobal
  var _ptrEnvironment = ?
endg


if used _ptrEnvironment
initialize LinuxEnvironmentLibrary
begin
        lea     eax, [esp+4]
        mov     [_ptrEnvironment], eax

        return
endp
end if



proc GetAllEnvironment
.return dd ?
begin
        pushad

        mov     [.return], 0
        mov     eax, [_ptrEnvironment]
        mov     ecx, [eax]              ; argument count

        lea     eax, [eax+4*ecx+8]      ; env table.

        mov     esi, [eax]
        test    esi, esi
        jz      .finish

        push    esi

.end_loop:
        cmp     word [esi], 0
        lea     esi, [esi+1]
        jne     .end_loop

        stc
        sbb     esi, [esp]
        lea     ecx, [esi+8]

        stdcall GetMem, ecx
        mov     [.return], eax
        mov     edi, eax
        mov     ecx, esi
        pop     esi
        rep movsb
        xor     eax, eax
        stosd

.finish:
        popad
        mov     eax, [.return]
        return
endp



proc GetEnvVariable, .varname
begin
        push    ebx ecx esi edi

        mov     esi, [_ptrEnvironment]
        mov     eax, [esi]
        mov     esi, [esi+4*eax+8]

        stdcall StrPtr, [.varname]
        mov     ebx, eax

.outer:
        cmp     byte [esi], 0
        je      .not_found

        mov     edi, ebx
.inner:
        mov     al, [esi]
        mov     ah, [edi]
        lea     esi, [esi+1]
        lea     edi, [edi+1]

        test    ah, ah
        jnz     .check_al

        cmp     al, '='
        je      .found

.check_al:
        test    al, al
        jz      .outer

        cmp     al, ah
        je      .inner

; skip to next record
.skip:
        cmp     byte [esi], 0
        lea     esi, [esi+1]
        jne     .skip
        jmp     .outer

.not_found:
        xor     eax, eax
        stc
        pop     edi esi ecx ebx
        return

.found:
        stdcall StrDup, esi
        pop     edi esi ecx ebx
        clc
        return

endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































Deleted freshlib/system/Linux/files.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Files manipulation library. Linux part.
;
;  Target OS: Linux
;
;  Dependencies: Uses system calls for file processing and memory.asm for memory
;                allocations.
;
;  Notes:
;_________________________________________________________________________________________

DIR_SLASH equ '/'

fsFromBegin     = 0
fsFromEnd       = 2
fsFromCurrent   = 1

sys_read        = 03h
sys_write       = 04h
sys_open        = 05h
sys_close       = 06h
sys_unlink      = 0Ah
sys_lseek       = 013h

;   file access bits:
O_ACCMODE       = 0003o
O_RDONLY        = 00o
O_WRONLY        = 01o
O_RDWR          = 02o
O_CREAT         = 0100o
O_EXCL          = 0200o
O_NOCTTY        = 0400o
O_TRUNC         = 01000o
O_APPEND        = 02000o
O_NONBLOCK      = 04000o
O_NDELAY        = O_NONBLOCK
O_SYNC          = 010000o ;specific to ext2 fs and block devices
FASYNC          = 020000o ;fcntl, for BSD compatibility
O_DIRECT        = 040000o ;direct disk access hint - currently ignored
O_LARGEFILE     = 0100000o
O_DIRECTORY     = 0200000o ;must be a directory
O_NOFOLLOW      = 0400000o ;don't follow links

;   file permissions flags
S_ISUID         = 04000o ;set user ID on execution
S_ISGID         = 02000o ;set group ID on execution
S_ISVTX         = 01000o ;sticky bit
S_IRUSR         = 00400o ;read by owner (S_IREAD)
S_IWUSR         = 00200o ;write by owner (S_IWRITE)
S_IXUSR         = 00100o ;execute/search by owner (S_IEXEC)
S_IRGRP         = 00040o ;read by group
S_IWGRP         = 00020o ;write by group
S_IXGRP         = 00010o ;execute/search by group
S_IROTH         = 00004o ;read by others (R_OK)
S_IWOTH         = 00002o ;write by others (W_OK)
S_IXOTH         = 00001o ;execute/search by others (X_OK)


initialize InitStdHandles
begin
  if used STDIN
        mov     dword [__std_handle_in], 0
  end if

  if used STDOUT
        mov     dword [__std_handle_out], 1
  end if

  if used STDERR
        mov     dword [__std_handle_err], 2
  end if
        return
endp





;--------------------------------------
; if CF = 0, eax is handle to the file.
; if CF = 1, eax is error code.
;--------------------------------------
proc FileOpen, .filename
begin
        push    edx ecx ebx

        if defined ptrStrTable
          stdcall StrPtr, [.filename]
          mov     ebx, eax
        else
          mov   ebx, [.filename]
        end if

        mov     eax, sys_open
        mov     ecx, O_RDONLY;O_RDWR
        mov     edx, S_IWUSR+S_IWGRP+S_IWOTH
        int     $80
        cmp     eax, -1
        jle     .error
        clc
        pop     ebx ecx edx
        return

.error:
        neg     eax

if defined options.DebugMode & options.DebugMode = 1
        DebugMsg "Error open file. Error code:"
        OutputRegister regEAX, 16
        pushad
        stdcall GetErrorString, eax
        stdcall Output, eax
        stdcall FreeErrorString, eax
        popad
end if

        stc
        pop     ebx ecx edx
        return
endp



;--------------------------------------
; if CF = 0, eax is handle to the file.
; if CF = 1, eax is error code.
;--------------------------------------
proc FileCreate, .filename
begin
        push    edx ecx ebx

if defined ptrStrTable
        stdcall StrPtr, [.filename]
        mov     ebx, eax
else
        mov     ebx, [.filename]
end if

        mov     eax, sys_open
        mov     ecx, O_CREAT+O_TRUNC+O_RDWR
        mov     edx, S_IRUSR+S_IWUSR+S_IRGRP+S_IROTH
        int     $80
        cmp     eax, -1
        jle     .error
        clc
        pop     ebx ecx edx
        return
.error:
        neg     eax
        stc
        pop     ebx ecx edx
        return
endp




;--------------------------------------
; if CF = 0, the file was closed.
; if CF = 1, eax is error code.
;--------------------------------------
proc FileClose, .handle
begin
        push    ebx
        mov     eax, sys_close
        mov     ebx, [.handle]
        int     $80
        cmp     eax, -1
        jle     .error
        clc
        pop     ebx
        return
.error:
        neg     eax
        stc
        pop     ebx
        return
endp


; returns 32bit file size in eax
proc FileSize, .handle
.stat STAT
begin
        push    edx ecx ebx

        mov     eax, sys_newfstat
        mov     ebx, [.handle]
        lea     ecx, [.stat]
        int     $80

        cmp     eax, -1
        jle     .error

        mov     eax, [.stat.st_size]
        clc
        pop     ebx ecx edx
        return

.error:
        neg     eax
        stc
        pop     ebx ecx edx
        return
endp



proc FileRead, .handle, .buffer, .count
begin
        push    edx ecx ebx
        mov     eax, sys_read
        mov     ebx, [.handle]
        mov     ecx, [.buffer]
        mov     edx, [.count]
        int     $80
        cmp     eax, -1
        jle     .error
        clc
        pop     ebx ecx edx
        return

.error:
        neg     eax
        stc
        pop     ebx ecx edx
        return
endp


proc FileWrite, .handle, .buffer, .count
begin
        push    edx ecx ebx
        mov     eax, sys_write
        mov     ebx, [.handle]
        mov     ecx, [.buffer]
        mov     edx, [.count]
        int     $80
        cmp     eax, -1
        jle     .error
        clc
        pop     ebx ecx edx
        return

.error:
        neg     eax
        stc
        pop     ebx ecx edx
        return
endp


;----------------------------------------------------
; if CF = 0, eax is the new possition in the file
; if CF = 1, eax is error code.
;----------------------------------------------------
proc FileSeek, .handle, .dist, .direction
begin
        push    edx ecx ebx
        mov     eax,sys_lseek
        mov     ebx,[.handle]
        mov     ecx,[.dist]
        mov     edx,[.direction]
        int     $80
        cmp     eax,-1
        jle     .error
        clc
        pop     ebx ecx edx
        return

.error:
        neg     eax
        stc
        pop     ebx ecx edx
        return
endp



;--------------------------------------
; if CF = 0, the file was deleted.
; if CF = 1, eax is error code.
;--------------------------------------
proc FileDelete, .filename
begin
        push    ebx

        if defined ptrStrTable
          stdcall StrPtr, [.filename]
          mov     ebx, eax
        else
          mov   ebx, [.filename]
        end if

        mov     eax,sys_unlink
        int     $80
        cmp     eax,-1
        jle     .error
        clc
        pop     ebx
        return

.error:
        neg     eax
        stc
        pop     ebx
        return
endp



proc GetErrorString, .code
.buff dd ?
begin
        push    ecx edx
        cinvoke strerror_r, [.code], 0, 0       ; it is somewhat not clear about the returned string. Should we free it???
        pop     edx ecx
        clc
        return
endp




proc FreeErrorString, .ptrString
begin
        return
endp




ftDirectory  =  DT_DIR
ftUnknown    =  DT_UNKNOWN
ftFile       =  DT_REG


; reads all items of the directory and fills them in the TArray of type TDirItem.
; arguments:
;   dir - string with the path to the directory.
;
; returns:
;   if not error: CF=0; eax = pointer to TArray of TDirItem;
;   if error:     CF=1; eax = error code;

proc DirectoryRead, .dir
.buffer rb 1024
.size   dd ?
begin
        push    ebx ecx edx edi

        stdcall CreateArray, sizeof.TDirItem
        mov     edi, eax

; open the file
        if defined ptrStrTable
          stdcall StrPtr, [.dir]
          mov     ebx, eax
        else
          mov   ebx, [.dir]
        end if

        mov     eax, sys_open
        mov     ecx, O_RDONLY or O_DIRECTORY
        mov     edx, S_IWUSR+S_IWGRP+S_IWOTH
        int     $80
        test    eax, eax
        js      .error

        mov     ebx, eax

.read_loop:

        mov     eax, sys_getdents
        lea     ecx, [.buffer]
        mov     edx, 1024
        int     $80

; process read information

        test    eax, eax
        jz      .end_of_directory
        js      .error

        mov     [.size], eax

        xor     ecx, ecx

.buffer_parse:
        lea     eax, [.buffer+linux_dirent.d_name+ecx]
        stdcall StrDup, eax
        push    eax

        stdcall AddArrayItems, edi, 1
        mov     edi, edx

        pop     [eax+TDirItem.hFilename]

        movzx   edx, word [.buffer+ecx+linux_dirent.d_reclen]
        add     ecx, edx

        movzx   edx, byte [.buffer+ecx-1]       ; file type.
        mov     [eax+TDirItem.Type], edx

        cmp     ecx, [.size]
        jb      .buffer_parse

        jmp     .read_loop

.end_of_directory:

        mov     eax, sys_close
        int     $80


        mov     eax, edi
        pop     edi edx ecx ebx
        clc
        return

.error:
        neg     eax
        pop     edi edx ecx ebx
        stc
        return
endp





proc GetFileInfo, .hFile, .ptrFileInfo
.fstat STAT
begin
        push    edi ebx ecx eax

        lea     edi, [.fstat]
        mov     ecx, sizeof.STAT / 4
        xor     eax, eax
        rep stosd

        mov     eax, sys_newfstat
        mov     ebx, [.hFile]
        lea     ecx, [.fstat]
        int     $80

        test    eax, eax
        jnz     .error

        lea     ecx, [.fstat]
        mov     ebx, [.ptrFileInfo]

        mov     eax, [ecx+STAT.st_atime]
        cdq
        mov     dword [ebx+TFileInfo.timeAccessed], eax
        mov     dword [ebx+TFileInfo.timeAccessed+4], edx

        mov     eax, [ecx+STAT.st_mtime]
        cdq
        mov     dword [ebx+TFileInfo.timeModified], eax
        mov     dword [ebx+TFileInfo.timeModified+4], edx
; linux does not support creation time, so we set it as the modified time.
        mov     dword [ebx+TFileInfo.timeCreated], eax
        mov     dword [ebx+TFileInfo.timeCreated+4], edx

        pop     eax ecx ebx edi
        clc
        return

.error:
        neg     eax
        mov     [esp], eax

        pop     eax ecx ebx edi
        stc
        return

endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/system/Linux/memory.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Dynamic memory management library. Linux part.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes: Uses libc (malloc etc.) heap management functions.
;_________________________________________________________________________________________

if used SpaceAllocate & ~ used GetMem
initialize ReserveAddressSpace
begin
        mov     eax, sys_brk
        xor     ebx, ebx
        int     $80
        mov     [_MemoryFreeSpace], eax
        return
endp
end if



proc GetMem, .size
begin
        push    ebx ecx edx esi edi

        mov     ebx, [.size]
        add     ebx, 3
        and     bl, $fc          ; align to dword.

        cinvoke malloc, ebx
        test    eax, eax
        jz      .error
        push    eax

        cld
        mov     edi, eax
        mov     ecx, ebx
        shr     ecx, 2
        xor     eax, eax
        rep stosd

        pop     eax
        clc
        pop     edi esi edx ecx ebx
        return

.error:
        stc
        pop     edi esi edx ecx ebx
        return

endp



proc FreeMem, .ptr
begin
        cmp     [.ptr], 0
        je      @f
        pushad
        cinvoke free, [.ptr]
        popad
@@:
        clc
        return
endp




proc ResizeMem, .ptr, .newsize
begin
        push    ebx ecx edx esi edi

        mov     ebx, [.newsize]
        add     ebx, 3
        and     bl, $fc          ; align to dword.

        cinvoke realloc, [.ptr], ebx
        test    eax, eax
        jz      .error

        clc
        pop     edi esi edx ecx ebx
        return

.error:
        stc
        pop     edi esi edx ecx ebx
        return
endp




proc SpaceAllocate, .size
begin
        push ebx

        mov     eax, sys_brk
        mov     ebx, [_MemoryFreeSpace]
        add     ebx, [.size]
        int     $80
        pop  ebx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































Deleted freshlib/system/Linux/process.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Process management library. Linux part
;
;  Target OS: Linux
;
;  Dependencies: Uses pthreads library for thread creation.
;
;  Notes:
;_________________________________________________________________________________________


; Terminate current process
; Returns: eax = 0
proc Terminate,.exit_code
begin
        mov     eax, sys_exit
        mov     ebx, [.exit_code]
        int     0x80
        return
endp



proc GetCmdArguments
begin
        push    ecx edx esi

        mov     esi, [_ptrEnvironment]

        mov     ecx, [esi]
        add     esi, 4

        stdcall CreateArray, 4
        mov     edx, eax
        jecxz   .array_ok

        stdcall AddArrayItems, eax, ecx

.array_ok:
        push    edx
        jecxz   .arg_ok

        lea     edx, [edx+TArray.array]

.loop:
        lodsd
        stdcall StrDup, eax
        mov     [edx], eax
        add     edx, 4
        loop    .loop

.arg_ok:
        pop     eax
        pop     esi edx ecx
        return
endp





proc ThreadCreate, .ptrFunction, .ptrArguments
.threadid dd ?
begin
        push    ecx edx
        lea     eax, [.threadid]
        mov     [.threadid], 0
        cinvoke pthread_create, eax, NULL, [.ptrFunction], [.ptrArguments]
        mov     eax, [.threadid]
        test    eax, eax
        jz      .error

        clc
        pop     edx ecx
        return

.error:
        stc
        pop     edx ecx
        return
endp




; MUTEX functions
;_________________________________________________________________________________________

proc MutexCreate, .ptrName, .ptrMutex
begin
        push    eax ecx edx
        pop     edx ecx eax
        return
endp




proc WaitForMutex, .ptrMutex, .timeout
begin
        push    eax ecx edx
        clc
        pop     edx ecx eax
        return
endp




proc MutexRelease, .ptrMutex
begin
        pushf
        push    eax ecx edx
        pop     edx ecx eax
        popf
        return
endp



proc MutexDestroy, .ptrMutex
begin
        push    eax ecx edx
        pop     edx ecx eax
        return
endp









;__ThreadStackSize = 1024 * 1024  ; 1Mbyte for the thread stack
;
;; Creates a new execution thread
;; Returns: CF=1 if error.
;;          CF=0, eax = pid of the new process being created
;proc ThreadCreate, .ptr_to_function, .ptr_to_args
;begin
;        push    ebx ecx edx esi edi
;
;        push    ebp
;        mov     eax, sys_mmap_pgoff
;        xor     ebx, ebx
;        mov     ecx, __ThreadStackSize
;        mov     edx, PROT_READ or PROT_WRITE
;        mov     esi, MAP_ANONYMOUS or MAP_PRIVATE or MAP_GROWSDOWN or MAP_STACK
;        mov     edi, -1
;        xor     ebp, ebp
;        int $80
;        pop     ebp
;
;        cmp     eax, $ffffff00
;        jae     .error
;
;        lea     ecx, [eax+__ThreadStackSize-8]
;
;; transfer arguments in the new stack.
;        mov     eax, [.ptr_to_function]
;        mov     [ecx], eax
;        mov     eax, [.ptr_to_args]
;        mov     [ecx+4], eax
;
;        mov     eax, sys_clone
;        mov     ebx, CLONE_VM or CLONE_FILES or CLONE_SIGHAND or CLONE_IO or CLONE_THREAD
;        int 0x80
;
;        cmp     eax,-1
;        je      .error
;
;        test    eax, eax
;        jz      .is_clone
;
;        clc
;        pop     edi esi edx ecx ebx
;        return
;
;; The stack is not allocated or sys_clone exits with error.
;.error:
;        stc
;        pop     edi esi edx ecx ebx
;        return
;
;; this is the clone process - call the thread.
;.is_clone:
;        pop     eax
;        call    eax       ; the argument is already in the stack.
;        mov     esi, eax  ; the thread procedure can return exit code. Save it in esi.
;
;; release the stack.
;        mov     eax, sys_munmap
;        lea     ebx, [esp-__ThreadStackSize]
;        mov     ecx, __ThreadStackSize
;        int $80
;
;; and exit the process  - the question is - how to execute int $80 without a stack ??? However, by some magic, it works...
;        mov     ebx, esi
;        mov     eax, sys_exit
;        int     0x80
;endp
;
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































Deleted freshlib/system/Linux/timers.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Asynchronous timer library.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes: Linux port of the library uses independent thread to manage timers.
;_________________________________________________________________________________________

__sys_time_slice = 10 ;[ms]


uglobal
  if used TimerCreate
    __InternalTimerID     dd ?
    __InternalTimerThread dd ?
    __FlagTimerTerminate  dd ?
  end if
endg



if used TimerCreate
  if ~(defined options.DebugMode & options.DebugMode=1)

initialize InitLinuxTimers
  .action lnx_sigaction
  .timer lnx_sigevent
  .time  lnx_itimerspec
begin
; set the signal handler.
        mov     eax, sys_sigaction
        mov     ebx, SIGALRM
        lea     ecx, [.action]
        mov     [ecx+lnx_sigaction.sa_handler], __TimerProc
        mov     [ecx+lnx_sigaction.sa_mask], 0
        mov     [ecx+lnx_sigaction.sa_flags], 0
        xor     edx, edx

        int $80

;        DebugMsg 'Signal hadler set.'

; create the interval timer
        mov     eax, sys_timer_create
        mov     ebx, CLOCK_REALTIME

        lea     ecx, [.timer]
        mov     [ecx+lnx_sigevent.notify], SIGEV_SIGNAL
        mov     [ecx+lnx_sigevent.signo], SIGALRM
        mov     [ecx+lnx_sigevent.value], 0             ; not used but must be set - the function fails without it...
        mov     edx, __InternalTimerID

        int $80

;        DebugMsg 'Interval timer created.'

; then start a thread that will process timer expiration events.

        stdcall ThreadCreate, __TimerHandler, 0

;        DebugMsg 'Timer thread created'

        mov     [__InternalTimerThread], eax

; start the timer
        mov     ebx, [__InternalTimerID]
        mov     eax, sys_timer_settime
        lea     edx, [.time]
        mov     [edx+lnx_itimerspec.it_interval.tv_sec], 0
        mov     [edx+lnx_itimerspec.it_interval.tv_nsec], __sys_time_slice*1000000
        mov     [edx+lnx_itimerspec.it_value.tv_sec], 0
        mov     [edx+lnx_itimerspec.it_value.tv_nsec], __sys_time_slice*1000000
        xor     esi, esi
        int $80

;        DebugMsg 'Timer started'

        return
endp




finalize FreeLinuxTimers
begin
; stop the timer
        mov     eax, sys_timer_delete
        mov     ebx, [__InternalTimerID]
        int $80

;        DebugMsg 'Timer stopped.'

        cmp     [__InternalTimerThread], 0
        je      .finish

; then stop the handling thread
        mov     [__FlagTimerTerminate], 1
        cinvoke pthread_kill, [__InternalTimerThread], SIGRTMAX

; waiting to timer thread to finish. This is bad implementation,
;here should be timer wait with signal terminate on timeout.
@@:
        cmp     [__InternalTimerThread], 0
        jne     @b

;        DebugMsg 'Timer thread terminated.'

.finish:
        return
endp
  end if
end if




; This procedure is called by the system on every time quantum.
; It is Linux signal handler, so the actions this procedure can
; perform are limited.

proc __TimerProc, .signal
begin
        push    ebx edi

        cmp     [fGlobalTerminate], 0
        jne     .exit

        lea     eax, [__ptrFirstTimer]
        xor     edi, edi

.loop:
        mov     eax, [eax+TTimer.next]
        test    eax, eax
        jz      .end_timers

        test    [eax+TTimer.flags], tmfRunning
        jz      .loop

        mov     ecx, [eax+TTimer.value]
        add     ecx, __sys_time_slice

        mov     [eax+TTimer.value], ecx
        cmp     ecx, [eax+TTimer.interval]
        jl     .loop

@@:
        inc     [eax+TTimer.Expired]
        inc     edi

        mov     ecx, [eax+TTimer.interval]
        sub     [eax+TTimer.value], ecx
        cmp     [eax+TTimer.value], ecx
        jge     @b
        jmp     .loop


.end_timers:
        test    edi, edi
        jz      .exit
        cinvoke pthread_kill, [__InternalTimerThread], SIGRTMAX
.exit:
        pop     edi ebx
        cret
endp



; This is thread procedure, that checks the timer expiration and then executes the timer callback procedure (if any)

proc __TimerHandler, .argument
.remain dd ?
.action lnx_sigaction
begin
        mov     eax, sys_sigaction
        mov     ebx, SIGRTMAX
        lea     ecx, [.action]
        mov     [ecx+lnx_sigaction.sa_handler], __continue_proc
        mov     [ecx+lnx_sigaction.sa_mask], 0
        mov     [ecx+lnx_sigaction.sa_flags], 0;SA_NODEFER
        xor     edx, edx
        int $80

        mov     [__FlagTimerTerminate], 0

.from_begin:
        cmp     [__FlagTimerTerminate], 0
        jne     .quit

        mov     [.remain], 0
        lea     eax, [__ptrFirstTimer]

.listloop:
        mov     eax, [eax+TTimer.next]

.listloop2:
        test    eax, eax
        jz      .end_list

        mov     ecx, [eax+TTimer.Expired]
        jecxz   .listloop

        dec     ecx
        mov     [eax+TTimer.Expired], ecx
        add     [.remain], ecx

        cmp     [eax+TTimer.Callback], 0
        je      .listloop

        mov     ecx, [eax+TTimer.flags]
        and     ecx, $0f
        cmp     ecx, tmfDoNothing
        je      .end_event

; call the callback procedure.
        pushad
        push    eax
        cinvoke XLockDisplay, [hApplicationDisplay]
        pop     eax
        stdcall [eax+TTimer.Callback], eax
        cinvoke XUnlockDisplay, [hApplicationDisplay]
        popad

.end_event:
        test    [eax+TTimer.flags], tmfSyncDestroy
        jz      .listloop

        push    eax
        mov     eax, [eax+TTimer.next]  ; after the destruction, this pointer will be lost.
        stdcall TimerDestroy ; pointer from the stack.
        jmp     .listloop2


.end_list:
        cmp     [.remain], 0
        jne     .from_begin

; wait for signal
        mov     eax, sys_pause
        int $80
        jmp     .from_begin

.quit:
        mov     [__InternalTimerThread], 0

        stdcall Terminate, 0
endp



proc __continue_proc, .signal
begin
        cret
endp


; this procedure provides easy way to make time delays
; it is independent and does not lead to including whole timer library.

proc Sleep, .msec
.time lnx_timespec
begin
        pushad

        mov     eax, [.msec]
        xor     edx, edx
        mov     ecx, 1000
        div     eax

        mov     [.time.tv_sec], eax     ; seconds
        imul    edx, 1000000
        mov     [.time.tv_nsec], edx

        mov     eax, sys_nanosleep
        lea     ebx, [.time]
        xor     ecx, ecx
        int $80

        popad
        return
endp




proc GetTime
begin
        push    ebx

        mov     eax, sys_time
        xor     ebx, ebx
        int     $80

        cdq
        pop     ebx
        return
endp



struct lnx_timeb
  .time    dd ?
  .millitm dd ?
  .timezone dd ?
  .dstflag  dd ?
ends


proc GetLocalTimeOffset
;.time lnx_timespec
begin
;        stdcall GetTime
;        push    eax
;
;        mov     eax, sys_clock_gettime
;        mov     ebx, CLOCK_REALTIME
;        lea     ecx, [.time]
;
;        int     $80
;
;
;        pop     edx
;        mov     eax, [.time.tv_sec]
;
;        OutputRegister regEAX, 10
;        OutputRegister regEDX, 10
;        int3

        xor     eax, eax
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/system/Win32/clipboard.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Clipboard management library.
;
;  Target OS: Win32
;
;  Dependencies:
;_________________________________________________________________________________________


; returns eax = handle to string with the clipboard data.
proc ClipboardRead
.result dd ?
begin
        pushad
        xor     eax, eax
        mov     [.result], eax

        invoke  OpenClipboard, eax
        test    eax, eax
        jz      .finish

        invoke  GetClipboardData, CF_UNICODETEXT
        test    eax, eax
        jz      .close

        mov     ebx, eax

        invoke  GlobalSize, ebx
        mov     edi, eax

        invoke  GlobalLock, ebx
        mov     esi, eax

        lea     ecx, [8*edi]

        stdcall GetMem, ecx
        jc      .close3
        mov     edi, eax

        invoke  WideCharToMultiByte, CP_UTF8, 0, esi, -1, edi, ecx, 0, 0
        test    eax, eax
        jz      .close2

        mov     dword [edi+eax], 0

        stdcall StrDup, edi
        mov     [.result], eax

.close2:
        stdcall FreeMem, edi
.close3:
        invoke  GlobalUnlock, ebx
.close:
        invoke  CloseClipboard
        popad
.finish:
        mov     eax, [.result]
        return
endp



; writes the string .hstring to the clipboard.
; returns nothing.

proc ClipboardWrite, .hstring
begin
        pushad
        xor     eax, eax
        invoke  OpenClipboard, eax
        test    eax, eax
        jz      .finish

        invoke  EmptyClipboard

        stdcall utf8ToWideChar, [.hstring]
        mov     esi, eax
        shl     ecx, 3

        invoke  GlobalAlloc, GMEM_MOVEABLE or GMEM_ZEROINIT or GMEM_DDESHARE, ecx
        test    eax, eax
        jz      .close
        mov     ebx, eax

        invoke  GlobalLock, ebx
        mov     edi, eax
        invoke  lstrcpy, edi, esi
        invoke  GlobalUnlock, ebx

        invoke  SetClipboardData, CF_UNICODETEXT, ebx

.close:
        stdcall FreeMem, esi
        invoke  CloseClipboard
.finish:
        popad
        return
endp


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































Deleted freshlib/system/Win32/environment.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Win32 environment management library.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


proc GetAllEnvironment
.return dd ?
begin
        pushad

        invoke  GetEnvironmentStringsA
        push    eax
        mov     esi, eax

.end_loop:
        cmp     word [esi], 0
        lea     esi, [esi+1]
        jne     .end_loop

        stc
        sbb     esi, [esp]
        lea     ecx, [esi+8]

        stdcall GetMem, ecx
        mov     [.return], eax
        mov     edi, eax
        mov     ecx, esi
        mov     esi, [esp]
        rep movsb
        xor     eax, eax
        stosd

        invoke  FreeEnvironmentStrings ; from the stack
        popad
        mov     eax, [.return]
        return
endp



proc GetEnvVariable, .varname
.buffer rb 1024
begin
        push    ebx ecx edx

        stdcall utf8ToWideChar, [.varname]
        mov     [.varname], eax

        lea     ebx, [.buffer]
        invoke  GetEnvironmentVariable, [.varname], ebx, 1024
        test    eax, eax
        jz      .missing

        stdcall FreeMem, [.varname]
        stdcall WideCharToUtf8, ebx
        clc
        pop     edx ecx ebx
        return

.missing:
        stdcall FreeMem, [.varname]
        stc
        pop     edx ecx ebx
        return


endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































Deleted freshlib/system/Win32/files.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Files manipulation library. Win32 part.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

DIR_SLASH equ '\'


fsFromBegin     = FILE_BEGIN
fsFromEnd       = FILE_END
fsFromCurrent   = FILE_CURRENT

if used STDIN | used STDOUT | used STDERR

  initialize InitStdHandles
  begin
    if used STDIN
          invoke  GetStdHandle, STD_INPUT_HANDLE
          mov     [__std_handle_in], eax
    end if

    if used STDOUT
          invoke  GetStdHandle, STD_OUTPUT_HANDLE
          mov     [__std_handle_out], eax
    end if

    if used STDERR
          invoke  GetStdHandle, STD_ERROR_HANDLE
          mov     [__std_handle_err], eax
    end if
          return
  endp

end if

;--------------------------------------
; if CF = 0, eax is handle to the file.
; if CF = 1, eax is error code.
;--------------------------------------
proc FileOpen, .filename
begin
        push    edx ecx

if GlobalAPI eq unicode
        stdcall utf8ToWideChar, [.filename]
        push    eax
else
        if defined StrPtr
          stdcall StrPtr, [.filename]
        else
          mov   eax, [.filename]
        end if
end if
        invoke  CreateFile, eax, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0

if GlobalAPI eq unicode
        stdcall FreeMem ; from the stack
end if

        cmp     eax, INVALID_HANDLE_VALUE
        je      .error

        clc
        pop     ecx edx
        return

.error:
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     ecx edx
        return
endp



proc FileCreate, .filename
begin
        push    edx ecx

if GlobalAPI eq unicode
        stdcall utf8ToWideChar, [.filename]
        push    eax
else
        stdcall StrPtr, [.filename]
end if
        invoke  CreateFile, eax, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0

if GlobalAPI eq unicode
        stdcall FreeMem ; from the stack
end if
        cmp     eax, INVALID_HANDLE_VALUE
        je      .error

        clc
        pop     ecx edx
        return

.error:
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     ecx edx
        return
endp




proc FileClose, .handle
begin
        push    edx ecx eax
        invoke  CloseHandle, [.handle]
        test    eax, eax
        jz      .error

        clc
        pop     eax ecx edx
        return

.error:
        pop     eax
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     ecx edx
        return
endp


; returns 32bit file size in eax
proc FileSize, .handle
begin
        push    edx ecx

        xor     eax, eax
        invoke  GetFileSize, [.handle], eax
        cmp     eax, -1
        je      .error

        clc
        pop     ecx edx
        return

.error:
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     ecx edx
        return
endp



proc FileRead, .handle, .buffer, .count
.read dd ?
begin
        push    edx ecx

        lea     eax, [.read]
        invoke  ReadFile, [.handle], [.buffer], [.count], eax, 0
        test    eax, eax
        jz      .error

        mov     eax, [.read]
        clc
        pop     ecx edx
        return

.error:
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     ecx edx
        return
endp




proc FileWrite, .handle, .buffer, .count
.bytes dd ?
begin
        push    edx ecx

        lea     ecx, [.bytes]
        invoke  WriteFile, [.handle], [.buffer], [.count], ecx, NULL
        test    eax, eax
        jz      .error

        mov     eax, [.bytes]
        clc
        pop     ecx edx
        return

.error:
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     ecx edx
        return
endp




;----------------------------------------------------
; if CF = 0, eax is the new possition in the file
; if CF = 1, eax is error code.
;----------------------------------------------------
proc FileSeek, .handle, .dist, .direction
begin
        push    edx ecx
        invoke  SetFilePointer, [.handle], [.dist], 0, [.direction]
        cmp     eax, -1
        je      .error

        clc
        pop     ecx edx
        return

.error:
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     ecx edx
        return
endp



;----------------------------------------------------
; if CF = 0 - the file was deleted
; if CF = 1, eax is error code.
;----------------------------------------------------
proc FileDelete, .filename
begin
        push    ecx edx eax

if GlobalAPI eq unicode
        stdcall utf8ToWideChar, [.filename]
        push    eax
else
        stdcall StrPtr, [.filename]
end if
        invoke  DeleteFile, eax

if GlobalAPI eq unicode
        stdcall FreeMem ; from the stack
end if
        test    eax, eax
        jz      .error
        clc
        pop     eax edx ecx
        return

.error:
        pop     eax
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     edx ecx
        return
endp







proc GetErrorString, .code
.buff dd ?
begin
        push    edx ecx
        lea     eax, [.buff]

        if GlobalAPI eq ascii
          invoke  FormatMessage, FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM, 0, [.code], LANG_NEUTRAL or SUBLANG_DEFAULT, eax, 0, 0
        else
          invoke  FormatMessageA, FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM, 0, [.code], LANG_NEUTRAL or SUBLANG_DEFAULT, eax, 0, 0
        end if
        mov     eax, [.buff]
        clc
        pop     ecx edx
        return
endp



proc FreeErrorString, .ptrString
begin
        push    edx ecx
        invoke  LocalFree, [.ptrString]
        pop     ecx edx
        return
endp





ftUnknown    =  0
ftDirectory  =  1
ftFile       =  2



; reads all items of the directory and fills them in the TArray of type TDirItem.
; arguments:
;   dir - string with the path to the directory.
;
; returns:
;   if not error: CF=0; eax = pointer to TArray of TDirItem;
;   if error:     CF=1; eax = error code;

proc DirectoryRead, .dir
.finddata FINDDATAW
.size   dd ?
begin
        push    ebx ecx edx edi

; open the file
        stdcall StrDup, [.dir]
        push    eax
        stdcall StrCat, eax, .searchall

        stdcall utf8ToWideChar, eax
        stdcall StrDel ; from the stack

        push    eax

        lea     ecx, [.finddata]
        invoke  FindFirstFile, eax, ecx
        stdcall FreeMem ; from the stack

        cmp     eax, INVALID_HANDLE_VALUE
        je      .error

        mov     ebx, eax

        stdcall CreateArray, sizeof.TDirItem
        mov     edi, eax

.addloop:
        lea     eax, [.finddata.cFileName]
        stdcall WideCharToUtf8, eax
        push    eax

        stdcall AddArrayItems, edi, 1
        mov     edi, edx

        pop     [eax+TDirItem.hFilename]

        mov     ecx, ftDirectory
        test    [.finddata.dwFileAttributes], FILE_ATTRIBUTE_DIRECTORY
        jnz     .typeok
        mov     ecx, ftFile
.typeok:
        mov     [eax+TDirItem.Type], ecx

        lea     eax, [.finddata]
        invoke  FindNextFile, ebx, eax
        test    eax, eax
        jnz     .addloop

        invoke  GetLastError
        push    eax

.end_of_directory:

        invoke  FindClose, ebx

        pop     eax
        cmp     eax, ERROR_NO_MORE_FILES
        jne     .finish_error

        mov     eax, edi
        pop     edi edx ecx ebx
        clc
        return

.error:
        invoke  GetLastError

.finish_error:
        pop     edi edx ecx ebx
        stc
        return

.searchall db '\*.*', 0
endp




proc GetFileInfo, .hFile, .ptrFileInfo
begin
        pushad

        mov     esi, [.ptrFileInfo]
        lea     ecx, [esi+TFileInfo.timeAccessed]
        lea     edx, [esi+TFileInfo.timeModified]

        invoke  GetFileTime, [.hFile], esi, ecx, edx
        test    eax, eax
        jz      .error

        mov     eax, dword [esi+TFileInfo.timeCreated]
        mov     edx, dword [esi+TFileInfo.timeCreated+4]
        call    FileTimeToUnixTime
        mov     dword [esi+TFileInfo.timeCreated], eax
        mov     dword [esi+TFileInfo.timeCreated+4], edx

        mov     eax, dword [esi+TFileInfo.timeAccessed]
        mov     edx, dword [esi+TFileInfo.timeAccessed+4]
        call    FileTimeToUnixTime
        mov     dword [esi+TFileInfo.timeAccessed], eax
        mov     dword [esi+TFileInfo.timeAccessed+4], edx

        mov     eax, dword [esi+TFileInfo.timeModified]
        mov     edx, dword [esi+TFileInfo.timeModified+4]
        call    FileTimeToUnixTime
        mov     dword [esi+TFileInfo.timeModified], eax
        mov     dword [esi+TFileInfo.timeModified+4], edx

        clc
        popad
        return

.error:
        stc
        popad
        return

endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/system/Win32/memory.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Dynamic memory management library. Win32 part.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes: Uses Heap functions of Win32 API. Also contains some debug and profiling code,
;         that needs some revision in order to be either removed, or legalized.
;_________________________________________________________________________________________

uglobal
  var _hHeap=?
endg


uglobal
  var ptrMemoryStack = ?
  var flagNoDebug    = ?
endg


if DebugMemory

    struct TMemoryItem
      .pointer dd ?
      .callfrom dd ?
    ends

    proc InitAllocStack
    begin
            mov     [flagNoDebug], 1
            stdcall CreateArray, sizeof.TMemoryItem
            mov     [ptrMemoryStack], eax
            mov     [flagNoDebug], 0
            return
    endp

end if


if used SpaceAllocate & ~ used GetMem
initialize ReserveAddressSpace
begin
        invoke  VirtualAlloc, 0, 1024*1024*1024, MEM_RESERVE, PAGE_READWRITE
        mov     [_MemoryFreeSpace], eax
        return
endp
end if


if used GetMem & ~ used SpaceAllocate
initialize InitMemoryManager
begin
        invoke  GetProcessHeap
        mov     [_hHeap], eax

if DebugMemory
        call    InitAllocStack
end if
        return
endp
end if



if DebugMemory
finalize FinalizeMemoryManager
begin
        mov     eax, [ptrMemoryStack]

        int3
        xor     eax, eax
        xchg    eax, [ptrMemoryStack]
        stdcall FreeMem, eax
        return
endp
end if



; Allocates memory block with given size.
; Returns: CF=1 if error.
;          if CF=0, eax = pointer to the memory block allocated.

proc GetMem, .size
begin
        push    ecx edx
        if defined options.NoZeroMemory & options.NoZeroMemory = 1
          invoke  HeapAlloc, [_hHeap], 0, [.size]
        else
          invoke  HeapAlloc, [_hHeap], HEAP_ZERO_MEMORY, [.size]
        end if
        test    eax, eax
        jz      .error

if DebugMemory
            cmp     [flagNoDebug], 0
            jne     .exit

            pushad
            push    [flagNoDebug]
            mov     [flagNoDebug], 1

            mov     ecx, eax
            stdcall AddArrayItems, [ptrMemoryStack], 1
            mov     [ptrMemoryStack], edx
            jnc     @f

            int3
@@:
            mov     [eax+TMemoryItem.pointer], ecx
            mov     ecx, [esp+12*4]
            cmp     ecx, CreateArray.retaddr
            jne     @f
            mov     ecx, [esp+12*4+5*4]
@@:
            mov     [eax+TMemoryItem.callfrom], ecx

            pop     [flagNoDebug]
            popad

    .exit:
end if
        clc
        pop     edx ecx
        return

.error:
        stc
        pop     edx ecx
        return
endp



proc FreeMem, .ptr
begin
        push    eax ecx edx

if DebugMemory
            cmp     [flagNoDebug], 0
            jne     .exit

            pushad

            mov     esi, [ptrMemoryStack]
            mov     ebx, [esi+TArray.count]
            mov     eax, [.ptr]

            xor     ebx, ebx

    .loop:
            cmp     ebx, [esi+TArray.count]
            jae     .notfound

            cmp     [esi+TArray.array+8*ebx], eax
            je      .found

            inc     ebx
            jmp     .loop

    .notfound:
            int3
            jmp     .exit2

    .found:
            push    [flagNoDebug]
            mov     [flagNoDebug], 1

            stdcall DeleteArrayItems, esi, ebx, 1
            jnc     @f
            int3
@@:
            mov     [ptrMemoryStack], edx

            pop     [flagNoDebug]

    .exit2:
            popad
    .exit:
end if

        invoke  HeapFree, [_hHeap], 0 , [.ptr]
        pop     edx ecx eax
        return
endp




proc ResizeMem, .ptr, .newsize
begin
        push    ecx edx

        invoke  HeapReAlloc, [_hHeap], HEAP_ZERO_MEMORY, [.ptr], [.newsize]
        test    eax, eax
        jz      .error

if DebugMemory
            cmp     [flagNoDebug], 0
            jne     .exit

            pushad

            mov     esi, [ptrMemoryStack]
            mov     ebx, [esi+TArray.count]
            mov     ecx, [.ptr]

            xor     ebx, ebx

    .loop:
            cmp     ebx, [esi+TArray.count]
            jae     .notfound

            cmp     [esi+TArray.array+8*ebx], ecx
            je      .found

            inc     ebx
            jmp     .loop

    .notfound:
            int3
            jmp     .exit2

    .found:
            mov     [esi+TArray.array+8*ebx], eax
            mov     ecx, [esp+11*4]
            cmp     ecx, AddArrayItems.readdr
            jne     @f
            mov     ecx, [esp+12*4+5*4]
@@:
            mov     [esi+TArray.array+8*ebx+4], ecx

    .exit2:
            popad
    .exit:
end if

        clc
        pop     edx ecx
        return

.error:
        mov     eax, [.ptr]
        stc
        pop     edx ecx
        return
endp



;
;proc GetMemSize, .ptr
;begin
;        push    ecx edx
;        invoke  HeapSize, [_hHeap], 0, [.ptr]
;        cmp     eax, -1
;        je      .error
;        clc
;        pop     edx ecx
;        return
;
;.error:
;        stc
;        pop     edx ecx
;        return
;endp



proc SpaceAllocate, .size
begin
        push    ecx edx
        invoke  VirtualAlloc, [_MemoryFreeSpace], [.size], MEM_COMMIT, PAGE_READWRITE
        test    eax, eax
        pop     edx ecx
        return
endp


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































































































































































































































































































Deleted freshlib/system/Win32/process.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Process management library. Win32 part.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


; Terminate current process
; Returns: eax = 0

proc Terminate,.exit_code
begin
        invoke ExitProcess, [.exit_code]
        return
endp



proc GetCmdArguments
.argc dd ?
.array dd ?
begin
        pushad
        invoke  GetCommandLine
        lea     ecx, [.argc]
        invoke  CommandLineToArgv, eax, ecx
        test    eax, eax
        jz      .error

        push    eax
        mov     esi, eax

        stdcall CreateArray, 4
        mov     [.array], eax

.argloop:
        cmp     [.argc], 0
        je      .endarg

        stdcall WideCharToUtf8, [esi]
        push    eax
        stdcall AddArrayItems, [.array], 1
        mov     [.array], edx
        pop     dword [eax]

        add     esi, 4
        dec     [.argc]
        jmp     .argloop

.endarg:
        invoke  LocalFree ; from the stack...
        popad
        mov     eax, [.array]
        clc
        return

.error:
        popad
        stc
        return
endp



; Creates a new execution thread
; Returns: CF=1 if error.
;          CF=0, eax = pid of the new process being created

proc ThreadCreate, .ptr_to_function, .ptr_to_args
begin
        push    ecx edx

        invoke  CreateThread,NULL,0,[.ptr_to_function],[.ptr_to_args],0,0
        test    eax, eax
        jz      .error

        clc
        pop     edx ecx
        return

.error:
        stc
        pop     edx ecx
        return
endp




; MUTEX functions
;_________________________________________________________________________________________

proc MutexCreate, .ptrName, .ptrMutex
begin
        push    eax ecx edx

        invoke  CreateMutex, 0, TRUE, 0
        mov     ecx, [.ptrMutex]
        mov     [ecx], eax
        pop     edx ecx eax
        return
endp




proc WaitForMutex, .ptrMutex, .timeout
begin
        push    eax ecx edx
        mov     ecx, [.ptrMutex]
        invoke  WaitForSingleObject, [ecx], [.timeout]
        cmp     eax, WAIT_TIMEOUT
        clc
        jne     @f
        stc
@@:
        pop     edx ecx eax
        return
endp




proc MutexRelease, .ptrMutex
begin
        pushf
        push    eax ecx edx

        mov     eax, [.ptrMutex]
        invoke  ReleaseMutex, [eax]

        pop     edx ecx eax
        popf
        return
endp



proc MutexDestroy, .ptrMutex
begin
        push    eax ecx edx
        mov     eax, [.ptrMutex]
        pushd   [eax]
        mov     dword [eax], 0
        invoke  CloseHandle ; from the stack
        pop     edx ecx eax
        return
endp

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


























































































































































































































































































































Deleted freshlib/system/Win32/timers.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Asynchronous timer library.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

__sys_time_slice = 10 ;[ms]


uglobal
  if used TimerCreate
    __InternalTimerID     dd ?
    __InternalTimerThread dd ?
  end if
endg



if used TimerCreate

initialize InitWin32Timers
begin
        invoke  SetTimer, 0, 0, __sys_time_slice, __TimerProc
        mov     [__InternalTimerID], eax

        return
endp



finalize FreeWin32Timers
begin
; stop the timer
        invoke  KillTimer, 0, [__InternalTimerID]
        return
endp

end if


; This procedure is called by the system on every time quantum.
; this procedure is Win32 TimerProc

proc __TimerProc, .hwnd, .msg, .timerID, .time
begin
        lea     eax, [__ptrFirstTimer]

.loop:
        mov     eax, [eax+TTimer.next]
.loop2:
        test    eax, eax
        jz      .end_timers

        test    [eax+TTimer.flags], tmfRunning
        jz      .loop

        mov     ecx, [eax+TTimer.value]
        add     ecx, __sys_time_slice
        mov     [eax+TTimer.value], ecx

        cmp     ecx, [eax+TTimer.interval]
        jl      .loop

.exploop:
        inc     [eax+TTimer.Expired]

        mov     ecx, [eax+TTimer.interval]
        sub     [eax+TTimer.value], ecx
        cmp     [eax+TTimer.value], ecx
        jge     .exploop

        cmp     [eax+TTimer.Callback], 0
        je      .end_event

        mov     ecx, [eax+TTimer.flags]
        and     ecx, $0f
        cmp     ecx, tmfDoNothing
        je      .end_event

; call the callback procedure.
.execloop:
        pushad
        stdcall [eax+TTimer.Callback], eax
        popad

        sub     [eax+TTimer.Expired], 1
        jg      .execloop

.end_event:
        test    [eax+TTimer.flags], tmfSyncDestroy
        jz      .loop

        push    eax
        mov     eax, [eax+TTimer.next]  ; after the destruction, this pointer will be lost.
        stdcall TimerDestroy ; pointer from the stack.
        jmp     .loop2

.end_timers:
        return
endp






proc GetSysTime
.time dq ?
begin
        pushad

        lea     eax, [.time]
        invoke  GetSystemTimeAsFileTime, eax


        popad
        return
endp



__filetimeOffset = $19DB1DED53E8000


proc FileTimeToUnixTime
begin
        push    ebx ecx

        sub     eax, __filetimeOffset and $ffffffff
        sbb     edx, __filetimeOffset shr 32

        mov     ebx, eax
        mov     ecx, 10000000   ; 100 ns -> s

        mov     eax, edx
        cdq
        idiv    ecx

        xchg    eax, ebx

        idiv    ecx
        mov     edx, ebx

        pop     ecx ebx
        return
endp



proc GetTime
.time dq ?
begin
        push    ecx

        lea     eax, [.time]
        invoke  GetSystemTimeAsFileTime, eax

        mov     eax, dword [.time]
        mov     edx, dword [.time+4]

        call    FileTimeToUnixTime

        pop     ecx
        return
endp



proc GetLocalTimeOffset
.info TIME_ZONE_INFORMATION
begin
        push    ecx edx

        lea     eax, [.info]
        invoke  GetTimeZoneInformation, eax
        mov     ecx, [.info.bias]

        cmp     eax, TIME_ZONE_ID_DAYLIGHT
        jne     @f
        add     ecx, [.info.DaylightBias]
@@:

        cmp     eax, TIME_ZONE_ID_STANDARD
        jne     @f
        add     ecx, [.info.StandardBias]
@@:

        imul    ecx, 60
        neg     ecx

        mov     eax, ecx
        pop     edx ecx
        return
endp
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































Deleted freshlib/system/all.asm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: System amalgamation include file. Includes all system libraries of FreshLib
;
;  Target OS: Any
;_________________________________________________________________________________________


include 'process.asm'
include 'memory.asm'
include 'files.asm'
include 'clipboard.asm'
include 'environment.asm'
include 'timers.asm'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































Deleted freshlib/system/clipboard.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Clipboard functions for inter-program communications.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: This file contains the OS independent part of the library and includes the
;         respective OS dependent file.
;_________________________________________________________________________________________

module "Clipboard library"


include '%TargetOS%/clipboard.asm'










endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































Deleted freshlib/system/environment.asm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: OS environment functions.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: This file contains the OS independent part of the library and includes the
;         respective OS dependent file.
;_________________________________________________________________________________________

module "Environment library"


include '%TargetOS%/environment.asm'


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































Deleted freshlib/system/files.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Files manipulation library.
;
;  Target OS: Any
;
;  Dependencies: Uses memory.asm for memory allocations.
;
;  Notes: This file contains OS independent part of the library and also include
;         the respective OS dependent part.
;_________________________________________________________________________________________
module "Files library"

struct TFileInfo
  .timeCreated   dq ?
  .timeAccessed  dq ?
  .timeModified  dq ?
ends

iglobal
__std_handle_in:
  var STDIN  = 0
__std_handle_out:
  var STDOUT = 1
__std_handle_err:
  var STDERR = 2
endg

;--------------------------------------------------------------------
; Allocates needed memory and loads the entire file in this memory.
; Returns pointer to memory block or NULL if there is error.
; Returns size in ecx
;--------------------------------------------------------------------
proc LoadBinaryFile, .ptrFileName
begin
        push    esi edi ebx

        stdcall FileOpen, [.ptrFileName]
        jc      .error

        mov     edi, eax

        stdcall FileSize, edi
        jc      .errorclose

        mov     ebx, eax
        lea     ecx, [eax+8]    ; It is for the case that the file is
                                ; text and we want to use it as null terminated
                                ; string.

        stdcall GetMem, ecx
        jc      .errorclose
        mov     esi, eax

        stdcall FileRead, edi, esi, ebx
        jc      .errorclosemem

        mov     ecx, eax

        stdcall FileClose, edi

        mov     eax, esi
        clc
        pop     ebx edi esi
        return


.errorclosemem:
        stdcall FreeMem, esi

.errorclose:
        push    eax
        stdcall FileClose, edi
        pop     eax

.error:
        xor     ecx, ecx
        stc
        pop     ebx edi esi
        return
endp



;--------------------------------------------------------------------
; Saves to the file [size] bytes from given [ptr] address.
; returns CF=1 if error and CF=0 if OK.
;--------------------------------------------------------------------
proc SaveBinaryFile, .ptrFileName, .aptr, .size
begin
        push    edi

        stdcall FileCreate, [.ptrFileName]
        jc      .error

        mov     edi, eax
        stdcall FileWrite, edi, [.aptr], [.size]
        jc      .errorclose

        push    eax
        stdcall FileClose, edi
        pop     eax

        clc
        pop     edi
        return

.errorclose:
        push    eax
        stdcall FileClose, edi
        pop     eax

.error:
        stc
        pop     edi
        return
endp


; reads a line from the text file and positions the file pointer to the begining of
; the next line.
; returns string handle with the line in EAX
; returns CF=1 and EAX=error code on error.

proc FileReadLine, .hfile
.result dd ?
.buffer rb 1028
begin
        pushad

        stdcall StrNew
        mov     [.result], eax

.read_loop:
        lea     esi, [.buffer]
        stdcall FileRead, [.hfile], esi, 1024
        jc      .error_read
        test    eax, eax
        jz      .end_of_file

        mov     ebx, eax
        mov     dword [esi+ebx], 0

        cmp     word [esi], $bbef
        jne     .proceed
        cmp     byte [esi+2], $bf
        jne     .proceed

        add     esi, 3

.proceed:
        mov     edi, esi        ; start of the line

.char_loop:
        mov     al, [esi]
        lea     esi, [esi+1]

        cmp     al, $0d
        je      .found
        cmp     al, $0a
        je      .found
        test    al, al
        jnz     .char_loop

.found:
        mov     byte [esi-1], 0
        stdcall StrCat, [.result], edi

        test    al, al
        jnz     .end_of_line
        cmp     ebx, 1024
        je      .read_loop
        jmp     .file_ok

.end_of_line:
        xor     al, $0d xor $0a
        cmp     byte [esi], al
        jne     .eol_ok
        inc     esi
.eol_ok:
        lea     eax, [.buffer]
        sub     esi, eax
        sub     esi, ebx
        jz      .file_ok

        stdcall FileSeek, [.hfile], esi, fsFromCurrent

.file_ok:
        popad
        mov     eax, [.result]
        clc
        return

.error_read:
        stdcall StrDel, [.result]
        stc
        popad
        return

.end_of_file:
        stdcall StrLen, [.result]
        test    eax, eax
        jnz     .file_ok

        stdcall StrDel, [.result]
        popad
        xor     eax, eax
        clc
        return

endp



proc FileWriteString, .file, .hString
begin
        push    ecx

        stdcall StrLen, [.hString]
        mov     ecx, eax
        stdcall StrPtr, [.hString]
        stdcall FileWrite, [.file], eax, ecx

        pop     ecx
        return
endp




; Returns:
; CF=1 if the file NOT EXISTS
; CF=0 if the file EXISTS

proc FileExists, .ptrFileName
begin
        push    eax

        push    [.ptrFileName]
        stdcall FileOpen
        jc      .exit
        stdcall FileClose, eax
        clc
.exit:
        pop     eax
        return
endp




; This structure contains one directory item information.
;

struct TDirItem
  .hFilename dd ?       ; handle of string with the filename.
  .Type      dd ?       ; type of the file. Value of type ftXXXXXX (defined in the OS depending library).
ends



proc FreeDirArray, .pDirArray
begin
        push    eax ecx

        mov     eax, [.pDirArray]
        mov     ecx, [eax+TArray.count]

.freelist:
        dec     ecx
        js      .exit

        stdcall StrDel, [eax+TArray.array+sizeof.TDirItem*ecx+TDirItem.hFilename]
        jmp     .freelist
.exit:
        stdcall FreeMem, eax
        pop     ecx eax
        return
endp



fdsByName = 1
fdsByType = 2

fdsDescending = $80

proc SortDirArray, .pDirArray, .HowToSort
begin
        push    ebx ecx esi

        mov     esi, [.pDirArray]
        xor     ecx, ecx
.outer:

        mov     ebx, ecx
.inner:
        inc     ebx
        cmp     ebx, [esi+TArray.count]
        jae     .next_outer

        test    [.HowToSort], fdsByType
        jz      .by_name

        mov     eax, [esi+TArray.array+8*ecx+TDirItem.Type]
        cmp     eax, [esi+TArray.array+8*ebx+TDirItem.Type]
        ja      .swap
        jb      .inner

.by_name:
        test    [.HowToSort], fdsByName
        jz      .inner

        stdcall StrCompSort, [esi+TArray.array+8*ecx+TDirItem.hFilename], [esi+TArray.array+8*ebx+TDirItem.hFilename]
        test    [.HowToSort], fdsDescending
        jnz     @f
        neg     eax
@@:
        test    eax, eax
        jns     .inner

.swap:
        push    [esi+TArray.array+8*ecx+TDirItem.hFilename]
        push    [esi+TArray.array+8*ecx+TDirItem.Type]

        push    [esi+TArray.array+8*ebx+TDirItem.hFilename]
        push    [esi+TArray.array+8*ebx+TDirItem.Type]

        pop     [esi+TArray.array+8*ecx+TDirItem.Type]
        pop     [esi+TArray.array+8*ecx+TDirItem.hFilename]

        pop     [esi+TArray.array+8*ebx+TDirItem.Type]
        pop     [esi+TArray.array+8*ebx+TDirItem.hFilename]
        jmp     .inner

.next_outer:
        inc     ecx
        mov     eax, [esi+TArray.count]
        dec     eax
        cmp     ecx, eax
        jb      .outer

        pop     esi ecx ebx
        return

endp


include '%TargetOS%/files.asm'

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/system/memory.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Dynamic memory management library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: This file contains the OS independent part of the library and includes the
;         respective OS dependent file.
;_________________________________________________________________________________________

module "Memory library"

DebugMemory = 0
cInitialCapacity = 10


include '%TargetOS%/memory.asm'


  ;___________________________________________________________________________
  ;
  ; This is a pointer to the active resize strategy procedure.
  ; There can be many different strategies for resizing dynamic memory objects.
  ; ResizeIt points to a procedure that resizes ecx, according to the particular
  ; strategy.
  ; The resize procedure returns CF=1 if the resize can not be provided.
  ;____________________________________________________________________________
  if used ResizeIt
    ResizeIt dd StrategyGentle
  end if

uglobal
  var _MemoryFreeSpace=?
endg

;____________________________
;
; NewSize = (OldSize+1)*2
; Very aggressive strategy.
;____________________________

proc StrategyAgressive
begin
        add     ecx, 1
        jc      @f
        shl     ecx, 1
@@:
        return
endp



;____________________________
;
; NewSize = (OldSize+2)*1.5
; Normal strategy.
;____________________________

proc StrategyMedium
begin
        push    ecx
        add     ecx, 1
        jc      .exit
        shr     ecx, 1
        add     [esp], ecx
        pop     ecx

        cmp     ecx, cInitialCapacity
        jae     .exit
        mov     ecx, cInitialCapacity
        clc
.exit:
        return
endp


;____________________________
;
; NewSize = (OldSize+2)*1.25
; Memory spare strategy.
;____________________________

proc StrategyGentle
begin
        push    ecx
        add     ecx, 1
        jc      .exit
        shr     ecx, 2
        add     [esp], ecx
        pop     ecx

        cmp     ecx, cInitialCapacity
        jae     .exit
        mov     ecx, cInitialCapacity
        clc
.exit:
        return
endp


endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































Deleted freshlib/system/process.asm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Process management library.
;
;  Target OS: Any
;
;  Dependencies:
;
;  Notes: Includes the proper OS dependent part of the library.
;_________________________________________________________________________________________
module "Process library"

include '%TargetOS%/process.asm'

endmodule
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































Deleted freshlib/system/timers.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Asynchronous timer library.
;
;  Target OS: Any
;
;  Dependencies: memory.asm
;
;  Notes: This is OS independent part. Includes OS dependent part files as well.
;_________________________________________________________________________________________
module "Timers library"

tmfDoNothing  = 0       ; when the timer expires no action should be performed. .Expired field of the timer will be incremented.
tmfCallProc   = 1       ; [.callback] contains pointer to procedure that to be executed once per timer expiration.

tmfSyncDestroy = $10    ; If this flag is set, the timer will be destroyed on the next timer expiration. In this case, the configured event is fired and then the timer is destroyed.
                        ; The flag is checked after the event returns, so the event handler can reset this flag and thus to prevent destruction.

tmfRunning     = $80    ; If this flag is set, the timer runs. If the event handler resets this flag, the timer will fire only once and will be suspended.



struct TTimer
; internal pointers of the linked list. The field .next MUST have offset = 0
  .next dd ?            ; don't touch this

; timers parameters.
  .interval dd ?        ; in ms
  .value    dd ?        ; current value in ms. When this value becomes higher than [.interval] an event is fired and the value becomes 0.
                        ; the value is incremented by the system dependent time - probably something like 1..100ms

  .flags    dd ?        ; set of tmfXXXX values.
  .Callback dd ?        ; callback - proc Timer, .ptrTimer; TWindow or 0
  .Expired  dd ?        ; count of the timer expirations.
  .tag      dd ?        ; user value associated with the timer.
ends


struct TDateTime
  .date    dd ?         ; [1..31] depending on month
  .month   dd ?         ; [1..12]
  .year    dd ?         ;
  .hour    dd ?         ; [0..23]
  .minute  dd ?         ; [0..59]
  .second  dd ?         ; [0..59]
  .day     dd ?         ; [0..6] == [monday..sanday]
ends



uglobal
  if used __ptrFirstTimer
    __ptrFirstTimer dd ?
  end if
endg



; Creates a timer and returns pointer to TTimer structure.
; the timer is created suspended. The user can set or reset tmfRunning in [.flags] in order to start or stop the timer.
; also, the user have to enter proper values in the remaining fields.
proc TimerCreate
begin
        push    ecx

        stdcall GetMem, sizeof.TTimer
        jc      .finish

        mov     ecx, [__ptrFirstTimer]
        mov     [eax+TTimer.next], ecx
        mov     [__ptrFirstTimer], eax
        clc

.finish:
        pop     ecx
        return
endp





proc TimerDestroy, .ptrTimer
begin
        push    eax ecx

        mov     eax, [__ptrFirstTimer]
        mov     ecx, __ptrFirstTimer

        test    eax, eax
        jz      .finish                 ; if the list is empty - returns no error.

.loop:
        cmp     eax, [.ptrTimer]
        je      .found

        mov     ecx, eax
        mov     eax, [eax+TTimer.next]
        test    eax, eax
        jnz     .loop

;not found
        pop     ecx eax
        stc
        return

.found:
        push    [eax+TTimer.next]
        pop     [ecx+TTimer.next]       ; if this is the first timer, ecx == __ptrFirstTimer

        stdcall FreeMem, eax

.finish:
        pop     ecx eax
        clc
        return
endp



SECONDS_PER_DAY = 24*60*60
YEAR_EPOCH_START     = 1970


proc TimeToDateTime, .pTime, .pDateTime
.days   dd ?
begin
        pushad

        mov     edi, [.pDateTime]
        mov     esi, [.pTime]

        mov     eax, [esi+4]
        cdq

        mov     ecx, SECONDS_PER_DAY

        idiv    ecx

        mov     eax, [esi]

        idiv    ecx

        test    edx, edx
        jns     @f
        add     edx, SECONDS_PER_DAY
        sub     eax, 1
@@:
        mov     [.days], eax  ; dword [esi] := time div SECONDS_PER_DAY

        mov     eax, edx
        mov     ecx, 60
        cdq                    ; the time should be positive here...

        idiv    ecx
        mov     [edi+TDateTime.second], edx

        cdq
        idiv    ecx
        mov     [edi+TDateTime.minute], edx
        mov     [edi+TDateTime.hour], eax

; date processing. I will assume it is 32bit
; some time in the future, it will overflow (around the 5000000 year), so it will needs a fix. ;)

        mov     edx, [.days]    ; days after YEAR_EPOCH_START
        xor     ebx, ebx        ; years after YEAR_EPOCH_START

.year_loop:
        test    edx, edx
        jns     .positive
; negative days

        dec     ebx
        lea     eax, [ebx+YEAR_EPOCH_START]
        stdcall DaysPerYear, eax
        add     edx, eax
        jmp     .year_loop

.positive:
        lea     eax, [ebx+YEAR_EPOCH_START]
        stdcall DaysPerYear, eax

        cmp     edx, eax
        jb      .finish_year

        sub     edx, eax
        inc     ebx
        jmp     .year_loop

.finish_year:
        add     ebx, YEAR_EPOCH_START
        mov     [edi+TDateTime.year], ebx

; edx contains the days since the current year. It is positive here.
        xor     ebx, ebx

.months_loop:
        stdcall DaysPerMonth, ebx, [edi+TDateTime.year]
        cmp     edx, eax
        jb      .month_ok

        sub     edx, eax
        inc     ebx
        jmp     .months_loop

.month_ok:
        inc     edx
        inc     ebx
        mov     [edi+TDateTime.date], edx
        mov     [edi+TDateTime.month], ebx

; day of the week.

        mov     eax, [.days]      ; days after YEAR_EPOCH_START
        add     eax, 3  ; it was Thursday on 1.1.1970
        cdq
        mov     ecx, 7
        idiv    ecx
        mov     [edi+TDateTime.day], edx

        popad
        return
endp


; redurns the days in the given month or CF=1 on invalid month.
; month should be in [0..11] range.

proc DaysPerMonth, .month, .year
begin
        push    ecx

        mov     ecx, [.month]
        cmp     ecx, 11
        ja      .error

        movzx   ecx, byte [.month_list+ecx]
        cmp     ecx, 28
        jne     .finish

        stdcall DaysPerYear, [.year]
        cmp     eax, 365
        je      .finish

        inc     ecx

.finish:
        mov     eax, ecx
        clc
        pop     ecx
        return

.error:
        xor     eax, eax
        stc
        pop     ecx
        return

.month_list db 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
endp


proc DaysPerYear, .year
begin
        push    ebx ecx edx

        mov     eax, [.year]
        mov     ecx, 400
        cdq
        idiv    ecx

        test    edx, edx
        jz      .leap

        mov     eax, edx
        mov     ecx, 100
        cdq
        idiv    ecx
        test    edx, edx
        jz      .not_leap

        test    edx, $03
        jz      .leap

.not_leap:
        mov     eax, 365
        pop     edx ecx ebx
        return

.leap:
        mov     eax, 366
        pop     edx ecx ebx
        return
endp




include '%TargetOS%/timers.asm'


endmodule



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































































































































































































































































































































































































































































Deleted freshlib/test_code/FreshLibUse.fpr.

cannot compute difference between binary files

Deleted freshlib/test_code/main.asm.

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
include '%lib%/freshlib.inc'

_BinaryType console

include '%lib%/freshlib.asm'

start:
        InitializeAll

uglobal
ttime dq ?

file_info TFileInfo
endg

.loop:
        stdcall GetTime

        stdcall NumToStr, eax, ntsDec or ntsSigned
        stdcall StrCharCat, eax, $0a

        push    eax eax

        stdcall StrLen, eax
        mov     ecx, eax

        stdcall StrPtr ; from the stack

        stdcall FileWrite, [STDOUT], eax, ecx
        stdcall StrDel ; from the stack

        stdcall FileOpen, filename
        mov     ebx, eax

        stdcall GetFileInfo, ebx, file_info
        jc      .show_error

        mov     eax, dword [file_info.timeModified]

.show_error:
        stdcall NumToStr, eax, ntsDec or ntsSigned
        stdcall StrCharCat, eax, $0a0a

        push    eax eax

        stdcall StrLen, eax
        mov     ecx, eax

        stdcall StrPtr ; from the stack

        stdcall FileWrite, [STDOUT], eax, ecx
        stdcall StrDel ; from the stack

        stdcall FileClose, ebx

        stdcall Sleep, 1000
        jmp     .loop

        FinalizeAll
        stdcall Terminate, 0

filename text 'eve.asm'

uglobal
  buffer rb 1000
endg


_AllImportEmbeded


_AllDataEmbeded
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































Deleted freshlib/test_code0/TestGround.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;   Description: Very simple test application for FreshLib.
;                The content may change arbitrary.
;
;   Target OS: All/Linux/Win32 - depending on current test needs.
;
;   Dependencies:
;
;   Notes: The main test program calls "PrepareDemo" procedure.
;_________________________________________________________________________________________

__TestGround:

; Global data...
iglobal

__TestData:

frmMainForm:
        ObjTemplate  tfParent or tfEnd, Form, frmMain, \
                     x, 300,        \
                     y, 250,        \
                     width, 360,    \
                     height, 240,   \
                     Visible, TRUE, \
                     Caption, 'FreshLib minimal application test.'
           ObjTemplate tfChild, TreeView, tvTestTree, x, 200, y, 8, width, 150, height, 224, Visible, TRUE, Align, waRight
           ObjTemplate tfChild or tfEnd, Button, btnOpenModal, x, 50, y, 50, width, 120, height, 75, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle or dtfWordWrap , Caption, 'Click to check your assembly skills.', OnClick, OpenModalForm


__TestDataSize = $ - __TestData
endg




proc PrepareDemo
begin
        stdcall CreateFromTemplate, frmMainForm, 0
        mov     ecx, [pApplication]
        mov     [ecx+TApplication.MainWindow], frmMain

        return
endp


proc OpenModalForm, .self, .button
begin
        push    ebx

        stdcall ShowMessage, [frmMain], smiQuestion, .msgTitle, .msgTest, smbYes or smbNo or smbMaybe ; or smbAbort or smbRetry or smbIgnore or smbYes or smbNo or smbHelp

        mov     esi, .msgYes
        mov     ecx, smiInformation
        cmp     eax, mrYes
        je      .finish

        mov     esi, .msgNo
        mov     ecx, smiError
        cmp     eax, mrNo
        je      .finish

        mov     esi, .msgMaybe
        mov     ecx, smiQuestion
        cmp     eax, mrMaybe
        je      .finish

        mov     esi, .msgRefuse
        mov     ecx, smiWarning
.finish:
        stdcall ShowMessage, [frmMain], ecx, .msgTitle2, esi, smbOK
        pop     ebx
        return

.msgTest   db 'Are you agree, that FlatAssembler is the best assembler world-wide?', 0
.msgYes    db 'You really understand the spirit of the assembly! Congratulations!', 0
.msgNo     db "So, go write some C# and don't mess with assembly. It is not for you.", 0
.msgMaybe  db "You should forget about your doubts and reject these HLL temptations, or your soul will be lost forever! Go, write some assembly and feel the power!", 0
.msgRefuse db "It is wrong to avoid to answer, only because you are not sure...", 0
.msgTitle  db 'One question test:', 0
.msgTitle2 db 'Test results', 0
endp




proc SetModalResult, .self, .button
begin
        push    eax
        stdcall Get, [.self], TWindow.Parent
        mov     [eax+TForm.ModalResult], mrOK
        pop     eax
        return
endp


DispSize 'Test ground dummy code:', ($-__TestGround)+__TestDataSize
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































































































































Deleted freshlib/test_code0/TestGroundComplex.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;   Description: Complex test application for FreshLib the content may change arbitrary.
;
;   Target OS: All/Linux/Win32 - depending on current test needs.
;
;   Dependencies:
;
;   Notes: The main test program calls "PrepareDemo" procedure.
;_________________________________________________________________________________________

__TestGround:

iglobal

__TestData:
; This is a form template.
; It will be created by the visual editor.
; This template engine can contains any count of properties for every
; component of the template. Also it can contains non visual components
; such as action lists, image lists, etc.

TemplateMainForm:
        ObjTemplate  tfParent or tfEnd, Form, frmMain, \
                     x, 100,        \
                     y, 50,         \
                     width, 656,    \
                     height, 496,   \
                     Visible, TRUE, \
                     OnDestroy, FormOnDestroy,  \
                     Caption, 'Fresh portable Win32/Linux application test.'

          ObjTemplate  tfChild, Button, btnChild1,          \
                     x, 48,         \
                     y, 48,         \
                     width, 80,     \
                     height, 48,    \
                     TextAlign, dtfAlignLeft or dtfAlignMiddle or dtfCRLF or dtfWordWrap,\
                     Caption, 'Button1',        \
                     Visible, TRUE, \
                     OnClick, Button1Click

          ObjTemplate  tfChild, Button, btnChild3,          \
                     x, 48,         \
                     y, 112,         \
                     width, 80,     \
                     height, 48,    \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle or dtfWordWrap,\
                     Caption, 'Stop/Start timer1',        \
                     Visible, TRUE, \
                     OnClick, Button3Click

          ObjTemplate  tfChild, Button, btnChild4,          \
                     x, 48,         \
                     y, 162,         \
                     width, 80,     \
                     height, 48,    \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle or dtfWordWrap,\
                     Caption, 'Stop/Start timer2',        \
                     Visible, TRUE, \
                     OnClick, Button4Click

          ObjTemplate  tfChild, Edit, editChild1,          \
                     x, 48,         \
                     y, 8,         \
                     width, 294,     \
                     height, 21,    \
                     Caption, 'Edit1',        \
                     Visible, TRUE, \
                     Text, utf8_string

         ObjTemplate tfChild, Progress, Progress1,      \
                     x, 48, y, 262,                      \
                     width, 294, height, 21,              \
                     Color, $000080,                      \
                     Max, 1000, Pos, 350,                  \
                     Align, waBottom,                      \
                     Visible, TRUE

         ObjTemplate  tfChild or tfEnd, Button, btnChild2,          \
                     x, 140,         \
                     y, 48,         \
                     width, 202,     \
                     height, 202,        \
                     TextAlign, dtfAlignJustify or dtfAlignMiddle or dtfCRLF or dtfWordWrap,\
                     Caption, utf8_long,       \
                     Visible, TRUE,  \
                     OnClick, Button2Click


include "UTF8_examples.asm"


  cGifIcon file '_test_images/icon.gif'
  sizeof.cGifIcon = $ - cGifIcon


; example of menu structure - it is typical File menu.
; It should be created with CreateFromTemplate procedure.
; If can be child of some form as well and then it should
; appears as a main menu in the form.

;menuFile:
;    ObjTemplate tfParent or tfEnd, Menu, .PopupMenu1,        \
;                  caption, 'File'
;      ObjTemplate tfChild, MenuItem, .menuItemNew,  \
;                  kind, mikCommand,             \
;                  pAction, FileActions.actFileNew
;      ObjTemplate tfChild, MenuItem, .menuItemOpen,  \
;                  kind, mikCommand,      \
;                  pAction, FileActions.actFileOpen
;      ObjTemplate tfChild or tfParent, Menu, .menuReopen, \
;                  caption, 'Reopen'
;
;            ObjTemplate tfChild, MenuItem, .menuItemCleanup,     \
;                        kind, mikCommand,                         \
;                        pAction, FileActions.actReopenMenuCleanup
;
;            ObjTemplate tfChild or tfEnd, MenuItem, .menuSep1,   \
;                        kind, mikSeparator
;      ObjTemplate tfChild, MenuItem, .menuSep2,      \
;                  kind, mikSeparator
;      ObjTemplate tfChild, MenuItem, .menuItemSave,  \
;                  kind, mikCommand,                 \
;                  pAction, FileActions.actSave
;      ObjTemplate tfChild, MenuItem, .menuItemSaveAs,  \
;                  kind, mikCommand,                 \
;                  pAction, FileActions.actSaveAs
;      ObjTemplate tfChild, MenuItem, .menuItemSaveAll,  \
;                  kind, mikCommand,                 \
;                  pAction, FileActions.actSaveAll
;      ObjTemplate tfChild, MenuItem, .separator2,      \
;                  kind, mikSeparator
;      ObjTemplate tfChild or tfEnd, MenuItem, .menuItemExit,  \
;                  kind, mikCommand,                 \
;                  pAction, FileActions.actExit
;
; just for test

;ActionList FileActions,                                                     \
;  .actFileNew, '&New', 'Creates new file', 0, <Ctrl, 'N'>, NONE, NONE,      \
;  .actFileOpen, '&Open', 'Open file from disk', 0, <Ctrl, 'O'>, NONE, NONE, \
;  .actReopenMenuCleanup, 'Cleanup list', 'Cleans the reopen list.', 0, NONE, NONE, NONE, \
;  .actSave, '&Save', 'Save current file', 0, <Ctrl, 'S'>, NONE, NONE, \
;  .actSaveAs, 'Sa&ve as', 'Save current file with new name.', 0, <Ctrl+Alt, 'S'>, NONE, NONE, \
;  .actSaveAll, 'Save &All', 'Save all changed files.', 0, <Ctrl+Shift, 'S'>, NONE, NONE, \
;  .actExit, 'E&xit', 'Exit application', 0, <Alt, 'X'>, NONE, NONE


__TestDataSize = $ - __TestData

endg





; Sample event handlers. They work with other objects on the form.

proc FormOnDestroy, .self
begin
        DebugMsg "MainForm destroy event handler."
        stdcall TimerDestroy, [test_timer1]
        stdcall TimerDestroy, [test_timer2]
        return
endp


proc Button4Click, .self, .button
begin
        mov     ecx, [test_timer2]
        xor     [ecx+TTimer.flags], tmfRunning

        stdcall Set, [Progress1], TProgress.Pos, 0

        DebugMsg 'Button4 clicked'
        return
endp



proc Button3Click, .self, .button
begin
        mov     eax, [test_timer1]
        xor     [eax+TTimer.flags], tmfRunning

        DebugMsg 'Button3 clicked'
        return

        mov     ebx, [frmMain]

        stdcall Get, ebx, TWindow.x
        push    eax
        stdcall Get, ebx, TWindow.y
        push    eax

        stdcall Get, ebx, TWindow.borderKind
        xor     eax, 1
        stdcall Set, ebx, TWindow.borderKind, eax
        stdcall Set, [.self], TWindow.Caption, [_dual_caption+4*eax]

iglobal
  _dual_caption dd _cCaption1, _cCaption2

  _cCaption1 text 'Remove the title'
  _cCaption2 text 'Restore the title'
endg

; The old coordinates must be restored, because the window manager moves the window
; when restoring the title bar.
        stdcall Set, ebx, TWindow.y ; from the stack
        stdcall Set, ebx, TWindow.x ; from the stack

        return
endp




proc Button1Click, .self, .button
begin
        DebugMsg 'Button1 clicked'

        stdcall Get, [btnChild2], TButton.TextAlign
        mov     ecx, eax
        and     ecx, not $03
        inc     eax
        and     eax, 3
        or      eax, ecx
        stdcall Set, [btnChild2], TButton.TextAlign, eax

        stdcall Get, [btnChild1], TButton.Caption
        stdcall Set, [editChild1], TEdit.Text, eax
        stdcall StrDel, eax

iglobal
  cGifFile file '_test_images/test.gif'
  sizeof.cGifFile = $ - cGifFile
endg

        stdcall CreateImageGIF, cGifFile, sizeof.cGifFile
        mov     esi, eax

        mov     eax, [frmMain]
        stdcall AllocateContext, [eax+TWindow.handle]
        jc      .end
        push    eax
        stdcall SetDrawMode, eax, cmCopy
        stdcall DrawImage, eax, esi, 394, 0
        stdcall ReleaseContext ; from the stack

.end:
        stdcall DestroyImage, esi
        return
endp



proc Button2Click, .self, .button
begin
       DebugMsg 'Button2 clicked'

        stdcall Get, [btnChild1], TButton.IconPosition
        inc     eax
        and     eax, 3
        stdcall Set, [btnChild1], TButton.IconPosition, eax

        mov     eax, [_text_align_for_icon+4*eax]
        stdcall Set, [btnChild1], TButton.TextAlign, eax

iglobal
  _text_align_for_icon dd dtfAlignLeft or dtfAlignMiddle
                       dd dtfAlignRight or dtfAlignMiddle
                       dd dtfAlignCenter or dtfAlignTop
                       dd dtfAlignCenter or dtfAlignBottom
endg

        stdcall Get, [btnChild2], TButton.Caption
        stdcall Set, [editChild1], TEdit.Text, eax
        stdcall StrDel, eax

        return
endp



uglobal
  test_timer1 dd ?
  test_timer2 dd ?
endg



proc procTestTimer1, .ptrTimer
begin
        stdcall Get, [btnChild1], TButton.IconPosition
        and     eax, 3
        mov     eax, [__align4+4*eax]
        stdcall Set, [btnChild1], TButton.IconPosition, eax

        mov     eax, [_text_align_for_icon+4*eax]
        stdcall Set, [btnChild1], TButton.TextAlign, eax
        return
endp

iglobal
  __align4 dd AlignTop, AlignBottom, AlignRight, AlignLeft
endg

uglobal
  Flag dd ?
  .Y dd ?
  .X dd ?
  .incX dd ?
  .incY dd ?
endg




proc procTestTimer2, .ptrTimer
.width dd ?
.height dd ?
begin

        execute [Progress1], TProgress.Step
;        stdcall Get, [Progress1], TProgress.Pos
;        mov     ecx, eax
;        stdcall Get, [Progress1], TProgress.Max
;
;        inc     ecx
;        cmp     ecx, eax
;        jle     @f
;        xor     ecx, ecx
;@@:
;        stdcall Set, [Progress1], TProgress.Pos, ecx

;        DebugMsg "Timer2 enter"

        mov     eax, [frmMain]
        stdcall AllocateContext, [eax+TWindow.handle]
        jc      .exit
        mov     ebx, eax

        stdcall Get, [frmMain], TWindow.width
        sub     eax, 16
        mov     [.width], eax
        stdcall Get, [frmMain], TWindow.height
        sub     eax, 16
        mov     [.height], eax

        stdcall DrawFillRect, ebx, [Flag.X], [Flag.Y], 16, 16, $ff0000  ;c0c0c0

        mov     eax, [Flag.X]
        add     eax, [Flag.incX]
        js      .backx
        cmp     eax, [.width]
        jg      .backx

        mov     [Flag.X], eax
        jmp     .xok

.backx:
        neg     [Flag.incX]

.xok:
        mov     eax, [Flag.Y]
        add     eax, [Flag.incY]
        js      .backy
        cmp     eax, [.height]
        jg      .backy

        mov     [Flag.Y], eax
        jmp     .yok

.backy:
        neg     [Flag.incY]
.yok:
        stdcall SetDrawMode, ebx, cmCopy
        stdcall DrawImage, ebx, [Flag], [Flag.X], [Flag.Y]

        stdcall ReleaseContext, ebx

;        DebugMsg "Timer2 exit"
.exit:
        return
endp






proc PrepareDemo
begin
;        stdcall CaretAttach, 0

        stdcall CreateFromTemplate, TemplateMainForm, 0
        mov     ecx, [pApplication]
        mov     [ecx+TApplication.MainWindow], frmMain

        stdcall CreateImageGIF, cGifIcon, sizeof.cGifIcon
        stdcall Set, [btnChild1], TButton.Icon, eax
        stdcall Set, [btnChild1], TButton.IconPosition, AlignLeft

; the timers must be created before application start.
; I don't know why.
; Maybe it is safe to create timers in some event handlers... should be checked.
;
        stdcall CreateImageGIF, cGifIcon, sizeof.cGifIcon
        mov     [Flag], eax

        mov     [Flag.X], 120
        mov     [Flag.Y], 0
        mov     [Flag.incX], 1
        mov     [Flag.incY], 1


        stdcall TimerCreate
        mov     [test_timer1], eax
        mov     [eax+TTimer.interval], 100
        mov     [eax+TTimer.Callback], procTestTimer1
        mov     [eax+TTimer.flags], tmfCallProc

        stdcall TimerCreate
        mov     [test_timer2], eax
        mov     [eax+TTimer.interval], 2
        mov     [eax+TTimer.value], 0
        mov     [eax+TTimer.Callback], procTestTimer2
        mov     [eax+TTimer.flags], tmfCallProc

;
;        mov     eax, [test_timer1]
;        or     [eax+TTimer.flags], tmfRunning
;        mov     eax, [test_timer2]
;        or     [eax+TTimer.flags], tmfRunning
        return
endp


DispSize 'Test ground dummy code:', ($-__TestGround)+__TestDataSize
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/test_code0/TestGroundConfig.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568


iglobal
frmMainForm:
; The form
        ObjTemplate  tfParent or tfEnd, Form, frmMain, x, 100, y, 50, width, 640, height, 340, Visible, TRUE, Caption, 'FreshLib uConfig files editor.'

            ; log window
            ObjTemplate tfChild, FreshEdit, editLog, x, 330, y, 0, width, 240, height, 200, Visible, TRUE, Align, waClient, _fReadOnly, froReadOnlyNoCaret

            ObjTemplate  tfParent or tfEnd, Form, frmToolPanel, borderKind, borderNone, Align, waLeft,x ,0, y, 0, width, 200, height, 340, Visible, TRUE

                ; file buttons
                ObjTemplate tfChild, Button, btnNewDB, x, 4,   y, 2, width, 64, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle,  Caption, 'New', OnClick, procOnNewDB
                ObjTemplate tfChild, Button, btnOpenDB, x, 67,  y, 2, width, 64, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'Open', OnClick, procOnOpenDB
                ObjTemplate tfChild, Button, btnSaveDB, x, 130, y, 2, width, 64, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'Save', OnClick, procOnSaveDB

                ; record buttons
                ObjTemplate tfChild, Button, btnReadRecord, x, 4, y, 194, width, 60, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'Read', OnClick, procOnRead
                ObjTemplate tfChild, Button, btnWriteRecord, x, 69, y, 194, width, 60, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'Write', OnClick, procOnWrite
                ObjTemplate tfChild, Button, btnDeleteRecord, x, 134, y, 194, width, 60, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'Delete', OnClick, procOnDelete

                ; type buttons
                ObjTemplate tfChild, Label,  lblDataType,   x, 69, y, 224,  width, 60, height, 60, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'cdtString'
                ObjTemplate tfChild, Button, btnTypeString,  x, 4, y, 224, width,  60, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'String', OnClick, procOnType
                ObjTemplate tfChild, Button, btnTypeInt,     x, 4, y, 244, width,  60, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'Number', OnClick, procOnType
                ObjTemplate tfChild, Button, btnTypeNull,    x, 4, y, 264, width,  60, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'Null', OnClick, procOnType

                ; log buttons
                ObjTemplate tfChild, Button, btnListTree, x, 134, y, 244, width, 60, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'List >>>', OnClick, procOnListTree
                ObjTemplate tfChild, Button, btnClearLog, x, 134, y, 264, width, 60, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'Clear >>>', OnClick, procOnClearLog

                ; edit boxes
                ObjTemplate tfChild, Label, lblFilename,   x, 4, y, 24,  width, 100, height, 19, Visible, TRUE, TextAlign, dtfAlignLeft or dtfAlignBottom, Caption, 'File name:'
                ObjTemplate tfChild, Edit,  editFilename,  x, 4, y, 44,  width, 190, height, 19, Visible, TRUE, Text, 'test_config.udb'

                ObjTemplate tfChild, Label, lblSignature,  x, 4, y, 64,  width, 100, height, 19, Visible, TRUE, TextAlign, dtfAlignLeft or dtfAlignBottom, Caption, 'Signature:'
                ObjTemplate tfChild, Edit,  editSignature, x, 4, y, 84,  width, 190, height, 19, Visible, TRUE

                ObjTemplate tfChild, Label, lblKey,  x, 4, y, 104,  width, 100, height, 19, Visible, TRUE, TextAlign, dtfAlignLeft or dtfAlignBottom, Caption, 'Full key name:'
                ObjTemplate tfChild, Edit,  editKey, x, 4, y, 124,  width, 190, height, 19, Visible, TRUE, Text, 'dir1|dir2|dir3|key'

                ObjTemplate tfChild,          Label, lblValue, x, 4, y, 144,  width, 100, height, 19, Visible, TRUE, TextAlign, dtfAlignLeft or dtfAlignBottom, Caption, 'Value:'
                ObjTemplate tfChild or tfEnd, Edit,  editValue,    x, 4, y, 164,  width, 190, height, 19, Visible, TRUE
endg



proc PrepareDemo
begin
        stdcall CreateFromTemplate, frmMainForm, 0
        mov     ecx, [pApplication]
        mov     [ecx+TApplication.MainWindow], frmMain
        execute [frmMain], TForm.AlignChildren
        return
endp



uglobal
  DataBase dd ?
endg

iglobal
  DataType dd cdtString
endg


proc procOnType, .self, .button
begin
        mov     eax, [.self]
        cmp     eax, [btnTypeString]
        je      .string

        cmp     eax, [btnTypeInt]
        je      .int

        cmp     eax, [btnTypeNull]
        je      .null

        int3

.string:
        mov     [DataType], cdtString
        mov     eax, .txtString
        jmp     .finish

.int:
        mov     [DataType], cdtInteger
        mov     eax, .txtInteger
        jmp     .finish

.null:
        mov     [DataType], cdtNULL
        mov     eax, .txtNull

.finish:
        stdcall Set, [lblDataType], TLabel.Caption, eax
        execute [lblDataType], TLabel.Refresh
        return

.txtString db 'cdtString',0
.txtInteger db 'cdtInteger', 0
.txtNull    db 'cdtNULL', 0
endp


proc procOnClearLog, .self, .button
begin
        execute [editLog], TFreshEdit.Clear
        return
endp


proc procOnListTree, .self, .button
.prolog dd ?
begin
        push    esi

        mov     esi, [DataBase]
        test    esi, esi
        jz      .finish

        execute [editLog], TFreshEdit.Clear

        stdcall StrNew
;        stdcall StrCharCat, eax, $9c94e2
;        stdcall StrCharCat, eax, $8094e2
        stdcall __DoListTree, esi, eax

        execute [editLog], TFreshEdit.Refresh
        stdcall TFreshEdit.__UpdateScrollBars, [editLog]

.finish:
        pop     esi
        return
endp


proc __DoInsChar, .char
begin
        pushad
        execute [editLog], TFreshEdit.InsertChar, [.char]
        popad
        return
endp


proc __DoInsString, .str
begin
        pushad
        execute [editLog], TFreshEdit.InsertString, [.str]
        popad
        return
endp


proc __DoListTree, .array, .prolog
begin
        pushad

        mov     esi, [.array]
        mov     ecx, [esi+TArray.count]
        lea     esi, [esi+TArray.array]

.main_loop:
        test    ecx, ecx
        jz      .finish

        stdcall __DoInsString, [.prolog]

        mov     eax, $9c94e2
        cmp     ecx, 1
        jne     @f
        mov     eax, $9494e2
@@:
        stdcall __DoInsChar, eax
        stdcall __DoInsChar, $8094e2

        mov     ebx, [esi+TConfigRecord.KeyName]

.keynameloop:
        movzx   edx, bl
        stdcall __DoInsChar, edx
        shr     ebx, 8
        jnz     .keynameloop

        cmp     [esi+TConfigRecord.Type], cdtConfig
        je      .next_row

        stdcall __DoInsChar, '='

        cmp     [esi+TConfigRecord.Type], cdtString
        je      .handle_string

        cmp     [esi+TConfigRecord.Type], cdtInteger
        je      .handle_integer

        cmp     [esi+TConfigRecord.Type], cdtNULL
        je      .handle_null

        cmp     [esi+TConfigRecord.Type], cdtBlob
        jne     .next_row
; handle blobs
        stdcall __DoInsString, cBlobValue
        jmp     .next_row

cBlobValue text 'BLOB()'
cNULLValue text 'NULL'

.handle_null:
        stdcall __DoInsString, cNULLValue
        jmp     .next_row

.handle_integer:
        stdcall NumToStr, [esi+TConfigRecord.Data], ntsHex or ntsUnsigned
        push    eax
        stdcall __DoInsChar, '$'
        stdcall __DoInsString, eax
        stdcall StrDel ; from the stack
        jmp     .next_row

.handle_string:
        stdcall __DoInsChar, '"'
        stdcall __DoInsString, [esi+TConfigRecord.Data]
        stdcall __DoInsChar, '"'

.next_row:
        stdcall __DoInsChar, $0d

        cmp     [esi+TConfigRecord.Type], cdtConfig
        jne     .next

        stdcall StrLen, [.prolog]
        push    eax

        mov     eax, $8294e2  ;'|'
        cmp     ecx, 1
        jne     @f
        mov     eax, ' '
@@:
        stdcall StrCharCat, [.prolog], eax
        stdcall StrCharCat, [.prolog], ' '

        stdcall __DoListTree, [esi+TConfigRecord.Data], [.prolog]
        pop     edx

        stdcall StrPtr, [.prolog]
        mov     [eax+string.len], edx
        mov     dword [eax+edx], 0

.next:
        add     esi, sizeof.TConfigRecord
        dec     ecx
        jmp     .main_loop

.finish:
        mov     eax, [editLog]
        push    [eax+TFreshEdit._xCaret] [eax+TFreshEdit._yCaret]
        pop     [eax+TFreshEdit._ySelection] [eax+TFreshEdit._xSelection]
        popad
        return
endp



proc UpdateEdits, .config
.str rd 2
begin
        push    esi
        mov     esi, [.config]

        mov     eax, [esi+TArray.lparam]
        mov     [.str], eax
        mov     [.str+4], 0
        lea     eax, [.str]
        stdcall Set, [editSignature], TEdit.Text, eax

        pop     esi
        return
endp


proc procOnNewDB, .self, .button
begin
        stdcall FreeConfigDB, [DataBase]
        stdcall LoadConfigDB, 0, 'TEST'
        mov     [DataBase], eax

        stdcall UpdateEdits, eax

        stdcall LogMessage, cNewDatabase
        return
endp

cNewDatabase text 'New database created.', 13

proc procOnOpenDB, .self, .button
begin
        stdcall Get, [editFilename], TEdit.Text
        push    eax
        stdcall StrPtr, eax
        stdcall LoadBinaryFile, eax
        jc      .error_file

        mov     esi, eax
        stdcall StrDel ; from the stack

        stdcall FreeConfigDB, [DataBase]
        mov     [DataBase], 0
        stdcall LoadConfigDB, esi, -1
        jnc     .load_ok

        stdcall LogMessage, cErrorLoad

        stdcall FreeMem, esi
        return

.load_ok:
        mov     [DataBase], eax
        stdcall FreeMem, esi
        stdcall UpdateEdits, [DataBase]
        stdcall LogMessage, cLoadedOK
        return

.error_file:
        stdcall LogMessage, cErrorLoadFile
        return
endp

cErrorLoadFile text 'Error loading config database.', 13
cErrorLoad text 'Error parsing config database.', 13
cLoadedOK  text 'Database loaded successfully.', 13

proc LogMessage, .string
begin
        push    eax
        execute [editLog], TFreshEdit.InsertString, [.string]
        mov     eax, [editLog]
        push    [eax+TFreshEdit._xCaret] [eax+TFreshEdit._yCaret]
        pop     [eax+TFreshEdit._ySelection] [eax+TFreshEdit._xSelection]
        execute [editLog], TFreshEdit.Refresh
        stdcall TFreshEdit.__UpdateScrollBars, [editLog]        ; not this
        pop     eax
        return
endp


proc procOnSaveDB, .self, .button
.signature dd ?
begin
        stdcall Get, [editSignature], TEdit.Text
        push    eax
        stdcall StrPtr, eax
        mov     eax, [eax]
        mov     [.signature], eax
        stdcall StrDel ; from the stack

        stdcall Get, [editFilename], TEdit.Text
        mov     ecx, eax
        stdcall StrPtr, ecx
        mov     edx, eax

        stdcall SaveConfigFile, [DataBase], [.signature]
        mov     esi, eax
        lea     eax, [eax+TArray.array]

        mov     ebx, [esi+TArray.count]
        shl     ebx, 2
        stdcall SaveBinaryFile, edx, eax, ebx

        stdcall StrDel, ecx
        stdcall FreeMem, esi

.finish:
        return
endp


; returns edx - array to the directory.
; eax - the key name.

proc __DecodeDirectory, .hstring
begin
        push    ebx ecx esi

        stdcall CreateArray, 4
        mov     edx, eax

        stdcall StrPtr, [.hstring]
        mov     esi, eax

.main_loop:
        mov     ecx, 4
        xor     ebx, ebx

.byteloop:
        lodsb

        cmp     al, '|'
        je      .end_key
        cmp     al, 0
        je      .end_key

        ror     ebx, 8
        mov     bl, al

        loop    .byteloop

.end_key:
        inc     ecx
        shl     ecx, 3
        ror     ebx, cl

        test    al, al
        jz      .finish

        cmp     al, '|'
        je      .nameok

.search:
        lodsb
        test    al, al
        jz      .finish
        cmp     al, '|'
        jne     .search

.nameok:
        stdcall AddArrayItems, edx, 1
        mov     [eax], ebx
        jmp     .main_loop

.finish:
        stdcall AddArrayItems, edx, 1
        mov     dword [eax], 0
        mov     eax, ebx

        pop     esi ecx ebx
        return
endp





proc procOnWrite, .self, .button
begin
        push    eax ebx ecx edx

        cmp     [DataBase], 0
        je      .finish

; value
        stdcall Get, [editValue], TEdit.Text
        mov     ebx, eax

        cmp     [DataType], cdtNULL
        je      .null_handling

        cmp     [DataType], cdtInteger
        je      .int_handling

        cmp     [DataType], cdtString
        jne     .finish

; string handling.
        xor     ecx, ecx
        jmp     .continue

.int_handling:
        stdcall StrToNumEx, ebx
        stdcall StrDel, ebx
        mov     ebx, eax
        mov     ecx, 4
        jmp     .continue

.null_handling:
        stdcall StrDel, ebx
        xor     ebx, ebx
        xor     ecx, ecx

; key
.continue:
        stdcall Get, [editKey], TEdit.Text
        push    eax

        stdcall __DecodeDirectory, eax
        stdcall StrDel ; from the stack

        push    edx
        lea     edx, [edx+TArray.array]
        stdcall SetConfigParam, DataBase, edx, eax, [DataType], ebx, ecx
        stdcall FreeMem ; from the stack

        cmp     [DataType], cdtString
        jne     @f
        stdcall StrDel, ebx
@@:
        stdcall Set, [editValue], TEdit.Text, 0

.finish:
        pop     edx ecx ebx eax
        return
endp


proc procOnRead, .self, .button
begin
        push    eax
        cmp     [DataBase], 0
        je      .finish

; key
        stdcall Get, [editKey], TEdit.Text
        push    eax
        stdcall __DecodeDirectory, eax
        stdcall StrDel ; from the stack

        push    edx
        lea     edx, [edx+TArray.array]
        stdcall GetConfigParam.AsString, [DataBase], edx, eax
        stdcall FreeMem ; from the stack

        test    eax, eax
        jz      .not_found

        push    eax
        stdcall Set, [editValue], TEdit.Text, eax
        stdcall StrDel ; from the stack.

.finish:
        pop     eax
        return

.not_found:
        stdcall Set, [editValue], TEdit.Text, cNotAvailable
        jmp     .finish
endp

cNotAvailable text 'Not available'


proc procOnDelete, .self, .button
begin
        push    eax ebx ecx edx

        cmp     [DataBase], 0
        je      .finish

; key
        stdcall Get, [editKey], TEdit.Text
        push    eax

        stdcall __DecodeDirectory, eax
        stdcall StrDel ; from the stack

        push    edx
        lea     edx, [edx+TArray.array]
        stdcall DelCongigParam, DataBase, edx, eax
        stdcall FreeMem ; from the stack

.finish:
        pop     edx ecx ebx eax
        return
endp



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/test_code0/TestGroundDirFunctions.asm.

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


iglobal
frmMainForm:
; The form
        ObjTemplate  tfParent or tfEnd, Form, frmMain, x, 100, y, 50, width, 640, height, 340, Visible, TRUE, Caption, 'FreshLib directory functions test.'

            ; log window
            ObjTemplate tfChild, FreshEdit, editLog, x, 330, y, 0, width, 240, height, 200, Visible, TRUE, Align, waClient, _fReadOnly, froReadOnlyWithCaret

            ObjTemplate  tfParent or tfEnd, Form, frmToolPanel, borderKind, borderNone, Align, waLeft,x ,0, y, 0, width, 200, height, 340, Visible, TRUE

                ; file buttons
                ObjTemplate tfChild, Button, btnReadFile, x, 4,  y, 2, width, 64, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'ReadLine', OnClick, procOnReadFile
                ObjTemplate tfChild, Button, btnReadDir, x, 67,  y, 2, width, 64, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'ReadDir', OnClick, procOnReadDir

                ; log buttons
                ObjTemplate tfChild, Button, btnClearLog, x, 134, y, 264, width, 60, height, 19, Visible, TRUE, TextAlign, dtfAlignCenter or dtfAlignMiddle, Caption, 'Clear >>>', OnClick, procOnClearLog

                ; edit boxes
                ObjTemplate tfChild, Label, lblFilename,   x, 4, y, 24,  width, 100, height, 19, Visible, TRUE, TextAlign, dtfAlignLeft or dtfAlignBottom, Caption, 'File name:'
                ObjTemplate tfChild or tfEnd, Edit,  editFilename,  x, 4, y, 44,  width, 190, height, 19, Visible, TRUE, Text, '_doc'

endg



proc PrepareDemo
begin

        stdcall CreateFromTemplate, frmMainForm, 0
        mov     ecx, [pApplication]
        mov     [ecx+TApplication.MainWindow], frmMain
        execute [frmMain], TForm.AlignChildren

        return
endp



proc procOnClearLog, .self, .button
begin
        execute [editLog], TFreshEdit.Clear
        return
endp



proc procOnReadDir, .self, .button
begin
        pushad

        stdcall Get, [editFilename], TEdit.Text
        mov     esi, eax

        stdcall DirectoryRead, eax
        jc      .error

        mov     esi, eax

        stdcall SortDirArray, esi, fdsByType or fdsByName ;or fdsDescending


        mov     ecx, [esi+TArray.count]
        xor     ebx, ebx

.list_loop:
        stdcall LogMessage, [esi+TArray.array+8*ebx+TDirItem.hFilename]
        stdcall LogMessage, cNewLine
        inc     ebx
        loop    .list_loop

        stdcall FreeDirArray, esi
        popad
        return

.error:
        stdcall LogMessage, cErrorRead
        stdcall GetErrorString, eax
        stdcall LogMessage, eax
        stdcall FreeErrorString, eax
        popad
        return

endp

cNewLine   text '',13
cErrorRead text 'Error read directory: '
cErrorFile text 'Error read file: '


proc procOnReadFile, .self, .button
begin
        pushad

        stdcall Get, [editFilename], TEdit.Text
        mov     esi, eax

        stdcall FileOpen, esi
        jc      .error
        mov     ebx, eax

.loop:
        stdcall FileReadLine, ebx
        jc      .error
        test    eax, eax
        jz      .end_of_file

        stdcall LogMessage, eax
        stdcall StrDel, eax
        stdcall LogMessage, cNewLine
        jmp     .loop

.end_of_file:
        stdcall FileClose, ebx
        popad
        return

.error:
        stdcall LogMessage, cErrorFile
        stdcall GetErrorString, eax
        stdcall LogMessage, eax
        stdcall FreeErrorString, eax
        stdcall LogMessage, cNewLine
        popad
        return

endp



proc LogMessage, .string
begin
        pushad
        execute [editLog], TFreshEdit.InsertString, [.string]
        mov     eax, [editLog]
        push    [eax+TFreshEdit._xCaret] [eax+TFreshEdit._yCaret]
        pop     [eax+TFreshEdit._ySelection] [eax+TFreshEdit._xSelection]
        execute [editLog], TFreshEdit.Refresh
        stdcall TFreshEdit.__UpdateScrollBars, [editLog]        ; not this
        popad
        return
endp


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































































Deleted freshlib/test_code0/TestGroundFreshEdit.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;                                                                                        |
;   Description: Test program for TFreshEdit control.                                    |
;                                                                                        |
;   Target OS: All/Linux/Win32 - depending on current test needs.                        |
;                                                                                        |
;   Dependencies:                                                                        |
;                                                                                        |
;   Notes: The main test program calls "PrepareDemo" procedure.                          |
;________________________________________________________________________________________|


__TestGround:

; Global data...
iglobal

__TestData:

frmMainForm:
        ObjTemplate  tfParent or tfEnd, Form, frmMain, \
                     x, 100,        \
                     y, 50,         \
                     width, 640,    \
                     height, 480,   \
                     borderKind, borderFull,    \
                     Visible, TRUE, \
                     Caption, 'FreshEdit test application.'

        ObjTemplate  tfParent, Form, Toolbar,           \
                     x, 0, y, 0,                        \
                     width, 100, height, 20,            \
                     Align, waBottom,                   \
                     borderKind, borderNone,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnOpen,  \
                     x, 112, y, 2,                        \
                     width, 64, height, 21,            \
                     Align, waLeft,                     \
                     Caption, 'Open',                   \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnOpenFile,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnSave,  \
                     x, 180, y, 2,                     \
                     width, 64, height, 21,            \
                     Align, waLeft,                     \
                     Caption, 'Save',                   \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnSaveFile,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnNumbers,  \
                     x, 180, y, 2,                     \
                     width, 21, height, 21,            \
                     Align, waLeft,                     \
                     Caption, '#',                  \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnNumbers,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnZebra,  \
                     x, 180, y, 2,                     \
                     width, 21, height, 21,            \
                     Align, waLeft,                     \
                     Caption, 'Z',                  \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnZebra,         \
                     Visible, TRUE

        ObjTemplate  tfChild, Button, btnTheme,  \
                     x, 180, y, 2,                     \
                     width, 21, height, 21,            \
                     Align, waLeft,                     \
                     Caption, 'T',                  \
                     TextAlign, dtfAlignCenter or dtfAlignMiddle,       \
                     OnClick, OnTheme,         \
                     Visible, TRUE

        ObjTemplate  tfEnd, Edit, FilenameEdit,         \
                     x, 2, y, 2,                        \
                     width, 100, height, 21,            \
                     Align, waClient,                     \
                     Visible, TRUE

        ObjTemplate tfEnd, FreshEdit, Editor,   \
                    x, 8, y, 8,                 \
                    width, 624, height, 464,    \
                    Align, waClient,            \
                    Visible, TRUE


  SampleText file 'unicode_test.txt'
             dd   0

__TestDataSize = $ - __TestData
endg


uglobal
  Timer1 dd ?
endg

var FreshEditSetTheme = TFETheme.SetDefaultThemeWindows


proc OnTheme, .self, .mousebtn
begin
        xor     [FreshEditSetTheme], TFETheme.SetDefaultThemeWindows xor TFETheme.SetDefaultThemeClassic
        stdcall [FreshEditSetTheme], FreshEditTheme
        xor     [SynTheme], fasm_colors_classic xor fasm_colors_windows
        execute [Editor], TFreshEdit.Refresh
        return
endp


proc OnZebra, .self, .mousebtn
begin
        xor     [FreshEditTheme.Options], eoStripedBackground
        execute [Editor], TFreshEdit.Refresh
        return
endp


proc OnNumbers, .self, .mousebtn
begin
        xor     [FreshEditTheme.Options], eoLineNumbers
        execute [Editor], TFreshEdit.Refresh
        return
endp


cErrorTitleOpen text "Error open file."
cErrorTitleSave text "Error save file."

proc OnSaveFile, .self, .mousebtn
begin
        pushad

        stdcall Get, [FilenameEdit], TEdit.Text
        push    eax
        stdcall StrPtr, eax
        mov     edi, eax

        stdcall Get, [Editor], TFreshEdit.Text
        jc      .finish

        push    eax
        stdcall StrPtr, eax

        stdcall SaveBinaryFile, edi, eax, [eax+string.len]
        jnc     .end_save

        stdcall GetErrorString, eax
        mov     esi, eax
        stdcall ShowMessage, [frmMain], smiError, cErrorTitleSave, esi, smbOK
        stdcall FreeErrorString, esi

.end_save:
        stdcall StrDel ; from the stack
.finish:
        stdcall StrDel ; from the stack
        popad
        return
endp


proc OnOpenFile, .self, .mousebtn
begin
        pushad
; Load test file
        stdcall Get, [FilenameEdit], TEdit.Text
        push    eax

        stdcall StrPtr, eax
        stdcall LoadBinaryFile, eax
        jnc     .loaded

        stdcall GetErrorString, eax
        mov     esi, eax
        stdcall ShowMessage, [frmMain], smiError, cErrorTitleOpen, esi, smbOK
        stdcall FreeErrorString, esi
        jmp     .exit

.loaded:
        push    eax
        stdcall Set, [Editor], TFreshEdit.Text, eax
        stdcall FreeMem ; from the stack

.exit:
        stdcall StrDel ; from the stack

        mov     eax, [Editor]
        mov     [eax+TFreshEdit._xCaret], 0
        mov     [eax+TFreshEdit._yCaret], 0
        mov     [eax+TFreshEdit._xSelection], 0
        mov     [eax+TFreshEdit._ySelection], 0

;        stdcall ParseFolding, [eax+TFreshEdit._pLines]

        execute [Editor], TFreshEdit.Refresh
        execute [Editor], TFreshEdit.Focus
        popad
        return
endp



proc PrepareDemo
begin
        stdcall CreateFromTemplate, frmMainForm, 0
        mov     ecx, [pApplication]
        mov     [ecx+TApplication.MainWindow], frmMain

        stdcall Set, [Editor], TFreshEdit._procSyntax, SyntaxFASM
        stdcall Set, [Editor], TFreshEdit.OnControlKey, procKeyPress
        stdcall Set, [Editor], TFreshEdit.Text, SampleText

        mov     esi, [Editor]
; test - set some flags on line 33
        mov     eax, [esi+TFreshEdit._pLines]
        or      [eax+TArray.array+sizeof.TEditorLine*26+TEditorLine.flags], lfBreakpoint

; test - set some flags on line 34
        mov     eax, [esi+TFreshEdit._pLines]
        or      [eax+TArray.array+sizeof.TEditorLine*27+TEditorLine.flags], lfBreakpoint
        mov     [eax+TArray.array+sizeof.TEditorLine*27+TEditorLine.debugdata], $12345
        mov     [eax+TArray.array+sizeof.TEditorLine*28+TEditorLine.debugdata], $12345
        mov     [eax+TArray.array+sizeof.TEditorLine*29+TEditorLine.debugdata], $12345

        stdcall ParseFolding, eax
.exit:
        return
endp



proc procKeyPress, .self, .keyevent
begin
        mov     ebx, [.keyevent]

        mov     eax, [ebx+TKeyboardEvent.key]

        cmp     eax, $03        ; ctrl+C
        je      .copy
        cmp     eax, $16        ; ctrl+V
        je      .paste
        cmp     eax, 12 ; ctrl+L
        je      .length_list
        cmp     eax, 18 ; ctrl+R
        je      .clipright
        cmp     eax, 19 ; ctrl+S == save
        je      .save
        cmp     eax, 20 ; ctrl+T
        je      .test_something

        cmp     [ebx+TKeyboardEvent.scancode], keyF2
        je      .toggle_breakpoint

.finish:
        mov     eax, chgfNoClearSelection
.exit:
        return

.copy:
        stdcall Get, [.self], TFreshEdit.Selection
        test    eax, eax
        jz      .end_copy
        stdcall ClipboardWrite, eax
        stdcall StrDel, eax
.end_copy:
        mov     eax, chgfNoClearSelection
        return

.paste:
        stdcall ClipboardRead
        test    eax, eax
        jz      .end_paste

        stdcall Set, [.self], TFreshEdit.Selection, eax
        stdcall StrDel, eax

        mov     eax, chgfNeedRefresh
.end_paste:
        return


.save:
        stdcall OnSaveFile, [.self], 0
        xor     eax, eax
        return

.length_list:
        xor     eax, eax
        return

.clipright:
        stdcall Get, esi, TFreshEdit.CurrentLine
        jc      .finish
        stdcall StrClipSpacesR, [eax+TEditorLine.Data]
        mov     eax, chgfNeedRefresh
        return

.test_something:
        mov     eax, chgfNeedRefresh
        return


.toggle_breakpoint:
        cmp     [esi+TFreshEdit._fReadOnly], froReadWrite
        jne     .finish

        stdcall Get, esi, TFreshEdit.CurrentLine
        jc      .finish

        xor     [eax+TEditorLine.flags], lfBreakpoint
        mov     eax, chgfNeedRefresh or chgfNoClearSelection
        return


;. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

endp




; very primitive! To be rewrited from scratch to allow custom keywords.
proc ParseFolding, .pLines
begin
        pushad

        xor     ebx, ebx
        mov     esi, [.pLines]
        mov     ecx, [esi+TArray.count]
        lea     esi, [esi+TArray.array]

.loop:
        jecxz   .endparse

        stdcall StrPtr, [esi+TEditorLine.Data]
        jc      .forward

        cmp     [eax+string.len], 4
        jb      .forward

        cmp     dword [eax], 'proc'
        je      .up

        cmp     [eax+string.len], 6
        jb      .forward

        cmp     dword [eax], 'loca'
        jne     .forward
        cmp     word [eax+4], 'ls'
        jne     .forward

.up:
        inc     ebx
        or      [esi+TEditorLine.flags], lfFoldHeader

.forward:
        mov     [esi+TEditorLine.fold_level], ebx

        stdcall StrPtr, [esi+TEditorLine.Data]
        jc      .forward2

        cmp     [eax+string.len], 4
        jb      .forward2

        cmp     dword [eax], 'endp'
        je      .down
        cmp     dword [eax], 'endl'
        jne     .forward2

.down:
        test    ebx, ebx
        jz      .forward2
        dec     ebx

.forward2:
        add     esi, sizeof.TEditorLine
        dec     ecx
        jmp     .loop

.endparse:
        popad
        return
endp








DispSize 'Test ground dummy code:', ($-__TestGround)+__TestDataSize

; without this, the application crashes in Linux with untraceable seg fault. Why???
; It seems it crashes during the load, before even one instruction executed.
; Maybe it is some kind of bug in the elf formater...
; IT CRASHES ONLY SOMETIMES?????
;rb 64

include '%lib%/FreshEdit/fasm_syntax.asm'
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/test_code0/TestGroundKeyboard.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;   Description: This test source provides some testing of the keyboard facilities
;                of FreshLib
;
;   Target OS: All/Linux/Win32 - depending on current test needs.
;
;   Dependencies:
;
;   Notes: The main test program calls "PrepareDemo" procedure.
;_________________________________________________________________________________________

__TestGround:

; Global data...
iglobal

__TestData:

frmMainForm:
        ObjTemplate  tfEnd, Form, frmMain, \
                     x, 100,        \
                     y, 50,         \
                     width, 120,    \
                     height, 80,   \
                     Visible, TRUE, \
                     OnKeyPress, MainKeyPressed,        \
                     Caption, 'FreshLib minimal application test.'

__TestDataSize = $ - __TestData
endg






cKeyMessage text 'Key pressed:'
cCRLF       db   13, 10, 0
cSpace      db   '  ', 0



proc MainKeyPressed, .self, .keyevent
begin
        mov     esi, [.self]
        mov     edi, [.keyevent]

        stdcall Output, cKeyMessage
        stdcall OutputNumber, [edi+TKeyboardEvent.key], 16, 8
        stdcall Output, cSpace
        stdcall OutputNumber, [edi+TKeyboardEvent.scancode], 16, 8
        stdcall Output, cSpace
        stdcall OutputNumber, [edi+TKeyboardEvent.kbdStatus], 16, 8
        stdcall Output, cCRLF
        return
endp








proc PrepareDemo
begin
        stdcall CreateFromTemplate, frmMainForm, 0
        mov     ecx, [pApplication]
        mov     [ecx+TApplication.MainWindow], frmMain

        return
endp












DispSize 'Test ground dummy code', ($-__TestGround)+__TestDataSize
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































Deleted freshlib/test_code0/TestLib.asm.

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
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: The main file of FreshLib test application. Main file.
;
;  Target OS: Any
;
;  Dependencies: FreshLib - see includes in the source.
;
;  Notes: This is the main file of the project. It forms the common frame of the GUI
;         program. The real test code is separated in several different files,
;         named TestGround(xxxx).asm where (xxxx) is some suffix.
;         Include only one of these files.
;_________________________________________________________________________________________

include '%lib%/freshlib.inc'
_BinaryType GUI

include '%lib%/freshlib.asm'

options.FastEnter         = 0           ; enter/leave or push ebp/pop ebp approach to the procedures.
options.ShowSkipped       = 0           ; shows the procedures skiped because of no use.
options.ShowSizes         = 1           ; enable/disable work of DispSize macro.
options.DebugMode         = 1           ; enable/disable macroses of simpledebug library.


; use one and only one of the following files.
;
;include 'TestGround.asm'
;include 'TestGroundComplex.asm'
;include 'TestGroundKeyboard.asm'
;include 'TestGroundFreshEdit.asm'
include 'TestGroundConfig.asm'
;include 'TestGroundDirFunctions.asm'

;if TargetOS eq Linux
;  rb 604       ; this bytes simply make ELF file to be loadable.
;              ; there is a bug somewhere in the ELF generator (FASM or possibly ELF macros)
;              ; that makes some sizes of the ELF executable not loadable. (the Linux loader crashes with SEGFAULT)
;end if

iglobal
  time_test  dq -5

  date_time TDateTime
endg


; Main Program
start:

        stdcall GetTime
        mov     dword [time_test], eax
        mov     dword [time_test+4], edx

        stdcall GetLocalTimeOffset
        add     dword [time_test], eax
        adc     dword [time_test+4], 0

        stdcall TimeToDateTime, time_test, date_time

        OutputMemory date_time, sizeof.TDateTime

        int3

DebugMsg 'Before initializing.'

        InitializeAll

DebugMsg 'After initializing.'

        stdcall Create, CApplication
        jc      .start_error
        mov     [pApplication], ebx

        stdcall PrepareDemo

DebugMsg 'Just before run.'

        stdcall Run

.terminate:
        push    eax
        FinalizeAll

        DebugMsg 'Just before the end.'
        stdcall Terminate       ; from the stack

.start_error:
        mov     eax, 1
        DebugMsg "Can't create application object."
        jmp      .terminate

; end of main program

_AllDataSection

_AllImportSection


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































Deleted freshlib/test_code0/UTF8_examples.asm.

1
2
3
4
5
  utf8_string db $49, $C3, $B1, $74, $C3, $AB, $72, $6E, $C3, $A2, $74, $69, $C3, $B4, $6E, $C3, $A0, $6C, $69, $7A, $C3, $A6, $74, $69, $C3, $B8, $6E, $00 ; the word "Internationalization" written with different languages chars

; greek, cyrillic and latin in one text.
  utf8_long   file 'UnicodeSample.txt':3
              dd 0
<
<
<
<
<










Deleted freshlib/test_code0/UnicodeSample.txt.

1
2
3
4
5
6
Russian: Я могу есть стекло, оно мне не вредит. 
Yoruba: Mo lè je̩ dígí, kò ní pa mí lára.
Chinese: 我能吞下玻璃而不伤身体。 
Greek: Μπορώ να φάω σπασμένα γυαλιά χωρίς να πάθω τίποτα.
Québécois: J'peux manger d'la vitre, ça m'fa pas mal. 
Ukrainian: Я можу їсти скло, і воно мені не зашкодить. 
<
<
<
<
<
<












Deleted freshlib/test_code0/UnicodeSampleEng.txt.

1
The main goal of Fresh is to make programming in assembly as fast and efficient as in other visual languages, without sacrificing the small application size and the raw power of assembly language. Because Fresh is the logical continuation of the FASM project in the area of visual programming, it is perfectly compatible with FASM and you can use all your knowledge about FASM to program in Fresh.
<


Deleted freshlib/test_code0/_test_images/icon.gif.

cannot compute difference between binary files

Deleted freshlib/test_code0/_test_images/test.gif.

cannot compute difference between binary files

Deleted freshlib/test_code0/test.forth.

1
2
3
4
5
6
7
8
9
10
: TestWord
  1 2 3 4 5 6 7 8 9 10 * * * * * * * * *
  "
  Test multiline text
  Line1
  Line2
  Another line!
  This is forthScript.
  " .
;
<
<
<
<
<
<
<
<
<
<




















Deleted freshlib/test_code0/test_config.udb.

cannot compute difference between binary files

Deleted freshlib/test_code0/test_utf8.asm.

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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
test00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111
00000000011111111112222222222333333333344444444445555555555666666666677777777778888888888999999999900000000001111111111222222222233333333334
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;  Notes:
;    This is a test file. It is based on strlib.asm but has been modified and
;    should not be used as a library.
;    Това е тестов файл. Базиран е на strlib.asm но е модифициран и не бива да се използва като библиотека. В този тестов файл се използват форматиращи команди, които са съвместими с FASM и могат да се компилират без проблеми.
;    използва като библиотека.
;    Αυτό είναι ένα δοκιμαστικό αρχείο. Βασίζεται σε strlib.asm αλλά έχει
;    τροποποιηθεί και δεν πρέπει να χρησιμοποιείται ως βιβλιοθήκη.
;    ეს არის გამოცდა ფაილი. ის ეფუძნება strlib.asm მაგრამ შეიცვალა და არ უნდა
;    იქნას გამოყენებული ბიბლიოთეკაში.
;_________________________________________________________________________________________

            mov  eax, '1234'
            mov  ecx, 1234

__StringLibrary:

STR_MINSTRLEN = 15      ; must be N*8-1


struc string {
  .capacity dd ?
  .len      dd ?
  label .data byte
}

virtual at -(sizeof.string)
  string string
  sizeof.string = $-string
end virtual


; NumToStr flags
ntsSigned       = $00000
ntsUnsigned     = $10000
ntsFixedWidth   = $20000


ntsBin  = $0200
ntsQuad = $0400
ntsOct  = $0800
ntsDec  = $0a00
ntsHex  = $1000


; Global variable, storing parameters of dynamic strings list.
uglobal
  if used InitStrings
  ptrStrTable       dd  ?      ; StrLib strings arrray. Contains pointers to the memory allocated for strings.

  flagStringFastAdd dd  ?      ; Flag: when TRUE, enables "Fast addition mode" where new strings are allocated
                               ; without searching the ptrStrTable array for empty slots.
                               ; This can increase allocation speed, but at the expense of more memory allocated
                               ; in the array and not using possibly free handles. This mode should to be used
                               ; carefully and set to FALSE after the end of mass allocations.
  end if
endg



; < OS independent library functions >

;************************************************************************************
; Allocates memory for string table and allocates memory for strings.
; Start it before any work with strings. (Or better use InitializeAll macro)
; Returns 0 if failed to allocate needed memory.
;************************************************************************************
if used ptrStrTable
initialize InitStrings
begin
        StrLib = 1

        stdcall CreateArray, 4
        jc      .finish

        mov     [ptrStrTable], eax
        or      [eax+TArray.lparam], -1     ; lParam is the last allocated handle number

.finish:
        return
endp
end if

;**************************************************************************************
; Frees all memory used for strings library
; Call it before exit of the program or use FinalizeAll macro.
;**************************************************************************************
if used InitStrings
finalize FreeStrings
begin
        mov     esi, [ptrStrTable]
        mov     ecx, [esi+TArray.count]
        xor     ebx,ebx

.freeloop:
        dec     ecx
        js      .endloop

        cmp     [esi+TArray.array+4*ecx], ebx
        je      .freeloop

        stdcall FreeMem, [esi+TArray.array+4*ecx]
        jmp     .freeloop

.endloop:
        stdcall FreeMem, esi
        mov     [ptrStrTable], ebx

        return
endp
end if



;**************************************************************************************
;  Returns:
;    CF=0 no error; eax = pointer in memory of the hString
;    CF=1 on error - hString is handle, but is not in the table.*
;**************************************************************************************
proc StrPtr, .hString
begin
        mov     eax, [.hString]

        xor     eax, $c0000000
        test    eax, $c0000000
        jnz     .pointer

        push    ebx

        mov     ebx, [ptrStrTable]
        cmp     eax, [ebx+TArray.count]
        jae     .notfound

        mov     eax, [ebx+TArray.array+4*eax]
        test    eax, eax
        jz      .notfound

        add     eax, sizeof.string
        pop     ebx
        clc
        return

.pointer:
        xor     eax, $c0000000
        clc
        return

.notfound:
        stc
        pop     ebx
        return
endp

;**************************************************************************************
;  Creates new empty string and returns handle
;  Return: handle of the new created string.
;**************************************************************************************
proc StrNew
begin
        push    ecx edx esi

; Search for first empty place.
        mov     edx, [ptrStrTable]
        mov     ecx, [edx+TArray.count]

        cmp     [flagStringFastAdd], 0
        jne     .notfound

        mov     esi,[edx+TArray.lparam]
        xor     eax,eax

.search:
        dec     ecx
        js      .notfound

        inc     esi
        cmp     esi, [edx+TArray.count]
        jne     @f
        xor     esi,esi
@@:
        cmp     [edx+TArray.array+4*esi],eax
        je      .found
        jmp     .search

.notfound:
        mov     esi, [edx+TArray.count]
        stdcall AddArrayItem, edx
        mov     [ptrStrTable], edx

.found:
        mov     [edx+TArray.lparam], esi
        stdcall GetMem, STR_MINSTRLEN + sizeof.string + 1
        mov     [edx+TArray.array+4*esi], eax
        mov     [eax+sizeof.string+string.capacity], STR_MINSTRLEN

        mov     eax, esi
        or      eax, $c0000000

        pop     esi edx ecx
        return
endp


;**************************************************************************
; Deletes the string if it is possible.
;**************************************************************************
proc StrDel, .hString
begin
        push    eax ecx esi

        mov     esi, [ptrStrTable]
        mov     ecx, [.hString]
        jecxz   .finish

        xor     ecx, $c0000000
        test    ecx, $c0000000
        jnz     .pointer

        cmp     ecx, [esi+TArray.count]
        jae     .finish

.free:
        stdcall FreeMem, [esi+TArray.array+4*ecx]
        mov     [esi+TArray.array+4*ecx], 0

.finish:
        pop     esi ecx eax
        return

.pointer:
        xor     ecx, $c0000000

; search the pointer in the table.
        lea     eax, [ecx-sizeof.string]
        mov     ecx, [esi+TArray.count]

.search:
        dec     ecx
        js      .finish
        cmp     [esi+TArray.array+4*ecx], eax
        jne     .search
        jmp     .free
endp


;**************************************************************************
; Duplicates given string, and returns a handle to new one
;**************************************************************************
proc StrDup, .hSource
begin
        stdcall StrNew
        stdcall StrCopy, eax, [.hSource]
        return
endp


;**************************************************************************
; Arguments:
;  hString - handle or pointer to the string (static or dynamic)
; Returns:
;   CF=0; eax = length of the string in bytes.
;   CF=1; eax = 0 in case, the handle of the string can't be found in the
;               string table or the pointer is NULL.
;
; If pointer is passed the the procedure, it should be dword aligned and
; all bytes of the string including zero terminator to be accessed on
; qword boundary. Although, the zero terminator can be single byte zero.
;
; The performance of the procedure is high for pointers and
; instant for handles (the StrLib created string doesn't need any
; search, because the length is precomputed)
;**************************************************************************

proc StrLen, .hString    ; proc StrLen [hString]
begin
        push    esi

        mov     esi, [ptrStrTable]
        mov     eax, [.hString]

        xor     eax, $c0000000
        test    eax, $c0000000
        jnz     .pointer

        cmp     eax, [esi+TArray.count]
        jae     .error

        mov     eax, [esi+TArray.array+4*eax]
        test    eax, eax
        jz      .error

        mov     eax, [eax+sizeof.string+string.len]
        clc
        pop     esi
        return

.error:
        xor     eax, eax
        stc
        pop     esi
        return

.pointer:
        push    ecx edx edi

        xor     eax, $c0000000

; align on dword
.byte1:
        test    eax, 3
        jz      .scan

        cmp     byte [eax], 0
        je      .found

        inc     eax
        jmp     .byte1

.scan:
        mov     ecx, [eax]
        mov     edx, [eax+4]

        lea     eax, [eax+8]

        lea     esi, [ecx-$01010101]
        lea     edi, [edx-$01010101]

        not     ecx
        not     edx

        and     esi, ecx
        and     edi, edx

        and     esi, $80808080
        and     edi, $80808080

        or      esi, edi
        jz      .scan

        sub     eax, 9

; byte 0 was found: so search by bytes.
.byteloop:
        lea     eax, [eax+1]
        cmp     byte [eax], 0
        jne     .byteloop

.found:
        sub     eax, [.hString]
        clc
        pop     edi edx ecx esi
        return
endp





; This procedure calculates the length of zero terminated string and "fixes" [string.len] field.
; StrFixLen should be call when the content of the string is created by call to external to StrLib
; procedures - for example Win32 API functions.
;
proc StrFixLen, .hstring
begin
        push    eax ecx
        stdcall StrPtr, [.hstring]
        mov     ecx, eax
        stdcall StrLen, eax
        mov     [ecx+string.len], eax
        pop     ecx eax
        return
endp




;***************************************************************************
; If the hString is larger than length - do nothing
; If the hString is smaller than length -> set the length of string to length
; returns pointer to the new (old) string
;
; Arguments:
;   hString - string handle. /not pointer!/
;   length - new string length.
; Returns:
;   eax: pointer to the string.
;   CF: error flag. If 1 the pointer to the string is returned, but
;       the capacity is not changed.
;***************************************************************************
proc StrSetCapacity, .hString, .capacity
begin
        push    ebx ecx esi

        mov     eax, [.hString]

        xor     eax, $c0000000
        test    eax, $c0000000
        jnz     .pointer

        mov     esi, eax

        mov     ebx, [ptrStrTable]
        cmp     esi, [ebx+TArray.count]
        jae     .pointer

        mov     eax, [ebx+TArray.array+4*esi]   ; pointer to the string.
        mov     ecx, [.capacity]

        cmp     [eax+sizeof.string+string.capacity], ecx
        jae     .sizeok

        add     ecx, sizeof.string+8
        and     cl,  $f8                ; align the size to 8 bytes

        stdcall ResizeMem, eax, ecx
        jc      .error

        lea     ecx, [ecx-(sizeof.string+1)]
        mov     [ebx+TArray.array+4*esi], eax
        mov     [eax+sizeof.string+string.capacity], ecx

.sizeok:
        add     eax, sizeof.string
        pop     esi ecx ebx
        return

.error:
        add     eax, sizeof.string
        stc
        pop     esi ecx ebx
        return

.pointer:
        xor     eax, $c0000000
        stc
        pop     esi ecx ebx
        return
endp


;***************************************************************************************
;  Copies source to destination string.
;  Arguments:
;     dest - destination string (handle only)
;     source -  source string (handle or pointer)
;  Returns: nothing
;***************************************************************************************
proc StrCopy, .dest, .source
begin
        push    esi edi eax ecx

        stdcall StrLen, [.source]
        mov     ecx, eax
        stdcall StrSetCapacity, [.dest], ecx
        mov     edi, eax
        stdcall StrPtr, [.source]
        mov     esi, eax

        mov     [edi+string.len], ecx

        inc     ecx
        mov     eax, ecx
        shr     ecx, 2
        rep movsd
        mov     ecx, eax
        and     ecx, 3
        rep movsb

        pop     ecx eax edi esi
        return
endp



;***************************************************************************************
; Compares two strings - case sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;
; As long as this function uses StrLen, it will be very fast on handles and relatively
; slow on pointers.
;***************************************************************************************
proc StrCompCase, .str1, .str2
begin
        push    eax ecx esi edi

        mov     eax, [.str1]
        mov     ecx, [.str2]

        cmp     eax, ecx
        je      .equal

        test    eax, eax
        jz      .noteq

        test    ecx, ecx
        jz      .noteq

        stdcall StrLen, eax
        push    eax
        stdcall StrLen, ecx

        pop     ecx
        cmp     eax, ecx
        jne     .noteq

        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax

        mov     eax, ecx
        and     cl, $fc
        repe cmpsd
        jne     .noteq
        mov     ecx, eax
        and     ecx, 3
        repe cmpsb
        jne     .noteq

.equal:
        stc
        pop     edi esi ecx eax
        return

.noteq:
        clc
        pop     edi esi ecx eax
        return
endp


;***************************************************************************************
; Compares two strings - case NOT sensitive.
; Returns CARRY = 1 if the strings are equal.
; Returns CARRY = 0 if the strings are different.
;
; relatively slow, especially on equal strings, passed as pointers - this is the worst
; case. The nontrivial best case is "strings with different lengths passed as handles."
;***************************************************************************************
proc StrCompNoCase, .str1, .str2
begin
        push    eax ebx ecx edx esi edi

        mov     eax, [.str1]
        mov     ecx, [.str2]

        cmp     eax, ecx
        je      .equal

        test    eax, eax
        jz      .noteq

        test    ecx, ecx
        jz      .noteq

        stdcall StrLen, eax
        push    eax
        stdcall StrLen, ecx

        pop     ecx
        cmp     eax, ecx
        jne     .noteq

        stdcall StrPtr, [.str1]
        mov     esi,eax
        stdcall StrPtr, [.str2]
        mov     edi,eax


        mov     ebx, ecx
        shr     ecx, 2
        and     ebx, 3

.dword:
        dec     ecx
        js      .byte

        mov     eax, [esi]
        mov     edx, [edi]

        and     eax, $40404040
        and     edx, $40404040
        shr     eax, 1
        shr     edx, 1
        or      eax, [esi]
        or      edx, [edi]

        lea     esi, [esi+4]
        lea     edi, [edi+4]

        cmp     eax, edx
        jne     .noteq
        jmp     .dword

.byte:
        dec     ebx
        js      .equal

        mov     al, [esi]
        mov     ah, [edi]

        and     eax, $ffff
        mov     edx, eax
        and     eax, $4040
        shr     eax, 1
        or      eax, edx

        inc     esi
        inc     edi

        cmp     al, ah
        je      .byte

.noteq:
        clc
        pop     edi esi edx ecx ebx eax
        return

.equal:
        stc
        pop     edi esi edx ecx ebx eax
        return

endp



;**********************************************************
;  Creates string and assigns it to variable. If variable
;  already contains string handle, the old string will be
;  used.
;  Arguments:
;    [ptrHString] - variable containing string handle.
;    ptrSource - pointer to the source for string.
;**********************************************************
proc SetString, .ptrHString, .ptrSource
begin
        push    eax esi
        mov     esi, [.ptrHString]

        mov     eax, [esi]
        test    eax, eax
        jnz     @f
        stdcall StrNew
@@:
        mov     [esi], eax
        stdcall StrCopy, eax, [.ptrSource]
        pop     esi eax
        return
endp


;**********************************************************************************
; StrCat appends one string to another
; Arguments:
;   dest - destination string (handle only)
;   source - source string
;**********************************************************************************
proc StrCat, .dest, .source
begin
        push    eax ebx ecx esi edi

        stdcall StrLen, [.dest]
        mov     ebx,eax                 ; store dest length in ebx

        stdcall StrLen, [.source]
        mov     esi, eax
        lea     ecx, [eax+ebx]

        stdcall StrSetCapacity, [.dest], ecx

        mov     [eax+string.len], ecx
        lea     edi, [eax+ebx]

        stdcall StrPtr, [.source]
        lea     ecx, [esi+1]
        mov     esi, eax

        mov     ebx, ecx
        shr     ecx, 2
        rep movsd
        mov     ecx, ebx
        and     ecx, 3
        rep movsb

        pop     edi esi ecx ebx eax
        return
endp


;**********************************************************************************
; StrCharPos returns a pointer to the first occurence of a given char
;   in specified string
; Arguments:
;   Char - char to look for
;   hString -  string to search
; Returns: a pointer to the char in source, or NULL if char doesn't occur
;   in given string
;**********************************************************************************
proc StrCharPos, .hString, .char
begin
        push    esi

        stdcall StrPtr, [.hString]
        mov     esi,eax

        mov     eax, [.char]
        xchg    al,ah

.search:
        mov     al,[esi]
        inc     esi
        or      al,al
        je      .not_found
        cmp     al,ah
        jne     .search

        mov     eax, esi
        dec     eax
        pop     esi
        return

.not_found:
        xor     eax,eax
        pop     esi
        return
endp


;**********************************************************************************
; StrPos returns a pointer to the first occurence of a pattern string
;   in another string
; Arguments:
;   hPattern - 'pattern' string
;   hString -  string to search
; Returns: a pointer to the pattern string in source , or NULL if pattern string
; doesn't occur in the string to search
;**********************************************************************************
proc StrPos, .hString, .hPattern
begin
        push    ebx ecx edx esi edi     ; esp = esp -20
        mov     esi,[.hPattern]         ; mov esi,[hPattern]
        mov     edi,[.hString]          ; mov edi,[hString]
        stdcall StrLen, edi
        mov     ebx,eax                 ; now ebx holds lenght of the string to search
        stdcall StrLen, esi
        mov     edx,eax                 ; now edx holds length of the pattern string

        cmp     edx, ebx
        ja      .not_found              ; if the pattern is longer than the string

        stdcall StrPtr, esi
        mov     esi,eax                 ; put pointer to the pattern str in esi
        stdcall StrPtr,edi
        mov     edi,eax                 ; put pointer to the search str in edi
        lodsb                           ; load first character of the pattern
        mov     ecx,ebx                 ;
        mov     ebx,edx                 ; put str_len(pattern)-1 in ebx
        dec     ebx                     ;
        sub     ecx, ebx                ; there is no need to search to the end, but only to len(string)-len(pattern)-1

.search:
        repne   scasb
        jne     .not_found
        cmp     ecx,ebx
        jb      .not_found
        push    edi esi ecx
        or      ebx,ebx                 ; ebx==0 means that we were searching for one
        jz      .got_it                 ; character. We found it, so we stop.
        mov     ecx,ebx
        repe    cmpsb
        jne     .not_match

.got_it:
        pop     ecx esi edi
        dec     edi
        mov     eax,edi

.ret:
        pop     edi esi edx ecx ebx
        return

.not_match:
        pop     ecx esi edi
        jmp     .search

.not_found:
        xor     eax,eax
        jmp     .ret
endp





proc StrCopyPart, .dest, .source, .pos, .len
begin
        push    eax ecx esi edi

        stdcall StrPtr, [.source]
        mov     esi, eax
        stdcall StrLen, [.source]
        mov     ecx, eax

        mov     eax, [.pos]
        cmp     eax, ecx
        jae     .cleardest      ;

        sub     ecx, [.pos]
        mov     eax, [.len]

; ecx = min(ecx, eax)
        sub     eax, ecx
        sbb     edi, edi
        and     edi, eax
        add     ecx, edi

        add     esi, [.pos]

        stdcall StrSetCapacity, [.dest], ecx
        jc      .finish

        mov     edi, eax
        mov     [edi+string.len], ecx

        push    ecx
        shr     ecx, 2
        rep movsd
        pop     ecx
        and     ecx, 3
        rep movsb

        lea     ecx, [edi+3]
        and     cl, $fc
        sub     ecx, edi
        xor     eax, eax
        rep stosb

.finish:
        pop     edi esi ecx eax
        return

.cleardest:
        stdcall StrSetCapacity, [.dest], STR_MINSTRLEN
        mov     [eax+string.len], 0
        mov     dword [eax], 0
        jmp     .finish
endp




;**********************************************************************************
; StrExtract copies the part of [string] from [index] with lenght in [len]
; Returns handle to new created string.
;**********************************************************************************
proc StrExtract, .string, .pos, .len
begin
        stdcall StrNew
        stdcall StrCopyPart, eax, [.string], [.pos], [.len]
        return
endp




;__________________________________________________________________________________
; Splits the string on two strings, at position [.pos]
; Arguments:
;   .pString - pointer to string to be splitted.
;   .pos     - position where to split the string.
; Returns:
;   eax - handle to the new created string with second part of the string.
;         the original string does not reallocate memory and it's capacity
;         and the pointer will remains the same.
;__________________________________________________________________________________

proc StrSplit, .hString, .pos
begin
        push    ecx edi

        stdcall StrExtract, [.hString], [.pos], -1
        push    eax

        stdcall StrLen, eax
        mov     ecx, eax
        stdcall StrPtr, [.hString]

        sub     [eax+string.len], ecx   ; new length of the source string.
        add     eax, [eax+string.len]
        mov     edi, eax

        lea     ecx, [eax+3]
        and     cl, $fc
        sub     ecx, eax
        xor     eax, eax
        rep stosb

        pop     eax
        pop     edi ecx
        return
endp





;__________________________________________________________________________________
; StrInsert inserts one string into another at specified pos
; Arguments:
;   dest - destination where the source will be inserted.
;   source -  string to insert
;   pos    - where to insert.
; Returns:
;   nothing.
;__________________________________________________________________________________
proc StrInsert, .dest, .source, .pos
begin
        push    eax
        stdcall StrSplit, [.dest], [.pos]
        push    eax eax
        stdcall StrCat, [.dest], [.source]
        stdcall StrCat, [.dest] ; source from the stack.
        stdcall StrDel; from the stack.
        pop     eax
        return
endp


; TODO:
; String case functions are giving weird results in linux, so
; here are two functons I wrote some time ago.
; I have tested the following functions in win32 and worked well
; Perhaps it is time to fully support UTF encoded strings.
; These functions here are faster (20-25%), but the results are
; exactly the same as the strlib ones.
;                                    pelaillo

; -----------------------------------------------
; str_ucase:
;         Author: pelaillo
;           Date: Jan. 16, 2002
;    Converts also accented characters: ÑÚ <--> ñú
; -----------------------------------------------

proc StrUCase2, .hString
begin
        push    eax edx edi

        stdcall StrPtr, [.hString]
        mov     edi, eax
.str_ucase:
                mov     eax, [edi]
                mov     edx, eax
                and     edx, 40404040h
                ror     edx, 1
                xor     edx, -1
                and     eax, edx
                mov     [edi], eax
                add     edi, 4
                lea     edx, [eax-01010101h]
                xor     eax, edx
                and     eax, 80808080h
                jz      .str_ucase
                and     eax, edx
                jz      .str_ucase

        pop     edi edx eax
        return
endp

; -----------------------------------------------
; str_lcase:
;         Author: pelaillo
;           Date: Jan. 16, 2002
;    Converts also accented characters: ÑÚ <--> ñú
; -----------------------------------------------

proc StrLCase2, .hString
begin
        push    eax edx edi

        stdcall StrPtr, [.hString]
        mov     edi, eax
.str_lcase:
        mov     eax, [edi]
        mov     edx, eax
        and     edx, 40404040h
        ror     edx, 1
        or      eax, edx
        mov     [edi], eax
        add     edi, 4
        lea     edx, [eax-01010101h]
        xor     eax, edx
        and     eax, 80808080h
        jz      .str_lcase
        and     eax, edx
        jz      .str_lcase

        pop     edi edx eax
        return
endp


;**********************************************************************************
; Converts strings to Lower Case
;**********************************************************************************
proc StrLCase, .hString
begin
        push    eax ebx ecx edx edi

        stdcall StrPtr, [.hString]
        mov     edi, eax

        stdcall StrLen, [.hString]
        mov     ecx, eax
        mov     ebx, edi

        and     ebx, 3
        sub     ecx, ebx
        jbe     .byte2          ; the string is small enough, so process it by bytes.

.byte1:
        test    edi, 3
        jz      .ddword

        mov     al, [edi]
        and     al, $40
        shr     al, 1
        or      byte [edi], al

        inc     edi
        jmp     .byte1

.ddword:
        mov     ebx, ecx
        and     ebx, 3
        shr     ecx, 2
        jecxz   .byte

.qword:
        mov     eax, [edi]
        mov     edx, [edi+4]

        and     eax, $40404040
        and     edx, $40404040

        shr     eax, 1
        shr     edx, 1

        or      [edi], eax
        or      [edi+4], edx

        add     edi, 8
        dec     ecx
        jnz     .qword

.byte:
        dec     ebx
        js      .finish

        mov     al, [edi]
        and     al, $40
        shr     al, 1
        or      byte [edi], al

        inc     edi
        jmp     .byte

.byte2:
        mov     ebx, ecx
        jmp     .byte

.finish:
        pop     edi edx ecx ebx eax
        return
endp


;**********************************************************************************
; Converts strings to Upper Case
; First parameter = String to Convert to upper case
;**********************************************************************************
proc StrUCase, .hString
begin
        push    eax ebx ecx edx edi

        stdcall StrPtr, [.hString]
        mov     edi, eax

        stdcall StrLen, [.hString]
        mov     ecx, eax
        mov     ebx, edi

        and     ebx, 3
        sub     ecx, ebx
        jbe     .byte2          ; the string is small enough, so process it by bytes.

.byte1:
        test    edi, 3
        jz      .ddword

        mov     al, [edi]
        and     al, $40
        shr     al, 1
        not     al
        and     byte [edi], al

        inc     edi
        jmp     .byte1

.ddword:
        mov     ebx, ecx
        and     ebx, 3
        shr     ecx, 2
        jecxz   .byte

.qword:
        mov     eax, [edi]
        mov     edx, [edi+4]

        and     eax, $40404040
        and     edx, $40404040

        shr     eax, 1
        shr     edx, 1

        not     eax
        not     edx

        and     [edi], eax
        and     [edi+4], edx

        add     edi, 8
        dec     ecx
        jnz     .qword

.byte:
        dec     ebx
        js      .finish

        mov     al, [edi]
        and     al, $40
        shr     al, 1
        not     al
        and     byte [edi], al

        inc     edi
        jmp     .byte

.byte2:
        mov     ebx, ecx
        jmp     .byte

.finish:
        pop     edi edx ecx ebx eax
        return
endp




;**********************************************************************************
; _NumToStr converts the number in eax to the string in any radix approx. [2..26]
; Arguments:
;   [edi] - pointer to the string buffer
;   ecx - radix
;   eax - number to convert.
; There is no parameter check, so be careful.
; returns: edi points to the end of a converted number
;**********************************************************************************
proc _NumToStr
begin
    test  eax,eax
    jns   _NumToStrU
    neg   eax
    mov   byte [edi],"-"
    inc   edi
endp

proc _NumToStrU
begin
    cmp   eax,ecx
    jb    .lessA
    xor   edx,edx
    div   ecx
    push  edx
    call  _NumToStrU
    pop   eax
.lessA:
    cmp   al, 10
    sbb   al, 69h
    das
    stosb
    return
endp



;*****************************************************
; NumToStrF:
;   Converts signed integer value to string.
; NumToStrUF:
;   Converts unsigned integer value to string.
;
; edi - pointer to string buffer
; eax - Number to convert
; ecx - radix from 2 to $ff
; esi - length of the number in chars
;
; returns: edi - pointer to the end of converted num
;
; Note: Don't use 1 as radix.
;*****************************************************
proc _NumToStrF
begin
        test    eax,eax
        jns     _NumToStrUF
        neg     eax
        mov     byte [edi],'-'
        push    esi
        dec     esi
        add     edi, esi
        push    edi
        jmp     _NumToStrUF.loopc
endp

proc _NumToStrUF
begin
        push    esi
        add     edi, esi
        push    edi
        dec     edi
.loopc:
        xor     edx,edx
        div     ecx
        xchg    al,dl
        cmp     al,$0a
        sbb     al,$69
        das
        mov     [edi],al
        dec     edi
        xchg    al,dl
        dec     esi
        jnz     .loopc
        pop     edi
        pop     esi
        return
endp


;***********************************************************
; NumToStr - converts number to any radix.
; num - number to convert
; str - handle of the string. If NULL - creates new string.
; index - Offset in string where to put converted number.
; flags:
;   byte 0 - number of digits if ntsFixedWidth is set.
;   byte 1 - contains radix for the convertion.
;   byte 2,3 - flags.
; Returns:
;   eax - handle of the string.
;***********************************************************
proc NumToStr, .num, .flags
begin
        push    ebx ecx edx esi edi

        stdcall StrNew
        push    eax

        stdcall StrSetCapacity, eax, 40
        mov     edi, eax
        push    eax             ; pointer for the length.

; determine which conversion func to use
        movzx   eax, byte [.flags+2]    ; signed/fixed
        and     eax, (ntsUnsigned or ntsFixedWidth) shr 16
        mov     ebx, [.NumToStrFunc+4*eax]

        movzx   ecx, byte [.flags+1]       ; load radix into ecx
        movzx   esi, byte [.flags]
        mov     eax, [.num]
        call    ebx                     ; call low-level convertion routine
        mov     dword [edi], 0

        pop     eax
        sub     edi, eax
        mov     [eax+string.len], edi

        pop     eax
        pop     edi esi edx ecx ebx
        return

.NumToStrFunc dd _NumToStr, _NumToStrU, _NumToStrF, _NumToStrUF

endp




;-------------------------------------------------------
; function StrToNum
;   Converts specified string into a number
;
; Arguments:
;   hString - handle/pointer of the string containing
;     number to convert. It doesn't have to be ended by
;     NULL, any other character will stop conversion.
;     Number to convert must be decimal.
;
; Return:
;   eax - converted number
;
; Note: in case of failture (first char of given pointer
;   isn't a number) function returns -1.
;-------------------------------------------------------
proc StrToNum, .hString
begin
        push    ebx edx esi
        xor     ebx,ebx         ; ebx will store our number

        stdcall StrPtr, [.hString]
        mov     esi,eax
        xor     eax,eax
        mov     al,[esi]
        cmp     al,'0'
        jb      .error
        cmp     al,'9'
        jbe     .digit
        jmp     .error
     .digit:
        sub     al,'0'
        add     ebx,eax
        inc     esi
        mov     al,[esi]
        cmp     al,'0'
        jb      .finish
        cmp     al,'9'
        ja      .finish
        mov     edx,ebx         ; multiply ebx by 10
        shl     ebx,3
        add     ebx,edx
        add     ebx,edx
        jmp     .digit
     .finish:
        mov     eax,ebx
        pop     esi edx ebx
        return

     .error:
        xor     eax,eax
        dec     eax
        pop     esi edx ebx
        return
endp

;-------------------------------------------------------
; function StrCharCat
;   Appends up to 4 chard at the end of the string.
;
; Arguments:
;   hString - string to append
;   char - char(s) to add
; Returns:
;   nothing
;-------------------------------------------------------
proc StrCharCat, .hString, .char
begin
        push    eax ecx

        stdcall StrLen, [.hString]
        mov     ecx, eax
        add     eax, 8

        stdcall StrSetCapacity, [.hString], eax

        pushd   [.char]
        popd    [eax+ecx]
        mov     dword [eax+ecx+4], 0
        dec     ecx
.goend:
        inc     ecx
        cmp     byte [eax+ecx], 0
        jne     .goend

        mov     [eax+string.len], ecx

        pop     ecx eax
        return
endp


;------------------------------------------------------------
; function StrInsertChar
;   Inserts up to 4 chars into the given position of the string
;
; Arguments:
;   hString - string to append
;   char    - char to add
;   pos     - position where to add the char
;-------------------------------------------------------------
proc StrCharInsert, .hString, .char, .pos
.str rd 2
begin
        push    eax
        push    [.char]
        pop     [.str]
        mov     [.str+4], 0

        lea     eax, [.str]
        stdcall StrInsert, [.hString], eax, [.pos]
        pop     eax
        return
endp






;_______________________________________________________________________
;
; proc StrHash
;   Computes 32 bit hash value from the string.
;   This procedure implements the hash algoritm: FNV-1b
;
; Arguments:
;   ptrString - pointer to PASCAL string with dword length at [ptr-4]
;
; Return:
;   eax - 32bit hash value.
;
; Changes:
;   eax
;_______________________________________________________________________
proc StrHash, .hString
begin
        push    edx ecx esi

        stdcall StrPtr, [.hString]
        mov     esi, eax
        stdcall StrLen, [.hString]
        mov     ecx, eax
        mov     eax, $811C9DC5                  ; 2166136261              ; FNV offset basis

        jecxz   .exit

.hashloop:
        movzx   edx, byte [esi]
        xor     eax, edx
        inc     esi
        imul    eax, $01000193                  ;   16777619              ; FNV prime
        dec     ecx
        jnz     .hashloop

.exit:
        pop     esi ecx edx
        return
endp



proc StrURLEncode, .hstr
.res dd ?
begin
        push    ebx ecx edx esi edi
        stdcall StrPtr, [.hstr]
        mov     esi, eax

        stdcall StrLen, esi
        mov     ecx, eax
        lea     edx, [2*eax+eax]        ; the encoded string can be max 3x long as original string.

        stdcall StrNew
        mov     [.res], eax
        jecxz   .finish

        stdcall StrSetCapacity, eax, edx
        mov     edi, eax
        xor     edx, edx
        xor     ebx, ebx

        push    eax
.encode:
        lodsb
        cmp     al, $80
        jae     .store          ; it is a hack, but I hope save enough.

        mov     dl, al
        mov     bl, al
        shr     edx, 5
        and     ebx, $1f
        bt      dword [.URLCharTable+4*edx], ebx
        jnc     .store

        mov     ah, al
        mov     al, '%'
        stosb
        mov     al, ah
        shr     al, 4
        cmp     al, $0a
        sbb     al, $69
        das
        stosb
        mov     al, ah
        and     al, $0f
        cmp     al, $0a
        sbb     al, $69
        das

.store:
        stosb
        loop    .encode

        xor     al, al
        mov     [edi], al

        pop     eax
        sub     edi, eax
        mov     [eax+string.len], edi

.finish:
        mov     eax, [.res]
        pop     edi esi edx ecx ebx
        return

; Contains 1 where the character must be % encoded and 0 where it is save to pass it directly
.URLCharTable db 11111111b       ;
             db 11111111b       ;
             db 11111111b       ;
             db 11111111b       ; 0..31 -control chars | encoded
             db 11111111b       ; $27 - $20: '&%$#"!   | encoded
             db 11111111b       ; $2f - $28: /.-,+*)(  | encoded
             db 00000000b       ; $37 - $30: 76543210  | not encoded
             db 11111100b       ; $3f - $38: ?>=<;:98  | partially
             db 00000001b       ; $47 - $40: GFEDCBA@  | partially
             db 00000000b       ; $4f - $48: ONMLKJIH  | not encoded
             db 00000000b       ; $57 - $50: WVUTSRQP  | not encoded
             db 11111000b       ; $5f - $58: _^]\[ZYX  | partially
             db 00000001b       ; $67 - $60: gfedcba`  | partially
             db 00000000b       ; $6f - $68: onmlkjih  | not encoded
             db 00000000b       ; $77 - $70: wvutsrqp  | not encoded
             db 11111000b       ; $7f - $78:  ~}|{zyx  | partially

endp




; UTF-8 support functions.
; Some of the above functions also need some revision in order to support
; utf-8 strings properly.



proc StrLenUtf8, .hString, .len
.maxptr dd ?
begin
        push    esi ecx edx

        stdcall StrPtr, [.hString]
        mov     esi, eax
        mov     eax, [.len]
        cmp     eax, -1
        je      @f
        add     eax, esi
@@:
        mov     [.maxptr], eax
        xor     ecx, ecx

.loop:
        cmp     esi, [.maxptr]
        jae     .endofstring

        stdcall DecodeUtf8, [esi]
        jc      .error

        test    eax, eax
        jz      .endofstring

        add     esi, edx
        inc     ecx
        jmp     .loop

.endofstring:
        mov     eax, ecx
        pop     edx ecx esi
        clc
        return

.error:
        pop     edx ecx esi
        return
endp



proc StrOffsUtf8, .hString, .pos
begin
        push    edx esi

        stdcall StrPtr, [.hString]
        mov     esi, eax

.loop:
        dec     [.pos]
        js      .finish

        stdcall DecodeUtf8, [esi]
        jc      .error

        test    eax, eax
        jz      .finish

        add     esi, edx
        jmp     .loop

.finish:
        clc
        mov     eax, esi
        pop     esi edx
        return

.error:
        xor     eax, eax
        pop     esi edx
        return
endp



; decodes 4 bytes in [.chars] to UNICODE dword value.
; returns:
;   CF=0 - no error
;     eax - unicode value.
;     edx - byte count of the char. [1..4]
;   CF=1 - invalid utf-8 char;
;     eax = edx = 0  the character can not be decoded.
;     edx <> 0 -> eax = the overlong encoded character. edx = byte count of the char.
;
;  Note: When CF=1 and [.chars] are overlong encoded char.
;        eax contains the proper value and edx contains the proper length.
;        But it is still invalid character, according to the standards.
proc DecodeUtf8, .chars
begin
        push    ebx ecx

        xor     ecx, ecx

.loop1:
        shl     byte [.chars], 1
        jnc     .countok
        inc     ecx
        jmp     .loop1

.countok:
        jecxz   .ascii

        cmp     ecx, 1
        je      .error          ; internal byte
        cmp     ecx, 4
        ja      .error          ; more than 4 bytes

        mov     edx, 1
        xor     ebx, ebx
        movzx   eax, byte [.chars]
        shr     eax, cl
        shr     eax, 1

.loop2:
        mov     bl, byte [.chars+edx]
        and     bl, $c0
        cmp     bl, $80
        jne     .error
        mov     bl, byte [.chars+edx]
        and     bl, $3f
        shl     eax, 6
        or      eax, ebx
        inc     edx
        cmp     edx, ecx
        jne     .loop2

        and     eax, $1fffff
        cmp     eax, $10ffff
        ja      .error

        cmp     eax, [._minimal+4*edx-8]
        jb      .overlong   ; overlong coding.

        clc
        pop     ecx ebx
        return

.ascii:
        movzx   eax, byte [.chars]
        shr     eax, 1
        mov     edx, 1
        pop     ecx ebx
        clc
        return

.error:
        xor     eax, eax
        xor     edx, edx
.overlong:
        stc
        pop     ecx ebx
        return

._minimal dd $80, $800, $10000

endp



proc ScanForwardUtf8
begin
        push    eax

        mov     al, [esi]
        test    al, al
        jns     .finish

        and     al, 11000000b
        cmp     al, 11000000b
        je      .finish

; inc forward
.loopf:
        inc     esi
        mov     al, [esi]
        and     al, 11000000b
        cmp     al, 10000000b
        je      .loopf

.finish:
        pop     eax
        return
endp



proc ScanBackUtf8
begin
        push    eax

        mov     al, [esi]
        test    al, al
        jns     .finish

        and     al, 11000000b
        cmp     al, 11000000b
        je      .finish

; inc back
.loopf:
        dec     esi
        mov     al, [esi]
        and     al, 11000000b
        cmp     al, 10000000b
        je      .loopf

.finish:
        pop     eax
        return
endp


include '%TargetOS%/utf8.asm'



DispSize "String library", $ - __StringLibrary
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted freshlib/test_code0/unicode_test.txt.

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
;#F:w
;This is example text, aimed simply to show the features of the FreshEdit control.

;#F:w
;1. Word-wrap feature. It works only for the lines formated with word-wrap format. You can set/remove word-wrap format by Ctrl+W key.

;#F:w
;2. FreshEdit can save the format into the source file. The formating is transparent for FASM compiler, so you can compile the files without removing formating.

;3. FreshEdit uses UTF-8 encoding - see following samples:

;Russian: Я могу есть стекло, оно мне не вредит.
;Yoruba: Mo lè je̩ dígí, kò ní pa mí lára.
;Greek: Μπορώ να φάω σπασμένα γυαλιά χωρίς να πάθω τίποτα.
;Québécois: J'peux manger d'la vitre, ça m'fa pas mal.
;Ukrainian: Я можу їсти скло, і воно мені не зашкодить.
;English: I can eat glass and it doesn't hurt me.

;#F:bw
;5. The bookmarks are saved with the text as well. Use Ctrl+B to set/remove a bookmark.

;6. Also FreshEdit, has code folding feature.
proc SomeTestProcedure
begin
        nop
        mov     eax, 1234
        return
endp

;#F:w
;7. also, there are line numbers and breakpoint icons on the left margin of the editor. You can set/remove breakpoint with F2 key.

        nop
        nop
        int3

;#F:w
; 8. Color themes: Click on "T" button to switch the color theme for the editor.

;#F:w
; 9. Zebra background - if you like such eye-candy things. Click on "Z" button in order to switch it on/off.

proc AnotherTestProcedure
begin
        xor     eax, eax

locals  ; We have of course several folding levels.
  .x  dd  ?
  .y  dd  ?
  .rect TBounds
endl

        mov     ecx, 'ABCD'
        return
endp

; 10. Click "#" to turn on/off the line numbers.
; 11. Ctrl-T will switch ON/OFF the whole left margin field.
;#F:w
; 12. Alt+Ins will switch the type of selection - line, char and block are supported for now.

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<