|
|
|
[讨论]能不能写出这样的宏?能参数枚举与拼接
不用format宏无法推导参数个数,除非带个参数个数进去,或者根据参数定义多个宏,Log(n,...) 或者LogN(),都影响美观,很久以前就干过这样的。 用模板可以实现这样的功能 boost里面的function有类似的功能 利用typelist和模板递归可以实现, --- 实在不行用默认参数,Log(P1 p1=NULL, .... ,Pn pn = NULL); 蛋疼 其实也许你根本不需要这样的功能,记得以前想实现一个类似function的功能,搞了很多宏和模板,太琐碎,后来直接用脚本生成了Function0,Fucntion1,...FuncionN, 简单明了快捷 我记得有人说过,我们很多时间都浪费在寻找捷径上面,而且不是经常走的捷径。 |
|
[讨论]能不能写出这样的宏?能参数枚举与拼接
[QUOTE=exile;1314534]#ifdef DEBUG #define dbgPrintf dbgPrintf__ #else #define dbgPrintf #endif int dbgPrintf__(const char *fmt, ...) { va_list args; char buffer[...[/QUOTE] 宏比函数的好处可以方便处理一些编译器信息,例如插入函数名等等: #define LogError(Format, ...) Log(Log_Error, __FUNCTION__, __LINE__, Format, __VA_ARGS__) |
|
[讨论]能不能写出这样的宏?能参数枚举与拼接
路过回复一下: 较新的编译器(现在一般都支持的)宏可以用__VA_ARGS__支持动态参数,比如 #define LogError(Format, ...) xxx( Format, __VA_ARGS__) xxx的实现可以用vDbgPrintEx或者CString.FormatV等等快速实现,自己可以参见printf或者DbgPrint实现。 比较旧的编译器可以用()来包含动态参数,可以参见kdPrint |
|
|
|
|
|
|
|
swapcontext中 调用 KeSetSystemAffinityThread 会bsod 有什么其他方法能代替这个函数的呢
64位系统也是一样滴,现代操作系统的设计原理都差不多的。 检测如果是一个线程,线程依赖线程调度,同样无视之。 Patchguard也是内存检测,由于用的是TimerDpc,不受线程调度影响,所以改成DPC分发时让检测线程,进程(或者说此时的虚拟内存为正确完整的),完全可以透明绕过任何检测。 难点是多CPU,多线程(或DPC)同时执行,如何保证相同进程的不同线程同时执行时的虚拟内存不一致才是最重要的,哎哟,扯远了,不说这个了 |
|
swapcontext中 调用 KeSetSystemAffinityThread 会bsod 有什么其他方法能代替这个函数的呢
给个更邪恶的 内存检测,皆是浮云 //************************************************************************* void PreSwapContext(PETHREAD Thread) { PEPROCESS Process = PsGetCurrentProcess(); if(!IsXxxxProcess(Process)) return; if(!g_EnablePatch) return; PatchXxxx(TRUE); } //************************************************************************* void PostSwapContext(PETHREAD Thread) { PEPROCESS Process = PsGetCurrentProcess(); if(!IsXxxxProcess(Process)) return; if(!g_EnablePatch) return; if(IsXxxxMainThread(Thread)) PatchXxxx(FALSE); else PatchXxxx(TRUE); } //************************************************************************* __declspec(naked) NewSwapContext() { __asm { pushad push esi call PreSwapContext popad call OldSwapContext pushad push esi call PostSwapContext popad ret } } //************************************************************************* |
|
[分享]一道“简单”的c++题目(个人觉得还是要对c++对象模型有比较深刻的理解才行)
Mase() { Base base; PULONG_PTR Base_VTable =reinterpret_cast<PULONG_PTR>(dynamic_cast<Base*>(&base)); PULONG_PTR Mase_Base_VTable = reinterpret_cast<PULONG_PTR>(dynamic_cast<Base*>(this)); DWORD dwProtect; VirtualProtect((PVOID)Mase_Base_VTable, sizeof(ULONG_PTR), PAGE_READWRITE, &dwProtect); Mase_Base_VTable[0] = Base_VTable[0]; VirtualProtect((PVOID)Mase_Base_VTable, sizeof(ULONG_PTR), dwProtect, &dwProtect); } 不要用 (int*)this获取虚函数表,虚函数表不是一定在第一个。(RTTI的影响等) 不要用Base::fun获取类成员指针,因为得到的是一个thunk。 -------------------------------------------------------------------------------------- 知道C++内存布局是好事,不过尽量不要硬编码引用C++编译器生产的数据,不同的编译器会有差异的。 |
|
|
|
求助关于detours的问题
调试DLL的话: 在dll的工程里面直接F5调试,选择进程notepad,注入后就可以调了。 notepad崩溃后,弹出来的错误信息估计就可以初步知道错误原因了。 -- 想象一个: 你注入调用dll函数后,dll是不是被卸载掉了, |
|
[讨论]让PatchGuard变狗屎的那些方法~
用你的PageHack(改P*E) + Hook KiRetireDpcList(改CR3) |
|
[求助]CProcessLocal类的疑问
应该是进入下面这个吧 AFX_INLINE operator TYPE*() { return GetData(); } 指针赋值,类型转换。 没有构造类不会进入构造函数的。 |
|
[求助]驱动中可以写构造函数吗
跟编译原理一毛钱关系都没有的(编译原理一直想认真看看,就是看不下去) 看看vc目录下面的CRT源码加上IDA看看就知道了。(其实我是看Driver Works的) 驱动用C++尽量写完后用IDA看一遍,看看他添加了什么,优化了什么,妥当点。。 |
|
[求助]驱动中可以写构造函数吗
不是你加入了构造函数出错,是存在.CRT节数据未初始化。 当你有构造函数时,或者有全局变量需要计算的时,编译器会生成一个Stub函数处理初始化,并把函数指针放到.CRT初始化列表中,会有一个LNK4210 warning,所以会提示错误。 解决方法,在source里面加入LINK_LIB_IGNORE=4210就可以了,不过这样的话,构造函数还是没有被执行。要执行必须添加一些代码。 #ifndef cppsupport_HPP #define cppsupport_HPP //************************************************************************* #include "new.hpp" //************************************************************************* typedef void (__cdecl *PFN_T)(); //************************************************************************* class AtExitCall { public: AtExitCall(PFN_T pF) { m_pF = pF; m_Next = m_ListHeader; m_ListHeader = this; } ~AtExitCall(void) { m_pF(); m_ListHeader = this->m_Next; } static void Run() { while(m_ListHeader) delete m_ListHeader; } PFN_T m_pF; AtExitCall* m_Next; static AtExitCall* m_ListHeader; static NTSTATUS m_Status; }; //************************************************************************* __declspec(selectany) AtExitCall* AtExitCall::m_ListHeader = NULL; __declspec(selectany) NTSTATUS AtExitCall::m_Status = STATUS_SUCCESS; //************************************************************************* #if _X86_ #pragma data_seg(".CRT$XCA") __declspec(selectany) PFN_T xc_a[1] = {0}; #pragma data_seg(".CRT$XCZ") __declspec(selectany) PFN_T xc_z[1] = {0}; #else #pragma section(".CRT$XCA", long, read) __declspec(allocate(".CRT$XCA")) __declspec(selectany) PFN_T xc_a[1] = {0}; #pragma section(".CRT$XCZ", long, read) __declspec(allocate(".CRT$XCZ")) __declspec(selectany) PFN_T xc_z[1] = {0}; #endif #pragma data_seg() #pragma comment(linker, "/merge:.CRT=.data") //************************************************************************* inline NTSTATUS cpplib_Startup() { for(PFN_T *pF = xc_a;pF < xc_z;pF++) if(*pF) (*pF)(); return AtExitCall::m_Status; } //************************************************************************* inline void cpplib_Exit() { AtExitCall::Run(); } //************************************************************************* extern "C" inline int __cdecl atexit(PFN_T pF) { return (new AtExitCall(pF) == 0) ? (*pF)(), AtExitCall::m_Status = STATUS_UNSUCCESSFUL, 1 : 0; } //************************************************************************* extern "C" inline int _cdecl puts(const char *p) { DbgPrint(p); return 0; } //************************************************************************* extern "C" inline void _cdecl exit(int Code) { KeBugCheck(Code); } //************************************************************************* #endif LINK_LIB_IGNORE=4210,4254 如果要用new创建类的话,自己再实现new和delete。 |
|
[求助]逆向调试新手,这个内联HOOK函数怎么写
在popad前面加入 mov [esp + offset_of_eax], eax popad 偏移自己算 ---------------------------- 其实修改的是call指令,调用过程寄存器也会改变,没必要保存寄存器,除非有特定的数据保存的某些寄存器里面。 |
|
|
|
发两张图
那年,当windows xp还未出现时,Driver Studio已经在用STLPort 用C++写驱动难的不是没有运行时库,谁都写得出来的。 1,用C++写驱动的前提是精通C++,必须保证你知道C++代码编译后出来的所有一切。 2,用C++写驱动还必须精通驱动和内核,必须知道所有内存的生命周期,确保栈空间不会溢出。 3,我太水了,还不知道 |
|
[求助]所谓服务的核心实现实质是什么?????
一,通信 这个跟进程间通信一样的,通信方式很多种,管道,共享内存,LPC,RPC,网络等等。 进程间地址空间隔绝是永远的,无法打穿的! 跨进程操作,或者上面的所谓通信,并没有打破进程间的地址隔离。 二,如何知道请求的存在 1,被动式(中断,回调) 当有请求来时,找到注册的请求处理器,将请求交给处理器分发处理。 2,主动式(轮询) while(GetMessage) DispatchMessage; 三,服务的安全性 在请求中加入认证令牌,过滤掉非法请求。 |
操作理由
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 }}
勋章
兑换勋章
证书
证书查询 >
能力值