VS2008可以调试COM dll吗?

发布于 2024-11-05 14:28:29 字数 1455 浏览 1 评论 0原文

这可能是一个非常愚蠢的问题。
是否可以在 VS2008 中调试我没有源代码的 COM dll?

我想要这样做的原因是我将一个数组传递给 COM 方法,并且我希望该数组由该方法填充。
然而,该数组并未被填充。所以我想进入 COM 方法看看发生了什么。这可能吗?

下面是我正在使用的代码示例:

Array binaryArray = Array.CreateInstance(typeof(sbyte), 896);
bool success = photo.GetBinaryData(binaryArray);

GetBinaryData 方法的 IDL:

[id(0x000000c9)]
HRESULT GetBinaryData(
                [in] SAFEARRAY(char) buffer, 
                [out, retval] VARIANT_BOOL* retval);

GetBinaryData 方法是我想要单步执行的 COM 方法。

编辑:添加一个有效的 Delphi 测试脚本

procedure TComTestForm.TestUserBtnClick(Sender: TObject);
var
  nCnt :integer;
  User :IUser;
  Persona :IUserPersona;
  ArrayBounds :TSafeArrayBound;
  ArrayData :Pointer;
  TagList :PSafeArray;
  nSize :integer;
begin
  User := Session.GetUser;

  ArrayBounds.lLbound   := 0;
  ArrayBounds.cElements := 0;

  TagList := SafeArrayCreate( varInteger, 1, ArrayBounds );
  User.GetTags( TagList );
  if SafeArrayAccessData( TagList, ArrayData ) = S_OK then
    begin
      nSize := TagList.rgsabound[0].cElements;
      OutLine( '----Available Tags, ' + IntToStr(nSize) + ' tags' );
  for nCnt := 0 to nSize - 1 do
    begin
  OutLine( IntToStr( IntegerArray(ArrayData)[nCnt] ) );
end;

OutLine( '----');

SafeArrayUnAccessData( TagList ); SafeArrayDestroy( 标签列表 ); 结尾;

结尾;

This may be a very stupid question.
Is it possible to debug a COM dll in VS2008 for which I do not have the source code?

The reason I want to do this is I am passing an Array to a COM method and I expect this Array to be populated by the method.
However the Array is not being populated. So I want to step into the COM method to see whats happening. is this possible?

Below is an example of the code I am using:

Array binaryArray = Array.CreateInstance(typeof(sbyte), 896);
bool success = photo.GetBinaryData(binaryArray);

IDL for the GetBinaryData method:

[id(0x000000c9)]
HRESULT GetBinaryData(
                [in] SAFEARRAY(char) buffer, 
                [out, retval] VARIANT_BOOL* retval);

The GetBinaryData method is the COM method which I would like to step into.

EDIT: Adding a Delphi test script which works

procedure TComTestForm.TestUserBtnClick(Sender: TObject);
var
  nCnt :integer;
  User :IUser;
  Persona :IUserPersona;
  ArrayBounds :TSafeArrayBound;
  ArrayData :Pointer;
  TagList :PSafeArray;
  nSize :integer;
begin
  User := Session.GetUser;

  ArrayBounds.lLbound   := 0;
  ArrayBounds.cElements := 0;

  TagList := SafeArrayCreate( varInteger, 1, ArrayBounds );
  User.GetTags( TagList );
  if SafeArrayAccessData( TagList, ArrayData ) = S_OK then
    begin
      nSize := TagList.rgsabound[0].cElements;
      OutLine( '----Available Tags, ' + IntToStr(nSize) + ' tags' );
  for nCnt := 0 to nSize - 1 do
    begin
  OutLine( IntToStr( IntegerArray(ArrayData)[nCnt] ) );
end;

OutLine( '----');

SafeArrayUnAccessData( TagList );
SafeArrayDestroy( TagList );
end;

end;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉宸 2024-11-12 14:28:29

原则上是的,您可以逐条指令地单步调试 COM 方法实现的代码。

然而,即使您非常了解汇编并准确理解所有处理器指令的工作原理,以这种方式调试别人的代码也是一项艰巨的任务,除非它是一种非常非常简单的方法。

如果您是汇编程序新手,甚至不要考虑它,除非您准备好先进行几周的学习曲线。

如果 COM 方法似乎没有按照您根据其文档所期望的方式工作,我将首先尝试使用非托管代码(例如 C++)测试该方法,因为您的问题可能出在 COM Interop 编组中,而不是在COM 方法本身。

In principle, yes, you can step through the code of the COM method implementation instruction-by-instruction.

However, even if you know assembly well and understand exactly how all the processor instructions work, it's a tall order to debug someone else's code in this fashion unless it's a really, really simple method.

If you are new to assembler, don't even consider it unless you're prepared to do weeks of learning curve first.

If the COM method doesn't appear to be working in the way you expected based on its documentation, I would first try to test the method using unmanaged code (e.g. C++), as your problem may be in the COM Interop marshalling rather than in the COM method itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文