forked from starcasters/protowatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotow.cc
1201 lines (949 loc) · 37 KB
/
protow.cc
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
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include "protow.h"
//#define EASYINJECTION
#define TEXTFILE_OUTPUT
int tlsIndex;
int __stdcall func2() {
if (TlsGetValue(tlsIndex) == 0) {
TlsSetValue(tlsIndex, (void*)((int)TlsGetValue(tlsIndex) + 1));
return 1;
}
return 0;
}
void __stdcall func3() {
TlsSetValue(tlsIndex, (void*)((int)TlsGetValue(tlsIndex) - 1));
}
//unsigned int D3__std__String = 0x3CE4A528;
unsigned int D3__std__String_delete = 0;
unsigned int D3__TextFormat__PrintToString = 0;
unsigned int D3__Descriptor__full_name = 0;
unsigned int D3__Message__GetDescriptor = 0;
unsigned int recvheader_entry = 0;
unsigned int recvheader_return = 0;
unsigned int sendheader_entry = 0;
unsigned int sendheader_return = 0;
unsigned int send_message_entry = 0;
unsigned int send_message_return = 0;
unsigned int send_message_entry1 = 0;
unsigned int send_message_return1 = 0;
unsigned int send_message_entry2 = 0;
unsigned int send_message_return2 = 0;
unsigned int message_parse_hook = 0;
unsigned int message_parse_return = 0;
unsigned int deserialize_message = 0;
#define REBASE(lib, var, addr, oldbase) var = lib + addr - oldbase;
/* 0.3
void RebaseFunctions()
{
unsigned int bnetlib = (unsigned int) GetModuleHandle("battle.net.dll");
REBASE(bnetlib, D3__std__String, 0x3CE4B234, 0x3C910000)
REBASE(bnetlib, D3__TextFormat__PrintToString, 0x3CB4E280, 0x3C910000)
REBASE(bnetlib, D3__Message__GetDescriptor, 0x3CAEB630, 0x3C910000)
REBASE(bnetlib, D3__Descriptor__full_name, 0x3C9E0220, 0x3C910000)
REBASE(bnetlib, hook_return, 0x3CAD8894, 0x3C910000)
//.text:3CD1D094 mov edx, [ecx]
//.text:3CD1D096 mov edx, [edx+28h]
//.text:3CD1D099 lea eax, [edi+ebx]
//.text:3CD1D09C push eax
//.text:3CD1D09D call edx
REBASE(bnetlib, outputhook_return, 0x3CD1C1D4, 0x3C910000)
REBASE(bnetlib, outputhead_return, 0x3CD03639, 0x3C910000)
REBASE(bnetliv, outputhead, 0x3CD1D094, 0x3C910000)
REBASE(bnetliv, message_parse_hook, 0x3CAD955C, 0x3C910000)
0x3CD0362C // recv header
}
*/
/* 0.3.4774
void RebaseFunctions()
{
unsigned int bnetlib = (unsigned int) GetModuleHandle("battle.net.dll");
// REBASE(bnetlib, D3__std__String, 0x3CE4B258, 0x3C910000)
REBASE(bnetlib, D3__std__String_delete, 0x3CE4B550, 0x3C910000)
REBASE(bnetlib, D3__TextFormat__PrintToString, 0x3CB4EF60, 0x3C910000)
REBASE(bnetlib, D3__Message__GetDescriptor, 0x3CAEC320, 0x3C910000)
REBASE(bnetlib, D3__Descriptor__full_name, 0x3C9AD830, 0x3C910000)
REBASE(bnetlib, message_parse_hook, 0x3CAD955C, 0x3C910000)
REBASE(bnetlib, message_parse_return, 0x3CAD9564, 0x3C910000)
//.text:3CD045BC mov cl, [ebp-2C4h]
//.text:3CD045C2 movzx ebx, word ptr [ebp-2BCh]
//.text:3CD045C9 cmp cl, 0FEh
REBASE(bnetlib, recvheader_entry, 0x3CD045BC, 0x3C910000)
REBASE(bnetlib, recvheader_return, 0x3CD045C9, 0x3C910000)
//.text:3CD1D094 mov edx, [ecx]
//.text:3CD1D096 mov edx, [edx+28h]
//.text:3CD1D099 lea eax, [edi+ebx]
//.text:3CD1D09C push eax
REBASE(bnetlib, send_message_entry, 0x3CD1D094, 0x3C910000)
REBASE(bnetlib, send_message_return, 0x3CD1D09C, 0x3C910000)
}
*/
/* v 0.3.7728
void RebaseFunctions()
{
unsigned int bnetlib = (unsigned int) GetModuleHandle("battle.net.dll");
// REBASE(bnetlib, D3__std__String, 0x3CE4B258, 0x3C910000)
REBASE(bnetlib, D3__std__String_delete, 0x3CE84610, 0x3C910000)
REBASE(bnetlib, D3__TextFormat__PrintToString, 0x3CBF31A0, 0x3C910000)
REBASE(bnetlib, D3__Message__GetDescriptor, 0x3CB90900, 0x3C910000)
REBASE(bnetlib, D3__Descriptor__full_name, 0x3CB8D7A0, 0x3C910000)
//.text:3CB7DB3C mov edx, [eax+10h]
//.text:3CB7DB3F call edx
//.text:3CB7DB41 movzx eax, al
REBASE(bnetlib, message_parse_hook, 0x3CB7DB3C, 0x3C910000)
REBASE(bnetlib, message_parse_return, 0x3CB7DB44, 0x3C910000)
//.text:3CD045BC mov cl, [ebp-2C4h]
//.text:3CD045C2 movzx ebx, word ptr [ebp-2BCh]
//.text:3CD045C9 cmp cl, 0FEh
//.text:3CD354CE mov cl, [ebp-2FCh]
//.text:3CD354D4 movzx ebx, word ptr [ebp-2F4h]
//.text:3CD354DB cmp cl, 0FEh
REBASE(bnetlib, recvheader_entry, 0x3CD354CE, 0x3C910000)
REBASE(bnetlib, recvheader_return, 0x3CD354DB, 0x3C910000)
//.text:3CD1D094 mov edx, [ecx]
//.text:3CD1D096 mov edx, [edx+28h]
//.text:3CD1D099 lea eax, [edi+ebx]
//.text:3CD1D09C push eax
//.text:3CD4DBBE mov eax, [edx+28h]
//.text:3CD4DBC1 mov ecx, esi
//.text:3CD4DBC3 call eax
//.text:3CD4DBC5 pop edi
REBASE(bnetlib, sendheader_entry, 0x3CD4DBBE, 0x3C910000)
REBASE(bnetlib, sendheader_return, 0x3CD4DBC5, 0x3C910000)
//.text:3CD4EE90 lea ecx, [edi+ebx]
//.text:3CD4EE93 push ecx
//.text:3CD4EE94 mov ecx, eax
//.text:3CD4EE96 call edx
REBASE(bnetlib, send_message_entry, 0x3CD4EE90, 0x3C910000)
REBASE(bnetlib, send_message_return, 0x3CD4EE96, 0x3C910000)
}
*/
/* v 0.4.7841
void RebaseFunctions()
{
unsigned int bnetlib = (unsigned int) GetModuleHandle("battle.net.dll");
// REBASE(bnetlib, D3__std__String, 0x3CE4B258, 0x3C910000)
REBASE(bnetlib, D3__std__String_delete, 0x3CED4618, 0x3C910000)
REBASE(bnetlib, D3__TextFormat__PrintToString, 0x3cc16700, 0x3C910000)
REBASE(bnetlib, D3__Message__GetDescriptor, 0x3CBB3FF0, 0x3C910000)
REBASE(bnetlib, D3__Descriptor__full_name, 0x3CBB0E90, 0x3C910000)
//.text:3CBA121C >>> mov edx, [eax+10h]
//.text:3CBA121F call edx
//.text:3CBA1221 movzx eax, al
//.text:3CBA1224 <<< test eax, eax
//3ced4618
//3cc16700
REBASE(bnetlib, message_parse_hook, 0x3CBA121C, 0x3C910000)
REBASE(bnetlib, message_parse_return, 0x3CBA1224, 0x3C910000)
//.text:3CD045BC mov cl, [ebp-2C4h]
//.text:3CD045C2 movzx ebx, word ptr [ebp-2BCh]
//.text:3CD045C9 cmp cl, 0FEh
//.text:3CD354CE mov cl, [ebp-2FCh]
//.text:3CD354D4 movzx ebx, word ptr [ebp-2F4h]
//.text:3CD354DB cmp cl, 0FEh
//.text:3CBA14B4 call deserialize_message
//.text:3CBA14B9 add esp, 8
//.text:3CBA14BC movzx ecx, al
REBASE(bnetlib, deserialize_message, 0x3CBA12F0, 0x3C910000)
REBASE(bnetlib, recvheader_entry, 0x3CBA14B4, 0x3C910000)
REBASE(bnetlib, recvheader_return, 0x3CBA14BC, 0x3C910000)
//.text:3CD92D0E mov eax, [edx+28h]
//.text:3CD92D11 mov ecx, esi
//.text:3CD92D13 call eax
//.text:3CD92D15 pop edi
REBASE(bnetlib, sendheader_entry, 0x3CD92D0E, 0x3C910000)
REBASE(bnetlib, sendheader_return, 0x3CD92D15, 0x3C910000)
//.text:3CD93FE0 lea ecx, [edi+ebx]
//.text:3CD93FE3 push ecx
//.text:3CD93FE4 mov ecx, eax
//.text:3CD93FE6 call edx
REBASE(bnetlib, send_message_entry, 0x3CD93FE0, 0x3C910000)
REBASE(bnetlib, send_message_return, 0x3CD93FE6, 0x3C910000)
//.text:3CD7A468 mov edx, [eax+28h]
//.text:3CD7A46B add ecx, ebx
//.text:3CD7A46D push ecx
//.text:3CD7A46E mov ecx, edi
REBASE(bnetlib, send_message_entry1, 0x3CD7A468, 0x3C910000)
REBASE(bnetlib, send_message_return1, 0x3CD7A46E, 0x3C910000)
//.text:3CD8311C lea ecx, [ebx+edi]
//.text:3CD8311F push ecx
//.text:3CD83120 mov ecx, eax
//.text:3CD83122 call edx
REBASE(bnetlib, send_message_entry2, 0x3CD8311C, 0x3C910000)
REBASE(bnetlib, send_message_return2, 0x3CD83122, 0x3C910000)
}
*/
/* v 0.5.1.8101
void RebaseFunctions()
{
unsigned int bnetlib = (unsigned int) GetModuleHandle("battle.net.dll");
// REBASE(bnetlib, D3__std__String, 0x3CE4B258, 0x3C910000)
//3CED4618
REBASE(bnetlib, D3__std__String_delete, 0x3CEAB618, 0x3C910000)
REBASE(bnetlib, D3__TextFormat__PrintToString, 0x3CB7FD30, 0x3C910000)
REBASE(bnetlib, D3__Message__GetDescriptor, 0x3CB803B0, 0x3C910000)
REBASE(bnetlib, D3__Descriptor__full_name, 0x3CB807B0, 0x3C910000)
REBASE(bnetlib, deserialize_message, 0x3CB9C1C0, 0x3C910000)
//.text:3CBA121C >>> mov edx, [eax+10h]
//.text:3CBA121F call edx
//.text:3CBA1221 movzx eax, al
//.text:3CBA1224 <<< test eax, eax
//.text:3CB9C0EC >>> mov edx, [eax+10h]
//.text:3CB9C0EF call edx
//.text:3CB9C0F1 movzx eax, al
//.text:3CB9C0F4 <<< test eax, eax
REBASE(bnetlib, message_parse_hook, 0x3CB9C0EC, 0x3C910000)
REBASE(bnetlib, message_parse_return, 0x3CB9C0F4, 0x3C910000)
//.text:3CBA14B4 call deserialize_message
//.text:3CBA14B9 add esp, 8
//.text:3CBA14BC movzx ecx, al
//.text:3CB9C384 call deserialize_message
//.text:3CB9C389 add esp, 8
//.text:3CB9C38C movzx ecx, al
REBASE(bnetlib, recvheader_entry, 0x3CB9C384, 0x3C910000)
REBASE(bnetlib, recvheader_return, 0x3CB9C38C, 0x3C910000)
//.text:3CD92D0E mov eax, [edx+28h]
//.text:3CD92D11 mov ecx, esi
//.text:3CD92D13 call eax
//.text:3CD92D15 pop edi
//.text:3CD7C14E mov eax, [edx+28h]
//.text:3CD7C151 mov ecx, esi
//.text:3CD7C153 call eax
//.text:3CD7C155 pop edi
REBASE(bnetlib, sendheader_entry, 0x3CD7C14E, 0x3C910000)
REBASE(bnetlib, sendheader_return, 0x3CD7C155, 0x3C910000)
//.text:3CD93FE0 lea ecx, [edi+ebx]
//.text:3CD93FE3 push ecx
//.text:3CD93FE4 mov ecx, eax
//.text:3CD93FE6 call edx
//.text:3CD7D47B lea ecx, [edi+ebx]
//.text:3CD7D47E push ecx
//.text:3CD7D47F mov ecx, eax
//.text:3CD7D481 call edx
REBASE(bnetlib, send_message_entry, 0x3CD7D47B, 0x3C910000)
REBASE(bnetlib, send_message_return, 0x3CD7D481, 0x3C910000)
//.text:3CD7A468 mov edx, [eax+28h]
//.text:3CD7A46B add ecx, ebx
//.text:3CD7A46D push ecx
//.text:3CD7A46E mov ecx, edi
//.text:3CD617C8 mov edx, [eax+28h]
//.text:3CD617CB add ecx, ebx
//.text:3CD617CD push ecx
//.text:3CD617CE mov ecx, edi
REBASE(bnetlib, send_message_entry1, 0x3CD617C8, 0x3C910000)
REBASE(bnetlib, send_message_return1, 0x3CD617CE, 0x3C910000)
//.text:3CD8311C lea ecx, [ebx+edi]
//.text:3CD8311F push ecx
//.text:3CD83120 mov ecx, eax
//.text:3CD83122 call edx
//.text:3CD6C703 lea ecx, [ebx+edi]
//.text:3CD6C706 push ecx
//.text:3CD6C707 mov ecx, eax
//.text:3CD6C709 call edx
REBASE(bnetlib, send_message_entry2, 0x3CD6C703, 0x3C910000)
REBASE(bnetlib, send_message_return2, 0x3CD6C709, 0x3C910000)
}
*/
/* v 0.6.0.8296
void RebaseFunctions()
{
unsigned int bnetlib = (unsigned int) GetModuleHandle("battle.net.dll");
// REBASE(bnetlib, D3__std__String, 0x3CE4B258, 0x3C910000)
//3CED4618
REBASE(bnetlib, D3__std__String_delete, 0x3CECA62C, 0x3C910000)
REBASE(bnetlib, D3__TextFormat__PrintToString, 0x3CB8BBB0, 0x3C910000)
REBASE(bnetlib, D3__Message__GetDescriptor, 0x3CB8C230, 0x3C910000)
REBASE(bnetlib, D3__Descriptor__full_name, 0x3CB8C630, 0x3C910000)
REBASE(bnetlib, deserialize_message, 0x3CBA8010, 0x3C910000)
//UPDATED
//.text:3CB9C0EC >>> mov edx, [eax+10h]
//.text:3CB9C0EF call edx
//.text:3CB9C0F1 movzx eax, al
//.text:3CB9C0F4 <<< test eax, eax
//.text:3CBA7F3C mov edx, [eax+10h]
//.text:3CBA7F3F call edx
//.text:3CBA7F41 movzx eax, al
//.text:3CBA7F44 test eax, eax
REBASE(bnetlib, message_parse_hook, 0x3CBA7F3C, 0x3C910000)
REBASE(bnetlib, message_parse_return, 0x3CBA7F44, 0x3C910000)
//UPDATED
//.text:3CBA81D4 call deserialize_message
//.text:3CBA81D9 add esp, 8
//.text:3CBA81DC movzx ecx, al
REBASE(bnetlib, recvheader_entry, 0x3CBA81D4, 0x3C910000)
REBASE(bnetlib, recvheader_return, 0x3CBA81DC, 0x3C910000)
//UPDATED
//.text:3CD96E9E mov eax, [edx+28h]
//.text:3CD96EA1 mov ecx, esi
//.text:3CD96EA3 call eax
//.text:3CD96EA5 pop edi
REBASE(bnetlib, sendheader_entry, 0x3CD96E9E, 0x3C910000)
REBASE(bnetlib, sendheader_return, 0x3CD96EA5, 0x3C910000)
//updated
//.text:3CD981CB lea ecx, [edi+ebx]
//.text:3CD981CE push ecx
//.text:3CD981CF mov ecx, eax
//.text:3CD981D1 call edx
REBASE(bnetlib, send_message_entry, 0x3CD981CB, 0x3C910000)
REBASE(bnetlib, send_message_return, 0x3CD981D1, 0x3C910000)
//updated
//.text:3CD5F539 mov edx, [eax+28h]
//.text:3CD5F53C add ecx, ebx
//.text:3CD5F53E push ecx
//.text:3CD5F53F mov ecx, edi
REBASE(bnetlib, send_message_entry1, 0x3CD5F539, 0x3C910000)
REBASE(bnetlib, send_message_return1, 0x3CD5F53F, 0x3C910000)
//updated
//.text:3CD87453 lea ecx, [ebx+edi]
//.text:3CD87456 push ecx
//.text:3CD87457 mov ecx, eax
//.text:3CD87459 call edx
REBASE(bnetlib, send_message_entry2, 0x3CD87453, 0x3C910000)
REBASE(bnetlib, send_message_return2, 0x3CD87459, 0x3C910000)
}
*/
/* v 0.6.0.8392
void RebaseFunctions()
{
unsigned int bnetlib = (unsigned int) GetModuleHandle("battle.net.dll");
// REBASE(bnetlib, D3__std__String, 0x3CE4B258, 0x3C910000)
//3CED4618
REBASE(bnetlib, D3__std__String_delete, 0x3CECA62C, 0x3C910000)
REBASE(bnetlib, D3__TextFormat__PrintToString, 0x3CB8BBB0, 0x3C910000)
REBASE(bnetlib, D3__Message__GetDescriptor, 0x3CB8C230, 0x3C910000)
REBASE(bnetlib, D3__Descriptor__full_name, 0x3CB8C630, 0x3C910000)
REBASE(bnetlib, deserialize_message, 0x3CBA8010, 0x3C910000)
//UPDATED
//.text:3CB9C0EC >>> mov edx, [eax+10h]
//.text:3CB9C0EF call edx
//.text:3CB9C0F1 movzx eax, al
//.text:3CB9C0F4 <<< test eax, eax
//.text:3CBA7F3C mov edx, [eax+10h]
//.text:3CBA7F3F call edx
//.text:3CBA7F41 movzx eax, al
//.text:3CBA7F44 test eax, eax
REBASE(bnetlib, message_parse_hook, 0x3CBA7F3C, 0x3C910000)
REBASE(bnetlib, message_parse_return, 0x3CBA7F44, 0x3C910000)
//UPDATED
//.text:3CBA81D4 call deserialize_message
//.text:3CBA81D9 add esp, 8
//.text:3CBA81DC movzx ecx, al
REBASE(bnetlib, recvheader_entry, 0x3CBA81D4, 0x3C910000)
REBASE(bnetlib, recvheader_return, 0x3CBA81DC, 0x3C910000)
//UPDATED
//.text:3CD96E9E mov eax, [edx+28h]
//.text:3CD96EA1 mov ecx, esi
//.text:3CD96EA3 call eax
//.text:3CD96EA5 pop edi
REBASE(bnetlib, sendheader_entry, 0x3CD96E9E, 0x3C910000)
REBASE(bnetlib, sendheader_return, 0x3CD96EA5, 0x3C910000)
//updated
//.text:3CD981CB lea ecx, [edi+ebx]
//.text:3CD981CE push ecx
//.text:3CD981CF mov ecx, eax
//.text:3CD981D1 call edx
REBASE(bnetlib, send_message_entry, 0x3CD981CB, 0x3C910000)
REBASE(bnetlib, send_message_return, 0x3CD981D1, 0x3C910000)
//updated
//.text:3CD5F539 mov edx, [eax+28h]
//.text:3CD5F53C add ecx, ebx
//.text:3CD5F53E push ecx
//.text:3CD5F53F mov ecx, edi
REBASE(bnetlib, send_message_entry1, 0x3CD5F539, 0x3C910000)
REBASE(bnetlib, send_message_return1, 0x3CD5F53F, 0x3C910000)
//updated
//.text:3CD87453 lea ecx, [ebx+edi]
//.text:3CD87456 push ecx
//.text:3CD87457 mov ecx, eax
//.text:3CD87459 call edx
REBASE(bnetlib, send_message_entry2, 0x3CD87453, 0x3C910000)
REBASE(bnetlib, send_message_return2, 0x3CD87459, 0x3C910000)
}
*/
/* v 0.6.0.8610
void RebaseFunctions()
{
unsigned int bnetlib = (unsigned int) GetModuleHandle("battle.net.dll");
// REBASE(bnetlib, D3__std__String, 0x3CE4B258, 0x3C910000)
//3CED4618
REBASE(bnetlib, D3__std__String_delete, 0x3CEB1688, 0x3C910000)
REBASE(bnetlib, D3__TextFormat__PrintToString, 0x3CB863F0, 0x3C910000)
REBASE(bnetlib, D3__Message__GetDescriptor, 0x3CB86A70, 0x3C910000)
REBASE(bnetlib, D3__Descriptor__full_name, 0x3CB86E70, 0x3C910000)
REBASE(bnetlib, deserialize_message, 0x3CBA28B0, 0x3C910000)
//UPDATED
//.text:3CBA7F3C mov edx, [eax+10h]
//.text:3CBA7F3F call edx
//.text:3CBA7F41 movzx eax, al
//.text:3CBA7F44 test eax, eax
//.text:3CBA27DC mov edx, [eax+10h]
//.text:3CBA27DF call edx
//.text:3CBA27E1 movzx eax, al
//.text:3CBA27E4 test eax, eax
REBASE(bnetlib, message_parse_hook, 0x3CBA27DC, 0x3C910000)
REBASE(bnetlib, message_parse_return, 0x3CBA27E4, 0x3C910000)
//UPDATED
//.text:3CBA81D4 call deserialize_message
//.text:3CBA81D9 add esp, 8
//.text:3CBA81DC movzx ecx, al
//.text:3CBA2A74 call deserialize_message
//.text:3CBA2A79 add esp, 8
//.text:3CBA2A7C movzx ecx, al
REBASE(bnetlib, recvheader_entry, 0x3CBA2A74, 0x3C910000)
REBASE(bnetlib, recvheader_return, 0x3CBA2A7C, 0x3C910000)
//UPDATED
//.text:3CD96E9E mov eax, [edx+28h]
//.text:3CD96EA1 mov ecx, esi
//.text:3CD96EA3 call eax
//.text:3CD96EA5 pop edi
//.text:3CD7B74E mov eax, [edx+28h]
//.text:3CD7B751 mov ecx, esi
//.text:3CD7B753 call eax
//.text:3CD7B755 pop edi
REBASE(bnetlib, sendheader_entry, 0x3CD7B74E, 0x3C910000)
REBASE(bnetlib, sendheader_return, 0x3CD7B755, 0x3C910000)
//updated
//.text:3CD981CB lea ecx, [edi+ebx]
//.text:3CD981CE push ecx
//.text:3CD981CF mov ecx, eax
//.text:3CD981D1 call edx
//.text:3CD7CA7C lea ecx, [edi+ebx]
//.text:3CD7CA7F push ecx
//.text:3CD7CA80 mov ecx, eax
//.text:3CD7CA82 call edx
REBASE(bnetlib, send_message_entry, 0x3CD7CA7C, 0x3C910000)
REBASE(bnetlib, send_message_return, 0x3CD7CA82, 0x3C910000)
//updated
//.text:3CD5F539 mov edx, [eax+28h]
//.text:3CD5F53C add ecx, ebx
//.text:3CD5F53E push ecx
//.text:3CD5F53F mov ecx, edi
REBASE(bnetlib, send_message_entry1, 0x3CD5F539, 0x3C910000)
REBASE(bnetlib, send_message_return1, 0x3CD5F53F, 0x3C910000)
//updated
//.text:3CD87453 lea ecx, [ebx+edi]
//.text:3CD87456 push ecx
//.text:3CD87457 mov ecx, eax
//.text:3CD87459 call edx
//.text:3CD6B74D lea ecx, [ebx+edi]
//.text:3CD6B750 push ecx
//.text:3CD6B751 mov ecx, eax
//.text:3CD6B753 call edx
REBASE(bnetlib, send_message_entry2, 0x3CD6B74D, 0x3C910000)
REBASE(bnetlib, send_message_return2, 0x3CD6B753, 0x3C910000)
}
*/
/* v 0.8.0.8860 */
void RebaseFunctions()
{
unsigned int bnetlib = (unsigned int) GetModuleHandle("battle.net.dll");
// REBASE(bnetlib, D3__std__String, 0x3CE4B258, 0x3C910000)
//3CED4618
REBASE(bnetlib, D3__std__String_delete, 0x3CE8669C, 0x3C910000)
REBASE(bnetlib, D3__TextFormat__PrintToString, 0x3CB68FB0, 0x3C910000)
REBASE(bnetlib, D3__Message__GetDescriptor, 0x3CB69630, 0x3C910000)
REBASE(bnetlib, D3__Descriptor__full_name, 0x3CB69A30, 0x3C910000)
REBASE(bnetlib, deserialize_message, 0x3CB85480, 0x3C910000)
//.text:3CBA27DC mov edx, [eax+10h]
//.text:3CBA27DF call edx
//.text:3CBA27E1 movzx eax, al
//.text:3CBA27E4 test eax, eax
//.text:3CBA295C mov edx, [eax+10h]
//.text:3CBA295F call edx
//.text:3CBA2961 movzx eax, al
//.text:3CBA2964 test eax, eax
//.text:3CB853AC mov edx, [eax+10h]
//.text:3CB853AF call edx
//.text:3CB853B1 movzx eax, al
//.text:3CB853B4 test eax, eax
REBASE(bnetlib, message_parse_hook, 0x3CB853AC, 0x3C910000)
REBASE(bnetlib, message_parse_return, 0x3CB853B4, 0x3C910000)
//.text:3CBA2A74 call deserialize_message
//.text:3CBA2A79 add esp, 8
//.text:3CBA2A7C movzx ecx, al
//.text:3CBA2BF4 call D3__DeserializeMessage
//.text:3CBA2BF9 add esp, 8
//.text:3CBA2BFC movzx ecx, al
//.text:3CB85644 call D3__DeserializeMessage
//.text:3CB85649 add esp, 8
//.text:3CB8564C movzx ecx, al
REBASE(bnetlib, recvheader_entry, 0x3CB85644, 0x3C910000)
REBASE(bnetlib, recvheader_return, 0x3CB8564C, 0x3C910000)
//.text:3CD7B74E mov eax, [edx+28h]
//.text:3CD7B751 mov ecx, esi
//.text:3CD7B753 call eax
//.text:3CD7B755 pop edi
//.text:3CD7BBFE mov eax, [edx+28h]
//.text:3CD7BC01 mov ecx, esi
//.text:3CD7BC03 call eax
//.text:3CD7BC05 pop edi
//.text:3CD5AAAE mov eax, [edx+28h]
//.text:3CD5AAB1 mov ecx, esi
//.text:3CD5AAB3 call eax
//.text:3CD5AAB5 pop edi
REBASE(bnetlib, sendheader_entry, 0x3CD5AAAE, 0x3C910000)
REBASE(bnetlib, sendheader_return, 0x3CD5AAB5, 0x3C910000)
//.text:3CD7CA7C lea ecx, [edi+ebx]
//.text:3CD7CA7F push ecx
//.text:3CD7CA80 mov ecx, eax
//.text:3CD7CA82 call edx
//.text:3CD7CF3C lea ecx, [edi+ebx]
//.text:3CD7CF3F push ecx
//.text:3CD7CF40 mov ecx, eax
//.text:3CD7CF42 call edx
//.text:3CD5BC48 lea ecx, [edi+ebx]
//.text:3CD5BC4B push ecx
//.text:3CD5BC4C mov ecx, eax
//.text:3CD5BC4E call edx
REBASE(bnetlib, send_message_entry, 0x3CD5BC48, 0x3C910000)
REBASE(bnetlib, send_message_return, 0x3CD5BC4E, 0x3C910000)
//not found?
//.text:3CD5F539 mov edx, [eax+28h]
//.text:3CD5F53C add ecx, ebx
//.text:3CD5F53E push ecx
//.text:3CD5F53F mov ecx, edi
REBASE(bnetlib, send_message_entry1, 0x3CD5F539, 0x3C910000)
REBASE(bnetlib, send_message_return1, 0x3CD5F53F, 0x3C910000)
//.text:3CD6B74D lea ecx, [ebx+edi]
//.text:3CD6B750 push ecx
//.text:3CD6B751 mov ecx, eax
//.text:3CD6B753 call edx
//.text:3CD6BBEA lea ecx, [ebx+edi]
//.text:3CD6BBED push ecx
//.text:3CD6BBEE mov ecx, eax
//.text:3CD6BBF0 call edx
//.text:3CD4AF49 lea ecx, [ebx+edi]
//.text:3CD4AF4C push ecx
//.text:3CD4AF4D mov ecx, eax
//.text:3CD4AF4F call edx
REBASE(bnetlib, send_message_entry2, 0x3CD4AF49, 0x3C910000)
REBASE(bnetlib, send_message_return2, 0x3CD4AF4F, 0x3C910000)
}
char* D3__std__string_to_char(unsigned int astr)
{
if (*(int *)(astr + 0x18) > 0x0f) {
return *(char **)(astr + 4);
} else {
return (char *)(astr + 4);
}
}
void __fastcall D3__std__String(int ecx) {
*(unsigned int*)(ecx+0x4) = 0x00;
*(unsigned int*)(ecx+0x14) = 0x0;
*(unsigned int*)(ecx+0x18) = 0x0f;
}
int new_std_string() {
int res = (int)malloc(0x30);
D3__std__String(res);
return res;
}
void delete_std_string(int res) {
asm(" pusha\n\t");
asm(" mov 0x08(%ebp), %ecx\n\t");
asm(" mov %0, %%eax\n\t" : : "m"(D3__std__String_delete));
asm(" call *(%eax)\n\t");
asm(" popa\n\t");
free((void*)res);
}
void __stdcall LDebugString(const char* stringptr)
{
#ifdef TEXTFILE_OUTPUT
FILE *file;
file = fopen("dbgoutput.txt","a+");
fprintf(file, "%s\n", stringptr);
fclose(file);
#endif
OutputDebugString(stringptr);
}
void __stdcall lol_OutputDebugString(unsigned int msg)
{
char* stringptr = D3__std__string_to_char(msg);
LDebugString(stringptr);
}
void hexdump(char* data, int size, char * outbuf, int osize) {
char *abuf = outbuf;
int remaining = osize - 4;
for (int i=0; i < size; i++) {
unsigned int next = (unsigned char) *data++;
if (next < 0x10) {
snprintf(abuf, remaining, "0%x ",next);
} else {
snprintf(abuf, remaining, "%x ", next);
}
abuf+=3;
remaining-=3;
if ((i+1) % 16 == 0) {
snprintf(abuf, remaining, "\n");
abuf += 1;
remaining -= 1;
}
}
}
void __stdcall print_msg_to_str(int message, int resstr) {
asm(" pusha\n\t");
asm(" movl 0x0c(%ebp), %ecx\n\t"
" push %ecx\n\t"
" movl 0x08(%ebp), %eax\n\t"
" push %eax\n\t");
asm(" movl %0, %%eax\n\t" : : "m"(D3__TextFormat__PrintToString));
asm(" movl $0, %ecx\n\t"
" call *%eax\n\t"
" add $8, %esp\n\t"
);
asm(" popa\n\t");
}
void __stdcall print_recv_header(int header_message) {
char buf[300];
int msg_str = new_std_string();
print_msg_to_str(header_message, msg_str);
snprintf(buf, sizeof(buf)-1, "[ Recv ] ");
LDebugString(buf);
char *message = D3__std__string_to_char(msg_str);
for (int i=0; message[i] != 0; i++) {
if ((message[i] == 10) | (message[i] == 13)) {
message[i] = 32;
}
}
LDebugString(message);
delete_std_string(msg_str);
}
void __stdcall print_send_header(int header_message) {
char buf[300];
int msg_str = new_std_string();
print_msg_to_str(header_message, msg_str);
snprintf(buf, sizeof(buf)-1, "[ Send ] ");
LDebugString(buf);
char *message = D3__std__string_to_char(msg_str);
for (int i=0; message[i] != 0; i++) {
if ((message[i] == 10) | (message[i] == 13)) {
message[i] = 32;
}
}
LDebugString(message);
delete_std_string(msg_str);
}
void __stdcall print_msg(int message)
{
asm(" sub $0x50, %esp\n\t");
//alloc std::string
asm(" lea -0x30(%ebp), %ecx\n\t");
asm(" mov %0, %%eax\n\t" : : "i"(D3__std__String));
asm(" call *%eax\n\t");
//print messagetype
asm(" movl 0x08(%ebp), %ecx\n\t");
asm(" mov %0, %%eax\n\t" : : "m"(D3__Message__GetDescriptor));
asm(" call *%eax\n\t"
" movl %eax, %ecx\n\t");
asm(" mov %0, %%eax\n\t" : : "m"(D3__Descriptor__full_name));
asm(" call *%eax\n\t");
asm(" movl %eax, -0x34(%ebp)\n\t");//store result
asm(" push %eax\n\t");
asm(" mov %0, %%eax\n\t" : : "i"(check_ignore_msg));
asm(" call *%eax\n\t");
asm(" test %eax, %eax\n\t");
asm(" jnz 1f\n\t");
asm(" movl -0x34(%ebp), %eax\n\t");
asm(" push %eax\n\t");
asm(" mov %0, %%eax\n\t" : : "i"(lol_OutputDebugString));
asm(" call *%eax\n\t");
//print message content
asm(" lea -0x30(%ebp), %ecx\n\t"
" push %ecx\n\t"
" movl 0x08(%ebp), %eax\n\t"
" push %eax\n\t");
asm(" mov %0, %%eax\n\t" : : "m"(D3__TextFormat__PrintToString));
asm(" movl $0, %ecx\n\t"
" call *%eax\n\t"
" add $8, %esp\n\t"
" lea -0x30(%ebp), %ecx\n\t"
" push %ecx\n\t"
);
asm(" mov %0, %%eax\n\t" : : "i"(lol_OutputDebugString));
asm(" call *%eax\n\t");
asm(" 1:\n\t"); //label to end
//clean std::string
asm(" lea -0x30(%ebp), %ecx\n\t");
asm(" mov %0, %%eax\n\t" : : "m"(D3__std__String_delete));
asm(" call *(%eax)\n\t");
asm(" add $0x50, %esp\n\t");
}
void func1()
{
asm(
" pop %ebp\n\t"
" movl 0x10(%eax), %edx\n\t"
" call *%edx\n\t"
" movzx %al, %eax\n\t"
" push %eax\n\t"
" push 0x0c(%ebp)\n\t" //param to the hooked function
" push %ebp\n\t"
" mov %esp, %ebp\n\t"
" sub $0x200, %esp\n\t"
" pusha\n\t"
);
//skip if anidated:
asm(" mov %0, %%eax\n\t" : : "i"(func2));
asm(" call *%eax\n\t"
" test %eax, %eax\n\t"
" jz 1f\n\t");
//print the message:
asm(" movl 0x04(%ebp), %eax\n\t"
" push %eax\n\t");
asm(" mov %0, %%eax\n\t" : : "i"(print_msg));
asm(" call *%eax\n\t");
asm(" mov %0, %%eax\n\t" : : "i"(func3));
asm(" call *%eax\n\t"
" 1:\n\t"
" popa \n\t"
" add $0x200, %esp\n\t"
" pop %ebp\n\t"
" pop %eax\n\t" //param
" pop %eax\n\t");
asm(" push %0\n\t" : : "m"(message_parse_return));
asm(" ret \n\t");
}
void sendheader_hook()
{
asm(
" pop %ebp\n\t"
);
asm(" pusha\n\t");
asm(" push %esi\n\t");
asm(" mov %0, %%eax\n\t" : : "i"(print_send_header));
asm(" call *%eax\n\t");
asm(" popa\n\t");
//.text:3CD4DBBE mov eax, [edx+28h]
//.text:3CD4DBC1 mov ecx, esi
//.text:3CD4DBC3 call eax
//.text:3CD4DBC5 pop edi
asm(" mov 0x28(%edx), %eax\n\t"
" mov %esi, %ecx\n\t"
" call *%eax\n\t"
);
asm(" push %0\n\t" : : "m"(sendheader_return));
asm(" ret \n\t");
}
void __stdcall c_print_msg(int protobuff_msg)
{
LDebugString("[[");
print_msg(protobuff_msg);
LDebugString("]]");
}
void send_message_hook()
{
asm(
" pop %ebp\n\t"
);
//.text:3CD93FE0 lea ecx, [edi+ebx]
//.text:3CD93FE3 push ecx
//.text:3CD93FE4 mov ecx, eax
//.text:3CD93FE6 call edx
//.text:3CD7D47B lea ecx, [edi+ebx]
//.text:3CD7D47E push ecx
//.text:3CD7D47F mov ecx, eax
//.text:3CD7D481 call edx
asm(" pusha\n\t");
asm(" push %eax\n\t");
asm(" mov %0, %%eax\n\t" : : "i"(c_print_msg));
asm(" call *%eax\n\t");
asm(" popa\n\t");
asm(
" lea (%edi, %ebx), %ecx\n\t"
" push %ecx\n\t"
" mov %eax, %ecx\n\t");
asm(" push %0\n\t" : : "m"(send_message_return));
asm(" ret \n\t");
}
void send_message_hook1()
{
asm(
" pop %ebp\n\t"
);
asm(" pusha\n\t");
asm(" push %edi\n\t");
asm(" mov %0, %%eax\n\t" : : "i"(c_print_msg));
asm(" call *%eax\n\t");
asm(" popa\n\t");
//.text:3CD7A468 mov edx, [eax+28h]
//.text:3CD7A46B add ecx, ebx
//.text:3CD7A46D push ecx
//.text:3CD7A46E mov ecx, edi
//.text:3CD617C8 mov edx, [eax+28h]
//.text:3CD617CB add ecx, ebx
//.text:3CD617CD push ecx
//.text:3CD617CE mov ecx, edi
asm(" mov 0x28(%eax), %edx\n\t"
" add %ebx, %ecx\n\t"
" push %ecx\n\t"
);
asm(" push %0\n\t" : : "m"(send_message_return1));
asm(" ret \n\t");
}
char nsend_message_hook2[] = "send_message_hook2\0";
void send_message_hook2()
{
asm(
" pop %ebp\n\t"
);