Hi all, Just looking over fole_s_connect() in win32ole.c and I noticed this bit: hr = CLSIDFromProgID(pBuf, &clsid); ... hr = GetActiveObject(&clsid, 0, &pUnknown); ... hr = pUnknown->lpVtbl->QueryInterface( pUnknown, &IID_IDispatch, (void **)&pDispatch ); Using win32-api, that would be something like: IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack(''ISSCCCCCCCC'') clsid = 0.chr * 16 unknown = 0.chr * IID_IUnknown.size hr = CLSIDFromProgID(multi_to_wide(server), clsid) ... GetActiveObject(clsid, nil, unknown) ... ??? And here is where I''m stuck. How do I unravel a pointer to a struct and then call a function on it? What is the equivalent of pUnknown->lpVtbl->QueryInterface() ? BTW, the prototype for GetActiveObject is: HRESULT GetActiveObject( REFCLSID rclsid, void FAR* pvReserved, IUnknown FAR* FAR* ppunk ); Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
Hi, ----- Original Message ----- From: "Berger, Daniel" <Daniel.Berger at qwest.com> To: "Development and ideas for win32utils projects" <win32utils-devel at rubyforge.org> Sent: Tuesday, June 10, 2008 11:55 PM Subject: [Win32utils-devel] Unraveling a FAR*> Hi all, > > Just looking over fole_s_connect() in win32ole.c and I noticed this bit: > > hr = CLSIDFromProgID(pBuf, &clsid); > ... > hr = GetActiveObject(&clsid, 0, &pUnknown); > ... > hr = pUnknown->lpVtbl->QueryInterface( > pUnknown, > &IID_IDispatch, > (void **)&pDispatch > ); > > Using win32-api, that would be something like: > > IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack(''ISSCCCCCCCC'') > > clsid = 0.chr * 16 > unknown = 0.chr * IID_IUnknown.size > > hr = CLSIDFromProgID(multi_to_wide(server), clsid) > ... > GetActiveObject(clsid, nil, unknown) > ... > ??? > > And here is where I''m stuck. How do I unravel a pointer to a struct and > then call a function on it? What is the equivalent of > pUnknown->lpVtbl->QueryInterface() ? > > BTW, the prototype for GetActiveObject is: > > HRESULT GetActiveObject( > REFCLSID rclsid, > void FAR* pvReserved, > IUnknown FAR* FAR* ppunk > ); >In order to call a function with address, we need a new Win32::API.new constructor like this: somefunc = Win32::API.new(procaddress,prototype,return) # procaddress is long integer for function pointer somefunc.call(...) I guess the implementation is quite simple. Regards, Park Heesob
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Wednesday, June 11, 2008 9:44 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > Hi, > ----- Original Message ----- > From: "Berger, Daniel" <Daniel.Berger at qwest.com> > To: "Development and ideas for win32utils projects" > <win32utils-devel at rubyforge.org> > Sent: Tuesday, June 10, 2008 11:55 PM > Subject: [Win32utils-devel] Unraveling a FAR* > > > > Hi all, > > > > Just looking over fole_s_connect() in win32ole.c and I > noticed this bit: > > > > hr = CLSIDFromProgID(pBuf, &clsid); > > ... > > hr = GetActiveObject(&clsid, 0, &pUnknown); > > ... > > hr = pUnknown->lpVtbl->QueryInterface( > > pUnknown, > > &IID_IDispatch, > > (void **)&pDispatch > > ); > > > > Using win32-api, that would be something like: > > > > IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack(''ISSCCCCCCCC'') > > > > clsid = 0.chr * 16 > > unknown = 0.chr * IID_IUnknown.size > > > > hr = CLSIDFromProgID(multi_to_wide(server), clsid) > > ... > > GetActiveObject(clsid, nil, unknown) > > ... > > ??? > > > > And here is where I''m stuck. How do I unravel a pointer to > a struct and > > then call a function on it? What is the equivalent of > > pUnknown->lpVtbl->QueryInterface() ? > > > > BTW, the prototype for GetActiveObject is: > > > > HRESULT GetActiveObject( > > REFCLSID rclsid, > > void FAR* pvReserved, > > IUnknown FAR* FAR* ppunk > > ); > > > In order to call a function with address, we need a new > Win32::API.new > constructor like this: > > somefunc = Win32::API.new(procaddress,prototype,return) # > procaddress is > long integer for function pointer > somefunc.call(...) > > I guess the implementation is quite simple.I''d rather not overload API.new if we can help it. What about a separate subclass? Win32::API::Function.new perhaps? Does that seem reasonable? Or do you feel we should overload the API.new constructor? As for the implementation, I think it would just be a matter of subclassing API and redefining initialize. It looks like API.call could be used as-is, correct? Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
----- Original Message ----- From: "Berger, Daniel" <Daniel.Berger at qwest.com> To: "Development and ideas for win32utils projects" <win32utils-devel at rubyforge.org> Sent: Thursday, June 12, 2008 3:36 AM Subject: Re: [Win32utils-devel] Unraveling a FAR*> >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Park Heesob >> Sent: Wednesday, June 11, 2008 9:44 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Unraveling a FAR* >> >> Hi, >> ----- Original Message ----- >> From: "Berger, Daniel" <Daniel.Berger at qwest.com> >> To: "Development and ideas for win32utils projects" >> <win32utils-devel at rubyforge.org> >> Sent: Tuesday, June 10, 2008 11:55 PM >> Subject: [Win32utils-devel] Unraveling a FAR* >> >> >> > Hi all, >> > >> > Just looking over fole_s_connect() in win32ole.c and I >> noticed this bit: >> > >> > hr = CLSIDFromProgID(pBuf, &clsid); >> > ... >> > hr = GetActiveObject(&clsid, 0, &pUnknown); >> > ... >> > hr = pUnknown->lpVtbl->QueryInterface( >> > pUnknown, >> > &IID_IDispatch, >> > (void **)&pDispatch >> > ); >> > >> > Using win32-api, that would be something like: >> > >> > IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack(''ISSCCCCCCCC'') >> > >> > clsid = 0.chr * 16 >> > unknown = 0.chr * IID_IUnknown.size >> > >> > hr = CLSIDFromProgID(multi_to_wide(server), clsid) >> > ... >> > GetActiveObject(clsid, nil, unknown) >> > ... >> > ??? >> > >> > And here is where I''m stuck. How do I unravel a pointer to >> a struct and >> > then call a function on it? What is the equivalent of >> > pUnknown->lpVtbl->QueryInterface() ? >> > >> > BTW, the prototype for GetActiveObject is: >> > >> > HRESULT GetActiveObject( >> > REFCLSID rclsid, >> > void FAR* pvReserved, >> > IUnknown FAR* FAR* ppunk >> > ); >> > >> In order to call a function with address, we need a new >> Win32::API.new >> constructor like this: >> >> somefunc = Win32::API.new(procaddress,prototype,return) # >> procaddress is >> long integer for function pointer >> somefunc.call(...) >> >> I guess the implementation is quite simple. > > I''d rather not overload API.new if we can help it. What about a separate > subclass? > > Win32::API::Function.new perhaps? Does that seem reasonable? Or do you > feel we should overload the API.new constructor? >API::Function.new might be suitable.> As for the implementation, I think it would just be a matter of > subclassing API and redefining initialize. It looks like API.call could > be used as-is, correct? >Yes, you are correct. Regards, Park Heesob
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Wednesday, June 11, 2008 5:20 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > > ----- Original Message ----- > From: "Berger, Daniel" <Daniel.Berger at qwest.com> > To: "Development and ideas for win32utils projects" > <win32utils-devel at rubyforge.org> > Sent: Thursday, June 12, 2008 3:36 AM > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > > > > >> -----Original Message----- > >> From: win32utils-devel-bounces at rubyforge.org > >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > >> Park Heesob > >> Sent: Wednesday, June 11, 2008 9:44 AM > >> To: Development and ideas for win32utils projects > >> Subject: Re: [Win32utils-devel] Unraveling a FAR* > >> > >> Hi, > >> ----- Original Message ----- > >> From: "Berger, Daniel" <Daniel.Berger at qwest.com> > >> To: "Development and ideas for win32utils projects" > >> <win32utils-devel at rubyforge.org> > >> Sent: Tuesday, June 10, 2008 11:55 PM > >> Subject: [Win32utils-devel] Unraveling a FAR* > >> > >> > >> > Hi all, > >> > > >> > Just looking over fole_s_connect() in win32ole.c and I > >> noticed this bit: > >> > > >> > hr = CLSIDFromProgID(pBuf, &clsid); > >> > ... > >> > hr = GetActiveObject(&clsid, 0, &pUnknown); > >> > ... > >> > hr = pUnknown->lpVtbl->QueryInterface( > >> > pUnknown, > >> > &IID_IDispatch, > >> > (void **)&pDispatch > >> > ); > >> > > >> > Using win32-api, that would be something like: > >> > > >> > IID_IUnknown = [0,0,0,192,0,0,0,0,0,0,70].pack(''ISSCCCCCCCC'') > >> > > >> > clsid = 0.chr * 16 > >> > unknown = 0.chr * IID_IUnknown.size > >> > > >> > hr = CLSIDFromProgID(multi_to_wide(server), clsid) > >> > ... > >> > GetActiveObject(clsid, nil, unknown) > >> > ... > >> > ??? > >> > > >> > And here is where I''m stuck. How do I unravel a pointer to > >> a struct and > >> > then call a function on it? What is the equivalent of > >> > pUnknown->lpVtbl->QueryInterface() ? > >> > > >> > BTW, the prototype for GetActiveObject is: > >> > > >> > HRESULT GetActiveObject( > >> > REFCLSID rclsid, > >> > void FAR* pvReserved, > >> > IUnknown FAR* FAR* ppunk > >> > ); > >> > > >> In order to call a function with address, we need a new > >> Win32::API.new > >> constructor like this: > >> > >> somefunc = Win32::API.new(procaddress,prototype,return) # > >> procaddress is > >> long integer for function pointer > >> somefunc.call(...) > >> > >> I guess the implementation is quite simple. > > > > I''d rather not overload API.new if we can help it. What > about a separate > > subclass? > > > > Win32::API::Function.new perhaps? Does that seem > reasonable? Or do you > > feel we should overload the API.new constructor? > > > API::Function.new might be suitable. > > > As for the implementation, I think it would just be a matter of > > subclassing API and redefining initialize. It looks like > API.call could > > be used as-is, correct? > > > Yes, you are correct.Ok, I''ve added it to win32-api in CVS. Please take a look and let me know if it looks alright to you. The only thing I was concerned about was casting the function pointer address on line 380. If that''s wrong then please go ahead and correct it. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
Hi, ----- Original Message ----- From: "Berger, Daniel" <Daniel.Berger at qwest.com> To: "Development and ideas for win32utils projects" <win32utils-devel at rubyforge.org> Sent: Thursday, June 12, 2008 11:13 PM Subject: Re: [Win32utils-devel] Unraveling a FAR* <snip>>> >> > >> >> In order to call a function with address, we need a new >> >> Win32::API.new >> >> constructor like this: >> >> >> >> somefunc = Win32::API.new(procaddress,prototype,return) # >> >> procaddress is >> >> long integer for function pointer >> >> somefunc.call(...) >> >> >> >> I guess the implementation is quite simple. >> > >> > I''d rather not overload API.new if we can help it. What >> about a separate >> > subclass? >> > >> > Win32::API::Function.new perhaps? Does that seem >> reasonable? Or do you >> > feel we should overload the API.new constructor? >> > >> API::Function.new might be suitable. >> >> > As for the implementation, I think it would just be a matter of >> > subclassing API and redefining initialize. It looks like >> API.call could >> > be used as-is, correct? >> > >> Yes, you are correct. > > Ok, I''ve added it to win32-api in CVS. Please take a look and let me > know if it looks alright to you. The only thing I was concerned about > was casting the function pointer address on line 380. If that''s wrong > then please go ahead and correct it. >You''ve done almose perfect. I think Win32APIFunc structure is needless. But If you want to define Win32APIFunc structure and call it with api_call, Win32APIFunc size and Win32API size must be same. After mofication of Win32APIFunc like this: typedef struct { HANDLE dummy; FARPROC function; int return_type; int prototype[16]; } Win32APIFunc; Following Test code works fine. require ''win32/api'' require ''windows/library'' include Windows::Library hlib = LoadLibrary(''user32'') addr = GetProcAddress(hlib,''MessageBeep'') func = Win32::API::Function.new(addr,''L'',''L'') func.call(0) Regards, Park Heesob
> -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Park Heesob > Sent: Thursday, June 12, 2008 9:02 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > Hi, > ----- Original Message ----- > From: "Berger, Daniel" <Daniel.Berger at qwest.com> > To: "Development and ideas for win32utils projects" > <win32utils-devel at rubyforge.org> > Sent: Thursday, June 12, 2008 11:13 PM > Subject: Re: [Win32utils-devel] Unraveling a FAR* > > > <snip> > >> >> > > >> >> In order to call a function with address, we need a new > >> >> Win32::API.new > >> >> constructor like this: > >> >> > >> >> somefunc = Win32::API.new(procaddress,prototype,return) # > >> >> procaddress is > >> >> long integer for function pointer > >> >> somefunc.call(...) > >> >> > >> >> I guess the implementation is quite simple. > >> > > >> > I''d rather not overload API.new if we can help it. What > >> about a separate > >> > subclass? > >> > > >> > Win32::API::Function.new perhaps? Does that seem > >> reasonable? Or do you > >> > feel we should overload the API.new constructor? > >> > > >> API::Function.new might be suitable. > >> > >> > As for the implementation, I think it would just be a matter of > >> > subclassing API and redefining initialize. It looks like > >> API.call could > >> > be used as-is, correct? > >> > > >> Yes, you are correct. > > > > Ok, I''ve added it to win32-api in CVS. Please take a look and let me > > know if it looks alright to you. The only thing I was > concerned about > > was casting the function pointer address on line 380. If > that''s wrong > > then please go ahead and correct it. > > > You''ve done almose perfect. > I think Win32APIFunc structure is needless.Ok, I got a bit overzealous trying to save 4 points. I''ve undone that part. :) <snip>> Following Test code works fine. > > require ''win32/api'' > require ''windows/library'' > include Windows::Library > hlib = LoadLibrary(''user32'') > addr = GetProcAddress(hlib,''MessageBeep'') > func = Win32::API::Function.new(addr,''L'',''L'') > func.call(0)Yep, works great. I''ll release this as 1.1.0 this weekend, along with an updated windows-pr library (added a winsock module), and an updated win32-process library (now supports a real implementation of Process.ppid). Then I want to revisit win32-ole. :) Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
Hi,> Ok, I got a bit overzealous trying to save 4 points. I''ve > undone that part. :)Make that 4 *bytes*. I was thinking about a game or something when I wrote that. :) Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.