VESA VBE always failed

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
0x3D5
Posts: 3
Joined: Sun Oct 02, 2011 2:45 am

VESA VBE always failed

Post by 0x3D5 »

I am trying to use the int 0x10(VIDEO BIOS) but it always returns al != 0x4f(VBE Function failed). This is the code that I write in a driver:

Code: Select all

USHORT GetVbeMode()  

{  

__asm  

{  

cli  

mov eax,cr0  

mov Cr0Reg,eax  

and eax,0xffffffff  

mov cr0,eax  

 

mov eax,0x4F03      ;VESA VBE Function  

  

INT 0x10            ;VIDEO BIOS  

   

cmp al,0x4F  

jnz falhou          ;always al != 4f  



mov Resultado,bx  

mov eax,Cr0Reg  

mov cr0,eax  

sti  

jmp final  

   

falhou  

mov Resultado,0  

mov eax,Cr0Reg  

mov cr0,eax  

sti  

jmp final  

   

final:  

}  

return Resultado;  

} 
What is wrong at this code that I write???
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: VESA VBE always failed

Post by Combuster »

Code: Select all

mov eax,cr0 
mov Cr0Reg,eax 
and eax,0xffffffff 
mov cr0,eax
(...)
mov eax,Cr0Reg 
mov cr0,eax 
nop
nop
nop
nop
:roll:
Last edited by Combuster on Mon Oct 10, 2011 1:47 am, edited 1 time in total.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: VESA VBE always failed

Post by gerryg400 »

Code: Select all

mov eax,cr0  
mov Cr0Reg,eax  
and eax,0xffffffff  
mov cr0,eax  
What is this supposed to do ? Are you trying to get from 32bit protected mode to real mode ? That's not how to do it.

Even if you fix the obvious bug in your code, it still won't do what you want it to do.
If a trainstation is where trains stop, what is a workstation ?
0x3D5
Posts: 3
Joined: Sun Oct 02, 2011 2:45 am

Re: VESA VBE always failed

Post by 0x3D5 »

I am trying to switch to real mode to call the INT 0x10
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: VESA VBE always failed

Post by gerryg400 »

0x3D5 wrote:I am trying to switch to real mode to call the INT 0x10
Switching to real mode requires a lot more than simply changing a bit in CR0. (and your code does not modify CR0). You need to restore the entire real mode environment that the BIOS expects. You need to reverse all the operations that you performed to go from real mode to protected mode.
If a trainstation is where trains stop, what is a workstation ?
Post Reply