首页
社区
课程
招聘
[原创]第一阶段第三题
2008-10-8 15:30 2062

[原创]第一阶段第三题

2008-10-8 15:30
2062
第一阶段第三题

出错地点:

根据出错提示
R6002
floating-point support not loaded
找按钮按下的响应函数和可能出错的地方,找到下面的函数。
在00420D29处设置断点,单步往下走,在00420D81发现出错的函数。

.text:00420D20 sub_420D20      proc near
.text:00420D20
.text:00420D20 var_9C          = qword ptr -9Ch
.text:00420D20 var_94          = dword ptr -94h
.text:00420D20 Text            = word ptr -90h
.text:00420D20 Dst             = byte ptr -8Eh
.text:00420D20 var_C           = dword ptr -0Ch
.text:00420D20 var_8           = qword ptr -8
.text:00420D20
.text:00420D20                 push    ebp
.text:00420D21                 mov     ebp, esp
.text:00420D23                 sub     esp, 94h
.text:00420D29                 mov     eax, dword_429DA8
.text:00420D2E                 xor     eax, ebp
.text:00420D30                 mov     [ebp+var_C], eax
.text:00420D33                 mov     [ebp+var_94], ecx
.text:00420D39                 mov     ax, ds:word_425A30
.text:00420D3F                 mov     [ebp+Text], ax
.text:00420D46                 push    126             ; Size
.text:00420D48                 push    0               ; Val
.text:00420D4A                 lea     ecx, [ebp+Dst]
.text:00420D50                 push    ecx             ; Dst
.text:00420D51                 call    _memset
.text:00420D56                 add     esp, 0Ch
.text:00420D59                 fld     ds:dbl_425DC0
.text:00420D5F                 fstp    [ebp+var_8]
.text:00420D62                 fld     [ebp+var_8]
.text:00420D65                 fadd    st, st
.text:00420D67                 fstp    [ebp+var_8]
.text:00420D6A                 sub     esp, 8
.text:00420D6D                 fld     [ebp+var_8]
.text:00420D70                 fstp    [esp+9Ch+var_9C]
.text:00420D73                 push    offset aPi2F    ; "PI * 2 = %f"
.text:00420D78                 push    64              ; Count
.text:00420D7A                 lea     edx, [ebp+Text]
.text:00420D80                 push    edx             ; Dest
.text:00420D81                 call    __snwprintf                    // 出错的函数位置!
.text:00420D86                 add     esp, 14h
.text:00420D89                 push    64              ; uType
.text:00420D8B                 push    offset Caption  ; "TestFloag"
.text:00420D90                 lea     eax, [ebp+Text]
.text:00420D96                 push    eax             ; lpText
.text:00420D97                 mov     ecx, [ebp+var_94]
.text:00420D9D                 call    sub_405C75
.text:00420DA2                 mov     ecx, [ebp+var_C]
.text:00420DA5                 xor     ecx, ebp
.text:00420DA7                 call    sub_40ECBD
.text:00420DAC                 mov     esp, ebp
.text:00420DAE                 pop     ebp
.text:00420DAF                 retn
.text:00420DAF sub_420D20      endp

出错原因:

浮点库没有加载。

C Run-Time Error R6002
floating-point support not loaded
The program needs the floating-point library, but the
library was not linked to the program.

A format string for a printf or scanf function contained
a floating-point format specification, and the program
did not contain any floating-point values or variables.

解决办法:

以下是MSDN中的解释,原因很简单,不细说。
具体的解决办法:参照例子,修改源码。

Many Microsoft run-time library functions require
floating-point support from a math coprocessor or from
the floating-point libraries that accompany the compiler.
Floating-point support functions are loaded only if required.

When you use a floating-point type specifier in the
format string of a call to a function in the printf or
scanf family, you must specify a floating-point value
or a pointer to a floating-point value in the argument
list to tell the compiler that floating-point support
is required.

参考代码:

#include <stdio.h>

void main()
{
        char str[256] = "-0.00250213,-0.0423715";

        // VC6.0 运行时一般不加载浮点库。
        float fx;
        //随便写一个浮点操作即可加载浮点库。
        fx = 0.0f;

        sscanf(str,"%f",&fx);   // 如果没有加载浮点库程序执行到这里将报错
}

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
点赞0
打赏
分享
最新回复 (1)
雪    币: 264
活跃值: (30)
能力值: ( LV12,RANK:250 )
在线值:
发帖
回帖
粉丝
kangaroo 6 2008-10-14 15:53
2
0
请再仔细考虑!!!
游客
登录 | 注册 方可回帖
返回