|
[求助]p77 thiscall 的问题
这个push ecx是编译器优化后的局部变量分配,因为函数只用到一个DWORD大小的局部变量,编译器不使用sub esp,4来开辟局部变量的堆栈空间,而是使用push reg32来开辟,一般就是push ecx。 这个局部变量应该是一个临时的未初始化的对象,被作为this(ecx)传递给00401020函数。 所以不要被push ecx给迷惑了,以为是传递参数什么的。书上教的是死的,要结合环境判定作用。 再如lea eax,[eax+1234578]就是取地址吗?其实只是编译器用来做简单加法而已。 call $+5就是用来调用函数吗?其实只是用来压入下一个指令地址而已。 |
|
[已解决] 一个封包算法的解析求助
代码给你,有用的自己抠出来。到这地步你还不会,我也没办法了。 我看了网上在线转换UTF8的点,都很扯,转换完全不正确。 至于易语言,我不知道是不是它的实现不行,还是你的参数不正确。 建议去理解一下Unicode编码规范以及UTF-8编码规范。 另外,你贴出来的原始封包,并不是全是UTF-8,只有中间一段文字是UTF-8,不能全转换 ws_utf8.h /*! \file ws_utf8.h \brief ws_utf8.h用于如UTF8与UNICODE相互转换 \section ws_utf8 ver 1.1.1305.2510 (For All) - \b 2013-03-07 新增unicode与utf8编码的转换。\n ascii与utf8的转换需要自行先从ascii转换为unicode。0.1 - \b 2013-03-08 发现WinXP的ntdll不提供UTF函数,故参考UTF8文档,重新实现。0.1~1.0 - \b 2013-03-09 扩展支持4 byte Unicode - \b 2013-05-25 处理转换时多处理一个数据的BUG。1.0~1.1 \author triones \date 2013-03-07 */ #pragma once #include "blks.h" /*! 转换一个unicode字符为一个utf8字符 \param utf8 utf8结果缓冲,可为NULL \param unicode unicode字符 \return 返回转换字节数,返回0表示失败 */ int unicode_byte2utf8_byte(unsigned char* utf8, const unsigned long unicode); /*! 转换一个utf8字符为一个unicode字符\n 注意,自动跳过非法的UTF8字符、不完整的UTF8字符 \param unicode 结果缓冲,可为NULL \param utf8 utf8字符指针 \return 返回读取utf8字节数,返回0表示失败 */ int utf8_byte2unicode_byte(unsigned long* unicode, const unsigned char* const utf8); //! UNICODE串转换UTF8串(版本一) /*! \param utf8 指向转换UTF8结果的缓冲区 \param max_utf8 指示转换UTF8结果的缓冲区的最大容量(以byte计) \param ws 需要转换的UNICODE串 \param ws_len 需要转换的UNICODE串的长度(以宽字计)\n ws_len缺省为-1时,视ws为null结束的串\n 注意:需要用户自行提供足够转换缓冲。另请注意参数顺序 \return 转换成功与否 \code #include "ws_s.h" char str[40]; if(!ws2utf8(str,sizeof(str),L"文字")) { cout<<"ws2utf8转换出错,LastError:"<<GetLastError(); } \endcode */ bool ws2utf8(unsigned char* uft8, const int max_uft8, const wchar_t* ws, const int ws_len = -1); //! UNICODE串转换UTF8串(版本二) /*! \param ws 需要转换的UNICODE串 \return 转换后的对应UTF8串对象 \code #include "ws_s.h" blks<char> s = ws2utf8(L"文字"); if(s.empty()) { cout<<"ws2utf8转换出错,LastError:"<<GetLastError(); } \endcode */ blks<unsigned char> ws2utf8(const wchar_t* ws); //! UTF8串转换UNICODE串(版本一) /*! \param ws 指向转换UNICODE结果的缓冲区 \param max_ws 指示转换UNICODE结果的缓冲区的最大容量(以宽字计) \param utf8 需要转换的UTF8串 \param utf8_len 需要转换的UTF8串的长度(以宽字计)\n utf8_len缺省为-1时,视s为null结束的串 \return 转换成功与否\n 注意:需要用户自行提供足够转换缓冲。另请注意参数顺序 */ bool utf82ws(wchar_t* ws, const int max_ws, const unsigned char* utf8, const int utf8_len = -1); //! UTF8串转换UNICODE串(版本二) /*! \param utf8 需要转换的UTF8串 \return 转换后的对应UNICODE串对象 */ blks<wchar_t> utf82ws(const unsigned char* utf8); ------------------------------------------------ ws_utf8.cpp #include "ws_utf8.h" static const int gk_utf8_max_byte = 6; //utf8最大占用字节 #pragma warning(push) #pragma warning(disable:4244) //warning C4244: “=”: 从“const unsigned long”转换到“unsigned char”,可能丢失数据 int unicode_byte2utf8_byte(unsigned char* utf8, const unsigned long unicode) { unsigned char tu[gk_utf8_max_byte]; if(utf8 == NULL) utf8 = (unsigned char*)&tu; //0000 0000 0000 0000 0000 0000 0111 1111 7bit //0000 0000 0000 0000 0000 0000 0XXX XXXX 7bit if(unicode < 0x00000080) { utf8[0] = ((unicode & 0x0000007F) >> 0) | 0x00; return 1; } //0000 0000 0000 0000 0000 0000 10XX XXXX 6bit const unsigned long a = ((unicode & 0x0000003F) >> 0) | 0x80; //0000 0000 0000 0000 0000 0111 1111 1111 11bit //0000 0000 0000 0000 0011 0XXX XX00 0000 5bit if(unicode < 0x00000800) { utf8[1] = a; utf8[0] = ((unicode & 0x000007C0) >> 6) | 0xC0; return 2; } //0000 0000 0000 0000 0010 XXXX XX00 0000 6bit const unsigned long b = ((unicode & 0x00000FC0) >> 6) | 0x80; //0000 0000 0000 0000 1111 1111 1111 1111 16bit //0000 0000 0000 1110 XXXX 0000 0000 0000 4bit if(unicode < 0x00010000) { utf8[2] = a; utf8[1] = b; utf8[0] = ((unicode & 0x0000F000) >> 12) | 0xE0; return 3; } //0000 0000 0000 10XX XXXX 0000 0000 0000 6bit const unsigned long c = ((unicode & 0x0003F000) >> 12) | 0x80; //0000 0000 0001 1111 1111 1111 1111 1111 21bit //0000 0011 110X XX00 0000 0000 0000 0000 3bit if(unicode < 0x00200000) { utf8[3] = a; utf8[2] = b; utf8[1] = c; utf8[0] = ((unicode & 0x001C0000) >> 18) | 0xF0; return 4; } //0000 0010 XXXX XX00 0000 0000 0000 0000 6bit const unsigned long d = ((unicode & 0x00FC0000) >> 18) | 0x80; //0000 0011 1111 1111 1111 1111 1111 1111 26bit //1111 10XX 0000 0000 0000 0000 0000 0000 2bit if(unicode < 0x04000000) { utf8[4] = a; utf8[3] = b; utf8[2] = c; utf8[1] = d; utf8[0] = ((unicode & 0x03000000) >> 24) | 0xF8; return 5; } //00XX XXXX 0000 0000 0000 0000 0000 0000 6bit const unsigned long e = ((unicode & 0x3F000000) >> 24) | 0x80; //0111 1111 1111 1111 1111 1111 1111 1111 31bit //0X00 0000 0000 0000 0000 0000 0000 0000 1bit if(unicode < 0x80000000) { utf8[5] = a; utf8[4] = b; utf8[3] = c; utf8[2] = d; utf8[1] = e; utf8[0] = ((unicode & 0x04000000) >> 30) | 0xFC; return 6; } return 0; } #pragma warning(pop) int utf8_byte2unicode_byte(unsigned long* unicode, const unsigned char* const utf8) { if(utf8 == NULL) return 0; unsigned long tu; if(unicode == NULL) unicode = &tu; const unsigned char utf8_flag[gk_utf8_max_byte] = {0x7F,0xC0,0xE0,0xF0,0xF8,0xFC}; bool done = false; int lp = 0; while(!done) { if(utf8[lp] <= utf8_flag[0]) { *unicode = utf8[lp]; return 1; } if(utf8[lp] < utf8_flag[1]) //首字节非法,跳过 { ++lp; continue; } for(int i = 2; i < gk_utf8_max_byte; ++i) { if((utf8[lp] < utf8_flag[i])) { unsigned long u = utf8[lp] ^ utf8_flag[i-1]; ++lp; int j = 1; for(; j < i; ++j) { ++lp; if(utf8[lp-1] >= utf8_flag[1]) break; //后继字节非法,跳过 u <<= 6; u |= (utf8[lp-1] & 0x3F); } if(j == i) { *unicode = u; return lp; } done = true; //读取UTF字符不完整,需要重来 } if(done) { done = false; break; } } } return 0; } bool ws2utf8(unsigned char* uft8, const int max_uft8, const wchar_t * ws, const int ws_len) { if((uft8 == NULL) || (max_uft8 <= 1) || (ws == NULL) || (ws_len == 0)) return false; int wlen = ws_len; if(ws_len < 0) { for(wlen = 0; ws[wlen] != TEXT('\0'); ++wlen); } ++wlen; int lp = 0; for(int i = 0; i < wlen ; ++i) { int k = unicode_byte2utf8_byte(&uft8[lp],ws[i]); if(k == 0) return false; lp += k; if(lp >= max_uft8) return false; } return true; } blks<unsigned char> ws2utf8(const wchar_t* ws) { blks<unsigned char> utf8; if(ws == NULL) return utf8; int wlen = 0; for(; ws[wlen] != TEXT('\0'); ++wlen); ++wlen; unsigned char u[gk_utf8_max_byte]; for(int i = 0; i < wlen ; ++i) { int k = unicode_byte2utf8_byte(u,ws[i]); if(k == 0) { utf8.clear(); break; } utf8.put(u,k); } return utf8; } bool utf82ws(wchar_t* ws, const int max_ws, const unsigned char* utf8, const int utf8_len) { if((ws == NULL) || (max_ws <= 1) || (utf8 == NULL) || (utf8_len == 0)) return false; int ulen = utf8_len; if(utf8_len < 0) { for(ulen = 0; utf8[ulen] != '\0'; ++ulen); } ++ulen; int lp = 0; for(int i = 0; i < ulen ;) { unsigned long ch; int k = utf8_byte2unicode_byte(&ch,&utf8[i]); if(k == 0) return false; ws[lp] = (wchar_t)ch; if(lp >= max_ws) return false; ++lp; i += k; } return true; } blks<wchar_t> utf82ws(const unsigned char* utf8) { blks<wchar_t> ws; if(utf8 == NULL) return ws; int ulen = 0; for(; utf8[ulen] != '\0'; ++ulen); ++ulen; for(int i = 0; i < ulen ;) { unsigned long ch; int k = utf8_byte2unicode_byte(&ch,&utf8[i]); if(k == 0) { ws.clear(); return ws; } ws << (wchar_t)ch; i += k; } return ws; } |
|
[已解决] 一个封包算法的解析求助
哥,代码都贴给你了,还不信。不信去问百度http://baike.baidu.com/view/25412.htm 看了utf8编码的定义就可以知道,只要是中文,utf8编码应该都是3 byte,且都以0xE开头。 u5C0F是“小”的Unicode编码,不是UTF8编码 |
|
[已解决] 一个封包算法的解析求助
这编码,明显是UTF8。 win7及以上,kernel自带Unicode转UTF8的API,名字忘记了,自求度娘。 win7以下,系统不自带转换函数,需要自己实现。不过好像其它高级语言有转换的库函数,也自求度娘。 给你一个片段: static const int gk_utf8_max_byte = 6; //utf8最大占用字节 #pragma warning(push) #pragma warning(disable:4244) //warning C4244: “=”: 从“const unsigned long”转换到“unsigned char”,可能丢失数据 int unicode_byte2utf8_byte(unsigned char* utf8, const unsigned long unicode) { unsigned char tu[gk_utf8_max_byte]; if(utf8 == NULL) utf8 = (unsigned char*)&tu; //0000 0000 0000 0000 0000 0000 0111 1111 7bit //0000 0000 0000 0000 0000 0000 0XXX XXXX 7bit if(unicode < 0x00000080) { utf8[0] = ((unicode & 0x0000007F) >> 0) | 0x00; return 1; } //0000 0000 0000 0000 0000 0000 10XX XXXX 6bit const unsigned long a = ((unicode & 0x0000003F) >> 0) | 0x80; //0000 0000 0000 0000 0000 0111 1111 1111 11bit //0000 0000 0000 0000 0011 0XXX XX00 0000 5bit if(unicode < 0x00000800) { utf8[1] = a; utf8[0] = ((unicode & 0x000007C0) >> 6) | 0xC0; return 2; } //0000 0000 0000 0000 0010 XXXX XX00 0000 6bit const unsigned long b = ((unicode & 0x00000FC0) >> 6) | 0x80; //0000 0000 0000 0000 1111 1111 1111 1111 16bit //0000 0000 0000 1110 XXXX 0000 0000 0000 4bit if(unicode < 0x00010000) { utf8[2] = a; utf8[1] = b; utf8[0] = ((unicode & 0x0000F000) >> 12) | 0xE0; return 3; } //0000 0000 0000 10XX XXXX 0000 0000 0000 6bit const unsigned long c = ((unicode & 0x0003F000) >> 12) | 0x80; //0000 0000 0001 1111 1111 1111 1111 1111 21bit //0000 0011 110X XX00 0000 0000 0000 0000 3bit if(unicode < 0x00200000) { utf8[3] = a; utf8[2] = b; utf8[1] = c; utf8[0] = ((unicode & 0x001C0000) >> 18) | 0xF0; return 4; } //0000 0010 XXXX XX00 0000 0000 0000 0000 6bit const unsigned long d = ((unicode & 0x00FC0000) >> 18) | 0x80; //0000 0011 1111 1111 1111 1111 1111 1111 26bit //1111 10XX 0000 0000 0000 0000 0000 0000 2bit if(unicode < 0x04000000) { utf8[4] = a; utf8[3] = b; utf8[2] = c; utf8[1] = d; utf8[0] = ((unicode & 0x03000000) >> 24) | 0xF8; return 5; } //00XX XXXX 0000 0000 0000 0000 0000 0000 6bit const unsigned long e = ((unicode & 0x3F000000) >> 24) | 0x80; //0111 1111 1111 1111 1111 1111 1111 1111 31bit //0X00 0000 0000 0000 0000 0000 0000 0000 1bit if(unicode < 0x80000000) { utf8[5] = a; utf8[4] = b; utf8[3] = c; utf8[2] = d; utf8[1] = e; utf8[0] = ((unicode & 0x04000000) >> 30) | 0xFC; return 6; } return 0; } #pragma warning(pop) |
|
[求助]TP更新后双机调试的探究
TesSafe+0x25d6应该只与双机有关。单机依然无法附加。 所有内核修正能pass,DebugPort能恢复。已知:IO定时器一个、内核回调一个、内核线程两个、内核IAT钩子两个。 求heretic继续爆料 |
|
[求助]分析QQ2013协议,OD加载后,下什么断点
TXProtocol优先采用UDP协议进行登陆交互,不要先从TCP下手。 楼主连这个都不知道,恐怕这要跟出来,时间会把你的耐性消磨殆尽。 UDP八至九次尝试ping,首先响应者继续通讯。其余关闭。都未响应者开启TCP通讯。TCP同上。 协议中大量的MD5,及通讯交互的加密算法TEAN。加油吧 |
|
[求助]变量所占空间的字节计算问题,请教中!!!
注意我之前有提醒过你: [QUOTE=triones;1179705] 但是一般编译器对同类型数据有合并优化,如果你定义这样的结构: typedef struct { char ss[11]; char on; DWORD one; }ok_i; 那么,你应该能得到想要的结果sizeof(ok_i) == 16。 [/QUOTE] 编译器对连续的、同类型数据,有合并优化 |
|
|
|
[求助]变量所占空间的字节计算问题,请教中!!!
基本所有编译器都是这个规则,这个规则的制定是为了提高CPU的数据访问速度,利大于弊。 你要不就接受它,要不就在自己的代码写上#pragma pack (push,1),要不就设置编译选项:C/C++>>>代码生成>>>结构成员对齐(1字节 /Zp1) 注意强制对齐可能会影响你的程序执行效率。 |
|
[求助]变量所占空间的字节计算问题,请教中!!!
align,结构体内存对齐机制。默认情况下变量以CPU的一个字长对齐,目前多数是32位CPU,所以结构体变量都以DWORD对齐。于是: typedef struct { char ss[11]; //占用3个dword即12byte,最后一个byte无用被用以后继数据对齐 DWORD one; }ok_i; 而: typedef struct { char ss[11]; //同上 DWORD one; char one; //这个变量占用一个dword空间即4byte }ok_i; 但是一般编译器对同类型数据有合并优化,如果你定义这样的结构: typedef struct { char ss[11]; char on; DWORD one; }ok_i; 那么,你应该能得到想要的结果sizeof(ok_i) == 16。 另外,如果你非得要自己那么写结构体,又希望sizeof()如你所愿。可以这么写: #pragma pack (push,1) //强制1byte对齐 typedef struct { char ss[11]; DWORD one; }ok_i; #pragma pack (pop) //恢复默认对齐 sizeof(ok_i) == 15 , as your wish. |
|
[求助]各种对象的type问题
//http://hi.baidu.com/_achillis/blog/item/b175e2d254745ad8a8ec9a69.html typedef enum _SYSTEM_HANDLE_TYPE { OB_TYPE_UNKNOWN, OB_TYPE_TYPE, OB_TYPE_DIRECTORY, OB_TYPE_SYMBOLIC_LINK, OB_TYPE_TOKEN, OB_TYPE_PROCESS, OB_TYPE_THREAD, OB_TYPE_JOB, OB_TYPE_DEBUG_OBJECT, OB_TYPE_EVENT, OB_TYPE_EVENT_PAIR, OB_TYPE_MUTANT, OB_TYPE_CALLBACK, OB_TYPE_SEMAPHORE, OB_TYPE_TIMER, OB_TYPE_PROFILE, OB_TYPE_KEYED_EVENT, OB_TYPE_WINDOWS_STATION, OB_TYPE_DESKTOP, OB_TYPE_SECTION, OB_TYPE_KEY, OB_TYPE_PORT, OB_TYPE_WAITABLE_PORT, OB_TYPE_ADAPTER, OB_TYPE_CONTROLLER, OB_TYPE_DEVICE, OB_TYPE_DRIVER, OB_TYPE_IOCOMPLETION, OB_TYPE_FILE, OB_TYPE_WMIGUID } SYSTEM_HANDLE_TYPE; 你要的是这样的么? |
|
[求助]inline hook导致Chrome崩溃
DEP是可以主动用API开启的,具体是怎么写忘记了,外事google内事baidu... |
|
[求助]驱动开发环境
我常用的是VS2008,不过VS2010也一样配置,一样编译。以下是VS2008编译驱动的相关配置: C/C++ 常规 附加包含目录:D:\WINDDK\7600.16385.1\inc\ddk;D:\WINDDK\7600.16385.1\inc;D:\WINDDK\7600.16385.1\inc\api;D:\WINDDK\7600.16385.1\inc\crt(重要设置) 代码生成 启用C++异常:关闭 //驱动无法使用C++的try,如果不关闭也能编译,但驱动无法加载。 //驱动可以使用__try处理异常 运行库:MT //貌似使用DLL不行 缓冲区完全检查:关闭 //一般关闭 高级 调用约定:__stdcall(重要设置) 链接器 常规 启用增量:否 //增量经常造成一些莫名其妙的问题 忽略导入库:否 附加库目录:D:\WINDDK\7600.16385.1\LIB\WXP\I386(重要设置) 使用库依赖输入:否 输入 附加依赖项:ntoskrnl.lib(重要设置) 忽略所有默认库:否 清单文件 启用用户帐户控制(UAC):否(重要设置) 系统 子系统:控制台(重要设置) 驱动程序:驱动程序(重要设置) 高级 入口点:DriverEntry(重要设置) 基址:0x10000 以上设置是我当前使用的设置,希望对你有所帮助 |
|
[分享]关于某电子书商城随意免费下载的,准备写个续集
昨天它还做活动,全场电子书0元来着。不过我还是喜欢看纸介质,每年不都向它进贡不少老毛。。。 |
|
[求助]unicode 字符串问题
第一次得到的是类如"\uxxxx\uxxxx"的字符串,这只是表示Unicode字符的字符串,还没经过转换。 把它赋值给一个String。Striing的重载初始化内部将这串字符串转换了,于是,再输出,你看到了中文。 大多数WEB服务器都如此传输数据,所以一般接到的数据先decode一下。你现在遇到的是Unicode,以后还有UTF8呢。 |
|
如何向EXE程序中插入代码,修改PE,实现pediy?
Grid1.Cols = 110 Grid1.Rows = 3000 你随便提供的反汇编代码中,并没有体现这几个变量具体在哪个位置。问题样本不准确,所以没有人会知道如何帮助你。 解决方法:1、如楼上所说,自行定位关健位置。2、放出这个VB程序,并且至少指出这几个变量的原始值。 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值