Right know im working on MapViewofFile to get text out of one of MY dll buffers and put it into a buffer in the app....

I think this is a lot more work than simply having the dll send the text to the app buffer..

Could someone recommend some ways a dll send text to a app buffer. Text in the dll change quite often.

If i don't get back soon ... Thanks in advance
Posted on 2003-08-01 11:47:38 by cmax
What about passing the pointer of a string to the dll and let the dll make use of the pointer to store data?
Posted on 2003-08-01 11:49:56 by roticv
That will only work if the dll was loaded by your own app. If you try that from a hook library, it will not work because pointers would no longer be valid.

If this is the case, you could try sending the WM_COPYDATA message from the dll to a window in your app. The dll could find the window with FindWindow, you'll have to "hardcode" the class and window name in both your exe and dll files.

If it's a dll you loaded with LoadLibrary, for example, passing it a pointer will work just fine, as roticv pointed out.
Posted on 2003-08-01 12:59:43 by QvasiModo
Could use MailSlots, it would be more complicated but you could set up a notification with it.
Posted on 2003-08-01 13:37:56 by donkey
Just wondering, but whether it will work in a hook would depend on the method chosen. Seeing as that the dll has to access the data of the app, an appropriate way to get to the data would be attaching the dll to the app - thus under nt based systems the dll would be in the address space of the app and there would be no problem. Sort of the same thing as using loadlibrary, only it's the other way round - the dll attaches itself to the app. And ofcourse, under 9x it's not that much of a problem anyway, if memory serves me right.

Feel free to point out any obvious mistakes in my reasoning, it's been awhile since I dealt with the subject. Oh, and why are you trying to send text to an app that's not yours? Just wondering.

Fake
Posted on 2003-08-01 13:46:26 by Fake51
Add atoms and RegisterWindowMessage/PostMessage to the list of ideas.
Posted on 2003-08-01 14:09:42 by Will

Oh, and why are you trying to send text to an app that's not yours? Just wondering.

Actually, cmax didn't write anything like that - I suggested it. That's because he wrote about hook libraries in a different thread, so just in case I wanted to spare him the pain of learning the hard way what works and what doesn't with global hooks... :grin:
Posted on 2003-08-01 15:22:16 by QvasiModo

Add atoms and RegisterWindowMessage/PostMessage to the list of ideas.

Good one! It can be used with small strings (atoms use kernel memory, if I recall correctly).

BTW, how about memory mapped files? One more idea for the list :)
Posted on 2003-08-01 15:24:44 by QvasiModo
I guess the best solution depends on how much data you're talking about. For small strings (255 bytes), atoms are quick and easy. Then do a postmessage/sendmessage and you're set. I used to consider it a dirty solution, but it's actually a pretty solid workaround.
Posted on 2003-08-01 18:03:43 by Will
"Oh, and why are you trying to send text to an app that's not yours? Just wondering"

First of all thanks everybody. These are some GREAT ideas.

Fake51, i don't know if you are asking me this but it is my app and my dll and mostly with my own data. I looking into my own way of playing with data. And it's really interesting of what can be done with dll.

Since i am getting into QvasiModo lib im now rememebeing all the help and code wars people like Four-F, Fake51, and Will use to do... This was you guys world am im right ... These are the pro's

The only difference is now im trying to USE what you guys were discussing when i had no clue.

I am not that good with anything outside my own executionable, but if i find some time and a few more clues in asm to build an API hook with i will. c, C++ and Delphi Api hooks can be founded anywhere and the people who write them know ASM. So how about it being 100% assembler with-out those weak points ... Gets me ...

Im not a cracker\hacker, I have my own reasons and this lib may make things much clearer. To me its like my first asm tute, a real layout just like a asm file in Examples that made assember so easy to learn. I can't do everything at ones but i plan to get into it as i go.

Im in my working mode. I see you guys latter.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PS: Will that good d**e strong... I'll be reading something about atoms.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
WM_COPYDATA is cool but forget WM_ for everything.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I go with MapView but i caught an example running slow as h*ll when i was downloading a large file on the internet. but everything else ran fine on the machine ... 30 clocks just to gear up i hear. and it was only 5 bytes...2 - 3 full seconds to show....... .Makes me wonder
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
"pointer of a string" Sound like real assembler but i don't understand
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
"MailSlots" I hear about that and it sound good... they say it works...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I say MapView and atoms are the bast way to go ...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

?
Posted on 2003-08-01 23:58:31 by cmax
Will

"Then do a postmessage/sendmessage and you're set"

Thats exacly what i was trying to do at first, but i know nothing about atom. thats a plus...

I could sendmessage to the edit box in my app. But when a different string come it would not overwrite the editbox string. So i wrote code to clear it and then it would not accept any moire strings.

So i never got do do what i really wanted to do and that was to write the string to a buffer and not an editbox.

Anyway it acted like mapview. "You know the limitation that it has when maping files" Not change size and what nots..

For me that might be a coding problem. So moving on could you post a piece of code that show how to do the buffer thing if possible... One buy itself and one with atoms. Strings are small ... 255

P l e a s ePosted on 2003-08-02 00:28:06 by cmax
Cmax: sorry bout that, had the things Qvasi wrote in mind when I replied - figured you were trying to do a general dll to app transfer. Heh, furthermore, there are perfectly legit reasons for doing so, one doesn't have to be a hacker/cracker to be interested in that ;) Anyway, my apologies.

Fake

Ps. Since both dll and app are yours, easiest thing in the world is to pass the pointer.

Dll initializes buffer with data.
Prepares a message to send to the app.
Throws in the pointer to the buffer (your everyday offset buffer will do)
Send message.
App retrieves data from buffer, using the pointer.

If dll and app are working sort of asynchronously, you can use events to notify app when there's data in the buffer for graps. Guess there's a million ways to do this, really.
Posted on 2003-08-03 13:33:45 by Fake51
Thanks Fake51, I really thought so...


Will Must be to busy or just threw in another great idea as requested... don't worry about that Will. I "WILL" amd think this beat that, at lease on small strings. But now I try to get the Pointer thing in mind that got to be even quicker....

Anyway, it is amazing how something so simple can work if you try. I got
SetWindowText work properly. Some mis-placed code was over-writting the recieving buffer. My fault

PUSH offset DataBack
PUSH [ ahand_Edit1 ]
CALL SetWindowTextA

The key is to get your handles for the receiving window all at the same time while your app install of dll so there will ge no looping to do the same thing over and over again ... "i know everybody knows this BUT I JUST FOUNDED OUT"

And to think all the things that MapView has to do and in the end it's
some form of SetWindowTextA anyway if malipulated ... But for large data i guest MapView is THE greatest way to go.

From one app to the next ... You can't get much faster than a single "MAIN" API call to SetWindowText or can you... I think Windows itself lives for that ...

But I may even dump that and see about what POINTER can do ... I also take back what i said about WM_COPYDATA.


This was a great experence and i am still getting my job done flawlessly so far. You got to keep an eye on a press while typesetting the next pages as you go.

Thanks Everybody


PS: Posted on 2003-08-03 15:48:22 by cmax