Вот пример, как можно сеарилизовать скомпилированную функцию на диск,а потом запустить ее из другой программы, это может пригодится разработчикам интерпритаторов, компиляторов, защит от взлома и т.д.
#Compile Exe "compiler.exe"
#Dim All
#Include "win32api.inc"
Global L1 As Dword
Global L2 As Dword
Function Void(x As Long, y As Long) As Long
L1=CodePtr(Label1)
L2=CodePtr(Label2)
Label1:
Function=x+y
Exit Function
Label2:
End Function
Function PBMain () As Long
Void 0,0
Dim p As String
p=Peek$(L1,L2-L1)
Kill "Code.bin"
Open "Code.Bin" For Binary As 1
Put 1 , , p
Close 1
Shell "engine.exe"
End Function
Вставляем функцию с диска, прямо "внутрь" PB функции!
#Compile Exe "engine.exe"
#Dim All
#Include "win32api.inc"
Global L1 As Dword
Global L2 As Dword
Function Void(x As Long,y As Long) As Long
L1=CodePtr(Label1)
L2=CodePtr(Label2)
Label1:
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
! db &h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90,&h90
Label2:
End Function
Function PBMain () As Long
Dim p As String
'Èíèöèàëèçàöèÿ ïåðåìåííûõ L1 è L2
Void 0,0
'×òåíèå áèíàðíîãî êîíòåíòà
Dim BT As String
Dim SZ_BC As Dword
Open "Code.bin" For Binary As 1
SZ_BC=Lof(1)
Get$ 1,SZ_BC,BT
Close #1
Local OldProtect As Dword
VirtualProtect (ByVal L1, SZ_BC, %PAGE_EXECUTE_WRITECOPY, OldProtect)
Poke$ L1,BT
MsgBox Str$(Void (3,2))
End Function
Ответить
|