Using DLL witihin PHP!

Hello All,

Hope everything alright with everyone !

Right after a happy moment of the new year 2070 BS (Nepelese new year) celebration, I have got a strange task for my team here! I spent couple of hours since last night to find out the solution but no luck yet !

Requirement:
Some of the confidential data like SSN, Bank Account numbers have been saved in MS-SQL database and they are encrypted (with AES specification) and I am using that database to pull some information including those encrypted ones. But I am not being able to decrypt yet. When I asked the technical guys of that third party database server, they have given me a DLL file where they just say that I can use a function in c-style. They don’t know what exactly it can be read in PHP but they suggested to go through win32api but no luck. I tried COM and .NET libraries in Windows OS but no luck.

When trying to register the DLL in my windows with regsvr32 <dllfilename.dll>, it threw the following message:

The module "C:\\NLSClientLibrary.dll" was loaded but the entry-point DLLRegisterServer was not found.

Make sure that DLL file is a valid DLL or OCX file and then try again.

Is there anyway to work with such purely custom DLL files and use some of the functions in it? Guys I am really desperate now with this !

Thank you very much in advance !

Regards
Raju Gautam
Kathmandu, Nepal !

Further more so far, I have tried to use w32API but with no luck because I am not being able to load the extension yet in my PHP in Windows.

I am waiting someone can help me out here :slight_smile:

Why are you registering the DLL with the windows API? PHP has zero communication with windows in that manner, primarily because it’s cross platform.

To call a function in a DLL from within php you’re better off writing a PHP extension, here’s an introduction to how to do that: http://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend/

Hey Tom,

Thanks for the reply.

First of all, in case of PHP running in Windows OS, there is connection and PHP can play with windows’ API as well. You can look at COM/.NET library. And I am still not sure whether we need to register the DLL or not but I have found somewhere while googling, to work with COM in PHP we need to register them.

Secondly, the DLL that I have now is not under my control so I cannot convert/modify it and hence I cannot make it as PHP’s extension. The given DLL is just a DLL nothing to relate with PHP (at least as per my understanding so far). The provider of DLL doesn’t know about PHP and they even don’t know how to make the DLL for PHP.

Would be nice if anyone others have experience on this type of problem using DLLs directly in PHP and they share their ideas on this.

Off Topic:

By the way Tom, congratulations to you for being MOTM April. I just remembered the batch on my name almost 3 years back !

You won’t be able to register an arbitrary DLL with windows either, you need to expose certain methods to allow that; which also means being able to compile the DLL yourself. What happens if you register it with PHP using w32api_register_function? Does it error or give you any kind of information? As a last resort, you may need to write a PHP extension in C that loads the third party dll and maps the methods.

It really depends exactly what the DLL you’re trying to use contains. Is it a COM object? It’s been a long time since I’ve programmed using the W32 API but as far as I’m aware, COM components need to expose a specific interface.