Windows 7 dll import problem

R

roidy

I`m importing a function from a dll using the following code:-

Declare Function MP4Read Lib "e:\libmp4v2.dll" (ByVal filename As String,
ByVal verbosity As UInteger) As UIntPtr

filehandle = MP4Read("test.mp4", 0)


This works perfectly in WinXP but when I move my project over to Windows 7
RC to test it I keep getting the following exception:-

DllNotFoundException was unhandled
Unable to load DLL 'e:\libmp4v2.dll': The application has failed to start
because its side-by-side configuration is incorrect. Please see the
application event log or use the command-line sxstrace.exe tool for more
detail. (Exception from HRESULT: 0x800736B1)

Now if I place the dll file in the same folder as the exacutable and use:-

Declare Function MP4Read Lib "libmp4v2.dll" (ByVal filename As String, ByVal
verbosity As UInteger) As UIntPtr

Then I get the following exception:-

DllNotFoundException was unhandled
Unable to load DLL 'libmp4v2.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)

It`s driving me crazy, both versions work fine in WinXp but not in Windows 7
RC.

Help please
Rob
 
M

Mike

Loading DLLs under Windows can be problem is there are dependencies,
and with the SxS microsoft baloney, a lot of stuff is hidden.

Generally, with these type of erroneous messages says "it can' find
the dll" it is that it can't find a DEPENDENCY. Unfortunately, it
doesn't always show what dependency failed to load only the top level
file.

If you don't have it already, download DEPENDS from MSDN and run your
application from within DEPENDS. It will 100% tell you the story of
your process needs, what is open, what is closed, what DLL is missing
or can't find that LIBMP4V2.DLL needs.

When you download, you can start it from the command line

DEPENDS yourprogram.exe

or open it from within. Then do START | PROFILE and you will see
the stuff going on. You might be able to see the RED-BOLD highlights
in the DLL list panel before your start profile to see if that is any
hint.
 
M

Mike

Loading DLLs under Windows can be problem is there are dependencies,
and with the SxS microsoft baloney, a lot of stuff is hidden.

Generally, with these type of erroneous messages says "it can' find
the dll" it is that it can't find a DEPENDENCY. Unfortunately, it
doesn't always show what dependency failed to load only the top level
file.

If you don't have it already, download DEPENDS from MSDN and run your
application from within DEPENDS. It will 100% tell you the story of
your process needs, what is open, what is closed, what DLL is missing
or can't find that LIBMP4V2.DLL needs.

When you download, you can start it from the command line

DEPENDS yourprogram.exe

or open it from within. Then do START | PROFILE and you will see
the stuff going on. You might be able to see the RED-BOLD highlights
in the DLL list panel before your start profile to see if that is any
hint.
 
R

roidy

Thanks Mike,

When I open the program in Dependency Walker I get the following:-

Warning: At least one module has an unresolved import due to a missing
export function in a delay-load dependent module.

