Edit: Though what follows makes sense it is actually incorrect. I’m keeping it here just for reference, but I may delete the answer later.
Note however that (at least on Windows 10, which I used to check) even if relocation information is available in the file, if the module is not a DLL it is not applied, so even if you didn’t get that error, unless your INTERFAC.DLL applies relocations to PCLDRN.exe after loading it, trying to use it is likely to break somewhere along the way.
With the loader snaps output the situation seems pretty obvious to me.
The loader snaps output once the file is found are (I numbered the lines):
(1) 18a0:2a40 @ 06859098 - LdrpMapViewOfSection - ENTER: DLL name: C:QAPcdlrnWin32ReleasePCDLRN.exe
(2) 'CNCServer.exe': Loaded 'C:QAPcdlrnWin32ReleasePCDLRN.exe', Symbols loaded.
(3) 18a0:2a40 @ 06859597 - LdrpMapViewOfSection - RETURN: Status: 0x40000003
(4) 'CNCServer.exe': Unloaded 'C:QAPcdlrnWin32ReleasePCDLRN.exe'
(5) 18a0:2a40 @ 06859597 - LdrpFindOrMapDll - RETURN: Status: 0xc000007b
(6) 18a0:2a40 @ 06859597 - LdrpLoadImportModule - ERROR: Loading DLL PCDLRN.exe from path C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:
(7) 18a0:2a40 @ 06859597 - LdrpLoadImportModule - RETURN: Status: 0xc000007b
(8) 18a0:2a40 @ 06859597 - LdrpHandleOneOldFormatImportDescriptor - ERROR: Loading "?????" from the import table of DLL "C:QAPcdlrnWin32ReleaseINTERFAC.DLL" failed with status 0xc000007b
(9) 18a0:2a40 @ 06859613 - LdrpUnloadDll - INFO: Unmapping DLL "C:QAPcdlrnWin32ReleaseINTERFAC.DLL"
(10) 'CNCServer.exe': Unloaded 'C:QAPcdlrnWin32ReleaseINTERFAC.dll'
(11) 18a0:2a40 @ 06859613 - LdrpLoadDll - RETURN: Status: 0xc000007b
(12) 18a0:2a40 @ 06859613 - LdrLoadDll - RETURN: Status: 0xc000007b
LdrpMapViewOfSection
returns an error code (0x40000003) on line 3 which causes the module to unload (line 4) and then LdrpMapViewOfSection
‘s caller — LdrpFindOrMapDll
— translates the error code to 0xc000007b (STATUS_INVALID_IMAGE_FORMAT).
But the error that caused the load to fail was 0x40000003 — STATUS_IMAGE_NOT_AT_BASE
. The description of this NTSTATUS is:
{Image Relocated} An image file could not be mapped at the address that is specified in the image file. Local fixes must be performed on this image.
(Source: NTSTATUS Values)
By default, EXEs don’t contain relocation information (as was mentioned in the comments). Usually that’s not a problem as the address space is rather free when the EXE is loaded into it. But your address space isn’t free. To make matters worse, all EXEs compiled by Visual C++ share the same base address by default:
The /BASE option sets a base address for the program, overriding the default location for an .exe or DLL file. The default base address for an .exe file is 0x400000 for 32-bit images or 0x140000000 for 64-bit images. For a DLL, the default base address is 0x10000000 for 32-bit images or 0x180000000 for 64-bit images.
(Source: Linker Options: /BASE (Base Address))
That’s probably the situation you have. CNCServer.exe already occupies 0x400000 and that’s the only place PCDLRN.exe can go. LdrpMapViewOfSection
can’t map PCDLRN.exe to 0x400000 because it isn’t free and fails to map in anywhere else because there’s no relocation information.
And from there it goes up the call stack and changes the error, but not the underlying problem. Which is lack of relocation information.
You can see what happened when this error is encountered for a DLL with relocation information in your output too. When INTERFAC.dll is initially loaded:
18a0:2a40 @ 06858989 - LdrpFindOrMapDll - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windows
18a0:2a40 @ 06858989 - LdrpSearchPath - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL DLL path: C:QAPcdlrnCNCSERVERWin32Release;C:Windowssystem32;C:Windowssystem;C:Windows;.;C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTeamFoundationTeam ExplorerNativeBinariesx86;C:windowssystem32;C:windows;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowss
18a0:2a40 @ 06858989 - LdrpResolveFileName - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL
18a0:2a40 @ 06858989 - LdrpResolveFileName - RETURN: Status: 0x00000000
18a0:2a40 @ 06858989 - LdrpResolveDllName - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL
18a0:2a40 @ 06858989 - LdrpResolveDllName - RETURN: Status: 0x00000000
18a0:2a40 @ 06858989 - LdrpSearchPath - RETURN: Status: 0x00000000
18a0:2a40 @ 06859036 - LdrpMapViewOfSection - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL
'CNCServer.exe': Loaded 'C:QAPcdlrnWin32ReleaseINTERFAC.dll', Symbols loaded.
18a0:2a40 @ 06859098 - LdrpMapViewOfSection - RETURN: Status: 0x40000003
18a0:2a40 @ 06859098 - LdrpRelocateImage - ENTER: DLL name: C:QAPcdlrnWin32ReleaseINTERFAC.DLL
18a0:2a40 @ 06859098 - LdrpProtectAndRelocateImage - RETURN: Status: 0x00000000
18a0:2a40 @ 06859098 - LdrpRelocateImage - RETURN: Status: 0x00000000
18a0:2a40 @ 06859098 - LdrpFindOrMapDll - RETURN: Status: 0x00000000
When LdrpMapViewOfSection
returns STATUS_IMAGE_NOT_AT_BASE
, it’s caller (LdrpFindOrMapDll
) goes ahead and calls LdrpRelocateImage
, something it apparently can’t to for PCDLRN.exe.
I am creating a C++/CLI dll that will be loaded into a legacy c++ application. The legacy application does this with a traditional call to LoadLibrary. Both the application and the C++/CLI dll are compiled in 64 bit mode.
When the LoadLibrary call happens, it fails with error 193. This usually means that some non-64bit component is trying to load. When I look at the dll load output in visual studio 2010, I see the the failure is occurring when mscoree.dll is being loaded (to be exact, I see my dll loaded, then mscoree loaded, then mscoree unloaded, then my dll unloaded, then the error returned). Specifically C:WindowsSystem32mscoree.dll is being loaded, when I examine this mscoree.dll, I find that it is targeting I386.
How can I ensure that my application will link against the correct mscoree.dll? I understand this could be done with a manifest, but I can’t find any good information about setting one up. The ideal solution would allow compilation in 32bit or 64bit mode and target the correct mscoree.dll.
As a side note, I found an mscoree.dll in a side-by-side folder that I verified is 64bit mode and copied it into my application directory with the hopes that it would pick up that one first. This didnt work and the C:WindowsSystem32 version was still loaded.
Thanks,
Max
Output of CorFlags.exe on the C++/CLI dll
Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Version : v4.0.30319
CLR Header: 2.5
PE : PE32+
CorFlags : 16
ILONLY : 0
32BIT : 0
Signed : 0
Output of pedump.exe on C:System32mscoree.dll
PS C:WindowsSystem32> pedump.exe .mscoree.dll
Dump of file .MSCOREE.DLL
File Header
Machine: 014C (I386)
Number of Sections: 0004
TimeDateStamp: 4B90752B -> Thu Mar 04 22:06:19 2010
PointerToSymbolTable: 00000000
NumberOfSymbols: 00000000
SizeOfOptionalHeader: 00E0
Characteristics: 2102
EXECUTABLE_IMAGE
32BIT_MACHINE
DLL
...
(pedump goes on from here to describe imports and exports but thats not important here)
Extended loading information
This is the full output from failed load.
Note: The C++/CLI dll is called DsfClr.dll
the output was obtained by running gflags.exe -i [exename] +sls and examining the results in a debugger
http://pastebin.com/FyumUiMN
UPDATE:
Using a tip posted in a below comment by Reuben, I was able to determine that mscoree.dll is indeed targeting AMD64, but pedump is providing invalid information because it is being run in WOW64. That being said I still cannot load this library, if anyone has any suggestions they would be greatly appreciated.
One more thing I have tried: I made a new C# application and referenced the C++/CLI dll, then, in the main() function, I instantiated a class in the C++/CLI dll. This caused an access violation exception before the main() function is called. When I remove the instantiation, the main function runs fine. My guess is that the instantiation is causing a delay load of my C++/CLI assembly, which causes the same load error I was seeing from the native assembly.
- Remove From My Forums
-
Question
-
I had a program developed in C# VS2010 and VS2005. The program still works just fine on all Window OSs from Win 2000->XP->Windows 7. All 32 bit versions. The problem came when this program runs on 64 bit Windows7. The program fails during
the call to LoadLibrary(). Used P/Invoke method to use this function. The LoadLibrary fails with
any dll and not only the one I want. My project settings are «built on x86» and the Target Platform as «Any CPU». Infact I tried a small program(thinking that My original program is buggy), a windows forms application with two buttons.
One Button will use LoadLibrary() and one for FreeLibrary(). Same issue on 64 bit. The LoadLibrary fails with error code 193. used same P/Invoke method for making use of the native kernel32.dll in the System32 folder. Can anyone point
me if I need to do anything additonal for the program to work. I am using the C# VS2010 for development and still has to use .Net 2.0. Any suggestion is greatly appreciated.Thanks.
Here is my code:
using
using
using
using
using
using
using
using
using
using
using
namespace
{
{
public
Form1() public
class
UnManagedCodeB{
InitializeComponent();
}
{
#region
Kernel32 DLL Import Functions
arSet =
CharSet.Auto,
BestFitMapping = false,
SetLastError = true)]
public
static
extern
IntPtr
LoadLibrary(string
lpFilename);[
[
[
[
[
#endregion
}
{
m_DllHandle =
{
{error_code =
M
}
}
{
error_code = U
}
}
{
}
nManagedCodeB.GetLastError();
MessageBox.Show(error_code.ToString(),
«Dll Handle Return code»);
Application.Exit();
private
void
button3_Click(object
sender, EventArgs
e) UnManagedCodeB.FreeLibrary(m_DllHandle);
}
catch
(Exception
x) MessageBox.Show(x.Message,
«DLL Loading problem(LoadUSBLibrary())!»);if
(m_DllHandle == IntPtr.Zero)
UnManagedCodeB.GetLastError();
essageBox.Show(error_code.ToString(),
«Dll load failed(LoadLibrary()»);
throw
new
ApplicationException(«Error
loading « + filename.ToString());private
IntPtr
m_DllHandle;
private
void
button1_Click(object
sender, EventArgs
e) int
error_code ;
string
filename = «C:\Windows\SysWOW64\UAUSBIP.dll»;
UnManagedCodeB.LoadLibrary(
filename);
trypublic
static
extern
int
GetLastError();DllImport(«C:\Windows\System32\kernel32.dll»,
CharSet = CharSet.Ansi,
ExactSpelling = true)]
public
static
extern
IntPtr
GetProcAddress(IntPtr
hModule, string
procName);
DllImport(«C:\Windows\System32\kernel32.dll»)]
public
static
extern
bool
FreeLibrary(IntPtr
hModule);
DllImport(«C:\Windows\System32\kernel32.dll»)]
public
static
extern
bool
SetDllDirectory(string
path);
DllImport(«C:\Windows\System32\kernel32.dll»,
SetLastError = true)]
public
static
extern
void
SetLastError(int
errorCode);
DllImport(«C:\Windows\System32\kernel32.dll»)][DllImport(«C:\Windows\System32\kernel32.dll»,
ChCS_64bit_TestApp
public
partial
class
Form1
: FormSystem.Windows.Forms;System.Runtime.InteropServices;System.Threading;System.IO.Ports;System.IO;System.Text;System.Drawing;System.Data;System.ComponentModel;System.Collections.Generic;System;
Answers
-
Any CPU will give you a 64 bit process on win64, you cannot load a 32bits dll into a 64 bits process. If you have no 64 bits versions of your dlls you can change your soltion platform from ‘any cpu’ to ‘x86’ to force a 32 bits process which has no issues
loading 32 bits dlls.-
Marked as answer by
Tuesday, August 24, 2010 2:06 PM
-
Marked as answer by
Причин появления несколько: неполная установка, повреждение реестра из-за изменения (установки или удаления), вредоносное ПО и т.д.
Как исправить?
Просканируйте ПК на вирусы вредоносное ПО.
Есть вероятность, что проблема связана с заражением компьютера. Вирусы повреждают или удаляют файлы. Поэтому очистка, вероятно, решит возникшую проблему.
Очистите систему от временных документов и папок.
Как запустить очистку диска в Виндовс XP, Vista, 7, 8 и 10?
- Нажимаем Winkey + R.
- Печатаем «cleanmgr» -> Enter.
- Откроется диалоговое окно «очистка диска», содержащее флажки. В большинстве, категория «временные файлы» занимает большую часть.
- Установите флажки напротив не использующихся категорий и примените.
- Поставьте автоматическое обновление драйверов устройств.
Ошибки 193 иногда связаны с повреждением или устареванием драйверов
- Запустите sysdm.cpl. Для этого используйте кнопки «Winkey + R», вбейте «sysdm.cpl» в командной строке и тапните Enter.
- В окне «свойства системы» кликните вкладку «оборудование».
- В «параметрах установки устройств» проверьте настройку автоматического обновления.
- На той же вкладке найдите диспетчер устройств.
- Не установленные или поврежденные драйверы обозначаются желтым знаком восклицания.
- Обновите автоматически или вручную.
Используйте «восстановление системы Виндовс» для отмены последних изменений.
Это вернет файлы и программы на вашем ПК к тому времени, когда все работало нормально. Произведите следующие шаги:
- Нажмите «пуск».
- В поисковой строке введите «Восстановление системы» и нажмите «ок».
- В окне результатов выберите «Восстановление».
- По инструкциям уже «мастера настроек» завершите работу.
- Запустите проверку системных файлов Windows («sfc /scannow»).
Весьма удобный инструмент, позволяющий просканировать и исправить поврежденные файлы (включая те, что имеют отношение к ошибка 193).
- Выберите «пуск».
- Введите «cmd».
- Запустите от имени администратора.
- Наберите «sfc /scannow» и Enter.
- Проверка начнет сканирование на наличие проблем.
- Завершите процедуру по инструкциям на экране.
Hi,
One of our users is having a problem starting game using the lwjgl 3 library. It has taken quite a while, but we’ve now found the issue. The lwjgl 3 library is unable to unpack itself. I’ve asked the user to run the application with debugging flags and this is what we got:
C:UsersAwVzZhH>java -jar -Dorg.lwjgl.util.Debug=true %HOMEPATH%/.emps_world/em
ps-world-client.jar
[LWJGL] Version: 3.1.1 SNAPSHOT
[LWJGL] OS: Windows 8.1 v6.3
[LWJGL] JRE: 1.8.0_131 amd64
[LWJGL] JVM: Java HotSpot(TM) 64-Bit Server VM v25.131-b11 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL] Found at: C:UsersAwVzZhHAppDataLocalTemplwjglAwVzZhH3.1.1-SNAPSHOTlwjgl.dll
[LWJGL] Loaded from org.lwjgl.librarypath: C:UsersAwVzZhHAppDataLocalTemplwjglAwVzZhH3.1.1-SNAPSHOTlwjgl.dll
[LWJGL] MemoryUtil accessor: MemoryAccess$MemoryAccessorUnsafe
[LWJGL] Warning: Failed to instantiate memory allocator: org.lwjgl.system.jemall
oc.JEmallocAllocator. Using the system default.
[LWJGL] MemoryUtil allocator: MemoryManage$StdlibAllocator
[LWJGL] Loading library: glfw
[LWJGL] Found at: C:UsersAwVzZhHAppDataLocalTemplwjglAwVzZhH3.1.1-SNAPSHOTglfw.dll
[LWJGL] Loaded from org.lwjgl.librarypath: C:UsersAwVzZhHAppDataLoca
lTemplwjglAwVzZhH3.1.1-SNAPSHOTglfw.dll
[LWJGL] Loading library (system): lwjgl_opengl
[LWJGL] Found at: C:UsersAwVzZhHAppDataLocalTemplwjglAwVzZhH3.1.1
-SNAPSHOTlwjgl_opengl.dll
[LWJGL] Loaded from org.lwjgl.librarypath: C:UsersAwVzZhHAppDataLoca
lTemplwjglAwVzZhH3.1.1-SNAPSHOTlwjgl_opengl.dll
[LWJGL] Loading library: opengl32
Exception in thread «main» java.lang.UnsatisfiedLinkError: Failed to load library: C:UsersAwVzZhHAppDataLocalTemplwjglAwVzZhH3.1.1-SNAPSHOTopengl32.dll
(error code = 193)
at org.lwjgl.system.windows.WindowsLibrary.(Unknown Source)
at org.lwjgl.system.APIUtil.apiCreateLibrary(Unknown Source)
at org.lwjgl.system.Library.loadNative(Unknown Source)
at org.lwjgl.system.Library.loadNative(Unknown Source)
at org.lwjgl.system.Library.loadNative(Unknown Source)
at org.lwjgl.system.Library.loadNative(Unknown Source)
at org.lwjgl.opengl.GL.create(Unknown Source)
at org.lwjgl.opengl.GL.(Unknown Source)
at net.emps.client.f.b.a.a(Unknown Source)
at net.emps.client.f.b.run(Unknown Source)
at net.emps.client.model.Client.run(Unknown Source)
at net.emps.client.f.b.a(Unknown Source)
at net.emps.client.model.Client.main(Unknown Source)
I’ve already tried Googling this, but I couldn’t find anything regarding error code 193. So what is the issue and what does error code 193 stand for?
Thanks,
Thomy
Error 193 on Windows happens when LoadLibrary
tries to load a 32-bit library in a 64-bit process.
This error shouldn’t happen though. There shouldn’t be an opengl32.dll
in the temp 3.1.1-SNAPSHOT
folder. The OpenGL library is not bundled with LWJGL, it comes with the GPU drivers on user systems.
Note that opengl32
is the official name of the OpenGL client library on Windows and it’s the same even on x64 systems. It’s not related to the 32
suffix LWJGL adds to the x86 shared libraries it bundles.
Okay, thanks! Is this related to the user trying to run the game with a 64bit jvm? What Could I do to avoid that from happening? Could it be a faulty driver installation on the user’s end?
LWJGL runs fine (better actually) on 64bit JVMs. And as you can see in the debug output, lwjgl.dll
, glfw.dll
and lwjgl_opengl.dll
load successfully. The question is how can there be an opengl32.dll
in the classpath. I don’t have an explanation for that. But the shared library loader wouldn’t try to extract and load it if it wasn’t there.
A few things to try:
- Ask the user to reinstall their GPU drivers.
- Ask the user to delete the
C:UsersAwVzZhHAppDataLocalTemplwjglAwVzZhH
folder and relaunch your game. - You may want to update to
3.1.2-SNAPSHOT
. Or wait for3.1.2
, it’s going to be released tonight if all goes well.
Deleting the C:UsersAwVzZhHAppDataLocalTemplwjglAwVzZhH
folder has worked. I will keep this in mind and recommend it to users in the future. Cheers!