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
|
;relocation compression 0.2á
;based on a run length encoding range checking :)
;
;0.1á - first beta of this funny code
;0.2á - improved the compression with the apack library
RReloccInc_Start:
mov edi,dword ptr [MemStart]
mov esi,edi
xor ebx,ebx ; set relocation counter to 0
GetNextRelocation:
mov eax,[esi]
mov dword ptr [Paranoia],eax
mov ecx,dword ptr [esi+4] ; get the size of this relocation buffa
sub ecx,8 ; subtract the header
shr ecx,1 ; divide by 2
dec ecx
mov dword ptr [esi+4],ecx ; save it again
add ebx,8 ; add 8 ;))
lodsd
stosd
mov dword ptr [NullStellen],edi
lodsd
stosd
lodsw ; get the first relocation
and ax,0FFFh ; kick the reloc type away ;)
mov word ptr [RelocCofs],ax ; save the relocation offset
add ebx,2
stosw
cmp ecx,1
jnz RelocPack
Damnfuckinglamerelocations:
add esi,2
add ebx,2
jmp StuhlGekippt
RelocPack:
add ebx,2 ; every damn relocation is 1 word
lodsw ; get a fucking relocation
and ax,0FFFh ; gimme only 12 bits you lamer ;)
or ax,ax
jz Fickooon
push ax
sub ax,word ptr [RelocCofs] ; subtract for range checking
cmp ax,127 ; range smaller than 128?
ja NotCompressAble ; if not, not compressable
or al,80h
stosb ; save the compressed relocation
jmp ContinueWithPacking
NotCompressAble:
inc dword ptr [DamnCrap22]
pop ax
push ax
xchg ah,al
stosw
pop ax
jmp NoDamnWay
Fickooon:
push esi
mov esi,dword ptr [NullStellen]
dec dword ptr [esi]
pop esi
jmp StuhlGekippt
ContinueWithPacking:
pop ax
NoDamnWay:
mov word ptr [RelocCofs],ax ; save the new relocation offset
StuhlGekippt:
dec ecx ; dec reloccounter
jnz RelocPack ; decrease till end
cmp ebx,dword ptr [RelocLength] ; finished?
jnz GetNextRelocation ; if not , continue packing
sub edi,dword ptr [MemStart]
mov ecx,edi
mov dword ptr [RelocSize],ecx ; save the size before the 2nd compression
WriteConsole2 <offset Baukasten252>
mov byte ptr [RelocCCC],1 ; relocation compression is running now (flag)
jmp CompressThem
ContinueRelocationPacking:
WriteConsole2 <offset Baukasten253>
pop esi
mov eax,dword ptr [CCounter] ; get the size of the packed relocations
mov ebp,dword ptr [PEHeader+60] ; and align them
xor edx,edx
div ebp
inc eax
mul ebp
mov ecx,[esi+16] ; get the old value for calculation
mov [esi+16],eax ; write the new physical size value
mov dword ptr [CCounter],eax ; save the new size (aligned now)
sub ecx,eax ; calculate the difference
add dword ptr [Csize],ecx ; add to the special pack counter of pecrypt
mov edx,dword ptr [esi+20] ; seek to the obj start
call SeekFile
pushad
mov edi,offset RELOCSAVE
mov esi,dword ptr [MemStart]
mov ecx,5
rep movsw
movsb
mov edi,dword ptr [MemStart]
xor eax,eax
stosd
mov eax,10
stosd
xor ax,ax
stosw
mov esi,dword ptr [MemStart]
mov eax,[esi]
mov dword ptr [SAVEFIRSTRB],eax
mov [esi],eax
mov byte ptr [AddNew],1
popad
mov dword ptr [PEHeader+164],10
mov ecx,dword ptr [CCounter]
mov edx,dword ptr [MemStart] ; pointer to the packed relocations
call WritetoFile ; write the packed relocations 2 disk
RReloccInc_End:
End_Of_RelocCC:
|