Is possible to switch between protected mode and not protected mode, in MASM32? i.e. I wish to use INT 21, and after go back to notprotected mode.

Thanks
Posted on 2002-03-29 10:25:12 by nestor
nestor,

This does not make any sense with the information you supplied.

Win32API has completely replaced ( almost ) every DOS function, plus then some.

So what DOS function are you trying to use?

There are VXD's that let you do intXX programming from Windows without switching modes. There was another thread with that answer on the BB.

Enjoy your work, P1
Posted on 2002-03-29 12:14:34 by Pone
Once in protected mode you can't go back to real mode, the processor must be reset, but you can use Virtual 8086 mode.
Posted on 2002-03-29 14:12:01 by Asm_Freak
Reset was required ONLY for the 286 CPU since 386 CPU there are a lots of ways to get OUT (and IN) protected mode without a reset :)

Most notably seting a bit in CRO :) of course one can NOT do that in Ring3 Win32 (MASM or NOT) code neither inside a V86 Machine...

I see little use of that "return to inocennce" even from a VXD as that will bring havoc to the OS...but yes it can be done... after all VMM does it for "compatible mode" devices.

VMM gets back to real mode executes BIOS code in real mode and them switches back to protected mode...a dangerouse and somehow slow process...
Posted on 2002-03-29 14:34:42 by BogdanOntanu
Well, I was just asking because a couple times, when I was debugging some software with SoftIce, suddenly I land in 16bit code (like 1234:4567 mov ax, 0...), and after tracing a while, I got back in 32bit code...so I dont understand what was happening.

By the way, what means CRO? and ring3?:confused:

Thanks to all.
Posted on 2002-03-29 17:04:01 by nestor
CR0 is a control register, you cannot properly use this in ring 3.

Rings are like priviledge levels. Rings runs from 0 to 3. Ring0 is where the windows OS kernel runs, device drivers executes... A normal app runs in ring3. In Ring0 there are no restrictions which makes it a greater possibility you might destroy your "operating system files stuffs". In Ring3 is the most safest place, whenever an error occur there is less chance It might corrupt something.

Just remember: less rings, more priviledges, greater possibility you might corrupt a data. ;) and vice versa...


Before I forgot, about that mov ax, 0 you can still use that on a 32 bit program


xor eax, eax
mov ax, 5
EAX will now hold the value 5.
Posted on 2002-03-29 17:18:08 by stryker
I thought compatibility mode drivers ran in v86 mode?

nestor, the IA32 architecture can run "Virtual Machines" when in
32bit mode, which is the way dos apps are run - sort of "emulated
realmode", with a bunch of restrictions and hardware virtualization.

Swapping between pmode and rmode is possible from 386 and
upwards (and on 286 with the processor reset method), but it is
*very* slow...

Waddaya wanna do? :)
Posted on 2002-03-29 17:53:46 by f0dder

CR0 is a control register, you cannot properly use this in ring 3.

Rings are like priviledge levels. Rings runs from 0 to 3. Ring0 is where the windows OS kernel runs, device drivers executes... A normal app runs in ring3. In Ring0 there are no restrictions which makes it a greater possibility you might destroy your "operating system files stuffs". In Ring3 is the most safest place, whenever an error occur there is less chance It might corrupt something.

Just remember: less rings, more priviledges, greater possibility you might corrupt a data. ;) and vice versa...


Before I forgot, about that mov ax, 0 you can still use that on a 32 bit program


xor eax, eax
mov ax, 5
EAX will now hold the value 5.
BTW: one *can* read CR0 from ring3 (for what it's worth).. the trick is to use the SMSW instruction.
Posted on 2002-03-29 18:19:24 by Maverick
smsw only gives you part of cr0 though :)
Posted on 2002-03-29 18:27:53 by f0dder
Yup :) And it's totally useless anyway ("for what it's worth"..) :)

PS: it's undocumented, but you can get all 32 bits from SMSW (put a $66 prefix before).

PS2: my concept of "totally useless" was about Win32 applications.
Posted on 2002-03-29 18:29:23 by Maverick
Well, it's not *totally* useless, it allows raw-pmode apps to detect
if processor is already in protected mode, so they can abort gracefully
without throwing an exception on CR0 access :).
Posted on 2002-03-29 18:32:50 by f0dder