Jump to content
  • Advertisement
Sign in to follow this  
paulbird

dynamic win32

This topic is 4861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Anyone know how to do any of these things? A) Write a short program that when executed lists all Win32 functions. B) Same but lists all OpenGL functions. C) Same but with functions from stdio.h etc. D) A program that calls a given Win32 function by typing in the name of it. Is there a simple way of doing any of these?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by paulbird
Anyone know how to do any of these things?

A) Write a short program that when executed lists all Win32 functions.
B) Same but lists all OpenGL functions.
C) Same but with functions from stdio.h etc.
D) A program that calls a given Win32 function by typing in the name of it.

Is there a simple way of doing any of these?


For A and B you can call 'nm' on the lib files. (at least for MinGW)
For C maybe too unless they are inline, or try to disable inlining and optimisation.

For D you can use rundll32.exe.

Share this post


Link to post
Share on other sites
A) Define a "win32" function. What qualifies a function as being "win32" ? Do you want to enumerate every DLL in the System32\ folder and list all its functions? There is code to do this and it is possible, however, it is impossible to determine what parameters and return values those functions take. The list would be several megabytes.

B) It's easy to list all the exported functions from a DLL, including OpenGL. Same technique as A, except limited to the various OpenGL libraries.

C) Huh? stdio.h is a header file. It has no functions, only declarations.

D) Yes and no. Yes, the function can be called by name. No, you can't determine the return value, parameters or calling conventions therefore the function would at BEST return garbage, and LIKELY cause an application GP fault.

Robert

Share this post


Link to post
Share on other sites
Quote:
For D you can use rundll32.exe.


Afraid not. RunDLL32 calls any exported function from any DLL, this is true. However, in order for it to work that function must be __stdcall and must be declared using a specific set of parameters and return value. Calling any function not so declared will result in a GP fault.

Robert

Share this post


Link to post
Share on other sites
I suppose knowing how to list the functions from a DLL would be a good start.

My idea of a win32 function is a function written about in the win32 help files from the win32 SDK.

Share this post


Link to post
Share on other sites
Quote:
Original post by paulbird
I suppose knowing how to list the functions from a DLL would be a good start.

My idea of a win32 function is a function written about in the win32 help files from the win32 SDK.


DUMPBIN /EXPORTS <dllname> will dump all the exported functions in a given DLL. It will not tell you anything other than the function name -- so its near to useless becuase you can't determine parameters or return values from the name.

Furthermore, many MANY exported functions are exported by ordinal -- meaning they have no name, only a number. You would have to consult the .lib file and somehow dissect it to determine the function name from the ordinal.

Finally, the Microsoft Platform SDK lists hundreds of thousands of API calls across hundreds of DLL's in the System32\ and other folders. The SDK Help file will tell you what .lib and .dll the function can be found in. Furthermore, as MS moved from flat API's to COM, you'll find a lot of DLL's that have only a few COM-based exports but in reality expose hundreds of COM objects, interfaces and functions.

Robert

Share this post


Link to post
Share on other sites
So, are you saying that if I wanted to write a program that lists the names of functions in DLLs such as the common ones in the system folder this is not really possible?

Share this post


Link to post
Share on other sites
Quote:
Original post by paulbird
So, are you saying that if I wanted to write a program that lists the names of functions in DLLs such as the common ones in the system folder this is not really possible?


Not at all ... such a program is easily written. What I'm telling you is that the information you get will not be very useful as many of the functions in those DLL's have no names. Even if they DID have names, you couldn't actually CALL those functions armed only with their names. You'd just end up crashing your program.

Robert

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!