Autor Beitrag
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 18.08.03 21:18 
Hi,

ich hab ein kleines problem beim PostMessage..

und zwar möchte ich als lParam einen selbst definierten Record schicken.
Im grunde ja kein Problem, Pointer auf den Record, den in lParam und fertig.. ;)

Das klappt soweit auch.. allerdings nur solange die Message von Programm A and Programm A geschickt wurde, also im gleichen programm blieb...

Wenn die Message von Programm A and Probramm B geschickt wird, gibt's beim auswerterten der Message in Programm B ne Speicherverletzung, da Programm B kein zugriff auf den Pointer in Programm A hat...

So, das is auch schon mein Problem *g* Hat irgendjemand ne Ahnung ob/wie das lösbar ist??? (Ohne MMF!)

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mo 18.08.03 21:49 
Leider kann unter Windows kein Programm in den Speicherbereich eines anderen Programm ohne weiteres lesen/schreiben.
Schau mal im Forum unter shared Memory. Hatten wir letztens erst in der Diskussion.
grez
msch
teebee
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 109


D6 Prof
BeitragVerfasst: Di 19.08.03 11:28 
Wenn es Dir nur darum geht, aus dem 'fremden' Prozess zu lesen, sollte das mit ReadProcessMemory möglich sein. Vorher den Prozess mit OpenProcess und PROCESS_VM_READ öffnen. Die Prozess-ID kriegst Du mit GetWindowThreadProcessID.
Schreiben geht unter 9x nur mit MMF und unter NT per VirtualAllocEx.

Gruss, teebee
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 19.08.03 11:49 
Jedes Programm läuft in seinem eigenen Prozessraum, dh. ein Pointer eines Prozesses ist nur im Adressraum seines Prozesses gültig. Schickst du diesen Pointer also an einen anderen Prozess so kann dieser nichts damit anfangen (außer vielleicht die Daten per OpenProcess + ReadProcessMemory aus dem anderen Adressraum auszulesen).

Aber es gibt zum Glück genug andere Methoden für IPC (Inter Process Communication). Die einfachste ist wahrscheinlich WM_COPYDATA - funzt so ähnlich wie deine Message mit dem Pointer auf den Record, nur das Windows die Daten automatisch in den Adressraum des Zielprozesses mappt (Wichtig: WM_COPYDATA kann nur mit SendMessage verwendet werden - nicht mit PostMessage!)

andere Möglichkeiten wären:
COM/DCOM
Sockets
Pipes
Memory Mapped Files (die "Low-Level" Methode - auf dieser Methode basieren alle anderen IPC-Möglichkeiten)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Di 19.08.03 11:55 
Motzi hat folgendes geschrieben:
auf dieser Methode basieren alle anderen IPC-Möglichkeiten

Auch die Sockets? Das wäre ja wunderbar, wenn ich in den Speicher eines anderen, über das Internet erreichbaren, PCs meine Daten mappen könnte. :wink:

_________________
Ist Zeit wirklich Geld?
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 19.08.03 12:07 
;) Erwischt, hast aber DCOM vergessen! :P

Nein, aber solange alles nur den lokalen PC betrifft basiert alles auf MMFs.

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
UC-Chewie
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 531

WinXP
D5 Ent
BeitragVerfasst: Mi 20.08.03 02:45 
Noch was: WM_COPYDATA funktioniert nicht so ohne weiteres aus einem Service heraus (wie ich feststellen musste - siehe entsprechenden Thread in der DP).

_________________
Egal wie dumm man selbst ist, es gibt immer andere, die noch dümmer sind
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 20.08.03 14:27 
@UC-Chewie: das liegt daran, dass ein Service in einer anderen WindowStation läuft als die "normalen" Fenster mit denen der Benutzer interagieren kann, aber Fenster-Handles sind immer nur innerhalb ihrer WindowStation gültig! D.h. das Problem ist einfach, dass du vom Service aus keinen Zugriff auf das Fenster in der anderen WindowStation hast! Und das gilt für alle Zugriffe über ein Fenster-Handle, nicht nur für SendMessage und WM_COPYDATA!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
UC-Chewie
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 531

WinXP
D5 Ent
BeitragVerfasst: Mi 20.08.03 20:03 
@ Motzi: Das gleiche hast du auch in der DP geschrieben. Ich wollte die Info nur noch dem Fragesteller liefern.

_________________
Egal wie dumm man selbst ist, es gibt immer andere, die noch dümmer sind
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 21.08.03 14:38 
Ja, aber so wie du das formuliert hast hatte dachte ich du hättest den Eindruck gewonnen dass das Problem nur WM_COPYDATA betrifft...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
UC-Chewie
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 531

WinXP
D5 Ent
BeitragVerfasst: Do 21.08.03 17:27 
Ach so. Na ja, anfangs dachte ich halt, dass es an WM_COPYDATA liegt. Andere Messages hatte ich halt nicht ausprobiert. Aber ich hab etwas, dass nicht funktioniert und eine Érklärung, die logisch ist - was will ich mehr :D

_________________
Egal wie dumm man selbst ist, es gibt immer andere, die noch dümmer sind