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
?
I got err is 3765269347
The generic strategy with large error number values like this is to convert them to hex. 3765269347 == 0xE06D7363. That's a magic number, googles well too. One strategy used by Microsoft programmers is to make the last 3 bytes of an exception code ASCII codes. 6D7363 == "msc". Not enough room to add ++ :)
The diagnostic is that the DllMain() function inside the DLL died due to an unhandled C++ exception. That happens of course.
The way to debug it is to force the debugger to stop when the exception is thrown, before the OS loader can catch it and turn it into a failure code. Within Visual Studio, use Debug > Exceptions, tick the Thrown checkbox for C++ exceptions.
Making sense of what you see when the debugger stops depends a great deal on whether you have a good PDB file for the DLL and whether you have source code. Source is of course typically required to fix a problem. If you don't have access to anything like this then you do need help from the programmer that wrote that DLL. Send him a small repro project that reproduces the crash.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With