d3dbc.cpp

来自「包裝ffmpeg中的codecs成為DirectShow中的transform 」· C++ 代码 · 共 45 行

CPP
45
字号
#include "d3dbc.h"
#include <windows.h>

//-----------------------------------------------------------------------------
// 新增加的函数: VictorNtDllINT3() -- Victor Chen
//-----------------------------------------------------------------------------
// 如果在 debug 程序时频繁出现 ntdll.DbgBreakPoint 停下来,
// 需要按 200 多次 F9 (C++ Builder) 或 F5 (Visual C++) 才可跳过,
// 但这并不影响 .exe 文件, 也不是错误, 脱离环境可以正常运行。
// 如果你比较讨厌 ntdll.DbgBreakPoint, 或者想调试程序, 请在程序初始化时调用这个函数
//-----------------------------------------------------------------------------
void VictorNtDllINT3(void)
{
  HINSTANCE hNTDLL;
  DWORD BytesWritten;
  unsigned char *Address;
  unsigned char NOP = 0x90;

  OSVERSIONINFO ov;
  memset(&ov, 0, sizeof(OSVERSIONINFO));
  ov.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  if(GetVersionEx(&ov))
  if(ov.dwPlatformId == VER_PLATFORM_WIN32_NT)
   {
     if((hNTDLL = GetModuleHandle("NTDLL.DLL")) != NULL)
      {
        if((Address = (unsigned char *)GetProcAddress(hNTDLL, "DbgBreakPoint")) != NULL)
         {
           try
            {
              if(Address[0] == 0xcc)
               {
                 if(WriteProcessMemory(GetCurrentProcess(), Address, &NOP, 1, &BytesWritten))
                   FlushInstructionCache(GetCurrentProcess, Address, 1);
               }
            }
           catch(...)
            {
              //在这里遇到错误是没危险的, 所以不用处理这个错误
            }
         }
      }
   }
}
//-----------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?