主题:EM9360 wince5.0读文本文件的问题

  共有32034人关注过本帖    
帅哥哟,离线,有人找我吗?
bingdongcha
1楼 信息 | 搜索 | 邮箱


加好友 发短信
EM9360 wince5.0读文本文件的问题  发帖心情 Post By:2013-9-3 16:11:00   [显示全部帖子]

在开发板wince5.0系统的NandFlash文件夹下建立datlib文件夹。在datlib文件夹下有yc.txt文本文件。用vs2005编程序读这个文本文件,编译通过,生成解决方案通过,部署解决方案通过。在启动调试时,卡在在了加载模块: coredll.dll,这里不动了。显示如下:

加载模块: tt1.exe
加载模块: ws2.dll
加载模块: coredll.dll

但是当文本文件中的字符小于20行("2 20"这一行)时,在启动调试,一切正常,可以运行。显示如下:

加载模块: tt1.exe
加载模块: ws2.dll
加载模块: coredll.dll
加载模块: ssllsp.dll
加载模块: wspm.dll
CDT Thread run success by gaoyang 

MacuSend Thread run 

MacuReceive Thread run 

***************************************************
***************************************************
yc.txt文件内容如下:

"1 1"
"1 2"
"1 3"
"1 10"
"1 11"
"1 20"
"1 25"
"7 1"
"7 2"
"7 3"
"7 10"
"7 11"
"7 20"
"7 25"
"2 1"
"2 2"
"2 3"
"2 10"
"2 11"
"2 20"
"2 25"
"6 1"
"6 2"
"6 3"
"6 10"
"6 11"
"6 20"
"6 25"


程序代码如下:

// 读第一个CDT数据库点表  遥测表
// strcpy(strtmp1,"/NandFlash/datlib/CDTA.yc");
strcpy(strtmp1,"/NandFlash/datlib/yc.txt");
if((fp = fopen(strtmp1, "r")) != NULL)
{
for (tmp = 0; tmp < 256; tmp++)
{
if (!(fgets(cdt_str[tmp], 31, fp)))
break;
cdt_count++;
}
yc_total = 0;
fclose(fp);
for(tmp = 0; tmp < cdt_count; tmp++)
{
tmp1 = sscanf(cdt_str[tmp], "\"%d %d\"",
&cdt_tx0.ycd[tmp].dyno, &cdt_tx0.ycd[tmp].lxno);
if(tmp1 == 0)
break;
cdt_tx0.ycd[tmp].dyno--;
yc_total++;
}
cdt_tx0.a_all_len = yc_total / 2 + yc_total % 2;
}

***************************************************************************
在出现问题时,设置断点,可以看到程序已经把第20行后的所有数据都读出来了。继续单步运行程序,最后会跳到secchk.c这个文件,程序运行箭头停在这个程序的最后一行不动了。
程序只涉及到串口和IO操作,编的是电力CDT规约,应该没有涉及到cookie的东西。



  单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
bingdongcha
2楼 信息 | 搜索 | 邮箱


加好友 发短信
  发帖心情 Post By:2013-9-3 16:11:00   [显示全部帖子]

secchk.c的内容如下:

/***
*secchk.c - checks buffer overrun security cookie for x86
*
*       Copyright (c) Microsoft Corporation.  All rights reserved.
*
*Purpose:
*       Defines compiler helper __security_check_cookie, used by the /GS
*       compile switch to detect local buffer variable overrun bugs/attacks.
*
*       When compiling /GS, the compiler injects code to detect when a local
*       array variable has been overwritten, potentially overwriting the
*       return address (on machines like x86 where the return address is on
*       the stack).  A local variable is allocated directly before the return
*       address and initialized on entering the function.  When exiting the
*       function, the compiler inserts code to verify that the local variable
*       has not been modified.  If it has, then an error reporting routine
*       is called.
*
*******************************************************************************/

#include <windows.h>
#include <process.h>

/*
 * The global security cookie.  This name is known to the compiler.
 */
extern UINT_PTR __security_cookie;

/***
*__security_check_cookie(cookie) - check for buffer overrun
*
*Purpose:
*       Compiler helper.  Check if a local copy of the security cookie still
*       matches the global value.  If not, then report the fatal error.
*
*       The actual reporting is done by __report_gsfailure
*       since the cookie check routine must be minimal code that preserves
*       any registers used in returning the callee's result.
*
*Entry:
*       UINT_PTR cookie - local security cookie to check
*
*Exit:
*       Returns immediately if the local cookie matches the global version.
*       Otherwise, calls the failure reporting handler and exits.
*
*Exceptions:
*
*******************************************************************************/

void __declspec(naked) __fastcall __security_check_cookie(UINT_PTR cookie)
{
    /* x86 version written in asm to preserve all regs */
    __asm {
        cmp ecx, __security_cookie
        jne failure
        rep ret /* REP to avoid AMD branch prediction penalty */
failure:
        jmp __report_gsfailure
    }
}


  单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
bingdongcha
3楼 信息 | 搜索 | 邮箱


加好友 发短信
  发帖心情 Post By:2013-9-4 13:30:00   [显示全部帖子]

找到原因了。
这个程序是在别的系统移植过来的,原先系统对点表做了20个的限制。所以出现了BUG。

  单帖管理 | 引用 | 回复 回到顶部

返回首页

EM9360 wince5.0读文本文件的问题

用户名:
            验证码: 验证码,看不清楚?请点击刷新验证码
内容: