forked from RolfRolles/SynesthesiaYS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
synesthesia-symbolic-loops.ys
1192 lines (1130 loc) · 47.4 KB
/
synesthesia-symbolic-loops.ys
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
; Loosen yices' arbitrary restriction on iteration count. (')
(set-param ef-max-iters 1000)
(define-type Bit (bitvector 1))
(define-type Nibble (bitvector 4))
(define-type Byte (bitvector 8))
(define-type Word (bitvector 16))
(define-type Dword (bitvector 32))
(define-type RegIdx (bitvector 3))
(define R0Idx::RegIdx (mk-bv 3 0)) ; R0 = 0
(define R1Idx::RegIdx (mk-bv 3 1)) ; R1 = 1
(define R2Idx::RegIdx (mk-bv 3 2)) ; R2 = 2
(define R3Idx::RegIdx (mk-bv 3 3)) ; R3 = 3
(define R4Idx::RegIdx (mk-bv 3 4)) ; R4 = 4
(define R5Idx::RegIdx (mk-bv 3 5)) ; R5 = 5
(define R6Idx::RegIdx (mk-bv 3 6)) ; R6 = 6
(define R7Idx::RegIdx (mk-bv 3 7)) ; R7 = 7
(define-type Reg32State (bitvector 256))
(define-type SCState (bitvector 512)) ; 0x40-length shellcode
(define-type Mnem (bitvector 4))
(define XorRegReg ::Mnem (mk-bv 4 0))
(define AddRegReg ::Mnem (mk-bv 4 1))
(define MovRegReg ::Mnem (mk-bv 4 2))
(define GetscbyteReg::Mnem (mk-bv 4 3))
(define PutscbyteReg::Mnem (mk-bv 4 4))
(define NegReg ::Mnem (mk-bv 4 5))
(define NotReg ::Mnem (mk-bv 4 6))
(define AddRegImm ::Mnem (mk-bv 4 7))
(define XorRegImm ::Mnem (mk-bv 4 8))
(define MovRegImm ::Mnem (mk-bv 4 9))
(define JnzRegImm ::Mnem (mk-bv 4 10))
(define-type Instruction (bitvector 42))
; 3 0: Mnem
; 6 4: LHSReg
; 9 7: RHSReg
; 41 10: Imm32
(define-type DecodedInstruction (bitvector 60))
; 41 0: Instruction
; 42 42: Bit [extra]
; 43 43: Bit [is-jcc]
; 51 44: Byte [length]
; 59 52: Byte [nexteip]
(define di-get-insn::(-> DecodedInstruction Instruction)
(lambda (di::DecodedInstruction)
(bv-extract 41 0 di)
)
)
(define di-get-extra::(-> DecodedInstruction bool)
(lambda (di::DecodedInstruction)
(= 0b1 (bv-extract 42 42 di))
)
)
(define di-is-jcc::(-> DecodedInstruction bool)
(lambda (di::DecodedInstruction)
(= 0b1 (bv-extract 43 43 di))
)
)
(define di-get-len::(-> DecodedInstruction Byte)
(lambda (di::DecodedInstruction)
(bv-extract 51 44 di)
)
)
(define di-get-next::(-> DecodedInstruction Byte)
(lambda (di::DecodedInstruction)
(bv-extract 59 52 di)
)
)
(define WhichReg::RegIdx)
(define Eip0::Byte)
(define Eip1::Byte)
(define Eip2::Byte)
(define Eip3::Byte)
(define Eip4::Byte)
(define Eip5::Byte)
(define Eip6::Byte)
(define EipLoopBeg::Byte Eip1)
(define EipLoopEnd::Byte Eip6)
(define mk-label-pred::(-> Byte Bit)
(lambda (next::Byte)
(ite (or
(= next Eip0)
(= next Eip1)
(= next Eip2)
(= next Eip3)
(= next Eip4)
(= next Eip5)
(= next Eip6)
) 0b1 0b0)
)
)
(define Len0::Byte)
(define Len1::Byte)
(define Len2::Byte)
(define Len3::Byte)
(define Len4::Byte)
(define Len5::Byte)
(define DIC0::DecodedInstruction)
(define DIC1::DecodedInstruction)
(define DIC2::DecodedInstruction)
(define DIC3::DecodedInstruction)
(define DIC4::DecodedInstruction)
(define DIC5::DecodedInstruction)
(define Ins0::Instruction)
(define Ins1::Instruction)
(define Ins2::Instruction)
(define Ins3::Instruction)
(define Ins4::Instruction)
(define Ins5::Instruction)
(define-type SecondaryMachineState (bitvector 784))
; 255 0: Reg32State
; 767 256: SCState
; 775 768: Byte [scptr]
; 783 776: Byte [nexteip]
(define sms-getregstate::(-> SecondaryMachineState Reg32State)
(lambda (mstate::SecondaryMachineState)
(bv-extract 255 0 mstate)
)
)
(define sms-getscstate::(-> SecondaryMachineState SCState)
(lambda (mstate::SecondaryMachineState)
(bv-extract 767 256 mstate)
)
)
(define sms-getscptr::(-> SecondaryMachineState Byte)
(lambda (mstate::SecondaryMachineState)
(bv-extract 775 768 mstate)
)
)
(define sms-getnexteip::(-> SecondaryMachineState Byte)
(lambda (mstate::SecondaryMachineState)
(bv-extract 783 776 mstate)
)
)
(define sms-setnexteip::(-> SecondaryMachineState Byte SecondaryMachineState)
(lambda (mstate::SecondaryMachineState nexteip::Byte)
(bv-concat nexteip (bv-extract 775 0 mstate))
)
)
; getreg32(reg,state). Return the value of register 'reg' from state 'state'.
(define sms-getreg32::(-> RegIdx SecondaryMachineState Dword)
(lambda (x::RegIdx s::SecondaryMachineState)
(let ((z (sms-getregstate s)))
(ite (= x R0Idx) (bv-extract 31 0 z)
(ite (= x R1Idx) (bv-extract 63 32 z)
(ite (= x R2Idx) (bv-extract 95 64 z)
(ite (= x R3Idx) (bv-extract 127 96 z)
(ite (= x R4Idx) (bv-extract 159 128 z)
(ite (= x R5Idx) (bv-extract 191 160 z)
(ite (= x R6Idx) (bv-extract 223 192 z)
(bv-extract 255 224 z)
))))))))
)
)
; (define sms-getscbyte-byidx::(-> SecondaryMachineState Byte Byte)
; (lambda (mstate::SecondaryMachineState idx::Byte)
; (let ((sc (sms-getscstate mstate)))
; (let ((shiftamtone (bv-concat (bv-repeat 0x00 63) idx)))
; (let ((shiftamttwo (bv-concat (bv-repeat 0x00 63) 0x03)))
; (let ((shiftamt (bv-shl shiftamtone shiftamttwo)))
; (bv-extract 7 0 (bv-lshr sc shiftamt))
; )))))
; )
;
; (define sms-getscbyte::(-> SecondaryMachineState Byte)
; (lambda (mstate::SecondaryMachineState)
; (let ((scptr (sms-getscptr mstate)))
; (sms-getscbyte-byidx mstate scptr)
; ))
; )
(define sms-getscbyte-byidx::(-> SecondaryMachineState Byte Byte)
(lambda (mstate::SecondaryMachineState idx::Byte)
(let ((sc (sms-getscstate mstate)))
(ite (= idx 0x00) (bv-extract 7 0 sc)
(ite (= idx 0x01) (bv-extract 15 8 sc)
(ite (= idx 0x02) (bv-extract 23 16 sc)
(ite (= idx 0x03) (bv-extract 31 24 sc)
(ite (= idx 0x04) (bv-extract 39 32 sc)
(ite (= idx 0x05) (bv-extract 47 40 sc)
(ite (= idx 0x06) (bv-extract 55 48 sc)
(ite (= idx 0x07) (bv-extract 63 56 sc)
(ite (= idx 0x08) (bv-extract 71 64 sc)
(ite (= idx 0x09) (bv-extract 79 72 sc)
(ite (= idx 0x0A) (bv-extract 87 80 sc)
(ite (= idx 0x0B) (bv-extract 95 88 sc)
(ite (= idx 0x0C) (bv-extract 103 96 sc)
(ite (= idx 0x0D) (bv-extract 111 104 sc)
(ite (= idx 0x0E) (bv-extract 119 112 sc)
(ite (= idx 0x0F) (bv-extract 127 120 sc)
(ite (= idx 0x10) (bv-extract 135 128 sc)
(ite (= idx 0x11) (bv-extract 143 136 sc)
(ite (= idx 0x12) (bv-extract 151 144 sc)
(ite (= idx 0x13) (bv-extract 159 152 sc)
(ite (= idx 0x14) (bv-extract 167 160 sc)
(ite (= idx 0x15) (bv-extract 175 168 sc)
(ite (= idx 0x16) (bv-extract 183 176 sc)
(ite (= idx 0x17) (bv-extract 191 184 sc)
(ite (= idx 0x18) (bv-extract 199 192 sc)
(ite (= idx 0x19) (bv-extract 207 200 sc)
(ite (= idx 0x1A) (bv-extract 215 208 sc)
(ite (= idx 0x1B) (bv-extract 223 216 sc)
(ite (= idx 0x1C) (bv-extract 231 224 sc)
(ite (= idx 0x1D) (bv-extract 239 232 sc)
(ite (= idx 0x1E) (bv-extract 247 240 sc)
(ite (= idx 0x1F) (bv-extract 255 248 sc)
(ite (= idx 0x20) (bv-extract 263 256 sc)
(ite (= idx 0x21) (bv-extract 271 264 sc)
(ite (= idx 0x22) (bv-extract 279 272 sc)
(ite (= idx 0x23) (bv-extract 287 280 sc)
(ite (= idx 0x24) (bv-extract 295 288 sc)
(ite (= idx 0x25) (bv-extract 303 296 sc)
(ite (= idx 0x26) (bv-extract 311 304 sc)
(ite (= idx 0x27) (bv-extract 319 312 sc)
(ite (= idx 0x28) (bv-extract 327 320 sc)
(ite (= idx 0x29) (bv-extract 335 328 sc)
(ite (= idx 0x2A) (bv-extract 343 336 sc)
(ite (= idx 0x2B) (bv-extract 351 344 sc)
(ite (= idx 0x2C) (bv-extract 359 352 sc)
(ite (= idx 0x2D) (bv-extract 367 360 sc)
(ite (= idx 0x2E) (bv-extract 375 368 sc)
(ite (= idx 0x2F) (bv-extract 383 376 sc)
(ite (= idx 0x30) (bv-extract 391 384 sc)
(ite (= idx 0x31) (bv-extract 399 392 sc)
(ite (= idx 0x32) (bv-extract 407 400 sc)
(ite (= idx 0x33) (bv-extract 415 408 sc)
(ite (= idx 0x34) (bv-extract 423 416 sc)
(ite (= idx 0x35) (bv-extract 431 424 sc)
(ite (= idx 0x36) (bv-extract 439 432 sc)
(ite (= idx 0x37) (bv-extract 447 440 sc)
(ite (= idx 0x38) (bv-extract 455 448 sc)
(ite (= idx 0x39) (bv-extract 463 456 sc)
(ite (= idx 0x3A) (bv-extract 471 464 sc)
(ite (= idx 0x3B) (bv-extract 479 472 sc)
(ite (= idx 0x3C) (bv-extract 487 480 sc)
(ite (= idx 0x3D) (bv-extract 495 488 sc)
(ite (= idx 0x3E) (bv-extract 503 496 sc)
(bv-extract 511 504 sc)
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))
)
(define sms-getscbyte::(-> SecondaryMachineState Byte)
(lambda (mstate::SecondaryMachineState)
(let ((scptr (sms-getscptr mstate)))
(sms-getscbyte-byidx mstate scptr)
))
)
; (define sms-putscbyte::(-> SecondaryMachineState Byte SecondaryMachineState)
; (lambda (mstate::SecondaryMachineState b::Byte)
; (let ((sc (sms-getscstate mstate)))
; (let ((scptr (sms-getscptr mstate)))
; (bv-concat (sms-getnexteip mstate) (bv-add scptr 0x01)
; (ite (= scptr 0x00) (bv-concat (bv-extract 511 8 sc) b)
; (ite (= scptr 0x01) (bv-concat (bv-extract 511 16 sc) b (bv-extract 7 0 sc))
; (ite (= scptr 0x02) (bv-concat (bv-extract 511 24 sc) b (bv-extract 15 0 sc))
; (ite (= scptr 0x03) (bv-concat (bv-extract 511 32 sc) b (bv-extract 23 0 sc))
; (ite (= scptr 0x04) (bv-concat (bv-extract 511 40 sc) b (bv-extract 31 0 sc))
; (ite (= scptr 0x05) (bv-concat (bv-extract 511 48 sc) b (bv-extract 39 0 sc))
; (ite (= scptr 0x06) (bv-concat (bv-extract 511 56 sc) b (bv-extract 47 0 sc))
; (ite (= scptr 0x07) (bv-concat (bv-extract 511 64 sc) b (bv-extract 55 0 sc))
; (ite (= scptr 0x08) (bv-concat (bv-extract 511 72 sc) b (bv-extract 63 0 sc))
; (ite (= scptr 0x09) (bv-concat (bv-extract 511 80 sc) b (bv-extract 71 0 sc))
; (ite (= scptr 0x0A) (bv-concat (bv-extract 511 88 sc) b (bv-extract 79 0 sc))
; (ite (= scptr 0x0B) (bv-concat (bv-extract 511 96 sc) b (bv-extract 87 0 sc))
; (ite (= scptr 0x0C) (bv-concat (bv-extract 511 104 sc) b (bv-extract 95 0 sc))
; (ite (= scptr 0x0D) (bv-concat (bv-extract 511 112 sc) b (bv-extract 103 0 sc))
; (ite (= scptr 0x0E) (bv-concat (bv-extract 511 120 sc) b (bv-extract 111 0 sc))
; (ite (= scptr 0x0F) (bv-concat (bv-extract 511 128 sc) b (bv-extract 119 0 sc))
; (ite (= scptr 0x10) (bv-concat (bv-extract 511 136 sc) b (bv-extract 127 0 sc))
; (ite (= scptr 0x11) (bv-concat (bv-extract 511 144 sc) b (bv-extract 135 0 sc))
; (ite (= scptr 0x12) (bv-concat (bv-extract 511 152 sc) b (bv-extract 143 0 sc))
; (ite (= scptr 0x13) (bv-concat (bv-extract 511 160 sc) b (bv-extract 151 0 sc))
; (ite (= scptr 0x14) (bv-concat (bv-extract 511 168 sc) b (bv-extract 159 0 sc))
; (ite (= scptr 0x15) (bv-concat (bv-extract 511 176 sc) b (bv-extract 167 0 sc))
; (ite (= scptr 0x16) (bv-concat (bv-extract 511 184 sc) b (bv-extract 175 0 sc))
; (ite (= scptr 0x17) (bv-concat (bv-extract 511 192 sc) b (bv-extract 183 0 sc))
; (ite (= scptr 0x18) (bv-concat (bv-extract 511 200 sc) b (bv-extract 191 0 sc))
; (ite (= scptr 0x19) (bv-concat (bv-extract 511 208 sc) b (bv-extract 199 0 sc))
; (ite (= scptr 0x1A) (bv-concat (bv-extract 511 216 sc) b (bv-extract 207 0 sc))
; (ite (= scptr 0x1B) (bv-concat (bv-extract 511 224 sc) b (bv-extract 215 0 sc))
; (ite (= scptr 0x1C) (bv-concat (bv-extract 511 232 sc) b (bv-extract 223 0 sc))
; (ite (= scptr 0x1D) (bv-concat (bv-extract 511 240 sc) b (bv-extract 231 0 sc))
; (ite (= scptr 0x1E) (bv-concat (bv-extract 511 248 sc) b (bv-extract 239 0 sc))
; (ite (= scptr 0x1F) (bv-concat (bv-extract 511 256 sc) b (bv-extract 247 0 sc))
; (ite (= scptr 0x20) (bv-concat (bv-extract 511 264 sc) b (bv-extract 255 0 sc))
; (ite (= scptr 0x21) (bv-concat (bv-extract 511 272 sc) b (bv-extract 263 0 sc))
; (ite (= scptr 0x22) (bv-concat (bv-extract 511 280 sc) b (bv-extract 271 0 sc))
; (ite (= scptr 0x23) (bv-concat (bv-extract 511 288 sc) b (bv-extract 279 0 sc))
; (ite (= scptr 0x24) (bv-concat (bv-extract 511 296 sc) b (bv-extract 287 0 sc))
; (ite (= scptr 0x25) (bv-concat (bv-extract 511 304 sc) b (bv-extract 295 0 sc))
; (ite (= scptr 0x26) (bv-concat (bv-extract 511 312 sc) b (bv-extract 303 0 sc))
; (ite (= scptr 0x27) (bv-concat (bv-extract 511 320 sc) b (bv-extract 311 0 sc))
; (ite (= scptr 0x28) (bv-concat (bv-extract 511 328 sc) b (bv-extract 319 0 sc))
; (ite (= scptr 0x29) (bv-concat (bv-extract 511 336 sc) b (bv-extract 327 0 sc))
; (ite (= scptr 0x2A) (bv-concat (bv-extract 511 344 sc) b (bv-extract 335 0 sc))
; (ite (= scptr 0x2B) (bv-concat (bv-extract 511 352 sc) b (bv-extract 343 0 sc))
; (ite (= scptr 0x2C) (bv-concat (bv-extract 511 360 sc) b (bv-extract 351 0 sc))
; (ite (= scptr 0x2D) (bv-concat (bv-extract 511 368 sc) b (bv-extract 359 0 sc))
; (ite (= scptr 0x2E) (bv-concat (bv-extract 511 376 sc) b (bv-extract 367 0 sc))
; (ite (= scptr 0x2F) (bv-concat (bv-extract 511 384 sc) b (bv-extract 375 0 sc))
; (ite (= scptr 0x30) (bv-concat (bv-extract 511 392 sc) b (bv-extract 383 0 sc))
; (ite (= scptr 0x31) (bv-concat (bv-extract 511 400 sc) b (bv-extract 391 0 sc))
; (ite (= scptr 0x32) (bv-concat (bv-extract 511 408 sc) b (bv-extract 399 0 sc))
; (ite (= scptr 0x33) (bv-concat (bv-extract 511 416 sc) b (bv-extract 407 0 sc))
; (ite (= scptr 0x34) (bv-concat (bv-extract 511 424 sc) b (bv-extract 415 0 sc))
; (ite (= scptr 0x35) (bv-concat (bv-extract 511 432 sc) b (bv-extract 423 0 sc))
; (ite (= scptr 0x36) (bv-concat (bv-extract 511 440 sc) b (bv-extract 431 0 sc))
; (ite (= scptr 0x37) (bv-concat (bv-extract 511 448 sc) b (bv-extract 439 0 sc))
; (ite (= scptr 0x38) (bv-concat (bv-extract 511 456 sc) b (bv-extract 447 0 sc))
; (ite (= scptr 0x39) (bv-concat (bv-extract 511 464 sc) b (bv-extract 455 0 sc))
; (ite (= scptr 0x3A) (bv-concat (bv-extract 511 472 sc) b (bv-extract 463 0 sc))
; (ite (= scptr 0x3B) (bv-concat (bv-extract 511 480 sc) b (bv-extract 471 0 sc))
; (ite (= scptr 0x3C) (bv-concat (bv-extract 511 488 sc) b (bv-extract 479 0 sc))
; (ite (= scptr 0x3D) (bv-concat (bv-extract 511 496 sc) b (bv-extract 487 0 sc))
; (ite (= scptr 0x3E) (bv-concat (bv-extract 511 504 sc) b (bv-extract 495 0 sc))
; (bv-concat b (bv-extract 503 0 sc))
; )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
; (sms-getregstate mstate))
; )))
; )
(define sms-putscbyte::(-> SecondaryMachineState Byte SecondaryMachineState)
(lambda (mstate::SecondaryMachineState b::Byte)
(let ((sc (sms-getscstate mstate)))
(let ((scptr (sms-getscptr mstate)))
(let ((eidx (bv-concat (bv-repeat 0x00 63) scptr)))
(let ((eshv (bv-shl eidx (bv-concat (bv-repeat 0x00 63) 0x03))))
(let ((bvmask (bv-shl (bv-concat (bv-repeat 0x00 63) 0xFF) eshv)))
(let ((ebyte (bv-shl (bv-concat (bv-repeat 0x00 63) b) eshv)))
(let ((newsc (bv-or (bv-and sc (bv-not bvmask)) ebyte)))
(bv-concat (sms-getnexteip mstate) (bv-add scptr 0x01) newsc (sms-getregstate mstate))
))))))))
)
; putreg32(reg,state,value). Update register 'reg' to value 'value' in state
; 'state'; return the new state.
(define sms-putreg32::(-> RegIdx Dword SecondaryMachineState SecondaryMachineState)
(lambda (x::RegIdx y::Dword s::SecondaryMachineState)
(let ((z (sms-getregstate s)))
(bv-concat (bv-extract 783 256 s)
(ite (= x 0b000) (bv-concat (bv-extract 255 32 z) y)
(ite (= x 0b001) (bv-concat (bv-extract 255 64 z) y (bv-extract 31 0 z))
(ite (= x 0b010) (bv-concat (bv-extract 255 96 z) y (bv-extract 63 0 z))
(ite (= x 0b011) (bv-concat (bv-extract 255 128 z) y (bv-extract 95 0 z))
(ite (= x 0b100) (bv-concat (bv-extract 255 160 z) y (bv-extract 127 0 z))
(ite (= x 0b101) (bv-concat (bv-extract 255 192 z) y (bv-extract 159 0 z))
(ite (= x 0b110) (bv-concat (bv-extract 255 224 z) y (bv-extract 191 0 z))
(bv-concat y (bv-extract 223 0 z))
)))))))))
)
)
(define bytecode00::Byte) (define bytecode01::Byte)
(define bytecode02::Byte) (define bytecode03::Byte)
(define bytecode04::Byte) (define bytecode05::Byte)
(define bytecode06::Byte) (define bytecode07::Byte)
(define bytecode08::Byte) (define bytecode09::Byte)
(define bytecode0A::Byte) (define bytecode0B::Byte)
(define bytecode0C::Byte) (define bytecode0D::Byte)
(define bytecode0E::Byte) (define bytecode0F::Byte)
(define bytecode10::Byte) (define bytecode11::Byte)
(define bytecode12::Byte) (define bytecode13::Byte)
(define bytecode14::Byte) (define bytecode15::Byte)
(define bytecode16::Byte) (define bytecode17::Byte)
(define bytecode18::Byte) (define bytecode19::Byte)
(define bytecode1A::Byte) (define bytecode1B::Byte)
(define bytecode1C::Byte) (define bytecode1D::Byte)
(define bytecode1E::Byte) (define bytecode1F::Byte)
(define bytecode20::Byte) (define bytecode21::Byte)
(define bytecode22::Byte) (define bytecode23::Byte)
(define bytecode24::Byte) (define bytecode25::Byte)
(define bytecode26::Byte) (define bytecode27::Byte)
(define bytecode28::Byte) (define bytecode29::Byte)
(define bytecode2A::Byte) (define bytecode2B::Byte)
(define bytecode2C::Byte) (define bytecode2D::Byte)
(define bytecode2E::Byte) (define bytecode2F::Byte)
(define bytecode30::Byte) (define bytecode31::Byte)
(define bytecode32::Byte) (define bytecode33::Byte)
(define bytecode34::Byte) (define bytecode35::Byte)
(define bytecode36::Byte) (define bytecode37::Byte)
(define bytecode38::Byte) (define bytecode39::Byte)
(define bytecode3A::Byte) (define bytecode3B::Byte)
(define bytecode3C::Byte) (define bytecode3D::Byte)
(define bytecode3E::Byte) (define bytecode3F::Byte)
(define bytecode40::Byte) (define bytecode41::Byte)
(define bytecode42::Byte) (define bytecode43::Byte)
(define bytecode44::Byte) (define bytecode45::Byte)
(define bytecode46::Byte) (define bytecode47::Byte)
(define bytecode48::Byte) (define bytecode49::Byte)
(define bytecode4A::Byte) (define bytecode4B::Byte)
(define bytecode4C::Byte) (define bytecode4D::Byte)
(define bytecode4E::Byte) (define bytecode4F::Byte)
(define bytecode50::Byte) (define bytecode51::Byte)
(define bytecode52::Byte) (define bytecode53::Byte)
(define bytecode54::Byte) (define bytecode55::Byte)
(define bytecode56::Byte) (define bytecode57::Byte)
(define bytecode58::Byte) (define bytecode59::Byte)
(define bytecode5A::Byte) (define bytecode5B::Byte)
(define bytecode5C::Byte) (define bytecode5D::Byte)
(define bytecode5E::Byte) (define bytecode5F::Byte)
(define bytecode60::Byte) (define bytecode61::Byte)
(define bytecode62::Byte) (define bytecode63::Byte)
(define bytecode64::Byte) (define bytecode65::Byte)
(define bytecode66::Byte) (define bytecode67::Byte)
(define bytecode68::Byte) (define bytecode69::Byte)
(define bytecode6A::Byte) (define bytecode6B::Byte)
(define bytecode6C::Byte) (define bytecode6D::Byte)
(define bytecode6E::Byte) (define bytecode6F::Byte)
(define bytecode70::Byte) (define bytecode71::Byte)
(define bytecode72::Byte) (define bytecode73::Byte)
(define bytecode74::Byte) (define bytecode75::Byte)
(define bytecode76::Byte) (define bytecode77::Byte)
(define bytecode78::Byte) (define bytecode79::Byte)
(define bytecode7A::Byte) (define bytecode7B::Byte)
(define bytecode7C::Byte) (define bytecode7D::Byte)
(define bytecode7E::Byte) (define bytecode7F::Byte)
(define bytecode80::Byte) (define bytecode81::Byte)
(define bytecode82::Byte) (define bytecode83::Byte)
(define bytecode84::Byte) (define bytecode85::Byte)
(define bytecode86::Byte) (define bytecode87::Byte)
(define bytecode88::Byte) (define bytecode89::Byte)
(define bytecode8A::Byte) (define bytecode8B::Byte)
(define bytecode8C::Byte) (define bytecode8D::Byte)
(define bytecode8E::Byte) (define bytecode8F::Byte)
(define bytecode90::Byte) (define bytecode91::Byte)
(define bytecode92::Byte) (define bytecode93::Byte)
(define bytecode94::Byte) (define bytecode95::Byte)
(define bytecode96::Byte) (define bytecode97::Byte)
(define bytecode98::Byte) (define bytecode99::Byte)
(define bytecode9A::Byte) (define bytecode9B::Byte)
(define bytecode9C::Byte) (define bytecode9D::Byte)
(define bytecode9E::Byte) (define bytecode9F::Byte)
(define bytecodeA0::Byte) (define bytecodeA1::Byte)
(define bytecodeA2::Byte) (define bytecodeA3::Byte)
(define bytecodeA4::Byte) (define bytecodeA5::Byte)
(define bytecodeA6::Byte) (define bytecodeA7::Byte)
(define bytecodeA8::Byte) (define bytecodeA9::Byte)
(define bytecodeAA::Byte) (define bytecodeAB::Byte)
(define bytecodeAC::Byte) (define bytecodeAD::Byte)
(define bytecodeAE::Byte) (define bytecodeAF::Byte)
(define bytecodeB0::Byte) (define bytecodeB1::Byte)
(define bytecodeB2::Byte) (define bytecodeB3::Byte)
(define bytecodeB4::Byte) (define bytecodeB5::Byte)
(define bytecodeB6::Byte) (define bytecodeB7::Byte)
(define bytecodeB8::Byte) (define bytecodeB9::Byte)
(define bytecodeBA::Byte) (define bytecodeBB::Byte)
(define bytecodeBC::Byte) (define bytecodeBD::Byte)
(define bytecodeBE::Byte) (define bytecodeBF::Byte)
(define bytecodeC0::Byte) (define bytecodeC1::Byte)
(define bytecodeC2::Byte) (define bytecodeC3::Byte)
(define bytecodeC4::Byte) (define bytecodeC5::Byte)
(define bytecodeC6::Byte) (define bytecodeC7::Byte)
(define bytecodeC8::Byte) (define bytecodeC9::Byte)
(define bytecodeCA::Byte) (define bytecodeCB::Byte)
(define bytecodeCC::Byte) (define bytecodeCD::Byte)
(define bytecodeCE::Byte) (define bytecodeCF::Byte)
(define bytecodeD0::Byte) (define bytecodeD1::Byte)
(define bytecodeD2::Byte) (define bytecodeD3::Byte)
(define bytecodeD4::Byte) (define bytecodeD5::Byte)
(define bytecodeD6::Byte) (define bytecodeD7::Byte)
(define bytecodeD8::Byte) (define bytecodeD9::Byte)
(define bytecodeDA::Byte) (define bytecodeDB::Byte)
(define bytecodeDC::Byte) (define bytecodeDD::Byte)
(define bytecodeDE::Byte) (define bytecodeDF::Byte)
(define bytecodeE0::Byte) (define bytecodeE1::Byte)
(define bytecodeE2::Byte) (define bytecodeE3::Byte)
(define bytecodeE4::Byte) (define bytecodeE5::Byte)
(define bytecodeE6::Byte) (define bytecodeE7::Byte)
(define bytecodeE8::Byte) (define bytecodeE9::Byte)
(define bytecodeEA::Byte) (define bytecodeEB::Byte)
(define bytecodeEC::Byte) (define bytecodeED::Byte)
(define bytecodeEE::Byte) (define bytecodeEF::Byte)
(define bytecodeF0::Byte) (define bytecodeF1::Byte)
(define bytecodeF2::Byte) (define bytecodeF3::Byte)
(define bytecodeF4::Byte) (define bytecodeF5::Byte)
(define bytecodeF6::Byte) (define bytecodeF7::Byte)
(define bytecodeF8::Byte) (define bytecodeF9::Byte)
(define bytecodeFA::Byte) (define bytecodeFB::Byte)
(define bytecodeFC::Byte) (define bytecodeFD::Byte)
(define bytecodeFE::Byte) (define bytecodeFF::Byte)
; Used instead of an array lookup. Pass in byte XX, get back the bytecodeXX
; variable.
(define get-byte::(-> Byte Byte)
(lambda (x::Byte)
(ite (= x 0x00) bytecode00
(ite (= x 0x01) bytecode01
(ite (= x 0x02) bytecode02
(ite (= x 0x03) bytecode03
(ite (= x 0x04) bytecode04
(ite (= x 0x05) bytecode05
(ite (= x 0x06) bytecode06
(ite (= x 0x07) bytecode07
(ite (= x 0x08) bytecode08
(ite (= x 0x09) bytecode09
(ite (= x 0x0A) bytecode0A
(ite (= x 0x0B) bytecode0B
(ite (= x 0x0C) bytecode0C
(ite (= x 0x0D) bytecode0D
(ite (= x 0x0E) bytecode0E
(ite (= x 0x0F) bytecode0F
(ite (= x 0x10) bytecode10
(ite (= x 0x11) bytecode11
(ite (= x 0x12) bytecode12
(ite (= x 0x13) bytecode13
(ite (= x 0x14) bytecode14
(ite (= x 0x15) bytecode15
(ite (= x 0x16) bytecode16
(ite (= x 0x17) bytecode17
(ite (= x 0x18) bytecode18
(ite (= x 0x19) bytecode19
(ite (= x 0x1A) bytecode1A
(ite (= x 0x1B) bytecode1B
(ite (= x 0x1C) bytecode1C
(ite (= x 0x1D) bytecode1D
(ite (= x 0x1E) bytecode1E
(ite (= x 0x1F) bytecode1F
(ite (= x 0x20) bytecode20
(ite (= x 0x21) bytecode21
(ite (= x 0x22) bytecode22
(ite (= x 0x23) bytecode23
(ite (= x 0x24) bytecode24
(ite (= x 0x25) bytecode25
(ite (= x 0x26) bytecode26
(ite (= x 0x27) bytecode27
(ite (= x 0x28) bytecode28
(ite (= x 0x29) bytecode29
(ite (= x 0x2A) bytecode2A
(ite (= x 0x2B) bytecode2B
(ite (= x 0x2C) bytecode2C
(ite (= x 0x2D) bytecode2D
(ite (= x 0x2E) bytecode2E
(ite (= x 0x2F) bytecode2F
(ite (= x 0x30) bytecode30
(ite (= x 0x31) bytecode31
(ite (= x 0x32) bytecode32
(ite (= x 0x33) bytecode33
(ite (= x 0x34) bytecode34
(ite (= x 0x35) bytecode35
(ite (= x 0x36) bytecode36
(ite (= x 0x37) bytecode37
(ite (= x 0x38) bytecode38
(ite (= x 0x39) bytecode39
(ite (= x 0x3A) bytecode3A
(ite (= x 0x3B) bytecode3B
(ite (= x 0x3C) bytecode3C
(ite (= x 0x3D) bytecode3D
(ite (= x 0x3E) bytecode3E
(ite (= x 0x3F) bytecode3F
(ite (= x 0x40) bytecode40
(ite (= x 0x41) bytecode41
(ite (= x 0x42) bytecode42
(ite (= x 0x43) bytecode43
(ite (= x 0x44) bytecode44
(ite (= x 0x45) bytecode45
(ite (= x 0x46) bytecode46
(ite (= x 0x47) bytecode47
(ite (= x 0x48) bytecode48
(ite (= x 0x49) bytecode49
(ite (= x 0x4A) bytecode4A
(ite (= x 0x4B) bytecode4B
(ite (= x 0x4C) bytecode4C
(ite (= x 0x4D) bytecode4D
(ite (= x 0x4E) bytecode4E
(ite (= x 0x4F) bytecode4F
(ite (= x 0x50) bytecode50
(ite (= x 0x51) bytecode51
(ite (= x 0x52) bytecode52
(ite (= x 0x53) bytecode53
(ite (= x 0x54) bytecode54
(ite (= x 0x55) bytecode55
(ite (= x 0x56) bytecode56
(ite (= x 0x57) bytecode57
(ite (= x 0x58) bytecode58
(ite (= x 0x59) bytecode59
(ite (= x 0x5A) bytecode5A
(ite (= x 0x5B) bytecode5B
(ite (= x 0x5C) bytecode5C
(ite (= x 0x5D) bytecode5D
(ite (= x 0x5E) bytecode5E
(ite (= x 0x5F) bytecode5F
(ite (= x 0x60) bytecode60
(ite (= x 0x61) bytecode61
(ite (= x 0x62) bytecode62
(ite (= x 0x63) bytecode63
(ite (= x 0x64) bytecode64
(ite (= x 0x65) bytecode65
(ite (= x 0x66) bytecode66
(ite (= x 0x67) bytecode67
(ite (= x 0x68) bytecode68
(ite (= x 0x69) bytecode69
(ite (= x 0x6A) bytecode6A
(ite (= x 0x6B) bytecode6B
(ite (= x 0x6C) bytecode6C
(ite (= x 0x6D) bytecode6D
(ite (= x 0x6E) bytecode6E
(ite (= x 0x6F) bytecode6F
(ite (= x 0x70) bytecode70
(ite (= x 0x71) bytecode71
(ite (= x 0x72) bytecode72
(ite (= x 0x73) bytecode73
(ite (= x 0x74) bytecode74
(ite (= x 0x75) bytecode75
(ite (= x 0x76) bytecode76
(ite (= x 0x77) bytecode77
(ite (= x 0x78) bytecode78
(ite (= x 0x79) bytecode79
(ite (= x 0x7A) bytecode7A
(ite (= x 0x7B) bytecode7B
(ite (= x 0x7C) bytecode7C
(ite (= x 0x7D) bytecode7D
(ite (= x 0x7E) bytecode7E
(ite (= x 0x7F) bytecode7F
(ite (= x 0x80) bytecode80
(ite (= x 0x81) bytecode81
(ite (= x 0x82) bytecode82
(ite (= x 0x83) bytecode83
(ite (= x 0x84) bytecode84
(ite (= x 0x85) bytecode85
(ite (= x 0x86) bytecode86
(ite (= x 0x87) bytecode87
(ite (= x 0x88) bytecode88
(ite (= x 0x89) bytecode89
(ite (= x 0x8A) bytecode8A
(ite (= x 0x8B) bytecode8B
(ite (= x 0x8C) bytecode8C
(ite (= x 0x8D) bytecode8D
(ite (= x 0x8E) bytecode8E
(ite (= x 0x8F) bytecode8F
(ite (= x 0x90) bytecode90
(ite (= x 0x91) bytecode91
(ite (= x 0x92) bytecode92
(ite (= x 0x93) bytecode93
(ite (= x 0x94) bytecode94
(ite (= x 0x95) bytecode95
(ite (= x 0x96) bytecode96
(ite (= x 0x97) bytecode97
(ite (= x 0x98) bytecode98
(ite (= x 0x99) bytecode99
(ite (= x 0x9A) bytecode9A
(ite (= x 0x9B) bytecode9B
(ite (= x 0x9C) bytecode9C
(ite (= x 0x9D) bytecode9D
(ite (= x 0x9E) bytecode9E
(ite (= x 0x9F) bytecode9F
(ite (= x 0xA0) bytecodeA0
(ite (= x 0xA1) bytecodeA1
(ite (= x 0xA2) bytecodeA2
(ite (= x 0xA3) bytecodeA3
(ite (= x 0xA4) bytecodeA4
(ite (= x 0xA5) bytecodeA5
(ite (= x 0xA6) bytecodeA6
(ite (= x 0xA7) bytecodeA7
(ite (= x 0xA8) bytecodeA8
(ite (= x 0xA9) bytecodeA9
(ite (= x 0xAA) bytecodeAA
(ite (= x 0xAB) bytecodeAB
(ite (= x 0xAC) bytecodeAC
(ite (= x 0xAD) bytecodeAD
(ite (= x 0xAE) bytecodeAE
(ite (= x 0xAF) bytecodeAF
(ite (= x 0xB0) bytecodeB0
(ite (= x 0xB1) bytecodeB1
(ite (= x 0xB2) bytecodeB2
(ite (= x 0xB3) bytecodeB3
(ite (= x 0xB4) bytecodeB4
(ite (= x 0xB5) bytecodeB5
(ite (= x 0xB6) bytecodeB6
(ite (= x 0xB7) bytecodeB7
(ite (= x 0xB8) bytecodeB8
(ite (= x 0xB9) bytecodeB9
(ite (= x 0xBA) bytecodeBA
(ite (= x 0xBB) bytecodeBB
(ite (= x 0xBC) bytecodeBC
(ite (= x 0xBD) bytecodeBD
(ite (= x 0xBE) bytecodeBE
(ite (= x 0xBF) bytecodeBF
(ite (= x 0xC0) bytecodeC0
(ite (= x 0xC1) bytecodeC1
(ite (= x 0xC2) bytecodeC2
(ite (= x 0xC3) bytecodeC3
(ite (= x 0xC4) bytecodeC4
(ite (= x 0xC5) bytecodeC5
(ite (= x 0xC6) bytecodeC6
(ite (= x 0xC7) bytecodeC7
(ite (= x 0xC8) bytecodeC8
(ite (= x 0xC9) bytecodeC9
(ite (= x 0xCA) bytecodeCA
(ite (= x 0xCB) bytecodeCB
(ite (= x 0xCC) bytecodeCC
(ite (= x 0xCD) bytecodeCD
(ite (= x 0xCE) bytecodeCE
(ite (= x 0xCF) bytecodeCF
(ite (= x 0xD0) bytecodeD0
(ite (= x 0xD1) bytecodeD1
(ite (= x 0xD2) bytecodeD2
(ite (= x 0xD3) bytecodeD3
(ite (= x 0xD4) bytecodeD4
(ite (= x 0xD5) bytecodeD5
(ite (= x 0xD6) bytecodeD6
(ite (= x 0xD7) bytecodeD7
(ite (= x 0xD8) bytecodeD8
(ite (= x 0xD9) bytecodeD9
(ite (= x 0xDA) bytecodeDA
(ite (= x 0xDB) bytecodeDB
(ite (= x 0xDC) bytecodeDC
(ite (= x 0xDD) bytecodeDD
(ite (= x 0xDE) bytecodeDE
(ite (= x 0xDF) bytecodeDF
(ite (= x 0xE0) bytecodeE0
(ite (= x 0xE1) bytecodeE1
(ite (= x 0xE2) bytecodeE2
(ite (= x 0xE3) bytecodeE3
(ite (= x 0xE4) bytecodeE4
(ite (= x 0xE5) bytecodeE5
(ite (= x 0xE6) bytecodeE6
(ite (= x 0xE7) bytecodeE7
(ite (= x 0xE8) bytecodeE8
(ite (= x 0xE9) bytecodeE9
(ite (= x 0xEA) bytecodeEA
(ite (= x 0xEB) bytecodeEB
(ite (= x 0xEC) bytecodeEC
(ite (= x 0xED) bytecodeED
(ite (= x 0xEE) bytecodeEE
(ite (= x 0xEF) bytecodeEF
(ite (= x 0xF0) bytecodeF0
(ite (= x 0xF1) bytecodeF1
(ite (= x 0xF2) bytecodeF2
(ite (= x 0xF3) bytecodeF3
(ite (= x 0xF4) bytecodeF4
(ite (= x 0xF5) bytecodeF5
(ite (= x 0xF6) bytecodeF6
(ite (= x 0xF7) bytecodeF7
(ite (= x 0xF8) bytecodeF8
(ite (= x 0xF9) bytecodeF9
(ite (= x 0xFA) bytecodeFA
(ite (= x 0xFB) bytecodeFB
(ite (= x 0xFC) bytecodeFC
(ite (= x 0xFD) bytecodeFD
(ite (= x 0xFE) bytecodeFE
(ite (= x 0xFF) bytecodeFF
bytecode04))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)
)
(define shellcode00::Byte) (define shellcode01::Byte)
(define shellcode02::Byte) (define shellcode03::Byte)
(define shellcode04::Byte) (define shellcode05::Byte)
(define shellcode06::Byte) (define shellcode07::Byte)
(define shellcode08::Byte) (define shellcode09::Byte)
(define shellcode0A::Byte) (define shellcode0B::Byte)
(define shellcode0C::Byte) (define shellcode0D::Byte)
(define shellcode0E::Byte) (define shellcode0F::Byte)
(define shellcode10::Byte) (define shellcode11::Byte)
(define shellcode12::Byte) (define shellcode13::Byte)
(define shellcode14::Byte) (define shellcode15::Byte)
(define shellcode16::Byte) (define shellcode17::Byte)
(define shellcode18::Byte) (define shellcode19::Byte)
(define shellcode1A::Byte) (define shellcode1B::Byte)
(define shellcode1C::Byte) (define shellcode1D::Byte)
(define shellcode1E::Byte) (define shellcode1F::Byte)
(define shellcode20::Byte) (define shellcode21::Byte)
(define shellcode22::Byte) (define shellcode23::Byte)
(define shellcode24::Byte) (define shellcode25::Byte)
(define shellcode26::Byte) (define shellcode27::Byte)
(define shellcode28::Byte) (define shellcode29::Byte)
(define shellcode2A::Byte) (define shellcode2B::Byte)
(define shellcode2C::Byte) (define shellcode2D::Byte)
(define shellcode2E::Byte) (define shellcode2F::Byte)
(define shellcode30::Byte) (define shellcode31::Byte)
(define shellcode32::Byte) (define shellcode33::Byte)
(define shellcode34::Byte) (define shellcode35::Byte)
(define shellcode36::Byte) (define shellcode37::Byte)
(define shellcode38::Byte) (define shellcode39::Byte)
(define shellcode3A::Byte) (define shellcode3B::Byte)
(define shellcode3C::Byte) (define shellcode3D::Byte)
(define shellcode3E::Byte) (define shellcode3F::Byte)
(define initialsc::(bitvector 512) (bv-concat shellcode3F shellcode3E shellcode3D shellcode3C shellcode3B shellcode3A shellcode39 shellcode38 shellcode37 shellcode36 shellcode35 shellcode34 shellcode33 shellcode32 shellcode31 shellcode30 shellcode2F shellcode2E shellcode2D shellcode2C shellcode2B shellcode2A shellcode29 shellcode28 shellcode27 shellcode26 shellcode25 shellcode24 shellcode23 shellcode22 shellcode21 shellcode20 shellcode1F shellcode1E shellcode1D shellcode1C shellcode1B shellcode1A shellcode19 shellcode18 shellcode17 shellcode16 shellcode15 shellcode14 shellcode13 shellcode12 shellcode11 shellcode10 shellcode0F shellcode0E shellcode0D shellcode0C shellcode0B shellcode0A shellcode09 shellcode08 shellcode07 shellcode06 shellcode05 shellcode04 shellcode03 shellcode02 shellcode01 shellcode00))
(define realscbyte00::Byte 0xA0)
(define realscbyte01::Byte 0x8C)
(define realscbyte02::Byte 0x1C)
(define realscbyte03::Byte 0x29)
(define realscbyte04::Byte 0xA1)
(define realscbyte05::Byte 0xCC)
(define realscbyte06::Byte 0x38)
(define realscbyte07::Byte 0xFD)
(define realscbyte08::Byte 0x8D)
(define realscbyte09::Byte 0xF4)
(define realscbyte0A::Byte 0x8E)
(define realscbyte0B::Byte 0x59)
(define realscbyte0C::Byte 0x86)
(define realscbyte0D::Byte 0xB7)
(define realscbyte0E::Byte 0xCA)
(define realscbyte0F::Byte 0xFF)
(define realscbyte10::Byte 0x33)
(define realscbyte11::Byte 0x29)
(define realscbyte12::Byte 0xD6)
(define realscbyte13::Byte 0xE3)
(define realscbyte14::Byte 0x6F)
(define realscbyte15::Byte 0x4B)
(define realscbyte16::Byte 0x19)
(define realscbyte17::Byte 0x71)
(define realscbyte18::Byte 0x5C)
(define realscbyte19::Byte 0xBB)
(define realscbyte1A::Byte 0x4E)
(define realscbyte1B::Byte 0x90)
(define realscbyte1C::Byte 0xC3)
(define realscbyte1D::Byte 0xF7)
(define realscbyte1E::Byte 0x41)
(define realscbyte1F::Byte 0x9E)
(define realscbyte20::Byte 0xA2)
(define realscbyte21::Byte 0x1C)
(define realscbyte22::Byte 0x22)
(define realscbyte23::Byte 0xBF)
(define realscbyte24::Byte 0x25)
(define realscbyte25::Byte 0x0F)
(define realscbyte26::Byte 0xFE)
(define realscbyte27::Byte 0xA6)
(define realscbyte28::Byte 0x81)
(define realscbyte29::Byte 0x10)
(define realscbyte2A::Byte 0x43)
(define realscbyte2B::Byte 0x38)
(define realscbyte2C::Byte 0x92)
(define realscbyte2D::Byte 0x95)
(define realscbyte2E::Byte 0x21)
(define realscbyte2F::Byte 0x2B)
(define realscbyte30::Byte 0xE3)
(define realscbyte31::Byte 0xA6)
(define realscbyte32::Byte 0xE9)
(define realscbyte33::Byte 0xAC)
(define realscbyte34::Byte 0x08)
(define realscbyte35::Byte 0x4D)
(define realscbyte36::Byte 0xBA)
(define realscbyte37::Byte 0x08)
(define realscbyte38::Byte 0x0B)
(define realscbyte39::Byte 0xAB)
(define realscbyte3A::Byte 0x22)
(define realscbyte3B::Byte 0x84)
(define realscbyte3C::Byte 0x6B)
(define realscbyte3D::Byte 0x1F)
(define realscbyte3E::Byte 0xAD)
(define realscbyte3F::Byte 0x05)
(define realsc::SCState (bv-concat realscbyte3F realscbyte3E realscbyte3D realscbyte3C realscbyte3B realscbyte3A realscbyte39 realscbyte38 realscbyte37 realscbyte36 realscbyte35 realscbyte34 realscbyte33 realscbyte32 realscbyte31 realscbyte30 realscbyte2F realscbyte2E realscbyte2D realscbyte2C realscbyte2B realscbyte2A realscbyte29 realscbyte28 realscbyte27 realscbyte26 realscbyte25 realscbyte24 realscbyte23 realscbyte22 realscbyte21 realscbyte20 realscbyte1F realscbyte1E realscbyte1D realscbyte1C realscbyte1B realscbyte1A realscbyte19 realscbyte18 realscbyte17 realscbyte16 realscbyte15 realscbyte14 realscbyte13 realscbyte12 realscbyte11 realscbyte10 realscbyte0F realscbyte0E realscbyte0D realscbyte0C realscbyte0B realscbyte0A realscbyte09 realscbyte08 realscbyte07 realscbyte06 realscbyte05 realscbyte04 realscbyte03 realscbyte02 realscbyte01 realscbyte00))
(define getrealscbyte::(-> Byte Byte)
(lambda (idx::Byte)
(ite (= idx 0x00) realscbyte00
(ite (= idx 0x01) realscbyte01
(ite (= idx 0x02) realscbyte02
(ite (= idx 0x03) realscbyte03
(ite (= idx 0x04) realscbyte04
(ite (= idx 0x05) realscbyte05
(ite (= idx 0x06) realscbyte06
(ite (= idx 0x07) realscbyte07
(ite (= idx 0x08) realscbyte08
(ite (= idx 0x09) realscbyte09
(ite (= idx 0x0A) realscbyte0A
(ite (= idx 0x0B) realscbyte0B
(ite (= idx 0x0C) realscbyte0C
(ite (= idx 0x0D) realscbyte0D
(ite (= idx 0x0E) realscbyte0E
(ite (= idx 0x0F) realscbyte0F
(ite (= idx 0x10) realscbyte10
(ite (= idx 0x11) realscbyte11
(ite (= idx 0x12) realscbyte12
(ite (= idx 0x13) realscbyte13
(ite (= idx 0x14) realscbyte14
(ite (= idx 0x15) realscbyte15
(ite (= idx 0x16) realscbyte16
(ite (= idx 0x17) realscbyte17
(ite (= idx 0x18) realscbyte18
(ite (= idx 0x19) realscbyte19
(ite (= idx 0x1A) realscbyte1A
(ite (= idx 0x1B) realscbyte1B
(ite (= idx 0x1C) realscbyte1C
(ite (= idx 0x1D) realscbyte1D
(ite (= idx 0x1E) realscbyte1E
(ite (= idx 0x1F) realscbyte1F
(ite (= idx 0x20) realscbyte20
(ite (= idx 0x21) realscbyte21
(ite (= idx 0x22) realscbyte22
(ite (= idx 0x23) realscbyte23
(ite (= idx 0x24) realscbyte24
(ite (= idx 0x25) realscbyte25
(ite (= idx 0x26) realscbyte26
(ite (= idx 0x27) realscbyte27
(ite (= idx 0x28) realscbyte28
(ite (= idx 0x29) realscbyte29
(ite (= idx 0x2A) realscbyte2A
(ite (= idx 0x2B) realscbyte2B
(ite (= idx 0x2C) realscbyte2C
(ite (= idx 0x2D) realscbyte2D
(ite (= idx 0x2E) realscbyte2E
(ite (= idx 0x2F) realscbyte2F
(ite (= idx 0x30) realscbyte30
(ite (= idx 0x31) realscbyte31
(ite (= idx 0x32) realscbyte32
(ite (= idx 0x33) realscbyte33
(ite (= idx 0x34) realscbyte34
(ite (= idx 0x35) realscbyte35
(ite (= idx 0x36) realscbyte36
(ite (= idx 0x37) realscbyte37
(ite (= idx 0x38) realscbyte38
(ite (= idx 0x39) realscbyte39
(ite (= idx 0x3A) realscbyte3A
(ite (= idx 0x3B) realscbyte3B
(ite (= idx 0x3C) realscbyte3C
(ite (= idx 0x3D) realscbyte3D
(ite (= idx 0x3E) realscbyte3E
realscbyte3F
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))
)
; (define getrealscbyte::(-> Byte Byte)
; (lambda (idx::Byte)
; (let ((shiftamtone (bv-concat (bv-repeat 0x00 63) idx)))
; (let ((shiftamttwo (bv-concat (bv-repeat 0x00 63) 0x03)))
; (let ((shiftamt (bv-shl shiftamtone shiftamttwo)))
; (bv-extract 7 0 (bv-lshr realsc shiftamt))
; )))
; )
; )
(define compare-multiple-sc-bytes::(-> SCState SCState Byte bool)
(lambda (sc1::SCState sc2::SCState num::Byte)
(let ((shiftamtone (bv-concat (bv-repeat 0x00 63) (bv-sub 0x40 num))))
(let ((shiftamttwo (bv-concat (bv-repeat 0x00 63) 0x03)))
(let ((shiftamt (bv-shl shiftamtone shiftamttwo)))
(= (bv-shl sc1 shiftamt) (bv-shl sc2 shiftamt))
)))
)
)
(define compare-sc-bytes::(-> SCState SCState Byte bool)
(lambda (sc1::SCState sc2::SCState num::Byte)
(let ((shiftamtone (bv-concat (bv-repeat 0x00 63) num)))
(let ((shiftamttwo (bv-concat (bv-repeat 0x00 63) 0x03)))
(let ((shiftamt (bv-shl shiftamtone shiftamttwo)))
(= (bv-extract 7 0 (bv-lshr sc1 shiftamt)) (bv-extract 7 0 (bv-lshr sc2 shiftamt)))
)))
)
)
(define finalize-normal-decode::(-> Byte Mnem RegIdx RegIdx Dword Byte DecodedInstruction)
(lambda (eip::Byte mnem::Mnem lhs::RegIdx rhs::RegIdx imm32::Dword length::Byte)
(bv-concat (bv-add eip length) length 0b0 0b1 imm32 rhs lhs mnem)
)
)
(define finalize-conditional-jump::(-> Byte Mnem RegIdx Byte DecodedInstruction)
(lambda (nexteip::Byte mnem::Mnem lhs::RegIdx length::Byte)
(bv-concat nexteip length 0b1 (mk-label-pred nexteip) 0x00000000 0b000 lhs mnem)
)
)
(define decode-insn::(-> (-> Byte Byte) Byte DecodedInstruction)
(lambda (f-get-byte::(-> Byte Byte) eip::Byte)
(let ((byte0 (f-get-byte eip)))
(let ((byte1 (f-get-byte (bv-add 0x01 eip))))
(let ((byte2 (f-get-byte (bv-add 0x02 eip))))
(let ((byte3 (f-get-byte (bv-add 0x03 eip))))
(let ((byte4 (f-get-byte (bv-add 0x04 eip))))
(let ((eip-plus-one (bv-add eip 0x01)))
(let ((eip-plus-two (bv-add eip 0x02)))
(let ((eip-plus-five (bv-add eip 0x05)))
(let ((lhsreg0 (bv-extract 5 3 byte0)))
(let ((rhsreg0 (bv-extract 2 0 byte0)))
; xor reg, reg
(ite (= (bv-and byte0 0xC0) 0x00)