flat assembler
Message board for the users of flat assembler.

Index > Main > OllyDBG under wine, strtod, Inexact floating-point result

Author
Thread Post new topic Reply to topic
borbonhause



Joined: 18 Oct 2015
Posts: 23
borbonhause
For some reason, OllyDBG, if run under wine, keeps spamming "Inexact floating-point result" messages and pausing debugging. This makes debugging impossible, program just never finishes because of all those pauses. Is it possible to disable this somehow? Even the "pass all FPU exceptions" option makes little difference, because OllyDBG still pauses with a message "application was unable to process exception".

Maybe _controlfp() can disable them, somehow?

Here is an example of program where this happens, just so you can experience this for yourself:

Code:
; Example of making 32-bit PE program as raw code and data

format PE GUI
entry start

section '.text' code readable executable

  start:
        push    0
        push    _number
        call    [strtod]
        ; Here I'm getting "Inexact floating-point result - Shift+Run/Step to pass exception to the program
        ; And after shift-F9: "Inexact floating-point result - application was unable to process exception"

        push    0
        push    _caption
        push    _message
        push    0
        call    [MessageBoxA]

        push    0
        call    [ExitProcess]

section '.data' data readable writeable

  _caption db 'Win32 assembly program',0
  _message db 'Hello World!',0
  _number db '888888888.55',0

section '.idata' import data readable writeable

  dd 0,0,0,RVA kernel_name,RVA kernel_table
  dd 0,0,0,RVA user_name,RVA user_table
  dd 0,0,0,RVA msvcrt_name,RVA msvcrt_table
  dd 0,0,0,0,0

  kernel_table:
    ExitProcess dd RVA _ExitProcess
    dd 0
  user_table:
    MessageBoxA dd RVA _MessageBoxA
    dd 0
  msvcrt_table:
    strtod dd RVA _strtod
        dd 0

  kernel_name db 'KERNEL32.DLL',0
  user_name db 'USER32.DLL',0
  msvcrt_name db 'MSVCRT.DLL',0

  _ExitProcess dw 0
    db 'ExitProcess',0
  _MessageBoxA dw 0
    db 'MessageBoxA',0
  _strtod dw 0
    db 'strtod',0

section '.reloc' fixups data readable discardable       ; needed for Win32s
    


Also I need more info about FPU exceptions processing on windows. In C or fasm.

_________________
If you found bad grammar in my post, please PM me about it.
Post 08 Nov 2015, 10:44
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
I am using OllyDbg 1.10 and it works fine in Linux with the above example.
Post 08 Nov 2015, 10:52
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
You can disable the inexact exception with the control register. By default it should be disabled anyway. Try putting FINIT in your code before you do anything with the FPU.
Post 08 Nov 2015, 11:58
View user's profile Send private message Visit poster's website Reply with quote
borbonhause



Joined: 18 Oct 2015
Posts: 23
borbonhause
JohnFound wrote:
I am using OllyDbg 1.10 and it works fine in Linux with the above example.

I used version 2.01, and problem is solved after moving to 1.10. Thank you.

revolution wrote:
You can disable the inexact exception with the control register. By default it should be disabled anyway. Try putting FINIT in your code before you do anything with the FPU.

This fixes even for 2.01, but with some quirks. It works if I just press run, but if I execute command by command, FINIT command is ignored, and FST and FCW registers stay at 0000. Yes, and program starts with FST==0000 in OllyDBG 2.01 for some weird reason. Not sure if this is Olly bug of Wine bug, my Wine is at least year old.

Yes, and exceptions can also happen even inside MessageBoxA, deep deep inside.

Thank you for telling about this command, now I have more hints about how FPU exceptions work.

BTW, maybe anyone knows what those things under FPU registers mean? Words like "Cond", "Err", "Prec", "Mask", "Last cmnd", "E S P U O Z D I"?

_________________
If you found bad grammar in my post, please PM me about it.
Post 08 Nov 2015, 16:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
borbonhause: Perhaps you would like to read the Intel or AMD docs to learn about the FPU internal status registers. It would take too long to explain here in a forum post. But in brief those are indicating various internal events that occur in the FPU.
Post 08 Nov 2015, 21:35
View user's profile Send private message Visit poster's website Reply with quote
borbonhause



Joined: 18 Oct 2015
Posts: 23
borbonhause
I did read this instead: http://www.ray.masmcode.com/tutorial/fpuchap1.htm . But it uses a bit different abbriviations for everything. For example, it explains what P U O Z D I is, but E S is using different abbriviation in that page. 4bit "Cond" field is unexplained too, biggest field in Status Word Register is 3bit long. This "(GT)" to the right of "Err" is a mistery too.

I have read the OllyDBG manual for 2.01 yesterday, but didn't managed to find the meaning of these.
Post 09 Nov 2015, 06:50
View user's profile Send private message Reply with quote
borbonhause



Joined: 18 Oct 2015
Posts: 23
borbonhause
Maybe I should create a new thread instead of that "BTW"...
Post 09 Nov 2015, 07:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
borbonhause: I suggest you go to the source: Either the Intel for AMD docs. Other webpages can be mistaken, use different terminology and/or omit things (as you have found out).
Post 09 Nov 2015, 07:12
View user's profile Send private message Visit poster's website Reply with quote
borbonhause



Joined: 18 Oct 2015
Posts: 23
borbonhause
Redirecting to a 5000 pages long docs, that's pretty nice of you... Yeah, sure, I'll go there.
Post 09 Nov 2015, 10:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17714
Location: In your JS exploiting you and your system
revolution
The FPU is a complex unit. It needs a lot of explanation. And not all 5000 pages are about the FPU. Just a section or two is enough to find the descriptions of all the various registers and status bits that the FPU has.
Post 09 Nov 2015, 11:05
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.