VisualCpp.org Collection of Visual C++ Stuffs

7Apr/08Off

How use to rundll.exe ?

Rundll.exe application used by many applications (DLL Specifically), for running there program without executable, generally this type of stuff is required by virus writer, but some genuine program also need it. Anyways please follow this link to learn more about rundll.exe.

Windows Rundll and Rundll32 Interface

Filed under: DLL, General Comments Off
1Nov/071

In how many ways you could include the library file in your project?

 There three known ways to include library file in your project

1. Directly adding it to your project work space, like this :-

project workspace

(Image : VS 6)

2. Putting that in your project dependency, you have to set that in Project setting , either select that in Project | Project properties in VS2005 and Project! Settings in VS6 :-

ProjectSetting

3. using pragma to include that into your project for e.g.

if you want to include visualcpp.lib in your project, you can add this entry in your source code file.

#pragma comment (lib,_T(“visualcpp.lib”))

Filed under: DLL, General, MFC, Win32 1 Comment
1Aug/07Off

Difference between Dynamic Link Library (DLL) and TypeLibrary(TLB)?

Type Library

 A type library (.tlb) is a binary file that stores information about a COM or DCOM object's properties and methods in a form that is accessible to other applications at runtime. Using a type library, an application or browser can determine which interfaces an object supports, and invoke an object's interface methods. This can occur even if the object and client applications were written in different programming languages.

The COM/DCOM run-time environment can also use a type library to provide automatic cross-apartment, cross-process, and cross-machine marshaling for interfaces described in type libraries.

And that's of DLL

A dynamic-link library (DLL) is a module that contain functions and data that can be used by another module (application or DLL). In other words, TLB contains description of COM object. DLL
is just container of functions and resources. It's convenient to store COM object (or several objects) in DLL while having corresponding TLB's embedded in DLL module as binary resources.


------------------------------------------------------------------

Taken from MSDN forum,Tip owner PJ. van de Sande (MSMVP)

Filed under: COM/ATL, DLL, General Comments Off
23Jul/07Off

How to see all Function(s) exported by DLL?

MS provides you a Classic tool namely Dependency Walker (Depends.exe) which show you all the function exported by the particular DLL. Now what if your DLL shows only four functions like DllCanUnloadNow, DllGetClassObject, DllRegisterServer and DllUnregisterServer which signifies that it is COM DLL. You can use another tool provided by MS namely OleView which will show you the all interface associated with this COM DLL.

On other note, using Dependency Walker gives you Function Arguments in mangled form if exported by using _declspec, you can see original parameter list using UndName.exe

Filed under: DLL, General, Win32 Comments Off
10May/07Off

How to dynamically load function from any DLL?

For Dynamically loading Function from the DLL you have to take services of two api :- LoadLibrary and GetProcAddress

Here A Small code that will demonstrate dynamically loading of function from DLL.here,
I will load mciSendString function defined in WINMM.DLL .

// first make Function pointer
typedef MCIERROR (WINAPI * MCISENDSTRING)(
LPCTSTR lpszCommand,
LPTSTR lpszReturnString,
UINT cchReturn,
HANDLE hwndCallback
);

/// In function where you want to use about api
MCISENDSTRING fnmciSendString=NULL;
HMODULE hLibrary;

// load the library
hLibrary=LoadLibrary(_T("winmm.dll"));

// check is library loaded
if(hLibrary)
{
// if yes try to get Function addressfnmciSendString=(MCISENDSTRING)::GetProcAddress(_T("mciSendString"));
}

// check is we got Function Pointer
if(fnmciSendString)
{
// if yes call function
(fnmciSendString)(......);
}

Filed under: DLL, General, Win32 Comments Off