能力值:
( LV2,RANK:10 )
2 楼
Hi,
This code for encrypt exe's file.
*protect.prg
* decompiled by Foxtools 5.0
lparameters m.sourcefilename,m.targetfilename,m.pr_app
return protect1(m.sourcefilename,m.targetfilename,m.pr_app)
return function pr_fxp
lparameters m.body
if .NOT. fxp_rem_dbg(@m.body)
return .f.
endif
local m.proc_cnt,m.proc_beg,m.proc_len,m.proc_inf,m.i,m.proc_inf_beg,m.tek_pos_proc,m.proc_inf_new,m.proc_off,m.proc_name_len
local m.class_cnt,m.class_beg,m.class_len,m.class_inf,m.class_inf_beg,m.tek_pos_class,m.class_inf_new,m.class_off,m.class_name_len1,m.class_name_len2
m.proc_cnt = str2word(LEFT(m.body,2))
m.class_cnt = str2word(SUBSTR(m.body,3,2))
if m.proc_cnt = 0
m.proc_beg = 39
m.proc_len = str2word(SUBSTR(m.body,38,2))
else
if SUBSTR(m.body,38,7) == CHR(3)+CHR(0)+CHR(3)+CHR(0)+CHR(85)+CHR(0)+CHR(0)
m.proc_beg = 46
m.proc_len = str2word(SUBSTR(m.body,45,2))
else
m.proc_beg = 39
m.proc_len = str2word(SUBSTR(m.body,38,2))
endif
endif
m.body = STUFF(m.body,m.proc_beg+m.proc_len-2,0,CHR(4)+CHR(0)+CHR(66)+CHR(254)+CHR(11)+CHR(0)+CHR(37)+CHR(252)+CHR(45)+CHR(253)+CHR(249)+CHR(5)+CHR(32)+CHR(0)+CHR(254)+CHR(18)+CHR(0)+CHR(37)+CHR(252)+CHR(45)+CHR(240)+CHR(2)+CHR(0)+CHR(253)+CHR(254)+CHR(4)+CHR(0)+CHR(30)+CHR(254)+CHR(4)+CHR(0)+CHR(30)+CHR(254)+CHR(4)+CHR(0)+CHR(30)+CHR(254))
if m.proc_cnt > 0
m.body = STUFF(m.body,9,4,dword2str(str2dword(SUBSTR(m.body,9,4))+37))
endif
if m.class_cnt > 0
m.body = STUFF(m.body,13,4,dword2str(str2dword(SUBSTR(m.body,13,4))+37))
endif
m.body = STUFF(m.body,m.proc_beg-1,2,word2str(m.proc_len+37))
if m.proc_cnt > 0
m.proc_inf_beg = str2dword(SUBSTR(m.body,9,4))
m.proc_inf = SUBSTR(m.body,m.proc_inf_beg+1)
m.proc_inf_new = ""
m.tek_pos_proc = 0
for m.i = 1 to m.proc_cnt
m.proc_name_len = str2word(SUBSTR(m.proc_inf,m.tek_pos_proc+1,2))
m.proc_off = str2dword(SUBSTR(m.proc_inf,m.tek_pos_proc+3+m.proc_name_len,4))
m.proc_inf_new = m.proc_inf_new+IIF(m.i = 1 .AND. m.proc_beg = 46,SUBSTR(m.proc_inf,m.tek_pos_proc+1,10+m.proc_name_len),STUFF(SUBSTR(m.proc_inf,m.tek_pos_proc+1,10+m.proc_name_len),3+m.proc_name_len,4,dword2str(m.proc_off+37)))
m.tek_pos_proc = m.tek_pos_proc+10+m.proc_name_len
endfor
m.body = STUFF(m.body,m.proc_inf_beg+1,LEN(m.proc_inf_new),m.proc_inf_new)
endif
if m.class_cnt > 0
m.class_inf_beg = str2dword(SUBSTR(m.body,13,4))
m.class_inf = SUBSTR(m.body,m.class_inf_beg+1)
m.class_inf_new = ""
m.tek_pos_class = 0
for m.i = 1 to m.class_cnt
m.class_name_len1 = str2word(SUBSTR(m.class_inf,m.tek_pos_class+1,2))
m.class_name_len2 = str2word(SUBSTR(m.class_inf,m.tek_pos_class+3+m.class_name_len1,2))
m.class_off = str2dword(SUBSTR(m.class_inf,m.tek_pos_class+5+m.class_name_len1+m.class_name_len2,4))
m.class_inf_new = m.class_inf_new+STUFF(SUBSTR(m.class_inf,m.tek_pos_class+1,10+m.class_name_len1+m.class_name_len2),5+m.class_name_len1+m.class_name_len2,4,dword2str(m.class_off+37))
m.tek_pos_class = m.tek_pos_class+10+m.class_name_len1+m.class_name_len2
if str2word(RIGHT(m.class_inf_new,2)) <> 0
m.ol_cl = .t.
endif
endfor
m.body = STUFF(m.body,m.class_inf_beg+1,LEN(m.class_inf_new),m.class_inf_new)
endif
endfunc
function fxp_rem_dbg
lparameters m.body
local m.proc_cnt,m.new_body,m.proc_l,m.proc_lc,m.var_cnt_c,m.var_cnt,m.i,m.var_l,m.var_lc,m.class_cnt,m.class_pos,m.class_pos_new,m.class_inf,m.class_inf_new,m.tek_pos_class,m.class_name_len1,m.class_name_len2,m.class_off,m.class_lc,m.class_l
local m.tek_pos,m.proc_pos,m.proc_pos_new,m.proc_inf,m.proc_inf_new,m.tek_pos_proc,m.proc_name_len,m.proc_off,m.j,m.tek_var_pos
m.proc_cnt = str2word(LEFT(m.body,2))
m.class_cnt = str2word(SUBSTR(m.body,3,2))
m.proc_pos = str2dword(SUBSTR(m.body,9,4))
m.class_pos = str2dword(SUBSTR(m.body,13,4))
local m.add_func,m.rndp,m.rndn
m.add_func = CHR(3)+CHR(0)+word2str(rnd(12546,16146))+CHR(85)+CHR(rnd(4,6))+CHR(0)
m.new_body = word2str(m.proc_cnt)+word2str(m.class_cnt)+dword2str(37)+REPLICATE(CHR(0),20)+SUBSTR(m.body,29,4)+REPLICATE(CHR(0),4)+SUBSTR(m.body,37,1)
m.proc_lc = SUBSTR(m.body,38,2)
m.proc_l = str2word(m.proc_lc)
m.new_body = m.new_body+m.proc_lc+SUBSTR(m.body,40,m.proc_l)
m.var_cnt_c = SUBSTR(m.body,40+m.proc_l,2)
m.var_cnt = str2word(m.var_cnt_c)
m.new_body = m.new_body+m.var_cnt_c
m.tek_pos = 39+m.proc_l+2
if m.var_cnt > 0
for m.i = 1 to m.var_cnt
m.var_lc = SUBSTR(m.body,LEN(m.new_body)+1,2)
m.var_l = str2word(m.var_lc)
m.tek_pos = m.tek_pos+2+m.var_l
m.new_body = m.new_body+SUBSTR(m.body,LEN(m.new_body)+1,2+m.var_l)
endfor
endif
local m.pr_cl
m.proc_inf = SUBSTR(m.body,m.proc_pos+1)
m.proc_inf_new = ""
m.tek_pos_proc = 0
if m.proc_cnt > 0
if m.class_cnt = 0
if m.proc_cnt > 2
m.rndp = rnd(1,m.proc_cnt-1)
else
m.rndp = m.proc_cnt-1
endif
else
m.rndp = m.proc_cnt
endif
m.rndp = 0
m.rndn = rndname(m.proc_inf)
for m.i = 1 to m.proc_cnt
m.proc_name_len = str2word(SUBSTR(m.proc_inf,m.tek_pos_proc+1,2))
m.proc_off = str2dword(SUBSTR(m.proc_inf,m.tek_pos_proc+3+m.proc_name_len,4))
m.proc_inf_new = m.proc_inf_new+STUFF(SUBSTR(m.proc_inf,m.tek_pos_proc+1,10+m.proc_name_len),3+m.proc_name_len,4,dword2str(m.tek_pos))
m.pr_cl = SUBSTR(m.proc_inf,m.tek_pos_proc+3+m.proc_name_len+4,4)
m.tek_pos_proc = m.tek_pos_proc+10+m.proc_name_len
m.proc_lc = SUBSTR(m.body,m.proc_off+1,2)
m.proc_l = str2word(m.proc_lc)
m.new_body = m.new_body+m.proc_lc+SUBSTR(m.body,m.proc_off+3,m.proc_l)
m.var_cnt_c = SUBSTR(m.body,m.proc_off+3+m.proc_l,2)
m.var_cnt = str2word(m.var_cnt_c)
m.new_body = m.new_body+m.var_cnt_c
m.tek_pos = m.tek_pos+2+m.proc_l+2
if m.var_cnt > 0
m.tek_var_pos = m.proc_off+2+m.proc_l+2
for m.j = 1 to m.var_cnt
m.var_lc = SUBSTR(m.body,m.tek_var_pos+1,2)
m.var_l = str2word(m.var_lc)
m.tek_pos = m.tek_pos+2+m.var_l
m.new_body = m.new_body+SUBSTR(m.body,m.tek_var_pos+1,2+m.var_l)
m.tek_var_pos = m.tek_var_pos+2+m.var_l
endfor
endif
if m.i = m.rndp
m.proc_name_len = LEN(m.rndn)
m.proc_inf_new = m.proc_inf_new+word2str(m.proc_name_len)+m.rndn+dword2str(m.tek_pos)+m.pr_cl
m.new_body = word2str(str2word(LEFT(m.new_body,2))+1)+SUBSTR(m.new_body,3)+m.add_func
m.tek_pos = m.tek_pos+7
endif
endfor
m.new_body = m.new_body+m.proc_inf_new
m.new_body = STUFF(m.new_body,9,4,dword2str(m.tek_pos))
m.tek_pos = m.tek_pos+LEN(m.proc_inf_new)
endif
m.class_inf = SUBSTR(m.body,m.class_pos+1)
m.class_inf_new = ""
m.tek_pos_class = 0
if m.class_cnt > 0
for m.i = 1 to m.class_cnt
m.class_name_len1 = str2word(SUBSTR(m.class_inf,m.tek_pos_class+1,2))
m.class_name_len2 = str2word(SUBSTR(m.class_inf,m.tek_pos_class+3+m.class_name_len1,2))
m.class_off = str2dword(SUBSTR(m.class_inf,m.tek_pos_class+5+m.class_name_len1+m.class_name_len2,4))
m.class_inf_new = m.class_inf_new+STUFF(SUBSTR(m.class_inf,m.tek_pos_class+1,10+m.class_name_len1+m.class_name_len2),5+m.class_name_len1+m.class_name_len2,4,dword2str(m.tek_pos))
m.tek_pos_class = m.tek_pos_class+10+m.class_name_len1+m.class_name_len2
m.class_lc = SUBSTR(m.body,m.class_off+1,2)
m.class_l = str2word(m.class_lc)
m.new_body = m.new_body+m.class_lc+SUBSTR(m.body,m.class_off+3,m.class_l)
m.var_cnt_c = SUBSTR(m.body,m.class_off+3+m.class_l,2)
m.var_cnt = str2word(m.var_cnt_c)
m.new_body = m.new_body+m.var_cnt_c
m.tek_pos = m.tek_pos+2+m.class_l+2
if m.var_cnt > 0
m.tek_var_pos = m.class_off+2+m.class_l+2
for m.j = 1 to m.var_cnt
m.var_lc = SUBSTR(m.body,m.tek_var_pos+1,2)
m.var_l = str2word(m.var_lc)
m.tek_pos = m.tek_pos+2+m.var_l
m.new_body = m.new_body+SUBSTR(m.body,m.tek_var_pos+1,2+m.var_l)
m.tek_var_pos = m.tek_var_pos+2+m.var_l
endfor
endif
endfor
m.new_body = m.new_body+m.class_inf_new
m.new_body = STUFF(m.new_body,13,4,dword2str(m.tek_pos))
endif
m.body = m.new_body
endfunc
function rndname
lparameters m.pri
local m.nr,m.nl,m.i,m.st,m.cnt
m.cnt = 0
m.st = LEFT(m.pri,1)
do while m.st $ m.pri .AND. CNT < 10
m.cnt = m.cnt+1
m.nr = rnd(1,5)
m.st = ""
do case
case m.nr = 1
m.nl = rnd(3,5)
for m.i = 1 to m.nl
m.st = m.st+CHR(ASC("a")+rnd(0,25))
endfor
case m.nr = 2
m.nl = rnd(2,3)
for m.i = 1 to m.nl
m.st = m.st+CHR(ASC("a")+rnd(0,25))
endfor
m.st = m.st+PADL(rnd(1,99),2,"0")
case m.nr = 3
m.st = "_"+PADL(rnd(1,999),3,"0")
case m.nr = 4
m.nl = rnd(2,3)
for m.i = 1 to m.nl
m.st = m.st+CHR(ASC("a")+rnd(0,25))
endfor
m.st = m.st+STR(rnd(0,9),1)
m.nl = rnd(1,2)
for m.i = 1 to m.nl
m.st = m.st+CHR(ASC("a")+rnd(0,25))
endfor
case m.nr = 5
m.st = REPLICATE(CHR(0),rnd(5,7))
endcase
enddo
if EMPTY(m.st)
return REPLICATE(CHR(0),rnd(5,7))
else
return m.st
endif
endfunc
function pr_scx
lparameters m.scx_b,m.sct_b,m.scxname
local m.pth
m.pth = ADDBS(GETENV("Temp"))
erase (m.pth+"f1.dbf")
erase (m.pth+"f1.fpt")
STRTOFILE(m.scx_b,m.pth+"f1.dbf")
STRTOFILE(m.sct_b,m.pth+"f1.fpt")
use (m.pth+"f1.dbf") in 0 exclusive
select f1
local m.sysinf,m.fxp_body,m.fl,m.nflc,m.full_b,m.seed,m.d1,m.d2,m.d12,m.key1,m.key2,m.key0,m.key12
scan for .NOT. EMPTY(OBJCODE)
wait window nowait "Protecting "+m.scxname+" "+ALLTRIM(STR(RECNO()))
m.sysinf = LEFT(F1.objcode,41)
m.fl = str2dword(SUBSTR(m.sysinf,10,4))-41
m.fxp_body = SUBSTR(F1.objcode,42,m.fl)
pr_fxp(@m.fxp_body)
m.fxp_body = STUFF(m.fxp_body,5,2,word2str(0))
select f1
m.nflc = dword2str(LEN(m.fxp_body)+41)
m.sysinf = LEFT(m.sysinf,5)+CHR(1)+CHR(0)+CHR(0)+CHR(0)+m.nflc+m.nflc+REPLICATE(CHR(0),22)
m.sysinf = m.sysinf+word2str(crc16(SUBSTR(m.sysinf,3,35)))
m.fxp_body = m.fxp_body+CHR(0)+CHR(41)+REPLICATE(CHR(0),3)+m.nflc+REPLICATE(CHR(0),16)
m.full_b = m.sysinf+m.fxp_body
replace f1.objcode with m.full_b , f1.methods with ""
endscan
pack
use in f1
m.scx_b = FILETOSTR(m.pth+"f1.dbf")
m.sct_b = FILETOSTR(m.pth+"f1.fpt")
erase (m.pth+"f1.dbf")
erase (m.pth+"f1.fpt")
return
endfunc
function floor200
lparameters m.ad
local m.ad1
m.ad1 = MOD(m.ad,512)
return IIF(m.ad1 = 0,m.ad,m.ad+512-m.ad1)
endfunc
function floor1000
lparameters m.ad
local m.ad1
m.ad1 = MOD(m.ad,4096)
return IIF(m.ad1 = 0,m.ad,m.ad+4096-m.ad1)
endfunc
function protect1
lparameters m.sourcefilename,m.targetfilename,m.pr_app
private m.ol_cl
local m.ch_ol
m.ch_ol = .f.
m.ol_cl = .f.
local m.enc1,ar1(1),m.korr_fxp,m.prb_fxp,m.prot_fxp,m.prot_scx,m.ch_fat_lines
m.enc1 = .t.
m.sl_sc = .t.
m.korr_fxp = .f.
m.prb_fxp = .f.
m.prot_fxp = .t.
m.prot_scx = .t.
m.ch_fat_lines = .f.
if TYPE("m.sourcefilename") <> "C"
return 1
endif
if .NOT. m.pr_app .AND. .NOT. LOWER(JUSTEXT(m.sourcefilename)) == "exe"
return 2
endif
if m.pr_app .AND. .NOT. LOWER(JUSTEXT(m.sourcefilename)) == "app"
return 2
endif
if .NOT. FILE(m.sourcefilename)
return 3
endif
local m.hnd1,m.hnd2,m.file_len,m.r1,m.mo,m.seed,m.sysinf,m.fato,m.diro,m.df,m.fcnt,m.main,m.mainname
m.hnd1 = FOPEN(m.sourcefilename)
if m.hnd1 <= 0
return 4
endif
m.file_len = FSEEK(m.hnd1,0,2)
if .NOT. m.pr_app
= FSEEK(m.hnd1,-4,1)
m.r1 = ""
m.r1 = FREAD(m.hnd1,4)
if LEN(m.r1) <> 4
return 5
endif
m.mo = m.file_len-str2dword(m.r1)
if m.mo < 0
return 6
endif
else
m.mo = 0
endif
= FSEEK(m.hnd1,m.mo,0)
m.r1 = FREAD(m.hnd1,41)
if LEN(m.r1) <> 41
return 7
endif
if .NOT. LEFT(m.r1,2) == CHR(254)+CHR(242)
return 8
endif
local m.en,m.d1,m.d2,m.key12,m.key1,m.key2,m.key0,m.enc,m.key3,m.key4,m.key5,m.gb
m.en = SUBSTR(m.r1,3,1)
if .NOT. m.en $ CHR(255)+CHR(238)
return 9
endif
m.enc = (m.en = CHR(238))
if m.enc
m.seed = decr_si(@m.r1)
if crc16(SUBSTR(m.r1,3,35)) <> str2word(SUBSTR(m.r1,40,2))
return 10
endif
select tmp2
locate for RN = (MOD(m.seed,23))
if FOUND()
m.d1 = TMP2.d1
m.d2 = TMP2.d2
m.d12 = m.d1*m.d2
else
return 11
endif
m.key12 = ""
m.key12 = REPLICATE(CHR(0),512)
= keyg(@m.key12,m.seed,6221,13437)
m.key1 = LEFT(m.key12,m.d1)
m.key2 = SUBSTR(m.key12,m.d1+1,m.d2)
m.key0 = REPLICATE(m.key1,m.d2)
= bx(REPLICATE(m.key2,m.d1),@m.key0)
m.r1 = LEFT(m.r1,2)+CHR(255)+SUBSTR(m.r1,4,18)+REPLICATE(CHR(0),18)
m.sysinf = m.r1+word2str(crc16(SUBSTR(m.r1,3,35)))
else
if crc16(SUBSTR(m.r1,3,35)) <> str2word(SUBSTR(m.r1,40,2))
return 10
endif
m.sysinf = m.r1
endif
if .NOT. SUBSTR(m.sysinf,4,2) == CHR(32)+CHR(2)
return 11
endif
m.fcnt = str2word(SUBSTR(m.sysinf,6,2))
m.main = str2word(SUBSTR(m.sysinf,8,2))
m.fato = str2dword(SUBSTR(m.sysinf,10,4))
m.diro = str2dword(SUBSTR(m.sysinf,14,4))
m.df = str2dword(SUBSTR(m.sysinf,18,4))
if m.fato-m.diro <> m.df
return 12
endif
if m.fcnt = 0
return 13
endif
if m.main >= m.fcnt
return 14
endif
local m.dirbody,m.fatbody,m.debug_info,m.pathbody
= FSEEK(m.hnd1,m.mo+m.diro,0)
m.dirbody = FREAD(m.hnd1,m.fato-m.diro)
if LEN(m.dirbody) <> m.fato-m.diro
return 15
endif
if m.enc
bx(m.key0,@m.dirbody,MOD(m.diro,m.d12))
endif
m.debug_info = ".prg" $ m.dirbody .OR. ".mpr" $ m.dirbody .OR. ".qpr" $ m.dirbody
if m.prot_fxp .OR. m.prot_scx
m.debug_info = .f.
endif
m.fatbody = FREAD(m.hnd1,m.file_len-m.mo-m.fato-IIF(m.pr_app,0,14))
if LEN(m.fatbody) <> m.file_len-m.mo-m.fato-IIF(m.pr_app,0,14)
return 16
endif
if LEN(m.fatbody) <> m.fcnt*25
return 17
endif
if m.enc
bx(m.key0,@m.fatbody,MOD(m.fato,m.d12))
endif
local m.fats,m.gapend,m.fnn,m.pth,m.debi,m.pos,m.mg
create cursor tmp (ind I ,filename C (254 ) nocptrans ,pathname C (254 ) nocptrans ,new_path_off I ,deb_inf C (254 ) nocptrans ,filetype C (1 ) nocptrans ,file_beg_off I ,file_end_off I ,gap_end_off I ,filelen I ,gaplen I ,file_dir_off I ,path_dir_off I ,file_body M nocptrans ,gap_body M nocptrans ,k_t I ,seed I )
for i = 1 to m.fcnt
m.fats = SUBSTR(m.fatbody,25*I-24,25)
insert into tmp values (0,"","",0,"",LEFT(m.fats,1),str2dword(SUBSTR(m.fats,2,4)),str2dword(SUBSTR(m.fats,6,4)),0,str2dword(SUBSTR(m.fats,6,4))-str2dword(SUBSTR(m.fats,2,4)),0,str2dword(SUBSTR(m.fats,14,4)),str2dword(SUBSTR(m.fats,10,4)),"","",2,str2word(rndstr(2)))
endfor
select tmp
scan
m.mg = TMP.file_beg_off
select MIN(FILE_BEG_OFF) as file_beg_off ;
from tmp ;
where FILE_BEG_OFF > m.mg into cursor tmp1
if _tally = 0
m.gapend = m.diro
else
m.gapend = TMP1.file_beg_off
endif
select tmp
m.fnn = SUBSTR(m.dirbody,TMP.file_dir_off+1,254)
m.pos = AT(CHR(0),m.fnn)
if m.pos > 0
m.fnn = LEFT(m.fnn,m.pos-1)
endif
if m.debug_info
do case
case RIGHT(LOWER(ALLTRIM(m.fnn)),4) == ".fxp"
m.pos = AT(LEFT(m.fnn,LEN(m.fnn)-3)+"prg",m.dirbody)
if m.pos > 0
m.debi = LEFT(m.dirbody,m.pos+LEN(m.fnn)-1)
m.pos = RAT(CHR(0),m.debi)
if m.pos > 0
m.debi = SUBSTR(m.debi,m.pos+1)
endif
else
m.debi = ""
endif
case RIGHT(LOWER(ALLTRIM(m.fnn)),4) == ".mpx"
m.pos = AT(LEFT(m.fnn,LEN(m.fnn)-3)+"mpr",m.dirbody)
if m.pos > 0
m.debi = LEFT(m.dirbody,m.pos+LEN(m.fnn)-1)
m.pos = RAT(CHR(0),m.debi)
if m.pos > 0
m.debi = SUBSTR(m.debi,m.pos+1)
endif
else
m.debi = ""
endif
case RIGHT(LOWER(ALLTRIM(m.fnn)),4) == ".qpx"
m.pos = AT(LEFT(m.fnn,LEN(m.fnn)-3)+"qpr",m.dirbody)
if m.pos > 0
m.debi = LEFT(m.dirbody,m.pos+LEN(m.fnn)-1)
m.pos = RAT(CHR(0),m.debi)
if m.pos > 0
m.debi = SUBSTR(m.debi,m.pos+1)
endif
else
m.debi = ""
endif
otherwise
m.debi = ""
endcase
else
m.debi = ""
endif
m.pth = SUBSTR(m.dirbody,TMP.path_dir_off+1,254)
m.pos = AT(CHR(0),m.pth)
if m.pos > 0
m.pth = LEFT(m.pth,m.pos-1)
endif
replace gap_end_off with m.gapend , filename with m.fnn , pathname with m.pth , deb_inf with m.debi
replace gaplen with GAP_END_OFF-FILE_END_OFF
endscan
local m.pcnt
select PATHNAME, LEN(ALLTRIM(PATHNAME))+1 as plen ;
from tmp ;
where .NOT. EMPTY(PATHNAME) ;
group by 1 into cursor ptmp
create cursor ptmp2 (pathname C (254 ) nocptrans ,plen I ,plena I )
select ptmp
m.pcnt = 0
m.pathbody = ""
scan
insert into ptmp2 values (PTMP.pathname,PTMP.plen,m.pcnt)
m.pcnt = m.pcnt+PTMP.plen
m.pathbody = m.pathbody+ALLTRIM(PTMP.pathname)+CHR(0)
endscan
use in SELECT("ptmp")
select tmp
scan
select PLENA ;
from ptmp2 ;
where PATHNAME = TMP.PATHNAME into array ar1
if _tally > 0
replace new_path_off with AR1
endif
endscan
use in SELECT("ptmp2")
local m.snn1,m.sl_sc_bin
select tmp
goto (m.main+1) in tmp
m.mainname = ALLTRIM(TMP.filename)
if m.sl_sc
m.sl_sc_bin = FILETOSTR("q3216549.fxb")
m.snn1 = AT("Xxxxxxxx",m.sl_sc_bin)-1
do case
case LOWER(RIGHT(m.mainname,4)) = ".fxp"
m.sl_sc_bin = LEFT(m.sl_sc_bin,m.snn1)+PADR(JUSTSTEM(TMP.filename)+".fxp",128)+SUBSTR(m.sl_sc_bin,m.snn1+129)
case LOWER(RIGHT(m.mainname,4)) = ".mpx"
m.sl_sc_bin = LEFT(m.sl_sc_bin,m.snn1)+PADR(JUSTSTEM(TMP.filename)+".mpr",128)+SUBSTR(m.sl_sc_bin,m.snn1+129)
case LOWER(RIGHT(m.mainname,4)) = ".scx"
m.sl_sc_bin = LEFT(m.sl_sc_bin,m.snn1)+PADR("form "+JUSTSTEM(TMP.filename),128)+SUBSTR(m.sl_sc_bin,m.snn1+129)
otherwise
return 39
endcase
endif
m.mainname = "q3216547.fxp"
select MAX(FILE_BEG_OFF) as fbo , MAX(FILE_END_OFF) as feo , MAX(GAP_END_OFF) as geo , MIN(FILE_END_OFF-FILE_BEG_OFF) as fl , MIN(GAP_END_OFF-FILE_END_OFF) as gl , MAX(FILE_END_OFF-FILE_BEG_OFF) as fml , MAX(FILE_DIR_OFF) as fdo ;
from tmp into cursor tmp1
if TMP1.fbo > m.diro
return 18
endif
if TMP1.feo > m.diro
return 19
endif
if TMP1.geo > m.diro
return 20
endif
if TMP1.fl < 0
return 21
endif
if TMP1.gl < 0
return 22
endif
if TMP1.fml >= 04294967296
return 23
endif
if TMP1.fdo >= m.fato-m.diro
return 24
endif
select COUNT(*) as cnt ;
from tmp ;
where LOWER(FILENAME) = "q3216549.fxp" into cursor tmp1
if TMP1.cnt > 0
return 38
endif
use in SELECT("tmp1")
local m.fb,m.gb,m.flg
m.flg = 0
select tmp
scan
FSEEK(m.hnd1,m.mo+TMP.file_beg_off,0)
m.fb = FREAD(m.hnd1,TMP.file_end_off-TMP.file_beg_off)
if LEN(m.fb) <> TMP.file_end_off-TMP.file_beg_off
m.flg = 1
exit
endif
if TMP.gap_end_off-TMP.file_end_off > 0
m.gb = FREAD(m.hnd1,TMP.gap_end_off-TMP.file_end_off)
if LEN(m.gb) <> TMP.gap_end_off-TMP.file_end_off
m.flg = 2
exit
endif
else
m.gb = ""
endif
if m.enc
bx(m.key0,@m.fb,MOD(TMP.file_beg_off,m.d12))
endif
replace file_body with m.fb , gap_body with m.gb
endscan
do case
case m.flg = 1
return 25
case m.flg = 2
return 26
endcase
local m.fxp_body,m.fbl
if m.prot_fxp
select tmp
scan for INLIST(RIGHT(ALLTRIM(TMP.filename),4),".fxp",".mpx",".qpx")
wait window nowait "Protecting "+ALLTRIM(TMP.filename)
m.fxp_body = TMP.file_body
if pr_fxp(@m.fxp_body)
replace file_body with m.fxp_body , filelen with LEN(m.fxp_body)
endif
endscan
endif
local m.scx_body,m.sct_body,m.sec_fn,m.rn
if m.prot_scx
select tmp
scan for INLIST(RIGHT(ALLTRIM(TMP.filename),4),".scx",".vcx")
m.rn = RECNO()
m.scx_body = TMP.file_body
m.sec_fn = LEFT(ALLTRIM(TMP.filename),LEN(ALLTRIM(TMP.filename))-1)+"t"
select FILE_BODY ;
from tmp ;
where ALLTRIM(FILENAME) == m.sec_fn into array ar1
if _tally <> 1
loop
endif
m.sct_body = AR1
if pr_scx(@m.scx_body,@m.sct_body,ALLTRIM(TMP.filename))
select tmp
goto (m.rn)
replace tmp.file_body with m.scx_body , tmp.filelen with LEN(m.scx_body)
update tmp set file_body = m.sct_body,filelen = LEN(m.sct_body) ;
;
where ALLTRIM(FILENAME) == m.sec_fn
endif
goto (m.rn)
select tmp
endscan
endif
wait window nowait "Wait a minute, please"
insert into tmp values (0,"q3216549.fxp","",0,IIF(m.debug_info,"q3216549.prg",""),CHR(0),0,0,0,LEN(m.sl_sc_bin),0,0,0,m.sl_sc_bin,"",2,str2word(rndstr(2)))
local m.main_bin,m.rkf_bin,m.bx_bin,m.dx_bin
m.main_bin = FILETOSTR("q3216547.fxb")
m.rkf_bin = FILETOSTR("q3216548.fxb")
m.bx_bin = FILETOSTR("q3216547.bib")
m.dx_bin = FILETOSTR("q3216548.bib")
insert into tmp values (0,"q3216547.fxp","",0,IIF(m.debug_info,"q3216547.prg",""),CHR(0),0,0,0,LEN(m.main_bin),0,0,0,m.main_bin,"",1,0)
insert into tmp values (0,"q3216548.fxp","",0,IIF(m.debug_info,"q3216548.prg",""),CHR(0),0,0,0,LEN(m.rkf_bin),0,0,0,m.rkf_bin,"",1,0)
insert into tmp values (0,"q3216547.bin","",0,"",CHR(0),0,0,0,LEN(m.bx_bin),0,0,0,m.bx_bin,"",1,0)
local m.rstr0,m.rstr1,m.rstr2,m.rstr3,m.rstr4,m.rs1,m.rs2,m.rk1,m.dx_rnd
m.dx_rnd = rndstr(LEN(m.dx_bin))
bx(m.dx_rnd,@m.dx_bin)
insert into tmp values (0,"q3216548.bin","",0,"",CHR(0),0,0,0,LEN(m.dx_bin)*2,0,0,0,m.dx_bin+m.dx_rnd,"",1,0)
m.rstr0 = rndstr(1024)
m.rstr1 = m.rstr0
m.rstr2 = rndstr(64)
m.rstr3 = rndstr(64)
m.rstr4 = rndstr(64)
m.rs1 = LEFT(m.rstr2,29)
m.rs2 = SUBSTR(m.rstr2,30)
m.rk1 = REPLICATE(m.rs1,35)
bx(REPLICATE(m.rs2,29),@m.rk1)
bx(m.rk1,@m.rstr1)
insert into tmp values (0,"q321654b.bin","",0,"",CHR(0),0,0,0,LEN(m.rstr0),128,0,0,m.rstr0,m.rstr2+m.rstr4,1,0)
insert into tmp values (0,"q321654c.bin","",0,"",CHR(0),0,0,0,LEN(m.rstr3),0,0,0,m.rstr3,"",1,0)
local m.ptr_bin,m.ptrk,m.len_ptr_bin
m.ptr_bin = FILETOSTR("q3216549.bib")
m.ptrk = LEFT(m.ptr_bin,256)
m.ptr_bin = SUBSTR(m.ptr_bin,257)
m.len_ptr_bin = LEN(m.ptr_bin)
bx(m.ptrk,@m.ptr_bin)
update tmp set k_t = 1,seed = 0 ;
;
where LOWER(ALLTRIM(FILENAME)) = "config.fpw"
update tmp set k_t = 1,seed = 0 ;
;
where LOWER(ALLTRIM(FILENAME)) = "q3216546.fxp"
update tmp set ind = RECNO()*10 ;
update tmp set seed = 4889 ;
;
where SEED = 4888
select COUNT(*) ;
from tmp into array ar1
m.fcnt = AR1-7
local m.f_1,m.f_cnt,m.nname
if m.fcnt >= 10
select top 2 LEN(FILE_BODY)+0 as act_file_len ,* ;
from tmp ;
where INLIST(LOWER(JUSTEXT(ALLTRIM(FILENAME))),"ico","bmp","jpg","fxp","txt") order by 1 into cursor tmp3
do case
case _tally = 1
select tmp3
goto 1
m.f_1 = .f.
m.f_cnt = 0
m.nname = ""
do while m.f_1 = .f. .AND. m.f_cnt < 100
m.f_cnt = m.f_cnt+1
m.nname = changefilename(LOWER(ALLTRIM(FILENAME)))
select COUNT(*) ;
from tmp ;
where LOWER(ALLTRIM(FILENAME)) == m.nname into array ar1
if AR1 = 0
m.f_1 = .t.
endif
enddo
if m.f_1
select tmp
append from DBF("tmp3")
goto bottom
replace seed with 4888 , filename with m.nname , ind with rnd(0,MIN(INT(m.fcnt/3),5))*10+5
endif
case _tally >= 2
select tmp3
goto 1
m.f_1 = .f.
m.f_cnt = 0
m.nname = ""
do while m.f_1 = .f. .AND. m.f_cnt < 100
m.f_cnt = m.f_cnt+1
m.nname = changefilename(LOWER(ALLTRIM(FILENAME)))
select COUNT(*) ;
from tmp ;
where LOWER(ALLTRIM(FILENAME)) == m.nname into array ar1
if AR1 = 0
m.f_1 = .t.
endif
enddo
if m.f_1
select * ;
from tmp3 ;
where RECNO() = 1 into cursor tmp4
select tmp
append from DBF("tmp4")
goto bottom
replace seed with 4888 , filename with m.nname , ind with rnd(0,MIN(INT(m.fcnt/3),5))*10+5
endif
select tmp3
goto 2
m.f_1 = .f.
m.f_cnt = 0
m.nname = ""
do while m.f_1 = .f. .AND. m.f_cnt < 100
m.f_cnt = m.f_cnt+1
m.nname = changefilename(LOWER(ALLTRIM(FILENAME)))
select COUNT(*) ;
from tmp ;
where LOWER(ALLTRIM(FILENAME)) == m.nname into array ar1
if AR1 = 0
m.f_1 = .t.
endif
enddo
if m.f_1
select * ;
from tmp3 ;
where RECNO() = 2 into cursor tmp4
select tmp
append from DBF("tmp4")
goto bottom
replace seed with 4888 , filename with m.nname , ind with rnd(m.fcnt-1-MIN(INT(m.fcnt/3),5),m.fcnt-1)*10+5
endif
endcase
endif
use in SELECT("tmp3")
use in SELECT("tmp4")
select COUNT(*) ;
from tmp into array ar1
m.fcnt = AR1+1
m.ptr_bin = m.ptr_bin+REPLICATE(CHR(0),m.fcnt*6+8)
insert into tmp values (m.fcnt*10,"q3216549.bin","",0,"",CHR(0),0,0,0,LEN(m.ptr_bin),0,0,0,m.ptr_bin,"",1,0)
select tmp
index on IND tag ind
local m.hd,m.ft
if .NOT. m.pr_app
= FSEEK(m.hnd1,0,0)
m.hd = FREAD(m.hnd1,m.mo)
if LEN(m.hd) <> m.mo
return 27
endif
else
m.hd = ""
endif
local m.p6,m.p7,m.p8,m.p9
local m.ch_tmp
local m.hds
local m.dll_e,m.imp_t_of,m.imp_t,m.imp_t_fs,m.hnd_of
local m.text_fs,m.jmp_rel,m.zapl_len,m.data_fs,m.data_of
local m.zapl
local m.sgn1,m.sgn2,m.sgn3,m.sgn1p,m.sgn2p,m.fl1,m.fl2,m.fl3
local m.ch_tmp
local m.hds
local m.hstr,m.hstr_p,m.hln1,m.hln3,m.hof2,m.hof3,m.hof4,m.hof5,m.pep
local m.pe,m.len_oh,m.oh,m.e_point,m.ot,m.kol_sec
local m.vrn,m.n_sp,ad(1),m.posz
if .NOT. m.pr_app
m.fi = ""
m.pe = str2dword(SUBSTR(m.hd,61,4))
if .NOT. SUBSTR(m.hd,m.pe+1,4) == "PE"+CHR(0)+CHR(0)
return 54
endif
m.oh = m.pe+24
m.len_oh = str2word(SUBSTR(m.hd,m.pe+1+20,2))
m.ot = m.oh+m.len_oh
m.kol_sec = str2word(SUBSTR(m.hd,m.pe+1+6,2))
m.zapl = FILETOSTR("exe.bin")
m.virt_size = LEN(m.zapl)+LEN(m.fi)
m.phys_size = floor200(m.virt_size)
m.rva = floor1000(str2dword(SUBSTR(m.hd,m.ot+1+40*(m.kol_sec-1)+12,4))+str2dword(SUBSTR(m.hd,m.ot+1+40*(m.kol_sec-1)+16,4)))
m.phys_off = str2dword(SUBSTR(m.hd,m.ot+1+40*(m.kol_sec-1)+20,4))+str2dword(SUBSTR(m.hd,m.ot+1+40*(m.kol_sec-1)+16,4))
m.new_sec = ".xdata"+CHR(0)+CHR(0)+dword2str(m.virt_size)+dword2str(m.rva)+dword2str(m.phys_size)+dword2str(m.phys_off)+REPLICATE(CHR(0),12)+dword2str(3758096448)
m.hd = STUFF(m.hd,m.ot+1+40*m.kol_sec,40,m.new_sec)
m.hd = STUFF(m.hd,m.pe+1+6,2,word2str(m.kol_sec+1))
m.imp_t_fs = str2dword(SUBSTR(m.hd,m.ot+16+1+40,4))
m.imp_t_of = str2dword(SUBSTR(m.hd,m.ot+20+1+40,4))
m.imp_t = SUBSTR(m.hd,m.imp_t_of+1,m.imp_t_fs)
m.posz = AT("LoadLibrary",m.imp_t)
if m.posz = 0
return 59
endif
m.hnd_of = dword2str(m.posz-3+8192)
m.posz = AT(m.hnd_of,m.imp_t)
if m.posz = 0
return 60
endif
m.dll_e = m.posz-1+8192
m.ser_str = CHR(255)+CHR(21)+word2str(m.dll_e)
m.text_off = str2dword(SUBSTR(m.hd,m.ot+1+20,4))
m.text_len = str2dword(SUBSTR(m.hd,m.ot+1+16,4))
m.text_body = SUBSTR(m.hd,m.text_off+1,m.text_len)
m.posz = AT(m.ser_str,m.text_body)
if m.posz = 0
return 60
endif
if SUBSTR(m.text_body,m.posz+6,1) = CHR(201)
m.posz = AT(m.ser_str,m.text_body,2)
if m.posz = 0
return 61
endif
endif
m.jmp_off = m.rva-4096-m.posz-5
m.jmp_rel = 4294967296-(m.rva+LEN(m.zapl)-m.posz-4096-5)
m.hd = STUFF(m.hd,m.posz+m.text_off,6,CHR(144)+CHR(233)+dword2str(m.jmp_off))
m.posz = AT("LLLL"+CHR(0)+CHR(0),m.zapl)
m.zapl = STUFF(m.zapl,m.posz,4,m.ser_str)
m.zapl = LEFT(m.zapl,LEN(m.zapl)-4)+dword2str(m.jmp_rel)
m.posz = AT("GetModuleHandle",m.imp_t)
if m.posz = 0
return 59
endif
m.hnd_of = dword2str(m.posz-3+8192)
m.posz = AT(m.hnd_of,m.imp_t)
if m.posz = 0
return 60
endif
m.dll_e = m.posz-1+8192
m.posz = AT("GMHGPA",m.zapl)
m.zapl = STUFF(m.zapl,m.posz+6,2,word2str(m.dll_e))
m.posz = AT("GetProcAddress",m.imp_t)
if m.posz = 0
return 59
endif
m.hnd_of = dword2str(m.posz-3+8192)
m.posz = AT(m.hnd_of,m.imp_t)
if m.posz = 0
return 60
endif
m.dll_e = m.posz-1+8192
m.posz = AT("GMHGPA",m.zapl)
m.zapl = STUFF(m.zapl,m.posz+10,2,word2str(m.dll_e))
m.pe_seed = rndstr(2)
m.zapl = STUFF(m.zapl,m.posz+14,2,m.pe_seed)
m.pe_seed = str2word(m.pe_seed)
m.posz = AT("KERNEL32.DLL",m.zapl)
m.pose = AT("KDED01",m.zapl)+6
m.kod_str = ""
for m.i = 1 to m.pose-m.posz
m.pe_seed = BITAND(m.pe_seed*7933+13669,65535)
m.kod_str = m.kod_str+CHR(BITRSHIFT(m.pe_seed,8))
endfor
m.kod_str1 = SUBSTR(m.zapl,m.posz,m.pose-m.posz)
bx(m.kod_str,@m.kod_str1)
m.zapl = STUFF(m.zapl,m.posz,m.pose-m.posz,m.kod_str1)
m.hd = STUFF(m.hd,m.phys_off+1,0,PADR(m.zapl+m.fi,floor200(LEN(m.zapl)+LEN(m.fi)),CHR(0)))
m.hd = STUFF(m.hd,m.oh+1+8,4,dword2str(str2dword(SUBSTR(m.hd,m.oh+1+8,4))+floor200(LEN(m.zapl)+LEN(m.fi))))
m.hd = STUFF(m.hd,m.pe+1+80,4,dword2str(str2dword(SUBSTR(m.hd,m.pe+1+80,4))+floor1000(LEN(m.zapl)+LEN(m.fi))))
endif
if .NOT. m.pr_app
= FSEEK(m.hnd1,m.file_len-14,0)
m.ft = FREAD(m.hnd1,14)
if LEN(m.ft) <> 14
return 28
endif
else
m.ft = ""
endif
FCLOSE(m.hnd1)
local m.hnd2,m.wcnt,m.ddo,m.fnn
set safety off
if FILE(m.targetfilename)
m.OCOM.del_read_only(m.targetfilename)
endif
m.hnd2 = FCREATE(m.targetfilename)
if m.hnd2 <= 0
return 29
endif
if .NOT. m.pr_app
m.wcnt = FWRITE(m.hnd2,m.hd)
if m.wcnt <> LEN(m.hd)
return 30
endif
endif
select IND ;
from tmp ;
where ALLTRIM(FILENAME) = m.mainname into array ar1
if _tally = 0
return 41
endif
select COUNT(*) ;
from tmp ;
where IND < AR1 into array ar2
m.main = AR2
select SUM(FILELEN+GAPLEN) ;
from tmp into array ar1
m.diro = AR1+41
m.dirbody = m.pathbody
m.ddo = LEN(m.dirbody)
select tmp
scan
m.fnn = LOWER(ALLTRIM(TMP.filename))
if .NOT. EMPTY(TMP.deb_inf)
m.dirbody = m.dirbody+ALLTRIM(TMP.deb_inf)+CHR(0)+m.fnn+CHR(0)
replace file_dir_off with m.ddo+LEN(ALLTRIM(TMP.deb_inf))+1
m.ddo = m.ddo+LEN(m.fnn)+1+LEN(ALLTRIM(TMP.deb_inf))+1
else
m.dirbody = m.dirbody+m.fnn+CHR(0)
replace file_dir_off with m.ddo
m.ddo = m.ddo+LEN(m.fnn)+1
endif
endscan
local m.fll
m.fato = m.diro+LEN(m.dirbody)
m.sysinf = CHR(254)+CHR(242)+CHR(255)+CHR(32)+CHR(2)+word2str(m.fcnt)+word2str(m.main)+dword2str(m.fato)+dword2str(m.diro)+dword2str(m.fato-m.diro)+REPLICATE(CHR(0),18)
m.sysinf = m.sysinf+word2str(crc16(SUBSTR(m.sysinf,3,35)))
m.seed = 4888
local m.sysinf1
m.sysinf1 = m.sysinf
if m.enc1
do while m.seed = 4888
m.seed = encr_si(@m.sysinf1)
if m.seed <> 4888
m.sysinf = m.sysinf1
else
m.sysinf1 = m.sysinf
endif
enddo
else
m.seed = 0
endif
update tmp set seed = m.seed ;
;
where SEED = 0
local m.mainseed
m.mainseed = m.seed
if .NOT. protf(m.fcnt,m.seed,m.rstr1,m.len_ptr_bin,@m.fatbody)
clear program
return 30
endif
clear program
m.wcnt = FWRITE(m.hnd2,m.sysinf)
if m.wcnt <> 41
return 37
endif
local m.fnnn
m.fnnn = 0
select tmp
m.flg = 0
scan
m.fb = TMP.file_body
if m.enc1
select D1, D2 ;
from tmp2 ;
where RN = (MOD(TMP.seed,23)) into array ar1
if _tally = 1
m.d1 = ar1(1)
m.d2 = ar1(2)
m.d12 = m.d1*m.d2
else
return 31
endif
m.seed = TMP.seed
m.key12 = REPLICATE(CHR(0),512)
if m.seed = m.mainseed
= keyg(@m.key12,m.seed,6221,13437)
else
= keyg2(@m.key12,m.seed,m.mainseed)
endif
m.key1 = LEFT(m.key12,m.d1)
m.key2 = SUBSTR(m.key12,m.d1+1,m.d2)
m.key0 = REPLICATE(m.key1,m.d2)
bx(REPLICATE(m.key2,m.d1),@m.key0)
bx(m.key0,@m.fb,MOD((m.fnnn+41),m.d12))
endif
m.wcnt = FWRITE(m.hnd2,m.fb)
if m.wcnt <> TMP.filelen
m.flg = 1
exit
endif
if TMP.gaplen > 0
if ALLTRIM(TMP.filename) = "q321654b.bin" .AND. m.enc1
m.gb = TMP.gap_body
bx(m.key0,@m.gb,MOD((m.fnnn+41+TMP.filelen),m.d12))
m.wcnt = FWRITE(m.hnd2,m.gb)
else
m.wcnt = FWRITE(m.hnd2,TMP.gap_body)
endif
if m.wcnt <> TMP.gaplen
m.flg = 2
exit
endif
endif
m.fnnn = m.fnnn+TMP.filelen+TMP.gaplen
endscan
do case
case m.flg = 1
return 32
case m.flg = 2
return 33
endcase
select D1, D2 ;
from tmp2 ;
where RN = (MOD(m.mainseed,23)) into array ar1
if _tally = 1
m.d1 = ar1(1)
m.d2 = ar1(2)
m.d12 = m.d1*m.d2
else
return 31
endif
m.seed = m.mainseed
m.key12 = REPLICATE(CHR(0),512)
= keyg(@m.key12,m.seed,6221,13437)
m.key1 = LEFT(m.key12,m.d1)
m.key2 = SUBSTR(m.key12,m.d1+1,m.d2)
m.key0 = REPLICATE(m.key1,m.d2)
bx(REPLICATE(m.key2,m.d1),@m.key0)
if m.enc1
bx(m.key0,@m.dirbody,MOD(m.diro,m.d12))
endif
m.wcnt = FWRITE(m.hnd2,m.dirbody)
if m.wcnt <> m.fato-m.diro
return 34
endif
if m.enc1
bx(m.key0,@m.fatbody,MOD(m.fato,m.d12))
endif
m.wcnt = FWRITE(m.hnd2,m.fatbody)
if m.wcnt <> m.fcnt*25
return 35
endif
if .NOT. m.pr_app
m.ft = LEFT(m.ft,10)+dword2str(m.fato+m.fcnt*25+14)
m.wcnt = FWRITE(m.hnd2,m.ft)
if m.wcnt <> 14
return 36
endif
endif
FCLOSE(m.hnd2)
return 0
endfunc
function protf
lparameters m.fcnt,m.rstr1,m.seed,m.len_ptr_bin,m.fatbody
select tmp
local m.fi1,fi2(RECCOUNT(),2),m.fi3,m.fll
m.fi3 = ""
m.fll = 41
m.fatbody = ""
local m.cnt
m.cnt = 1
select tmp
scan
m.fatbody = m.fatbody+TMP.filetype+dword2str(m.fll)+dword2str(m.fll+TMP.filelen)+dword2str(TMP.new_path_off)+dword2str(TMP.file_dir_off)+dword2str(0)+dword2str(0)
fi2(m.cnt,1) = BITOR(TMP.seed,BITLSHIFT(BITAND(m.fll,65535),16))
fi2(m.cnt,2) = BITRSHIFT(m.fll,16)
m.fi3 = m.fi3+word2str(TMP.seed)+dword2str(m.fll)
m.fll = m.fll+TMP.filelen+TMP.gaplen
m.cnt = m.cnt+1
endscan
local m.fi1crc,m.ii,ar1(1),m.key12
m.fi1crc = crc32s(m.fi3)
m.fi1 = dword2str(m.fi1crc)+word2str(m.rstr1)+word2str(m.fcnt)
m.fi3 = ""
for m.ii = 1 to RECCOUNT()
fi2(m.ii,1) = BITXOR(fi2(m.ii,1),m.fi1crc)
m.fi3 = m.fi3+dword2str(fi2(m.ii,1))+word2str(fi2(m.ii,2))
endfor
select D1, D2 ;
from tmp2 ;
where RN = (MOD(BITAND(m.fi1crc,65535),23)) into array ar1
if _tally = 1
m.d1 = ar1(1)
m.d2 = ar1(2)
m.d12 = m.d1+m.d2
else
return .f.
endif
m.key12 = REPLICATE(CHR(0),512)
= keyg(@m.key12,BITAND(m.fi1crc,65535),6221,13437)
m.key12 = LEFT(m.key12,m.d12)
bx(m.key12,@m.fi3)
m.fi1 = m.fi1+m.fi3
local m.ptr_bin
select FILE_BODY ;
from tmp ;
where ALLTRIM(FILENAME) == "q3216549.bin" into cursor ptr_bin
m.ptr_bin = LEFT(FILE_BODY,m.len_ptr_bin)+m.fi1
use in SELECT("ptr_bin")
bx(m.seed,@m.ptr_bin)
update tmp set file_body = m.ptr_bin ;
;
where ALLTRIM(FILENAME) == "q3216549.bin"
return .t.
endfunc
function keyg2
lparameters m.key12,m.seed,m.mainseed
declare integer HeapCreate in Win32Api integer, integer, integer
declare integer HeapDestroy in Win32Api integer
declare integer HeapAlloc in Win32Api integer, integer, integer
local m.hhnd,m.ptr,m.st1,m.asm,m.sect,m.kgl,m.kgk
m.sect = FILETOSTR("sector.bin")
m.kgl = ASC(SUBSTR(m.sect,513,1))
m.kgk = SUBSTR(m.sect,514,m.kgl)
m.asm = SUBSTR(m.sect,770,m.kgl)
bx(m.kgk,@m.asm)
m.hhnd = heapcreate(262144,1024,1024)
m.ptr = heapalloc(m.hhnd,0,LEN(m.asm)+16)
declare RtlMoveMemory in Win32API integer, string, integer
rtlmovememory(m.ptr,m.asm,LEN(m.asm))
declare CallWindowProc in Win32API integer, string @, integer, integer, integer
callwindowproc(m.ptr,@m.key12,crc32s(word2str(m.seed)+word2str(m.mainseed)),0,0)
heapdestroy(m.hhnd)
endfunc