and a red box by the side of the following 2 dll`s:-

IEFRAME.DLL
SHLWAPI.DLL

both of which I have in Windows/System32 and my executable directorys.

Then when I profile the exe I get the following log:-

-------------------------------------------------------------------------------
Starting profile on 19/05/2009 at 15:57:46

Operating System: Microsoft Windows NT/2000/XP/2003/Vista based Ultimate
(32-bit), version 6.01.7100
Program Executable: c:\users\roidy\documents\visual studio
2008\projects\sample_libmp4v2\sample_libmp4v2\bin\debug\SAMPLE_LIBMP4V2.EXE
Program Arguments:
Starting Directory: C:\Users\roidy\Documents\Visual Studio
2008\Projects\sample_libmp4v2\sample_libmp4v2\bin\Debug\
Search Path:
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL
Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\

Options Selected:
Simulate ShellExecute by inserting any App Paths directories into the
PATH environment variable.
Log DllMain calls for process attach and process detach messages.
Hook the process to gather more detailed dependency information.
Log LoadLibrary function calls.
Log GetProcAddress function calls.
Log debug output messages.
Automatically open and profile child processes.
--------------------------------------------------------------------------------

Started "SAMPLE_LIBMP4V2.EXE" (process 0xA9C) at address 0x012A0000.
Successfully hooked module.
Loaded "NTDLL.DLL" at address 0x77C20000. Successfully hooked module.
Loaded "MSCOREE.DLL" at address 0x716B0000. Successfully hooked module.
Loaded "KERNEL32.DLL" at address 0x761F0000. Successfully hooked module.
Loaded "KERNELBASE.DLL" at address 0x75E40000. Successfully hooked module.
DllMain(0x75E40000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNELBASE.DLL"
called.
DllMain(0x75E40000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNELBASE.DLL"
returned 1 (0x1).
DllMain(0x761F0000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNEL32.DLL"
called.
DllMain(0x761F0000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNEL32.DLL"
returned 1 (0x1).
Injected "DEPENDS.DLL" at address 0x08370000.
DllMain(0x716B0000, DLL_PROCESS_ATTACH, 0x00000000) in "MSCOREE.DLL" called.
DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "DEPENDS.DLL" called.
DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "DEPENDS.DLL"
returned 1 (0x1).
GetProcAddress(0x761F0000 [KERNEL32.DLL], "FlsAlloc") called from
"MSCOREE.DLL" at address 0x716B6079 and returned 0x7624867D.

STATUS_STACK_BUFFER_OVERRUN encountered
Entrypoint reached. All implicit modules have been loaded.
Exited "SAMPLE_LIBMP4V2.EXE" (process 0xA9C) with code -1073740791
(0xC0000409).
 
R

roidy

Thanks Mike,

When I open the program in Dependency Walker I get the following:-

Warning: At least one module has an unresolved import due to a missing
export function in a delay-load dependent module.

and a red box by the side of the following 2 dll`s:-

IEFRAME.DLL
SHLWAPI.DLL

both of which I have in Windows/System32 and my executable directorys.

Then when I profile the exe I get the following log:-

-------------------------------------------------------------------------------
Starting profile on 19/05/2009 at 15:57:46

Operating System: Microsoft Windows NT/2000/XP/2003/Vista based Ultimate
(32-bit), version 6.01.7100
Program Executable: c:\users\roidy\documents\visual studio
2008\projects\sample_libmp4v2\sample_libmp4v2\bin\debug\SAMPLE_LIBMP4V2.EXE
Program Arguments:
Starting Directory: C:\Users\roidy\Documents\Visual Studio
2008\Projects\sample_libmp4v2\sample_libmp4v2\bin\Debug\
Search Path:
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL
Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\

Options Selected:
Simulate ShellExecute by inserting any App Paths directories into the
PATH environment variable.
Log DllMain calls for process attach and process detach messages.
Hook the process to gather more detailed dependency information.
Log LoadLibrary function calls.
Log GetProcAddress function calls.
Log debug output messages.
Automatically open and profile child processes.
--------------------------------------------------------------------------------

