滴水逆向联盟

标题: 求助:basic_ifstream反汇编参数说明求解 [打印本页]

作者: Onlyxiu    时间: 2023-11-21 20:45
标题: 求助:basic_ifstream反汇编参数说明求解
本帖最后由 Onlyxiu 于 2023-11-21 20:47 编辑


ifstream srcFile("./in.log", ios::in);
反汇编代码如下:
        ifstream srcFile("./in.log", ios::in);  //以文本模式打开in.txt备读
009CAC41  push        0B8h;不知道这个0B8h代表是什么意思?????
009CAC46  lea         ecx,[srcFile]  
009CAC4C  call        std::basic_ifstream<char,std::char_traits<char> >::__autoclassinit2 (09C1159h)  
009CAC51  push        1   ;不知道这个参数代表是什么意思?????
009CAC53  push        40h; _SH_DENYNO 0x40
009CAC55  push        1  ; static constexpr _Openmode in = static_cast<_Openmode>(0x01);
009CAC57  push        offset string "./in.log" (09D3F0Ch)  
009CAC5C  lea         ecx,[srcFile]  
009CAC62  call        std::basic_ifstream<char,std::char_traits<char> >::basic_ifstream<char,std::char_traits<char> > (09C1226h)  
009CAC67  mov         dword ptr [ebp-4],0;为什么是赋值0 ,使用ifstream 就是0??,使用ofstream 就是1 ??

ofstream destFile("./out.txt", ios::out); //以文本模式打开out.txt备写
009CAC6E  push        0B0h  ; 不知道这个0B0h代表是什么意思?????
009CAC73  lea         ecx,[destFile]  
009CAC79  call        std::basic_ofstream<char,std::char_traits<char> >::__autoclassinit2 (09C1235h)  
009CAC7E  push        1 ;不知道这个参数代表是什么意思?????
009CAC80  push        40h ; _SH_DENYNO 0x40
009CAC82  push        2 ;static constexpr _Openmode out = static_cast<_Openmode>(0x02);
009CAC84  push        offset string "./out.txt" (09D3F18h)  
009CAC89  lea         ecx,[destFile]  
009CAC8F  call        std::basic_ofstream<char,std::char_traits<char> >::basic_ofstream<char,std::char_traits<char> > (09C16D6h)  
009CAC94  mov         byte ptr [ebp-4],1  ;为什么是赋值 1 ??


根据微软提供的参数说明是:
_Filename:要打开的文件的名称。
_Mode:ios_base::openmode 中的枚举之一。
  1.    static constexpr _Openmode in         = static_cast<_Openmode>(0x01);
  2.     static constexpr _Openmode out        = static_cast<_Openmode>(0x02);
  3.     static constexpr _Openmode ate        = static_cast<_Openmode>(0x04);
  4.     static constexpr _Openmode app        = static_cast<_Openmode>(0x08);
  5.     static constexpr _Openmode trunc      = static_cast<_Openmode>(0x10);
  6.     static constexpr _Openmode _Nocreate  = static_cast<_Openmode>(0x40);
  7.     static constexpr _Openmode _Noreplace = static_cast<_Openmode>(0x80);
  8.     static constexpr _Openmode binary     = static_cast<_Openmode>(0x20);
复制代码
_Prot:默认文件打开保护,等同于 _fsopen、_wfsopen 中的 shflag 参数。
  1. #define _SH_DENYRW      0x10    // deny read/write mode
  2. #define _SH_DENYWR      0x20    // deny write mode
  3. #define _SH_DENYRD      0x30    // deny read mode
  4. #define _SH_DENYNO      0x40    // deny none mode
  5. #define _SH_SECURE      0x80    // secure mode
复制代码





作者: bcjc2005    时间: 2023-11-25 00:33
本帖最后由 bcjc2005 于 2023-11-25 00:37 编辑

push        0B8h;这个是传给编译器自动生成的 autoclassinit2函数中的memset函数参数的大小,就是memset初始化函数的大小
push 1的值的作用栈保护调用 __RTC_CheckEsp  检查
操作完再写回0,可以说这操作是编译器自动生成的








欢迎光临 滴水逆向联盟 (http://www.dtdebug.com/) Powered by Discuz! X3.2