' only an experimental test, 21-04-2025, frank brübach
' and it works :-)
#file "indep1d.exe" 'independent -> no need for it
'------
'PROLOG
'======
' I have added -------------- //
def _epilog 'FOR EXE
====================
._end_
mov edi,eax 'hold exit value in edi
push 0 'place for exit code
mov eax,esp
push eax
call getModuleHandle
push eax
call GetExitCodeProcess
mov eax,edi 'return exit value in eax
push eax
call ExitProcess
._error_
push 0x30
"MISSING OR UNLOADABLE"
push eax
push ecx
push 0
call [ebx+472]
mov eax,0
jmp _end_
end def 'eplilog for exe
' I have added -------------- //
mbox "hello" ' only for test purpose
push ebx : push esi : push edi : push ebp
mov ebp,esp
sub esp,256
'--------------------------------------------------------------
'MOVE BOOTSTRAP PROCEDURE POINTERS TO RUNTIME LIBRARY POSITIONS
'==============================================================
'
'GET ABSOLUTE ADDRESSES
'
call fwd here
.here
pop eax
sub eax,here
mov ebx,eax : add ebx,bssdata
mov edi,eax : add edi,import_address_table
'
mbox "hello2" ' only for test purpose
'--------------------------------
'COPY BOOTSTRAP LIBRARY ADDRESSES
'================================
'
mov eax,[edi+00] : mov [ebx+024],eax 'LoadLibrary
mov eax,[edi+04] : mov [ebx+040],eax 'GetProcAddress
mov eax,[edi+08] : mov [ebx+032],eax 'FreeLibrary
mov eax,[edi+12] : mov [ebx+440],eax 'GetModuleHandle
mov eax,[edi+16] : mov [ebx+448],eax 'GetGetCommandLine
mov eax,[edi+20] : mov [ebx+456],eax 'GetExitProcess
mov eax,[edi+24] : mov [ebx+464],eax 'ExitProcess
mov eax,[edi+28] : mov [ebx+480],eax 'CreateFileA
mov eax,[edi+32] : mov [ebx+488],eax 'Readfile
mov eax,[edi+36] : mov [ebx+496],eax 'CloseHandle
mov eax,[edi+44] : mov [ebx+472],eax 'MessageBoxA
'=============
jmp fwd endlib
'=============
mbox "hello3" ' only for test purpose
'-----------
TestMessage:
'===========
push 0
"title dolphin"
push eax
"message ocean"
push eax
push 0
call [ebx+472]
ret
'------------------
DisplayCommandLine:
'==================
push 0
"COMMAND LINE"
push eax
call [ebx+448]
push eax
push 0
call [ebx+472]
ret
'-------
Message:
'=======
pop edi
call [ebx+472]
push edi
ret 16
'======
endlib:
'======
'-----
'TESTS
'=====
call TestMessage
call DisplayCommandLine
call Message 0,"message oxygen","title o2h",1
mbox "ok4"
'------
'EPILOG
'======
endprog:
mov esp,ebp : pop ebp : pop edi : pop esi : pop ebx
ret
' ends
' Simple implementation for making runtime members
' - supports integer, float and string types.
'===================
class myfleximembers
'===================
indexbase 0
bstring buf, *varl
sys dp,en
method addVar(string name,dat)
sys le=len buf
if dp+16>le then
buf+=nuls 0x100 : le+=0x100 :
end if
@varl=?buf
varl[en]=name
varl[en+1]=dat
dp+=2*sizeof sys
en+=2 'next slot
end method
method find(string name) as sys
sys i
for i=0 to <en step 2
if name=varl[i] then return i+1
next
end method
method vars(string name) as string
sys f=find(name)
if f then return varl[f]
end method
method VarF(string name) as double
return vars(name)
end method
method VarI(string name) as sys
return vars(name)
end method
method vars(string name,dat)
bstring varl at buf
sys f=find(name)
if f then varl[f]=dat
end method
method delete()
sys i
sys v at buf
for i=0 to <en
freememory v[i]
next
freememory ?buf
? buf=0 : en=0 : dp=0
end method
end class
' demo test
myfleximembers z
z.addVar "p",5
z.addVar "q",4.5
z.addVar "r","123456"
print z.Vars("q")+z.vars("q") 'result 4.254.25
print z.Varf("q")+z.varf("q") 'result 9
print z.VarI("q")+z.vari("q") 'result 10
z.delete
' ends
'
' This is an Oxygen-independent program - the bare bones without a proper run time library.
' It has the minimal set of API calls to make it usable.
' This program cannot be run directly - it has to be compiled first. The EXE file size is 3.5k.
' You can use it for simple Asm with stack-based memory. There is no built in code
' for memory management or "bind" function.
' Charles
'
#file "indep.exe" independent
'------
'PROLOG
'======
push ebx : push esi : push edi : push ebp
mov ebp,esp
sub esp,256
'--------------------------------------------------------------
'MOVE BOOTSTRAP PROCEDURE POINTERS TO RUNTIME LIBRARY POSITIONS
'==============================================================
'
'GET ABSOLUTE ADDRESSES
'
call fwd here
.here
pop eax
sub eax,here
mov ebx,eax : add ebx,bssdata
mov edi,eax : add edi,import_address_table
'
'--------------------------------
'COPY BOOTSTRAP LIBRARY ADDRESSES
'================================
'
mov eax,[edi+00] : mov [ebx+024],eax 'LoadLibrary
mov eax,[edi+04] : mov [ebx+040],eax 'GetProcAddress
mov eax,[edi+08] : mov [ebx+032],eax 'FreeLibrary
mov eax,[edi+12] : mov [ebx+440],eax 'GetModuleHandle
mov eax,[edi+16] : mov [ebx+448],eax 'GetGetCommandLine
mov eax,[edi+20] : mov [ebx+456],eax 'GetExitProcess
mov eax,[edi+24] : mov [ebx+464],eax 'ExitProcess
mov eax,[edi+28] : mov [ebx+480],eax 'CreateFileA
mov eax,[edi+32] : mov [ebx+488],eax 'Readfile
mov eax,[edi+36] : mov [ebx+496],eax 'CloseHandle
mov eax,[edi+44] : mov [ebx+472],eax 'MessageBoxA
'=============
jmp fwd endlib
'=============
'-----------
TestMessage:
'===========
push 0
"title"
push eax
"message"
push eax
push 0
call [ebx+472]
ret
'------------------
DisplayCommandLine:
'==================
push 0
"COMMAND LINE"
push eax
call [ebx+448]
push eax
push 0
call [ebx+472]
ret
'-------
Message:
'=======
pop edi
call [ebx+472]
push edi
ret 16
'======
endlib:
'======
'-----
'TESTS
'=====
'call TestMessage
'call DisplayCommandLine
call Message 0,"message","title",1
'------
'EPILOG
'======
endprog:
mov esp,ebp : pop ebp : pop edi : pop esi : pop ebx
ret
'print "ok"
Page created in 0.092 seconds with 11 queries.