4

I have got this Loadlibraty() error 3765269347 bothering me. I am implementing a C++ console application, built as x64, to load a x64 native C++ dll. Following is the code in the C++ console application to load the dll:

  bool InitDll()
{
    HINSTANCE hInst = LoadLibrary(_T("C:\\TIS_Nick\\Hardware\\Devices\\ThorDetectorSwitch\\TDSTest\\TDSTest\\Debug\\Modules_Native\\ThorDetectorSwitch.dll"));
    if( hInst != NULL )
    {
        FreeLibrary( hInst ); 
        return true;
    }
    else
    {
        DWORD err = GetLastError();
        return false;
    }
}

I got err is 3765269347, which I think means C++ cannot handle this error. I am sure my path to load the dll is correct.

I also use Monitor Process to trace what the dll and functions get called. and here is the information I think relevant.

11:08:07.3196483 AM TDSTest.exe 1604    QueryNameInformationFile    C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\x64\Debug\TDSTest.exe   SUCCESS Name: \TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\x64\Debug\TDSTest.exe
11:08:08.5720585 AM TDSTest.exe 1604    CreateFile  C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:08:08.5721041 AM TDSTest.exe 1604    QueryBasicInformationFile   C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll SUCCESS CreationTime: 6/11/2013 6:30:08 PM, LastAccessTime: 6/11/2013 6:30:08 PM, LastWriteTime: 6/12/2013 11:00:28 AM, ChangeTime: 6/12/2013 11:05:51 AM, FileAttributes: A
11:08:08.5721293 AM TDSTest.exe 1604    CloseFile   C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll SUCCESS 
11:08:08.5722797 AM TDSTest.exe 1604    CreateFile  C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll SUCCESS Desired Access: Read Data/List Directory, Execute/Traverse, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a, OpenResult: Opened
11:08:08.5723228 AM TDSTest.exe 1604    CreateFileMapping   C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll FILE LOCKED WITH ONLY READERS   SyncType: SyncTypeCreateSection, PageProtection: 
11:08:08.5724896 AM TDSTest.exe 1604    CreateFileMapping   C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll SUCCESS SyncType: SyncTypeOther
11:08:08.5725861 AM TDSTest.exe 1604    Load Image  C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll SUCCESS Image Base: 0x7fef7830000, Image Size: 0x6d000
11:08:08.5726385 AM TDSTest.exe 1604    QueryNameInformationFile    C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll SUCCESS Name: \TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll
11:08:08.5728910 AM TDSTest.exe 1604    CreateFile  C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll SUCCESS Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:08:08.5912215 AM TDSTest.exe 1604    CloseFile   C:\TIS_Nick\Hardware\Devices\ThorDetectorSwitch\TDSTest\TDSTest\Debug\Modules_Native\ThorDetectorSwitch.dll SUCCESS 

I aplogize that looks a little messy, I was trying to post a picture here, but it turns out I don't have enough reputation to do so. Any suggestion is appreciated.

Update I have traced down to the constructor in ThorDetectorSwitch.dll, which looks like following:

ThorDetectorSwitch::ThorDetectorSwitch() : _mcSwitch(__uuidof(MCLControlClass))
{
    _A  = WstringToBSTR(L"A"); 
    _B  = WstringToBSTR(L"B");
    _C  = WstringToBSTR(L"C");
    _D  = WstringToBSTR(L"D");

    _deviceDetected = FALSE;
}

I set the break point at the first parenthesis, but it never gets into the function. Instead, it jumps to the exceptions. I suppose something wrong with the MCLControlClass, or_mcSwitch?

4

2 回答 2

11

我的错误是 3765269347

像这样具有大错误数值的通用策略是将它们转换为十六进制。3765269347 == 0xE06D7363。这是一个神奇的数字,谷歌也很好。Microsoft 程序员使用的一种策略是将异常代码的最后 3 个字节设置为 ASCII 代码。6D7363 == “MSC”。没有足够的空间来添加 ++ :)

诊断结果是 DLL 中的 DllMain() 函数由于未处理的 C++ 异常而死亡。这当然会发生。

调试它的方法是在抛出异常时强制调试器停止,然后操作系统加载程序可以捕获它并将其转换为故障代码。在 Visual Studio 中,使用调试 > 异常,勾选 C++ 异常的抛出复选框。

了解调试器停止时所看到的内容在很大程度上取决于您是否有适合 DLL 的 PDB 文件以及是否有源代码。当然通常需要源来解决问题。如果您无权访问此类内容,那么您确实需要编写该 DLL 的程序员的帮助。向他发送一个重现崩溃的小型重现项目。

于 2013-06-12T15:46:06.367 回答
4

这是一个特殊的例外。请从 MS 阅读此内容: 解码抛出的 C++ 异常的参数 (0xE06D7363)

于 2013-06-12T15:34:44.210 回答