// VM.SetMemory(FirstPartLength,Window,BlockEnd);
rarVM.setMemory(FirstPartLength, window, 0, BlockEnd);
}
VMPreparedProgram ParentPrg = filters.get(
flt.getParentFilter()).getPrg();
VMPreparedProgram Prg = flt.getPrg();
if (ParentPrg.getGlobalData().size() > RarVM.VM_FIXEDGLOBALSIZE) {
// copy global data from previous script execution if
// any
// Prg->GlobalData.Alloc(ParentPrg->GlobalData.Size());
// memcpy(&Prg->GlobalData[VM_FIXEDGLOBALSIZE],&ParentPrg->GlobalData[VM_FIXEDGLOBALSIZE],ParentPrg->GlobalData.Size()-VM_FIXEDGLOBALSIZE);
Prg.getGlobalData().setSize(
ParentPrg.getGlobalData().size());
for (int i = 0; i < ParentPrg.getGlobalData().size()
- RarVM.VM_FIXEDGLOBALSIZE; i++) {
Prg.getGlobalData().set(
RarVM.VM_FIXEDGLOBALSIZE + i,
ParentPrg.getGlobalData().get(
RarVM.VM_FIXEDGLOBALSIZE + i));
}
}
ExecuteCode(Prg);
if (Prg.getGlobalData().size() > RarVM.VM_FIXEDGLOBALSIZE) {
// save global data for next script execution
if (ParentPrg.getGlobalData().size() < Prg
.getGlobalData().size()) {
ParentPrg.getGlobalData().setSize(
Prg.getGlobalData().size());// ->GlobalData.Alloc(Prg->GlobalData.Size());
}
// memcpy(&ParentPrg->GlobalData[VM_FIXEDGLOBALSIZE],&Prg->GlobalData[VM_FIXEDGLOBALSIZE],Prg->GlobalData.Size()-VM_FIXEDGLOBALSIZE);
for (int i = 0; i < Prg.getGlobalData().size()
- RarVM.VM_FIXEDGLOBALSIZE; i++) {
ParentPrg.getGlobalData().set(
RarVM.VM_FIXEDGLOBALSIZE + i,
Prg.getGlobalData().get(
RarVM.VM_FIXEDGLOBALSIZE + i));
}
} else {
ParentPrg.getGlobalData().clear();
}
int FilteredDataOffset = Prg.getFilteredDataOffset();
int FilteredDataSize = Prg.getFilteredDataSize();
byte[] FilteredData = new byte[FilteredDataSize];
for (int i = 0; i < FilteredDataSize; i++) {
FilteredData[i] = rarVM.getMem()[FilteredDataOffset + i];// Prg.getGlobalData().get(FilteredDataOffset
// +
// i);
}
prgStack.set(I, null);
while (I + 1 < prgStack.size()) {
UnpackFilter NextFilter = prgStack.get(I + 1);
if (NextFilter == null
|| NextFilter.getBlockStart() != BlockStart
|| NextFilter.getBlockLength() != FilteredDataSize
|| NextFilter.isNextWindow()) {
break;
}
// apply several filters to same data block
rarVM.setMemory(0, FilteredData, 0, FilteredDataSize);// .SetMemory(0,FilteredData,FilteredDataSize);
VMPreparedProgram pPrg = filters.get(
NextFilter.getParentFilter()).getPrg();
VMPreparedProgram NextPrg = NextFilter.getPrg();
if (pPrg.getGlobalData().size() > RarVM.VM_FIXEDGLOBALSIZE) {
// copy global data from previous script execution
// if any
// NextPrg->GlobalData.Alloc(ParentPrg->GlobalData.Size());
NextPrg.getGlobalData().setSize(
pPrg.getGlobalData().size());
// memcpy(&NextPrg->GlobalData[VM_FIXEDGLOBALSIZE],&ParentPrg->GlobalData[VM_FIXEDGLOBALSIZE],ParentPrg->GlobalData.Size()-VM_FIXEDGLOBALSIZE);
for (int i = 0; i < pPrg.getGlobalData().size()
- RarVM.VM_FIXEDGLOBALSIZE; i++) {
NextPrg.getGlobalData().set(
RarVM.VM_FIXEDGLOBALSIZE + i,
pPrg.getGlobalData().get(
RarVM.VM_FIXEDGLOBALSIZE + i));
}
}
ExecuteCode(NextPrg);
if (NextPrg.getGlobalData().size() > RarVM.VM_FIXEDGLOBALSIZE) {
// save global data for next script execution
if (pPrg.getGlobalData().size() < NextPrg
.getGlobalData().size()) {
pPrg.getGlobalData().setSize(
NextPrg.getGlobalData().size());
}
// memcpy(&ParentPrg->GlobalData[VM_FIXEDGLOBALSIZE],&NextPrg->GlobalData[VM_FIXEDGLOBALSIZE],NextPrg->GlobalData.Size()-VM_FIXEDGLOBALSIZE);
for (int i = 0; i < NextPrg.getGlobalData().size()
- RarVM.VM_FIXEDGLOBALSIZE; i++) {
pPrg.getGlobalData().set(
RarVM.VM_FIXEDGLOBALSIZE + i,
NextPrg.getGlobalData().get(
RarVM.VM_FIXEDGLOBALSIZE + i));
}
} else {
pPrg.getGlobalData().clear();
}
FilteredDataOffset = NextPrg.getFilteredDataOffset();
FilteredDataSize = NextPrg.getFilteredDataSize();
FilteredData = new byte[FilteredDataSize];
for (int i = 0; i < FilteredDataSize; i++) {
FilteredData[i] = NextPrg.getGlobalData().get(
FilteredDataOffset + i);
}
I++;
prgStack.set(I, null);