Tips

1. "x" command in windbg requires the module name.
For example, if we only type "x createprocessa" in windbg, we will get nothing. "x kernel32!createprocessa" is the correct way.
If you really do not know the module name, but want to search certain symbol, you can do something like tihs:
x *!kiuserexceptiondispatcher

2. "call" and "ret" instructors
"call" and "ret" instructors in Windows are both in near form.
Call: place the next instructor address on the stack top, then transfer control to the operand address.
Ret: pop the DWORD from the stack top and load it into the EIP.

3. Calculate string length for WriteFile, ReadFile
When calculating string buffer length for string mainpulation API, we have 2 scenarios: string array and string pointer. The correct solution is listed below:

string array:
TCHAR szBuf[dwMessageLen];
dwMessageLen*sizeof(TCHAR) or sizeof(szBuf) +sizeof(TCHAR)

string pointer:
PTSTR pszMessage=TEXT("Default message from server...");
(_tcslen(pszMessage) +1)*sizeof(TCHAR)

Note: you should not use sizeof(pszMessage) for string pointer. This will yeild the pointer length instead of string buffer length. Also, for string pointer, we should count the last zero terminator since _tcslen will not take the zero terminator into account.  This is the same for sizeof, so we should add sizeof(TCHAR) to the sizeof(szBuf).

4. Return type and calling convention order
When definiting and declaring function, we should place return type BEFORE the calling convention, or a compile-time error will generate. For example, we should declare like this:
LONG WINAPI MSJExceptionHandler::MSJUnhandledExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo)
instead of
WINAPI  LONG MSJExceptionHandler::MSJUnhandledExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo)

转载于:https://www.cnblogs.com/jeffreytan/archive/2006/03/28/360865.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值