Author Topic: Hard Core  (Read 2817 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Hard Core
« on: January 05, 2011, 06:16:15 AM »

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

Code: [Select]

  #file "t.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

efgee

  • Guest
Re: Hard Core
« Reply #1 on: January 05, 2011, 03:26:50 PM »
Sweet!

BTW: IMHO the 16KB min size with the whole runtime sounds good too.

bye

Emil_halim

  • Guest
Re: Hard Core
« Reply #2 on: March 27, 2013, 09:16:22 AM »
Hi Charles ,

this example did not run in my system , compiled okay but did not run.

any help please.

Charles Pegge

  • Guest
Re: Hard Core
« Reply #3 on: March 27, 2013, 10:27:12 AM »
That was an early RTL64 stub

I would advise reverse-engineering the current RTLs, to get an understanding of how they work. The vectored functions and some of the macros are synchronised/mapped to the compiler, so I wouldnt touch those but you can add your own non-vectored functions to customise your own libraries if you so wish.