Started "SAMPLE_LIBMP4V2.EXE" (process 0xA9C) at address 0x012A0000.
Successfully hooked module.
Loaded "NTDLL.DLL" at address 0x77C20000. Successfully hooked module.
Loaded "MSCOREE.DLL" at address 0x716B0000. Successfully hooked module.
Loaded "KERNEL32.DLL" at address 0x761F0000. Successfully hooked module.
Loaded "KERNELBASE.DLL" at address 0x75E40000. Successfully hooked module.
DllMain(0x75E40000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNELBASE.DLL"
called.
DllMain(0x75E40000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNELBASE.DLL"
returned 1 (0x1).
DllMain(0x761F0000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNEL32.DLL"
called.
DllMain(0x761F0000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNEL32.DLL"
returned 1 (0x1).
Injected "DEPENDS.DLL" at address 0x08370000.
DllMain(0x716B0000, DLL_PROCESS_ATTACH, 0x00000000) in "MSCOREE.DLL" called.
DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "DEPENDS.DLL" called.
DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "DEPENDS.DLL"
returned 1 (0x1).
GetProcAddress(0x761F0000 [KERNEL32.DLL], "FlsAlloc") called from
"MSCOREE.DLL" at address 0x716B6079 and returned 0x7624867D.

STATUS_STACK_BUFFER_OVERRUN encountered
Entrypoint reached. All implicit modules have been loaded.
Exited "SAMPLE_LIBMP4V2.EXE" (process 0xA9C) with code -1073740791
(0xC0000409).
 
R

roidy

Well I recompiled the dll file from source in Windows 7 and now it
works..... Go figure.....

Thanks for the help

Rob
 
R

roidy

Well I recompiled the dll file from source in Windows 7 and now it
works..... Go figure.....

Thanks for the help

Rob
 
M

Mike

roidy said:
Well I recompiled the dll file from source in Windows 7 and now it
works..... Go figure.....

Thanks for the help

Good. I was going to say that a the STACK OVERFLOW was not good and
there was something not right with the DLL. I was going to suggest to
turn on all the profile check boxes to see more loading details of
MSCOREE.DLL.

--
 
M

Mike

roidy said:
Well I recompiled the dll file from source in Windows 7 and now it
works..... Go figure.....

Thanks for the help

Good. I was going to say that a the STACK OVERFLOW was not good and
there was something not right with the DLL. I was going to suggest to
turn on all the profile check boxes to see more loading details of
MSCOREE.DLL.

--
 
R

roidy

I just hope that the version of the dll compiled in Windows 7 will work in
WinXP. But I can't test it just yet as my XP machine is currently in bits
awaiting new parts..........
 
R

roidy

I just hope that the version of the dll compiled in Windows 7 will work in
WinXP. But I can't test it just yet as my XP machine is currently in bits
awaiting new parts..........
 
M

Mike

roidy said:
I just hope that the version of the dll compiled in Windows 7 will work
in WinXP. But I can't test it just yet as my XP machine is currently in
bits awaiting new parts..........

Use DEPENDS to get list of DEPENDENCIES for the LIBMP4V2.DLL. You can
also get the implicit loads using DUMPBIN.

DUMPBIN /DEPENDENTS LIBMP4V2.DLL

I wrote a command line version of DEPENDS called LDEPENDS.ZIP

ftp://ftp.santronics.com/wildcat/tools

and I use to quickly see what is needed by EXE and DLLs. It doesn't
work well with SxS baloney (but DEPENDS does)

For example, for us, WCSRV2.DLL is the our DLL for WIN32 and for .NET
DLLIMPORTING. For this solid 12 year old WIN32 version, LDEPENDS shows:

D:\wc63>ldepends wcsrv2.dll
Module: [wcsrv2.dll]
+ rpcrt4.dll
+ wsock32.dll
+ msvcrt.dll
+ mfc42.dll
+ kernel32.dll
+ user32.dll
+ advapi32.dll
+ ole32.dll

This is solid code for all WIN32 compatiable Windows OSes, but that
was compiled with VS98.

Now when its compiled using VS2005:

G:\wc7beta>ldepends wcsrv2.dll
Module: [wcsrv2.dll]
+ rpcrt4.dll
+ wsock32.dll
+ mfc80d.dll
+ msvcr80d.dll
+ kernel32.dll
+ user32.dll
+ advapi32.dll
+ ole32.dll
+ oleaut32.dll

**** report ****
MFC80D.DLL LoadLibrary() Error: 126
MSVCR80D.dll LoadLibrary() Error: 126

So there are more dependencies that uses 8.0 dlls files and these are
trying to load or aliased with SxS. Ldepends has a problem finding
SxS stuff, but when the EXE or DLL is loaded for real, the OS loader
(and DEPENDS) knows whats to do.

So your goal is to see what RTL (run time libraries) you want to use.
If you compile with VS200x then you will bring more libraries that
are for that compiler version RTL.

What I would do is find the minimum required for LIBMP3V2.DLL and
stick with it. But then again if you are compiling the main
application for .NET, then most likely you will need 8.0 (VS2005) or
9.0 (VS2008) files anyway.

--
 
M

Mike

roidy said:
I just hope that the version of the dll compiled in Windows 7 will work
in WinXP. But I can't test it just yet as my XP machine is currently in
bits awaiting new parts..........

Use DEPENDS to get list of DEPENDENCIES for the LIBMP4V2.DLL. You can
also get the implicit loads using DUMPBIN.

DUMPBIN /DEPENDENTS LIBMP4V2.DLL

I wrote a command line version of DEPENDS called LDEPENDS.ZIP

ftp://ftp.santronics.com/wildcat/tools

and I use to quickly see what is needed by EXE and DLLs. It doesn't
work well with SxS baloney (but DEPENDS does)

For example, for us, WCSRV2.DLL is the our DLL for WIN32 and for .NET
DLLIMPORTING. For this solid 12 year old WIN32 version, LDEPENDS shows:

D:\wc63>ldepends wcsrv2.dll
Module: [wcsrv2.dll]
+ rpcrt4.dll
+ wsock32.dll
+ msvcrt.dll
+ mfc42.dll
+ kernel32.dll
+ user32.dll
+ advapi32.dll
+ ole32.dll

This is solid code for all WIN32 compatiable Windows OSes, but that
was compiled with VS98.

Now when its compiled using VS2005:

G:\wc7beta>ldepends wcsrv2.dll
Module: [wcsrv2.dll]
+ rpcrt4.dll
+ wsock32.dll
+ mfc80d.dll
+ msvcr80d.dll
+ kernel32.dll
+ user32.dll
+ advapi32.dll
+ ole32.dll
+ oleaut32.dll

**** report ****
MFC80D.DLL LoadLibrary() Error: 126
MSVCR80D.dll LoadLibrary() Error: 126

So there are more dependencies that uses 8.0 dlls files and these are
trying to load or aliased with SxS. Ldepends has a problem finding
SxS stuff, but when the EXE or DLL is loaded for real, the OS loader
(and DEPENDS) knows whats to do.

So your goal is to see what RTL (run time libraries) you want to use.
If you compile with VS200x then you will bring more libraries that
are for that compiler version RTL.

What I would do is find the minimum required for LIBMP3V2.DLL and
stick with it. But then again if you are compiling the main
application for .NET, then most likely you will need 8.0 (VS2005) or
9.0 (VS2008) files anyway.

--
 
R

roidy

That's the thing, it`s not a problem with the version of VS used as both
versions of the dll file were compiled using Visual C Express 2008 the only
difference was one was compiled in WinXp and the other in Windows 7. It`s
just the version compiled under WinXp wouldn`t work in Windows 7.

Rob

Mike said:
roidy said:
I just hope that the version of the dll compiled in Windows 7 will work
in WinXP. But I can't test it just yet as my XP machine is currently in
bits awaiting new parts..........

Use DEPENDS to get list of DEPENDENCIES for the LIBMP4V2.DLL. You can
also get the implicit loads using DUMPBIN.

DUMPBIN /DEPENDENTS LIBMP4V2.DLL

I wrote a command line version of DEPENDS called LDEPENDS.ZIP

ftp://ftp.santronics.com/wildcat/tools

and I use to quickly see what is needed by EXE and DLLs. It doesn't work
well with SxS baloney (but DEPENDS does)

For example, for us, WCSRV2.DLL is the our DLL for WIN32 and for .NET
DLLIMPORTING. For this solid 12 year old WIN32 version, LDEPENDS shows:

D:\wc63>ldepends wcsrv2.dll
Module: [wcsrv2.dll]
+ rpcrt4.dll
+ wsock32.dll
+ msvcrt.dll
+ mfc42.dll
+ kernel32.dll
+ user32.dll
+ advapi32.dll
+ ole32.dll

This is solid code for all WIN32 compatiable Windows OSes, but that was
compiled with VS98.

Now when its compiled using VS2005:

G:\wc7beta>ldepends wcsrv2.dll
Module: [wcsrv2.dll]
+ rpcrt4.dll
+ wsock32.dll
+ mfc80d.dll
+ msvcr80d.dll
+ kernel32.dll
+ user32.dll
+ advapi32.dll
+ ole32.dll
+ oleaut32.dll

**** report ****
MFC80D.DLL LoadLibrary() Error: 126
MSVCR80D.dll LoadLibrary() Error: 126

So there are more dependencies that uses 8.0 dlls files and these are
trying to load or aliased with SxS. Ldepends has a problem finding SxS
stuff, but when the EXE or DLL is loaded for real, the OS loader (and
DEPENDS) knows whats to do.

So your goal is to see what RTL (run time libraries) you want to use. If
you compile with VS200x then you will bring more libraries that are for
that compiler version RTL.

What I would do is find the minimum required for LIBMP3V2.DLL and stick
with it. But then again if you are compiling the main application for
.NET, then most likely you will need 8.0 (VS2005) or 9.0 (VS2008) files
anyway.
[/QUOTE]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top