Msgbox asm

Started by Frank Brübach, May 06, 2024, 07:48:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

Hello Charles

Can you Help for this msgbox expl with asm?
Doesn't Work Here

' uses corewin
' msgbox 64 bit
'
print "ok"

Declare Function MessageBox Lib "user32.dll" alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long

zstring tit[] ="The great world of OxygenBasic..."
zstring msg[] ="Happy Easter"

sub  rsp,32
mov  r9d, 0 ' error here     
lea  r8,  tit   
lea  rdx, msg   
mov  rcx, 0       
call MessageBox
add  rsp,32

print "not ok2"

Charles Pegge

#1
Needs to use 32bit asm with the 32bit default oxygen.dll

Declare Function MessageBox Lib "user32.dll" alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long

zstring tit[] ="The great world of OxygenBasic..."
zstring msg[] ="Happy Easter"

'32bit asm
'=========
push 0 '1
addr eax,tit
push eax
addr eax,msg
push eax
push 0
call MessageBox

But you can create a 64bit binary instead of a JIT:

$filename "t.exe"
uses rtl64
'msgbox 64 bit
'
Declare Function MessageBox Lib "user32.dll" alias "MessageBoxA" (ByVal hwnd As sys, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long

zstring tit[] ="The great world of OxygenBasic..."
zstring msg[] ="Happy Easter"

sub  rsp,32
mov  r9d, 0     
lea  r8,  tit   
lea  rdx, msg   
mov  rcx, 0       
call MessageBox
add  rsp,32

Frank Brübach

Hi Charles again..

How I can add correct two numbers in 64 Bit Mode in this msgbox example?  Thx in advance , Frank

' 64 bit x86
'
$ FileName "test64add2number.exe"
#include "$\inc\RTL64.inc"

byte val1
byte val2
int result
   
    val1=4
    val2=6 '

     '' mov eax,val1 
     '' mov eax,val2  ''multiply eax by ebx  "
     '' mul val1 'ebx 
     '' mov result,eax


'------------------ //
     mov rax,rdi
     add rax, val2 
     'add val1 'rax,
     mov rdi,val1
     mov result,rax
'------------------ //

zstring tit[]="64Bit OxygenBasic"
zstring msg[]="Hello dear Animal World! " + str(result)

'' oxygen 64 bit
''
sub  rsp,40h
mov  r9,  0       
lea  r8,  tit   
lea  rdx, msg   
mov  rcx, 0
call messagebox       
add  rsp, 40h
''
'' output: Hello dear Animal World! 24


Charles Pegge

#3
Here's a trade secret:

You can reveal the Assembly code of any piece of Oxygen by using the #show command:

it shows the intermediate code followed by Asm code

int a,b,c
#show {
a=b+c
mbox str(a)
}

The code can also be stored directly into a text file:
int a,b,c
#show  "t.txt" {
a=b+c
mbox str(a)
}

Frank Brübach

#4
Thanks again Charles and didnt know yet that Show command

Found the solution by another c++ example about asm 64 Bit I was quite near the solution

Oxygen Code
'' -- add x64bit example, 30-5-2024 by frank bruebach
'' -- oxygen basic
''
$filename "t1b.exe"
uses rtl64
'
'messagebox 64 bit
'
Declare Function MessageBox Lib "user32.dll" alias "MessageBoxA" (ByVal hwnd As sys, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long

byte val1
byte val2
int result
   
    val1=4
    val2=6 '

    mov rax, [val1]
    add rax, [val2]
    mov [result], rax
    mov eax, 60

zstring tit[] ="The great world of OxygenBasic..."
zstring msg[]="Hello dear Animal World! " + str(result)

sub  rsp,40h
mov  r9d, 0     
lea  r8,  tit   
lea  rdx, msg   
mov  rcx, 0       
call MessageBox
add  rsp,40h
'
' ok result 10

Now I am calm No more questions today :)