What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Get information from pointer?

Get information from pointer?
Author: Message:
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
O.P. Get information from pointer?
Some Windows messages have a pointer to a structure as the lParam. How do I "follow" this pointer and get the data it points to? I need to be able to read the contents of the structure. I have no idea what to do with the pointer (it's a number).

Thanks!
12-17-2006 04:34 PM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Get information from pointer?
I think this is an example of the kind of thing you want...

code:
//Show color picker common dialog

    //Create our CHOOSECOLOR data block
    var CHOOSECOLOR = Interop.Allocate(36);
    CHOOSECOLOR.WriteDWORD(0, 36); //DWORD lStructSize
    CHOOSECOLOR.WriteDWORD(4, 0); //HWND hwndOwner
    CHOOSECOLOR.WriteDWORD(8, 0); //HWND hInstance
    CHOOSECOLOR.WriteDWORD(12, 0x000000FF); //COLORREF rgbResult (COLORREF = 0x00bbggrr)
    var CustColors = Interop.Allocate(64); //Create an array of 16 COLORREFs for CustColors
    CHOOSECOLOR.WriteDWORD(16, CustColors.DataPtr); //COLORREF *lpCustColors (pointer to our array)
    CHOOSECOLOR.WriteDWORD(20, 3); //DWORD Flags (3 = 2 (CC_FULLOPEN) + 1 (CC_RGBINIT) )
    CHOOSECOLOR.WriteDWORD(24, 0); //LPARAM lCustData
    CHOOSECOLOR.WriteDWORD(28, 0); //LPCCHOOKPROC lpfnHook
    CHOOSECOLOR.WriteDWORD(32, 0); //LPCTSTR lpTemplateName

    //Open the dialog box
    var result = Interop.Call('comdlg32.dll', 'ChooseColorA', CHOOSECOLOR);
    //If the user pressed ok convert it to hex
    if(result == 1){
      //Get decimal values
      var r = CHOOSECOLOR.ReadDWORD(12) & 0xFF;
      var g = (CHOOSECOLOR.ReadDWORD(12) / 0x100) & 0xFF;
      var b = (CHOOSECOLOR.ReadDWORD(12) / 0x10000) & 0xFF;
      Debug.Trace('RGB: ' + r + ',' + g + ',' + b)
      //Get hex values
      var hexchars="0123456789ABCDEF";
      var r = hexchars.charAt((r >> 4) & 0xf) + hexchars.charAt(r & 0xF);
      var g = hexchars.charAt((g >> 4) & 0xf) + hexchars.charAt(g & 0xF);
      var b = hexchars.charAt((b >> 4) & 0xf) + hexchars.charAt(b & 0xF);
      Debug.Trace('HEX: ' + r + g + b);
    }

You need to use Interop.Allocate and ReadDWORD and so on
<Eljay> "Problems encountered: shit blew up" :zippy:
12-17-2006 04:37 PM
Profile PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
O.P. RE: Get information from pointer?
No. That's making a pointer to my own data, I know how to do that :P

I need to get data from a pointer given to me by Windows.
12-17-2006 04:39 PM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Get information from pointer?
Don't you still have to specify the pointer? if you do that then can't you still use
code:
lpointer.ReadDWORD

AFAIK the structure behaves the same ^o)
<Eljay> "Problems encountered: shit blew up" :zippy:
12-17-2006 04:46 PM
Profile PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Get information from pointer?
heres an example of WM_COPYDATA

code:

/*
        typedef struct {
           DWORD dwData; 4
           DWORD cbData; 4
           PVOID lpData; 4
        } COPYDATASTRUCT; 12
        */
       
        var struct = Interop.Allocate(12);
        Interop.Call('Kernel32','RtlMoveMemory', struct, lParam,12);
       
        var dwData = struct.ReadDWORD(0);
        var cbData = struct.ReadDWORD(4);
        var lpData = struct.ReadDWORD(8);


This post was edited on 12-17-2006 at 04:48 PM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
12-17-2006 04:47 PM
Profile PM Web Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
O.P. RE: Get information from pointer?
Thanks! That worked :)

This post was edited on 12-17-2006 at 05:03 PM by deAd.
12-17-2006 05:02 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On