What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Developers heart felt wish!

Pages: (3): « First « 1 [ 2 ] 3 » Last »
Developers heart felt wish!
Author: Message:
matty
Scripting Guru
*****


Posts: 8337
Reputation: 109
34 / Male / Flag
Joined: Dec 2002
Status: Away
O.P. RE: Developers heart felt wish!
you are the man!

* matty wonders when we can expect 4.51...
02-06-2008 08:56 PM
Profile E-Mail PM Find Quote Report
Patchou
Messenger Plus! Creator
*****

Avatar

Posts: 8610
Reputation: 201
38 / Male / Flag
Joined: Apr 2002
RE: Developers heart felt wish!
* Patchou wonders too.... :p

Don't worry Matty, I'll bother you soon enough with aome private build to test.
[Image: signature2.gif]
02-06-2008 09:04 PM
Profile PM Web Find Quote Report
aNILEator
Skinning Contest Winner
*****

Avatar
...in the wake of the aNILEator

Posts: 3718
Reputation: 90
30 / Male / Flag
Joined: Oct 2003
Status: Away
RE: Developers heart felt wish!
and fix some skinny stuff to <3 :->
02-06-2008 11:54 PM
Profile PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
26 / Male / Flag
Joined: May 2006
RE: Developers heart felt wish!
What about SetWindowLong and SetWindowsHook? I want callbacks for those.

Technical answer: When C++ is compiled native, it means that the compiler basically converted the code to assembly code. This code is much more low-level, and very difficult to read by humans (but quite easy to understand), this is also why you cannot read the source-code of any program you've downloaded. You can say it's the language your processor is reading. Different functions have different calling conventions, they are called differently in the assembly code. You won't notice this when coding C++, but the outcome is different. The compiler stores the function signature (what address, calling convention, parameters) the function has, and if your line doesn't match, the compiler prints an error. To make programming more sorted, you put these often signatures in your header file (*.h/hpp), and then include that file on the top of the actual code (*.c/cpp). For example (this is the function signature):
code:
int myfunc(int a);
Mostly compilers use the __cdecl calling convention by default (C/C++ compilers). So the compiler would read it as:
code:
int __cdecl myfunc(int a);
If you change calling convention to, let's say, __stdcall, you won't notice any difference, the function will get called as you wanted, but the assembly code is different.
When you call it in your code you'll probably use something like this:
code:
myfunc(1);
But if you do anything wrong like: (this code is wrong since the myfunc-function only has 1 parameter.)
code:
myfunc(1,2);
What I wanted to show was that the compiler check for the signature when a callback function is called. When you apply yourself to a hooking-chain or another callback function, you simply leave an address in the memory to the function you want them to call, but they cannot find your calling convention, so Microsoft said:
quote:
Let's use the __stdcall calling convention for Win32 functions.
There's a way to bypass the signature check, because you cannot get the signature (well if you know assembly, you could figure it out) after the compilation, but when Windows wants to call your function, it simply uses __stdcall. When you call an API-function with a callback (when you want Windows to call your function), you leave an address to the function position in the memory it's loaded into. It knows which parameters the function must have, because you're using a technique called function-pointers, they defined the signature of the function in Windows code, so when they call it, the signature of your function must be the same as the signature they defined for your function. If the calling convention is wrong, you'll probably get a crash or something, it won't work simply.
And JScript isn't compiled code, it's not read by your processor, it's read by an emulator executed by the processor, the JScript-code is getting parsed in real time. The JScript functions aren't stored in memory, and they cannot be because they're not actually compiled code (assembly), so Windows cannot call them without knowing how to call them, and that's quite advanced, the JScript emulator doesn't allow this (this could probably be done with a lot of research and a very hacky result, but the Win32 library isn't written for scripting). Also different parameters in a function-call have different sizes, JScript doesn't because the function doesn't actually exist (this is one of the biggest reasons JScript is easier), it changes the function when it gets called, differently depending on what size of the parameters.
Now what Patchou is going to do, is that he creates the callback in his C/C++ code (he needs to know the signature before comiling!), and when his callback gets called he's going to call the JScript emulator, because he's the one with access to it.

This post was edited on 02-08-2008 at 03:25 PM by vikke.
02-08-2008 02:46 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
27 / Male / Flag
Joined: Apr 2004
RE: Developers heart felt wish!
Awesome explanation, vikke! :D Many thanks for clarifying this! :)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
02-08-2008 05:16 PM
Profile E-Mail PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
26 / Male / Flag
Joined: May 2006
RE: Developers heart felt wish!
Thanks. I was bored. :)
02-08-2008 05:58 PM
Profile E-Mail PM Find Quote Report
Patchou
Messenger Plus! Creator
*****

Avatar

Posts: 8610
Reputation: 201
38 / Male / Flag
Joined: Apr 2002
RE: Developers heart felt wish!
SetWindowLong and SetWindowsHook won't be supported by the new callback system. The restriction is that only synchronous calls made by the callee (like EnumWindows) are allowed.
[Image: signature2.gif]
02-08-2008 05:59 PM
Profile PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
26 / Male / Flag
Joined: May 2006
RE: Developers heart felt wish!
I was actually hoping for that, but yeah, I understand the restriction, and even if it would be implemented, it would cause a lot of delay to Messenger's windows-messages, since they have to get parsed through JScript before getting handled by the window.
02-08-2008 06:18 PM
Profile E-Mail PM Find Quote Report
Patchou
Messenger Plus! Creator
*****

Avatar

Posts: 8610
Reputation: 201
38 / Male / Flag
Joined: Apr 2002
RE: Developers heart felt wish!
yep, it would cause lots of delays and I tend to assume that if you want to go that low level, you'll prefer creating a DLL for that.
[Image: signature2.gif]
02-08-2008 07:37 PM
Profile PM Web Find Quote Report
felipEx
Scripting Contest Winner
***


Posts: 378
Reputation: 24
31 / Male / Flag
Joined: Jun 2006
RE: Developers heart felt wish!
Sorry for 'reviving' this thread, but i wonder if DdeCallback can be done with 4.51 :D

Edit:
i'd like to implement a small DDE client :cheesy:

This post was edited on 03-19-2008 at 08:10 PM by felipEx.
03-19-2008 07:24 PM
Profile E-Mail PM Find Quote Report
Pages: (3): « First « 1 [ 2 ] 3 » Last »
« 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