gpt4 book ai didi

c++ - 如何调试 regasm(注册哪些类型)

转载 作者:行者123 更新时间:2023-11-30 05:23:09 24 4
gpt4 key购买 nike

我们有一个托管 C++ DLL,当用 regasm 注册时,它似乎会向注册表添加一些垃圾类型。在 Blah 类中,任何使用 MyTeam.ManagedAutoPtr 的私有(private)变量都会添加到注册表中。此时我的问题是是否可以准确调试为什么将某些内容添加到注册表? regasm/verbose 没有帮助

    [HKEY_CLASSES_ROOT\MyTeam.ManagedAutoPtr<MyTeam::CustomType>]
@="MyTeam.ManagedAutoPtr<MyTeam::CustomType >"

[HKEY_CLASSES_ROOT\MyTeam.ManagedAutoPtr<MyTeam::CustomType >\CLSID]
@="{039DEE72-0D73-3DCC-84AC-900E6F734715}"

[HKEY_CLASSES_ROOT\CLSID\{039DEE72-0D73-3DCC-84AC-900E6F734715}]
@="MyTeam.ManagedAutoPtr<MyTeam::CustomType>"

[HKEY_CLASSES_ROOT\CLSID\{039DEE72-0D73-3DCC-84AC-900E6F734715}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="MyTeam.ManagedAutoPtr<MyTeam::CustomType>"
"Assembly"="BlahsNamespace.Blah, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v4.0.30319"

Blah 的相关部分是:

public ref class Blah
{
private:
MyTeam::ManagedAutoPtr<MyTeam::CustomType> _variable;
}

最后,这是完整的 ManagedAutoPtr

template <typename T> public ref class ManagedAutoPtr {
// This implementation is taken from
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/CplusCLIBP.asp

public:
/**
* Constructs an zero pointer.
*/
ManagedAutoPtr() : _p(0) {}

/**
* Constructs a pointer that references the given T instance. This
* ManagedAutoPtr will take ownership of @a *ptr.
*/
ManagedAutoPtr(T* ptr) : _p(ptr) {}

/**
* Constructs a pointer that references the same T instance as @a other.
* This ManagedAutoPtr will take over the ownership of the T instance,
* while @a other will lose it. @a other may represent a zero pointer.
*/
ManagedAutoPtr(ManagedAutoPtr<T>% other) : _p(other.release()) {}

/**
* Constructs a pointer that references the same T instance as @a other.
* This ManagedAutoPtr will take over the ownership of the T instance,
* while @a other will lose it. @a other may represent a zero pointer.
*/
template<typename Derived>
ManagedAutoPtr(ManagedAutoPtr<Derived>% other) : _p(other.release()) {}

/**
* Constructs a pointer that references the same T instance as @a other.
* This ManagedAutoPtr will take over the ownership of the T instance,
* while @a other will lose it. @a other may represent a zero pointer.
*/
template<typename Derived>
ManagedAutoPtr(esp::auto_ptr<Derived>& other) : _p(other.release()) {}

/**
* A finalizer that deletes any T instance that it might still hold.
*/
!ManagedAutoPtr() {
delete _p;
_p = 0;
}

/**
* Destroys this ManagedAutoPtr, and deletes any T instance it might
* reference.
*/
~ManagedAutoPtr() {
this->!ManagedAutoPtr();
}

/**
* Returns a raw pointer to the T instance referenced by this
* ManagedAutoPtr, if any.
*/
T* get() {
return _p;
}

/**
* Causes this ManagedAutoPtr to lose its ownership of the T
* instance that it is referencing (if any). A raw pointer to this T
* instance will be returned (or the zero pointer if this ManagedAutoPtr
* did not own any T instance).
*/
T* release() {
T* released = _p;
_p = 0;
return released;
}

/**
* Causes this ManagedAutoPtr to take ownership of the T instance
* pointed to by @a ptr. The T instance currently owned by this
* ManagedAutoPtr (if any) will be deleted. @a ptr may be zero.
*/
void reset(T* ptr) {
if (ptr != _p) {
delete _p;
_p = ptr;
}
}

/**
* Sets this ManagedAutoPtr to zero. The T instance owned
* by this ManagedAutoPtr (if any) will be deleted.
*/
void reset() {
reset(0);
}

/**
* Returns a reference to the T instances owned by
* @a autoPtr.
*
* @pre autoPtr.get() != 0
*/
static T& operator*(ManagedAutoPtr<T>% autoPtr) {
return *autoPtr._p;
}

/**
* Returns a non-zero raw pointer to the T instance referenced by this
* ManagedAutoPtr.
*
* @pre get() != 0
*/
static T* operator->(ManagedAutoPtr<T>% autoPtr) {
ESP_ASSERT(autoPtr._p != 0);
return autoPtr._p;
}

/**
* Assigns @a other to this ManagedAutoPtr. @a other loses the ownership of
* the T instance, and this ManagedAutoPtr gains the ownership.
*/
ManagedAutoPtr<T>% operator=(ManagedAutoPtr<T>% other) {
if (this != %other) {
reset(other.release());
}
return *this;
}

/**
* Assigns @a other to this ManagedAutoPtr. @a other loses the ownership of
* the T instance, and this ManagedAutoPtr gains the ownership.
*/
template<typename Derived>
ManagedAutoPtr<T>% operator=(ManagedAutoPtr<Derived>% other) {
reset(other.release());
return *this;
}

/**
* Assigns @a other to this ManagedAutoPtr. @a other loses the ownership of
* the T instance, and this ManagedAutoPtr gains the ownership.
*/
template<typename Derived>
ManagedAutoPtr<T>% operator=(esp::auto_ptr<Derived>& other) {
reset(other.release());
return *this;
}

private:
T* _p;
};

最佳答案

呵呵,找到了,相关工具是ildasm(也在VS命令提示符中)。关于程序集中有哪些类型的大量信息。

关于c++ - 如何调试 regasm(注册哪些类型),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39342026/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com