[Code removed, see second page for an updated version]
Enjoy and please if you make it better post it here so all can benefit from it

!;By Inf0Byt3, 10OCT07
;Free to use, credits appreciated
;Modifications/bugfixes must be made public
;The code address
CStart = ?X
CEnd = ?Y
CDiff = ?Y-?X
;Unprotect!
Mode = #PAGE_READWRITE
Result=VirtualProtect_(CStart,CDiff,Mode,@OrigMode)
;unXOR!
For I = CStart To CEnd
v=PeekB(I)
a=v ! 100
PokeB(I,a)
Next I
;Protect
VirtualProtect_(CStart,CDiff,OrigMode,Mode)
;Here's the protected code!
Goto lbl1
!_MarkBegin1 db "CRYPT_START"
lbl1:
X:
MessageRequester("","This code here is scrambled")
For t = 97 To 122
a$ + Chr(t)
Next
MessageRequester("","Result "+a$)
Goto ov:
Y:
!_MarkEnd1 db "CRYPT_END"
ov:
;The protected code ends here
Code: Select all
;By Inf0Byt3, 10OCT07
;Free to use, credits appreciated
;Modifications/bugfixes must be made public
; subtle "mod" by DoubleDutch, credits appreciated too! ;)
;The code address
CStart = ?X
CEnd = ?Y
CDiff = ?Y-?X
;Unprotect!
Mode = #PAGE_READWRITE
Result=VirtualProtect_(CStart,CDiff,Mode,@OrigMode)
;unXOR!
For I = CStart To CEnd-1
v=PeekB(I)
a=v ! 100
PokeB(I,a)
Next I
;Protect
VirtualProtect_(CStart,CDiff,OrigMode,Mode)
;Here's the protected code!
!_MarkBegin1 db $eb,$06,$eb,$fc,$eb,$fa,$eb,$f8
X:
MessageRequester("","This code here is scrambled")
For t = 97 To 122
a$ + Chr(t)
Next
MessageRequester("","Result "+a$)
Y:
!_MarkEnd1 db $eb,$06,$eb,$fc,$eb,$fa,$eb,$f8
End
;The protected code ends here!
; alternative tag: !db $eb,$04,$eb,$04,$eb,$fc,$eb,$fc
Code: Select all
;By Inf0Byt3, 10OCT07
;Free to use, credits appreciated
;Modifications/bugfixes must be made public
; subtle "mod" by DoubleDutch, credits appreciated too! ;)
If ReadFile(0,"Test.exe")
Total = Lof(0)
*Mem = AllocateMemory(Total)
ReadData(0,*Mem,Total)
CloseFile(0)
Tag.q=PeekQ(?EncoderTag)
*addr=*mem
For loop=0 To Total-8
If PeekQ(*addr)=Tag
If EStart
If EEnd
Debug("Error - more than one encoded section! "+Hex(*addr))
EStart=0
EEnd=0
Break
Else
Debug("found end "+Hex(*addr))
EEnd=*addr
EndIf
Else
Debug("found start "+Hex(*addr))
EStart=*addr
EndIf
EndIf
*addr+1
Next
Patched=0
If EStart And EEnd
For loop=EStart+8 To EEnd-1
x=PeekB(loop)&$ff
x!100
PokeB(loop,x)
patched+1
Next
EndIf
If CreateFile(0,"Test.exe")
WriteData(0,*Mem,Total)
Debug Str(patched)+" bytes patched"
CloseFile(0)
EndIf
EndIf
DataSection
EncoderTag: Data.b $eb,$06,$eb,$fc,$eb,$fa,$eb,$f8
Code: Select all
;Modifications/bugfixes must be made public
Code: Select all
;It would be nice to improve it if you have time and if you want to share the knowledge