News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

using dumpbin.exe to create a .def file

Started by MikeT, October 09, 2009, 09:46:06 AM

Previous topic - Next topic

MikeT

as mentioned here:
http://www.powerbasic.com/support/forums/Forum4/HTML/012129.html

I am having great difficulty with XPsp3 and VS2008.
dumpbin is giving me the error:
Microsoft (R) COFF Binary File Dumper Version 5.12.8078                         
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
                                                                         
Dump of file C:\sqlite3.dll                                                     
                                                                               
File Type: DLL                                                                 
C:\sqlite3.dll : fatal error LNK1106: invalid file or disk full: cannot seek to 0x6179a

When I look for 'queryopen' events in procmon I get NAME NOT FOUND errors for:
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\link.exe.Local

C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\dumpbin.exe.Local

(plus a few for manifest files)

Any idea how I can get dumpbin to work?

hutch--

Mike,

Where did you get the file -> sqlite3.dll. Its not in my windows version.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php


MikeT

#3
Hi Hutch,
Its just a renamed dll file. I have some legacy code to maintain that uses SQLite.dll (version2 I think) so to avoid accidents I renamed it.

I created a simple dll with P B called AddShow.dll. It can be found here:
http://www.transferbigfiles.com/Get.aspx?id=7d86fa0b-6ddc-4f6f-8d31-2c20824aae9a
along with the VC2008 project.

The task is to link it statically with a .LIB file in VS2008. This has thus far defeated everyone!

The main problem is that dumpbin will not run because it is trying to open dumpbin.exe.local. What on earth is that?

Vortex


MikeT

Thanks for that tool,
Actually this is the first step in creating a .LIB file. I should have made that clear.
The approach is summed up here:
http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/

I have a Dll and a header file. THATs IT.

now I need to export the functions using dumpbin which I just cannot get to run.

PBrennick

Have you tried the /DISASM option? This may be stupid but, do you know what the options that are available?

Paul
The GeneSys Project is available from:
The Repository or My crappy website

rags

 you mean the addshow.dll?
why are all the timestamps messed up showing 1969 and 1970?


addshow.dll                        (hex)           (dec)

.........
Portable Executable starts at                 80
Signature                               00004550 (PE)
Machine                                     014C (Intel 386)
Sections                                    0004
Time Date Stamp                         00003039 Wed Dec 31 22:25:45 1969
......................
....................
Exp Addr Hint   Ord Export Name by AddShow.dll - Sat Feb  7 03:47:36 1970
-------- ---- ----- ---------------------------------------------------------
00001E9C    0     1 AddTwoNum
00001E35    1     2 LIBMAIN
00001F26    2     3 ShowString



God made Man, but the monkey applied the glue -DEVO

MichaelW

Mike,

Is there some reason that you can't use the def file that is included with the DLL?

See sqlitedll-3_6_18.zip here.

eschew obfuscation

MikeT

 you mean the addshow.dll?
YES!
now why can't I do that?

>why are all the timestamps messed up showing 1969 and 1970?
because its made by powerbasic perhaps?

>Is there some reason that you can't use the def file that is included with the DLL?
There is no Def file with this dll. I'm really sorry I mentioned SQLite becuase it has only confused things. I am just trying to convert PB dll's with no .Def or .Lib files.

PBrennick

Do you realize that PowerBasic's DLLs are proprietory and what you are trying to do is illegal?

Paul
The GeneSys Project is available from:
The Repository or My crappy website

MichaelW

Mike,

I saw where you mentioned another DLL, but I dismissed it because it did not seem likely that you would need to automate the creation of a def file for a "simple DLL", where I interpreted simple to mean that it exported only a small number of functions.

This def file was created by pexports.exe from the MinGW\bin directory:

LIBRARY AddShow.dll
EXPORTS
AddTwoNum
LIBMAIN
ShowString

eschew obfuscation

MikeT

#12
>Do you realize that PowerBasic's DLLs are proprietory...
Huh? Are you working on the assumption that I am trying to decompile powerbasic compiler Dll's perhaps?
Please re-read the thread.
I have *CREATED* a Dll (AddShow.Dll) in this case, using the PB compiler (that I own).
The concept is to move (run) away from powerbasic and call my legacy PB code from C++ in this case as Dll's.
So to recap, its my Dll, made from my code, with my copy of the compiler.

Michael
oooh what is pexports.exe?
http://www.emmestech.com/moron_guides/moron1.html
When i use:
AddShow.DLL | sed 's/^_//'
I get:
C:\C++Projects\pexports.exe: 's/^_//': could not load PE image


Added:
I just installed MASM and ran dumpbin in the bin folder:
/EXPORTS AddShow.dll
It worked!

Microsoft (R) COFF Binary File Dumper Version 5.12.8078                       
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.                   
                                                                                                                                         
Dump of file AddShow.dll                                                       
                                                                               
File Type: DLL                                                                 
                                                                               
  Section contains the following exports for AddShow.dll                       
                                                                               
           0 characteristics                                                   
      314328 time date stamp Sat Feb 07 00:47:36 1970                           
        0.00 version                                                           
           1 ordinal base                                                       
           3 number of functions                                               
           3 number of names                                                   
                                                                               
    ordinal hint RVA      name                                                 
                                                                               
          1    0 00001E9C AddTwoNum                                             
          2    1 00001E35 LIBMAIN                                               
          3    2 00001F26 ShowString                                           
                                                                               
  Summary                                                                       
                                                                               
        1000 .data                                                             
        1000 .link                                                             
        1000 .rloc                                                             
        2000 .text


No idea why the dates are off....

So why wont it work in the VS2008 bin folder?

hutch--

Mike,

If I have it right you want to use a DLL you wrote in PowerBASIC in a C++ program that normally requires an import library to link it statically to the EXE file ? For those not familliar with PowerBASIC, it creates DLLs without any import libraries or DEF files.

Basicaly you need to write C++ prototypes for the DLL functions you EXPORT making sure that you use the correct calling convention which in this case is simple, PowerBASIC by default uses STDCALL, and make sure the names you EXPORT are prototyped in a case sensitive manner and C/C++ requires this.

I know how to do this in MASM but there may be tools that don't require that you learn enough MASM to create the library you need.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

MikeT

>If I have it right
yes.

>PowerBASIC by default uses STDCALL
yup. But I can also declare them as CDECL if need be

>make sure the names you EXPORT are prototyped in a case sensitive manner
yes

>C++ prototypes for the DLL functions
no problem

The issue for static linking is creating the .LIB file. Following this method:
http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/
I need to make the .Def file first with dumpbin (so far 3 days work finally requiring the install of MASM!
unless I am missing something, this is the only way.

For Dynamic linking, I can call LoadLibrary() and GetProcAddr() then call the functions with a pointer of course but I don't want to do that in this case.