Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how to read exe's dbgrid content in DLL???

Posted on 2004-11-26
12
Medium Priority
?
472 Views
Last Modified: 2010-04-05
i have a exe writen by delphi(no sourcecode), the exe load a DLL, i have the DLL sourcecode,but exe's Application not pass to DLL, so i cannt read any class from exe mainform, i want read dbgrid content from exe mainform in DLL,how to resolve it???
0
Comment
Question by:sundayboys
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 9

Expert Comment

by:ginsonic
ID: 12684941
Can't! The exe must send the values to dll to can use inside dll.
0
 
LVL 1

Author Comment

by:sundayboys
ID: 12684982
no way???sigh...
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12688121
It can be done but it requires a lot of knowledge of the Windows API and the Delphi VCL. You would have to find the window handle of the form that contains the grid, find the grid on this form, get the exact address of the grid itself and then use a typecast of the TDBGrid (if that is used) around the pointer that is pointing to the grid. You would have to be very aware of the memory manager in the main executable and see if you can connect to it too. (The use of Sharemem is useless since the EXE is probably NOT using it.) If you can't hook into the memory management of the main executable then you cannot use any strings in your communication between DLL and EXE since this would cause serious memory leaks and will crash the application.

I think it's easier to just rewrite that executable or just buy the source of it if someone made it for you. It might take too much time just to get it working correctly.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:sundayboys
ID: 12688683
i want use ReadProcessMemory to find the content of grid,is it a good idea?
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12696157
Use ReadProcessMemory if you want to read some memory area from another process. Since the DLL is injected in the same address space as the executable, you don't need it.
And I do consider this a very complex solution do do, what exactly? That application must be reading it's data from some database so why don't you read it from the same database?
0
 
LVL 5

Expert Comment

by:DeerBear
ID: 12701321
Hi,

Once you've found the window handle, you should be able to send it the
correct control messages( there should be a bunch for DBGrid I suppose ).

why don't you look for that?

HTH,

Andrew
0
 
LVL 1

Author Comment

by:sundayboys
ID: 12701962
yeah, i can find DBGrid handle,but i dont know any control message about DBGrid,could someone helps me???

i dont know which database that exe used, username and password nobody knows :-(
0
 
LVL 5

Expert Comment

by:DeerBear
ID: 12706026
Uhm... you might want to look at the Messages unit and the DBCtrls one to see if you can find any message.

Cheers,

Andrew
0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 2000 total points
ID: 12715112
@Andrew,
I'm sorry to have to say this but the Grid control (including DBGrid) does NOT provide any messages to read the contents of the cells. With the DBGrid, the cells are even drawn dynamically and the grid is a virtual grid. The grid itself won't even know the contents of the cells! Therefore, even if you could get the address of the DBGrid control itself, you still won't be able to retrieve the contents from the cells. The contents from the database fields are drawn directly from the table to the canvas of the grid.

In other words, there is NO way to get the text on a DBGrid... But if it's a read TDBGrid component, you could go to the DataSource component that should be linked to it. From there you can go to the Dataset that is linked to the grid. And then you can walk through the contents of this dataset to read the whole table. Combined with other information that you might extract from the DBGrid, you might be able to determine which record/field is currently selected. But you will need to find the address of the DBGrid object for this and that's not easy. The grid handle is NOT it's address and doesn't even provide you any way to find the address. I wonder if it's even possible to find the grid's address...

It might be easier to just analyze this executable, though. There are rsource extractors that allow you to extract Delphi forms from an executable. There's a tool called Resource Hacker at http://swiss.torry.net/tools/project/resources/reshacker.zip which you can use to see the Delphi forms that are used in this executable. By looking at these forms, you might find the grid that is used and with it, the database (type) that it connects to. Unless the application uses some custom grid and no dataset components, this tool will provide you quite a lot of information. (Perhaps even username and password.)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question