IDA __OFSUB__ 测试
生活随笔
收集整理的這篇文章主要介紹了
IDA __OFSUB__ 测试
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
IDA 反匯編插件有時會生成 OFSUB 這個宏,它的作用是測試兩個數相減是否溢出,返回溢出標志位。
// ofsub.cpp : 此文件包含 "main" 函數。程序執行將在此處開始并結束。 //#include <iostream> using namespace std;typedef char int8; typedef signed char sint8; typedef unsigned char uint8; typedef short int16; typedef signed short sint16; typedef unsigned short uint16; typedef int int32; typedef signed int sint32; typedef unsigned int uint32; typedef __int64 int64; typedef __int64 sint64; typedef unsigned __int64 uint64;// sign flag template<class T> int8 __SETS__(T x) {if (sizeof(T) == 1)return int8(x) < 0;if (sizeof(T) == 2)return int16(x) < 0;if (sizeof(T) == 4)return int32(x) < 0;return int64(x) < 0; }// overflow flag of subtraction (x-y) template<class T, class U> int8 __OFSUB__(T x, U y) {if (sizeof(T) < sizeof(U)){U x2 = x;int8 sx = __SETS__(x2);return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2 - y));}else{T y2 = y;int8 sx = __SETS__(x);return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x - y2));} }int main() {int res;unsigned char c1 = 0x80;unsigned char c2 = 0x01;res = __OFSUB__(c1, c2); // -128 - 1 溢出了cout << res << endl;c1 = 0x7F;c2 = 0x01;res = __OFSUB__(c1, c2); // 127 - 1 沒溢出cout << res << endl; }總結
以上是生活随笔為你收集整理的IDA __OFSUB__ 测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SEH反调试(SetUnhandledE
- 下一篇: 暴力关闭Windows defender