Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
45
Task/Machine-code/PureBasic/machine-code.basic
Normal file
45
Task/Machine-code/PureBasic/machine-code.basic
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
CompilerIf #PB_Compiler_Processor <> #PB_Processor_x86
|
||||
CompilerError "Code requires a 32-bit processor."
|
||||
CompilerEndIf
|
||||
|
||||
|
||||
; Machine code using the Windows API
|
||||
|
||||
Procedure MachineCodeVirtualAlloc(a,b)
|
||||
*vm = VirtualAlloc_(#Null,?ecode-?scode,#MEM_COMMIT,#PAGE_EXECUTE_READWRITE)
|
||||
If(*vm)
|
||||
CopyMemory(?scode, *vm, ?ecode-?scode)
|
||||
eax_result=CallFunctionFast(*vm,a,b)
|
||||
VirtualFree_(*vm,0,#MEM_RELEASE)
|
||||
ProcedureReturn eax_result
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
rv=MachineCodeVirtualAlloc( 7, 12)
|
||||
MessageRequester("MachineCodeVirtualAlloc",Str(rv)+Space(50),#PB_MessageRequester_Ok)
|
||||
|
||||
#HEAP_CREATE_ENABLE_EXECUTE=$00040000
|
||||
|
||||
Procedure MachineCodeHeapCreate(a,b)
|
||||
hHeap=HeapCreate_(#HEAP_CREATE_ENABLE_EXECUTE,?ecode-?scode,?ecode-?scode)
|
||||
If(hHeap)
|
||||
CopyMemory(?scode, hHeap, ?ecode-?scode)
|
||||
eax_result=CallFunctionFast(hHeap,a,b)
|
||||
HeapDestroy_(hHeap)
|
||||
ProcedureReturn eax_result
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
rv=MachineCodeHeapCreate(7,12)
|
||||
MessageRequester("MachineCodeHeapCreate",Str(rv)+Space(50),#PB_MessageRequester_Ok)
|
||||
End
|
||||
|
||||
; 8B442404 mov eax,[esp+4]
|
||||
; 03442408 add eax,[esp+8]
|
||||
; C20800 ret 8
|
||||
|
||||
DataSection
|
||||
scode:
|
||||
Data.a $8B,$44,$24,$04,$03,$44,$24,$08,$C2,$08,$00
|
||||
ecode:
|
||||
EndDataSection
|
||||
Loading…
Add table
Add a link
Reference in a new issue