First, sorry for my bad endlish. If you know what i say,please help me~
Thanks~
Here is a program maked with QBasic7.1, I reverse it by IDA Pro5.6 and found following SUB:
SEG01sub11728 proc far ; CODE XREF: SEG27sub5741D+19A4P
var_16 = word ptr -16h
var_14 = word ptr -14h
mov cx, 4
mov bx, 0
call far ptr B$ENRD ; Allocate space on stack
;
call near ptr EventChk1
call B$LINA
mov ds:word718E2, 64h ; 'd'
call near ptr EventChk1
call B$LINA
push offset word718E2
call SEG15sub35826
mov [bp+var_14], ax
mov si, 5FCh
mov ax, [bp+var_14]
mov [si+54B4h], ax ; here is problem1
call near ptr EventChk1
call B$LINA
mov ds:word718E4, 64h ; 'd'
call near ptr EventChk1
call B$LINA
push offset word718E4
call SEG15sub35826
mov [bp+var_16], ax
xor si, si
mov ax, [bp+var_16]
mov [si+54B4h], ax ; here is problem2
call near ptr EventChk1
call B$LINA
call far ptr B$EXSA
retf 0
SEG01sub11728 endp
Convert it to following QBasic code:
SUB SEG01sub11728
word718E2% = &H64
var14% = SEG15sub35826%(word718E2%)
'
' How the problem1 Asmcode are converted ?
'
word718E4% = &H64
var16% = SEG15sub35826%(word718E4%)
'
' How the problem2 Asmcode are converted ?
'
END SUB
Thanks fro your helping ~
QBasic reverse Need help
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
You probably will need help from somebody framiliar with ASM or Assembly code in Qbasic. There are some tutorials here:
http://www.petesqbsite.com/sections/tut ... mbly.shtml
Ted
http://www.petesqbsite.com/sections/tut ... mbly.shtml
Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Hi Ted:
Your link is so cool, but can not resolve my problem. I want to convert the AsmCode to
relevant QBasic code.
In problem1, The AsmCode written a memory address [si + 54B4h] and "si" is 5fch, in problem2 "si" is zero.
If "54b4h" is a global var's address, what is it type? an array or a user defined type?
1: if it is a array, like DIM A%(766), when we use the following QBasic code
a%(0) = 1
BC will generate following Asm code:
push 0 ' this is index
push 1
mov bx, OFFSET a%
call B$HARY
mov word ptr[bx], 1
2: if it is a UserType,like:
TYPE UserType
a1 AS INTEGER
a2 AS STRING * &H5f8
a3 AS INTEGER
END TYPE
DIM a AS UserType
a.a1 = 1
The relevant AsmCode is: mov ds:xxxxxxx, 1
Also we can write these code:
POKE VARPTR(a)+&H5fc, 2
The AsmCode is:
mov ax, 36h ; '6'
add ax, 5FCh
into
mov bx, ax
mov ax, 2
mov es, word ptr ds:b$seg
mov es:[bx], al
We can see, there are different~,
I am a QBasic beginner(about 1 month). Is there any other method can let BC generate the destnation AsmCode?
Thanks~
Your link is so cool, but can not resolve my problem. I want to convert the AsmCode to
relevant QBasic code.
In problem1, The AsmCode written a memory address [si + 54B4h] and "si" is 5fch, in problem2 "si" is zero.
If "54b4h" is a global var's address, what is it type? an array or a user defined type?
1: if it is a array, like DIM A%(766), when we use the following QBasic code
a%(0) = 1
BC will generate following Asm code:
push 0 ' this is index
push 1
mov bx, OFFSET a%
call B$HARY
mov word ptr[bx], 1
2: if it is a UserType,like:
TYPE UserType
a1 AS INTEGER
a2 AS STRING * &H5f8
a3 AS INTEGER
END TYPE
DIM a AS UserType
a.a1 = 1
The relevant AsmCode is: mov ds:xxxxxxx, 1
Also we can write these code:
POKE VARPTR(a)+&H5fc, 2
The AsmCode is:
mov ax, 36h ; '6'
add ax, 5FCh
into
mov bx, ax
mov ax, 2
mov es, word ptr ds:b$seg
mov es:[bx], al
We can see, there are different~,
I am a QBasic beginner(about 1 month). Is there any other method can let BC generate the destnation AsmCode?
Thanks~
Problem was resloved~ Its a UserType-Array-Var,
Code: Select all
TYPE UserType
a1 AS INTEGER
a2 AS LONG
a3 AS SINGLE
END TYPE
TYPE UserArr
pData(1) AS UserType
END TYPE
DIM SHARED aUserData AS UserArr
aUserData.pData(1).a1 = 1
' Now,BC does not generate B$HARY