Oxy Independent asm (old)

Started by Frank Brübach, April 19, 2025, 10:41:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach


hello charles, I have found this old o2 example. looks interesting.
how to use it? that's possible to make a message to print any output?

thanks, frank

'
' 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"

Charles Pegge

Hi Frank,

That looks like the beginnings of the 32bit run-time library: RTL32.inc. Before that, Oxygen binaries were dependent on including oxygen.dll with every app.

Frank Brübach

#2
Yes thanks Charles I know :-)

Ok.. How this old example can translate to actual rtl32 inc File? Or thats Nonsens value?  Thanks in advance nice Happy easter Party .. WE Had Sunny Times in Germany  and all is full of blossom plants and tress

Charles Pegge

It is a small part of RTL32, and does not mean very much without the PE file headers specified in inc\self\hdrs.inc. It is a small set of Windows API functions required to initiate Oxygen.dll before the remaining Runtime functions are constructed.

Excellent weather for Easter day, But very quiet down here. I heard a woodpecker in the distance, which is a good sign for our local ecology.

Frank Brübach


hello charles, made this example works. just for fun..
usage: compile/compile and run binary32
output: two mesage boxes and display a command line..

  ' 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