Windows Programming, calling external functions

Is there a way to detect the parameters that a function contained in a DLL requires?

Background: On a project I’m working on, the client has been using a reporting tool from the same vendor as my development tool. They have been manually creating reports, printing them, then printing the definition of the report. Part of what prints with the definition is a graphic representation of the layout.

My project was to automate the process of running these reports so that the users could queue up a bunch of them, and then using Windows Scheduler, have the my program execute all these reports in sequence, printing the results and when needed definitions.

Fine and dandy. Didn’t take very long to assemble, except for one small piece. The graphic representation.

The vendor does not provide any function call to print the report definition. Writing code to produce the text portion of the definition was relatively trivial because the vendor did provide some nice robust tools for that, just not the graphical part.

Shareware exists which can list what functions/subroutines are exposed to external calls in a windows dll, so after a bit of research, I believe I have found the DLL and function encapsulates this functionality, but I have no idea what parameters I need.

What I want to do may still not be possible, but I’m trying to exhaust every possible option before I have to try to either a) build a bicycle with a sledge hammer and anvil (re-create semi sophisticated graphics with a development platform more designed for applications programming), or pull in a C/C++ coder to recreate this particular wheel for me, which adds way too much to the maintenance load in the long run.

Any ideas?

-Doug

Does your .dll come with a type library? If not, that’s going to make things harder. If it was compiled with one of Microsoft’s programming tools then it probably does have a type library.

You can use this program to find the functions of a specific dll.

As for the parameters…if it has a type library, then you can load it up in one of the Microsoft Visual Studio programming languages. In Visual Basic, when you make a call to one of the dll’s functions, it will list the parameters that are needed. Visual Studio also has the “Object Viewer” which lists all the functions in a dll, the parameters and parameter types, and usually a brief description of the function if the programmer put it in their orginally.

The only other thing I can think of is to get someone familiar with Assembler to look at the dll. The functions in a Win32 dll can be fairly easily identified in assembled code, and possibly you could figure out the parameters from there.

Starbury

That’s exactly the sort of utility that I used to find the function I hope to use. I don’t think it has a type library because the vendor didn’t intend for me to be calling functions from this particular DLL in my code. (which is also why I’m asking here, as my posting to the vendor’s news group is unlikely to get a very inforamtive response beyond “that’s not supported” :slight_smile: )

I’ll see if I can find anyone familiar with Assembler in the IS group. I’m not considering it all that likely, but you never know.

I’m not sure if there’s a copy of VB or Visual Studio around, but it can’t hurt to see if that can detect anything additional as well. Thanks for the tips.

Without any outside information, your best bet is to use a disassembler. If the vendor supplied an application that uses the DLL, you might have better luck diassembling it and looking for the DLL call, than diassembling the DLL and trying to see what the function does with the stack.

If you can run the application in a debugger and set a breakpoint near the DLL call, even better. You’ll be able to look at the parameters on the stack and say “that looks like a pointer to a string, that looks like the length of the string, that looks like a color constant” etc.

Note also that what you’re asking for could very well be, for all practical purposes, impossible. You can run a disassembler and stare at the code until you figure out exactly what’s being passed to the function, but what happens when you find out that one of the parameters is a pointer to a complex and unspecified structure of proprietary info? The amount of painstaking reverse-engineering necessary could easily end up making it more practical to write your own rendering code.

If it’s an exported function, Quick View (which comes with Windows) gives details (at least that’s my recollection).

Mangetout

OK, I know I’ve seen it, but I don’t know the executable name of it.

Where do I find QuickView? I’m definitely leaning more toward Galt’s view because I know my skill levels and disassembling or walking it through a debugger and recognizing what’s on the stack is not within my normal bag of tricks.

If I can find a way to do this that costs me less than 20 hours of work, then it’s worth it. Even if I spend 20 hours on this and come up with nothing, it’s likely still time well spent because I exhausted my options before starting on my own rendering code.

Oh… and on an off chance…

Any bits and byte loving problem solvers out there familiar with PowerBuilder by Sybase? 'cause that’s the platform I’m talking about here and if someone who is very familiar with any of the techniques above who also happens to code PB might be able to solve this much more quickly and might want to try and figure it out for fun. *Hey, it’s worth a shot, right? *

-Doug