Page 1 of 1

Creating OSD from an C# Application

Posted: Sun Mar 02, 2008 4:32 am
by Isch
Hello,

i´m trying to create an OSD surface using an C++ DLL. Here is the code:

int OSDTEST(HWND DDHWND, DWORD dwHeight, DWORD dwWidth, DWORD dwLeft, DWORD dwTop, BYTE Transparency)
{

TOSDSurface osd;
osd.dwSize = sizeof(osd);
osd.dwHeight = dwHeight;
osd.dwWidth = dwWidth;
osd.dwTop = dwTop;
osd.dwLeft = dwLeft;
osd.Transparency = Transparency;
int hOSD = SendMessage(hAPP, WM_MODULE_MSG, DDMODAPI_OSD_CREATE_SURFACE, (LPARAM)&osd);
return hOSD;
//SendMessage(hAPP, WM_MODULE_MSG, DDMODAPI_OSD_SHOW_SURFACE, hOSD);

}

I call this function from my C# application. The code:

[DllImport("DDOSDHelper.dll")]
static extern int OSDTEST(IntPtr DDHWND, UInt32 dwHeight, UInt32 dwWidth, UInt32 dwLeft, UInt32 dwTop, byte Transparency);

...
OSDTEST(xxx, 50, 50, 10, 10, 1);
...

Evertime i call this code an error occurs in DD (see attached file).

Can anyone help?

Thanks
Isch

Posted: Sun Mar 02, 2008 6:43 am
by rel
the parameter you send through SendMessage should be in the same memory space with DvbDream.

so you can call this function only from a module (*.mod placed into \modules) otherwise there will be access-violations. (different apps = different memory space = different addressing)

Posted: Wed Mar 05, 2008 7:39 am
by smarg
You can do it with standalone app.

You need to allocate memory in DD process (with VirtualAllocEx API) of sizeof(TOSDSurface) size, fill local structure, copy the structure to the DD process with WriteProcessMemory API and then send message while passing the address of allocated memory in DD process.

Don forget to free DD memory when you finished, otherwise there will be memory leak in DD :)

Posted: Sat Mar 08, 2008 4:51 am
by Isch
Thanks for your tip.

Creating the OSD is working now!

Now my problem is to read the bitmap from DD´s memspace.
I use ReadProcessMemory, but how can i get the size of the OSD bitmap?

Any ideas?