Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


ActiveX Object in Win32?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue Aug 12, 2014 6:33 am    Post subject: ActiveX Object in Win32? Reply with quote

Is there a way to create ActiveX object using win32 API?
the native for
Code:

<script>
  var activex = new ActiveXObject("WScript.Shell");
</script>

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Aug 12, 2014 1:03 pm    Post subject: Reply with quote

If you are using VB.NET/C# you can do it via the Microsoft.VisualBasic .NET library via:
Code:
Microsoft.VisualBasic.Interaction.CreateObject


This will use the COM calls needed to create the instance of the object.

If you need to do it in C++ perhaps something like this will help:
http://www.x86pro.com/article/vb-c-cpp-com-2
http://www.codeproject.com/Articles/2539/Adding-VBScript-and-JScript-support-in-your-C-appl

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue Aug 12, 2014 4:08 pm    Post subject: Reply with quote

Awhhh..
It's giving me hard time with
cannot convert from CLSID to const IID*const when trying to use CoCreateInstance

WTH is going on here
I'm not familiar with those types and libraries :S
that's my code
Code:

int main()
{
   CLSID      clsidWshShell;
   IDispatch   *pdispWshShell = NULL;
   HRESULT      hr;

   setlocale(LC_CTYPE, "");
   CoInitialize(NULL);
   CLSIDFromProgID(L"WScript.Shell", &clsidWshShell);

   hr = CoCreateInstance(clsidWshShell,
                    NULL,
                    CLSCTX_ALL,
                    IID_IDispatch,
                    (void**)pdispWshShell);

   if(hr)
   {
      printf("Hey");
   }

   return 0;
}

Guess I'll just dive into that sh*t
Thanks for your help
If you have any solution, it'd be great!

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Aug 12, 2014 5:20 pm    Post subject: Reply with quote

Setting it like this works fine for me:
Code:

#include <Windows.h>
#include <stdio.h>
#include <locale.h>

int __cdecl main(int argc, char* argv[])
{
    // Set the system locale..
    ::setlocale(LC_CTYPE, "");

    // Initialize COM..
    ::CoInitialize(NULL);

    // Obtain the CLSID of WScript.Shell..
    CLSID clsidWSS;
    ::CLSIDFromProgID(L"WScript.Shell", &clsidWSS);

    // Initialize a COM object of the shell scripting..
    IDispatch* lpDispatch = NULL;
    HRESULT hResult = S_OK;
    if (SUCCEEDED(hResult = ::CoCreateInstance(clsidWSS, NULL, CLSCTX_ALL, IID_IDispatch, (void**)&lpDispatch)))
    {
        // do stuff here with the object..
    }

    // Shutdown COM..
    ::CoUninitialize();
    return 0;
}

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Aug 13, 2014 1:15 pm    Post subject: Reply with quote

Guess I had to set Options > Advanced > Compile as C++ code to make it work..
Nice..
BTW, I'm trying to inject that code as a dll to IE hopefully It'd be the same object as the original ActiveX object created with
Code:

<script>
  var activex = new ActiveXObject("WScript.Shell");
</script>

but it has nothing to do with it
any ideas on that?

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Aug 13, 2014 6:20 pm    Post subject: Reply with quote

Not quite sure I follow what you mean in that post.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Aug 17, 2014 10:52 am    Post subject: Reply with quote

Sorry.. XD
What I meant was,
When I create an ActiveX object using JavaScript, Its memory structure looks different than what I create using the native code
I thought using the native code injected into Internet Explorer will cause the ActiveX to get the same structure as the JavaScript version, But it's a different kind of ActiveX
Attached a photo of the ActiveX object created from the native code above
as you can see, it's not a normal ActiveX that is created through internet explorer
I'll upload the ActiveX memory structure created by IE in a few minutes...



myact.png
 Description:
 Filesize:  16.97 KB
 Viewed:  8793 Time(s)

myact.png



_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Aug 17, 2014 1:25 pm    Post subject: Reply with quote

Given that it has a two step process from being ran within Javascript, it wont have the same type at face value. Since the object is first defined and created within the Javascript host, then the host creates and allocates the object in whatever manager / GC method it has (if it has one).

You may need to follow some pointers to locate the actual base object for the WScript.Shell object. Not too sure though since I don't touch ActiveX or Internet Explorer.

Another idea would be to debug Internet Explorer. Set a breakpoint on CoCreateInstance and see if you can trace where it may be creating the object.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Aug 17, 2014 3:16 pm    Post subject: Reply with quote

Yeah, I thought about that
Only problem is that when the ActiveX object is created, there are several unexported functions that are being called.
So I guess I'll have to reverse some of them to get the idea

Thanks Very Happy

_________________
Stylo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites