flat assembler
Message board for the users of flat assembler.

Index > Windows > Interfacing with my WebBrowser control?

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004
Well im currently developing an application which will need a WebControl and after a week or so trying to figure it out i finally achieved it after thinking it was only possible with the MFC.

By using AtlAxWinInit() from atl.dll and then creating the control with the class name "AtlAxWin" i've made a simple browser control which opens to Google. It only required a few lines of code which was weird since i was expecting to write an essay Smile. But I can't seem to be able to communicate with the control at all. And this is where i hoped i could get some help Confused.

Do you have any ideas on how to interface with the control? I'm mostly interested in telling the control to navigate somewhere else if anything. Any links to websites or examples showing something relevant i would be very grateful for.

All the relevant code is in the wmcreate section of the window procedure if you wish to take a look:

Code:
format PE GUI 4.0
entry start
Include 'win32a.inc'

;;;;;;;;;;;;;;;;;;;;;;;;;
;    Data Section       ;
;;;;;;;;;;;;;;;;;;;;;;;;;

section '.data' data readable writeable
_title db 'Basic Web Browser By Calpol2004',0
_class db 'MyWindowClass',0
browserclassname db 'AtlAxWin',0                      ;class name of browser control
browserhome      db 'http://www.google.com/',0        ;page to go to
wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class
msg MSG
edithwnd dd ?
client RECT

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;             Start               ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

section '.code' code readable executable
start:
invoke  GetModuleHandle,0
mov     [wc.hInstance],eax
invoke  LoadIcon,0,IDI_APPLICATION
mov     [wc.hIcon],eax
invoke  LoadCursor,0,IDC_ARROW
mov     [wc.hCursor],eax
invoke  RegisterClass,wc
invoke  CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_SYSMENU+WS_MAXIMIZEBOX+WS_MINIMIZEBOX+WS_SIZEBOX,50,30,700,500,NULL,NULL,[wc.hInstance],NULL
msg_loop:
invoke  GetMessage,msg,NULL,0,0
or      eax,eax
jz      end_loop
invoke  TranslateMessage,msg
invoke  DispatchMessage,msg
jmp     msg_loop
end_loop:
invoke  ExitProcess,[msg.wParam]
;end message loop

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;        Window Procedure           ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

proc WindowProc hwnd,wmsg,wparam,lparam
push    ebx esi edi
cmp     [wmsg],WM_CLOSE
je      wmclose
cmp     [wmsg],WM_DESTROY
je      wmdestroy
cmp     [wmsg],WM_CREATE
je      wmcreate
cmp     [wmsg],WM_SIZE
je      wmsize
defwndproc:
invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
jmp     finish
        wmdestroy:
                invoke  PostQuitMessage,0
                xor     eax,eax
        jmp     finish
        wmclose:

                invoke  DestroyWindow,[hwnd]
        jmp     finish
        wmcreate:
                invoke  AtlAxWinInit         ;make class available
                invoke  GetClientRect,[hwnd],client      ;get size of window so browser control is set to the same size
                invoke  GetModuleHandle,0
                invoke  CreateWindowEx,WS_EX_CLIENTEDGE,browserclassname,browserhome,WS_CHILD+WS_VISIBLE+WS_VSCROLL+WS_HSCROLL,[client.left],[client.top],[client.right],[client.bottom],[hwnd],eax,0
                mov     [edithwnd],eax          ;hwnd returned by CreateWindowEx is moved onto edithwnd variable as its a parameter for MoveWindow()
        jmp     finish
        wmsize:
                invoke  GetClientRect,[hwnd],client       ;re-retrieve the window size
                invoke  MoveWindow,[edithwnd],[client.left],[client.top],[client.right],[client.bottom],TRUE        ;adjust size of control
        jmp     finish
finish:
pop     edi esi ebx
ret
endp
;end of window procedure

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;       Import Data           ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',user32,'USER32.DLL',atl,'ATL.dll'
include 'apia\kernel32.inc'
include 'apia\user32.inc'
import  atl,AtlAxWinInit,'AtlAxWinInit'
;end of imports            
    


I've included the source and compiled app if you want to look:


Description:
Download
Filename: WebControl.zip
Filesize: 2.88 KB
Downloaded: 93 Time(s)

Post 18 Jul 2007, 22:18
View user's profile Send private message MSN Messenger Reply with quote
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004
Well what i've found so far is that access the navigate() and refresh() "methods" i may well need to use a high-level language like c++ but i really do not want to do that Crying or Very sad, how do i do object orientated function calls in ASM? is it even possible?

I'm supposed to do this:
Code:
;oWb being an "object pointer"
oWb.Navigate(url)
    


how would i go about writing one of these statements in ASM?
Post 22 Jul 2007, 08:48
View user's profile Send private message MSN Messenger Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
You can check out the DDRAW example that comes with FASM for how to use com objects.

if you don't know the function pointer you can reverse it from the a compilation in c++.

-Write the code in C++
-Put a rarely used inline "__asm RDTSC" write before/after the line you want
-Have c++ compile the exe and open it up in a debugger
-By looking for RDTSC you'll be able to easily find the code C++ generated for say "oWb.Navigate(url)"
Post 22 Jul 2007, 11:18
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
The smarter approach would be getting the C++ compiler to generate an assembly listing, that way you don't need to hunt for instructions... For Visual C++, cl /O1 /Fa myfile.cpp is suitable for an assembly listing. I do tend to use IDA on .obj files instead to get rid of name mangling, though.
Post 22 Jul 2007, 14:26
View user's profile Send private message Visit poster's website Reply with quote
BigVent



Joined: 28 May 2008
Posts: 24
BigVent
Say you wanted to use this code for searches or other things... where would you put code to wait until the google page loads, then send a search for "Whatever" then press enter?

What I'm really searching for is that this proggie will open up my remote desktop (https), send my password, send a couple of tabs & paste a few dates, then exit.

Is this possible? I guess the chore would be sending keys to the keyboard buffer?

Any help is appreciated!!!

_________________
~BigVent
Post 28 May 2008, 18:30
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3056
Location: vpcmipstrm
bitRAKE
Look at this thread showing how to inject JavaScript using AutoHotKey. Of course, it can be done in any number of languages. I haven't seen any examples in x86 and I hate COM in x86, too.

_________________
¯\(°_o)/¯ unlicense.org
Post 29 May 2008, 01:56
View user's profile Send private message Visit poster's website Reply with quote
BigVent



Joined: 28 May 2008
Posts: 24
BigVent
Thanks for the link bitRAKE! It looks like some great work... now if I only knew js and where to place everything Razz

Many Thanks!

~BigVent
Post 29 May 2008, 02:35
View user's profile Send private message Reply with quote
Kenneth



Joined: 16 Nov 2005
Posts: 38
Location: United States of America
Kenneth
r22 wrote:
You can check out the DDRAW example that comes with FASM for how to use com objects.

if you don't know the function pointer you can reverse it from the a compilation in c++.

-Write the code in C++
-Put a rarely used inline "__asm RDTSC" write before/after the line you want
-Have c++ compile the exe and open it up in a debugger
-By looking for RDTSC you'll be able to easily find the code C++ generated for say "oWb.Navigate(url)"


Or just use int 3.
Post 29 May 2008, 03:52
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Kenneth wrote:
r22 wrote:
You can check out the DDRAW example that comes with FASM for how to use com objects.

if you don't know the function pointer you can reverse it from the a compilation in c++.

-Write the code in C++
-Put a rarely used inline "__asm RDTSC" write before/after the line you want
-Have c++ compile the exe and open it up in a debugger
-By looking for RDTSC you'll be able to easily find the code C++ generated for say "oWb.Navigate(url)"


Or just use int 3.

Fine if you want to break in a debugger, but useless if you want to locate it in a disassembler, since INT3 is generally used for padding...

_________________
Image - carpe noctem
Post 29 May 2008, 12:21
View user's profile Send private message Visit poster's website Reply with quote
BigVent



Joined: 28 May 2008
Posts: 24
BigVent
f0dder wrote:
Kenneth wrote:
r22 wrote:
You can check out the DDRAW example that comes with FASM for how to use com objects.

if you don't know the function pointer you can reverse it from the a compilation in c++.

-Write the code in C++
-Put a rarely used inline "__asm RDTSC" write before/after the line you want
-Have c++ compile the exe and open it up in a debugger
-By looking for RDTSC you'll be able to easily find the code C++ generated for say "oWb.Navigate(url)"


Or just use int 3.

Fine if you want to break in a debugger, but useless if you want to locate it in a disassembler, since INT3 is generally used for padding...


So what would you guys suggest? I'm a newb and it would take forever for me to learn what I'm seeing on the debugger.

All I need to do is pass data to the current window.

_________________
~BigVent
Post 29 May 2008, 13:33
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3056
Location: vpcmipstrm
bitRAKE
BigVent wrote:
So what would you guys suggest? I'm a newb and it would take forever for me to learn what I'm seeing on the debugger.
If you start today, it would be forever minus a day.

_________________
¯\(°_o)/¯ unlicense.org
Post 29 May 2008, 13:49
View user's profile Send private message Visit poster's website Reply with quote
BigVent



Joined: 28 May 2008
Posts: 24
BigVent
bitRAKE wrote:
BigVent wrote:
So what would you guys suggest? I'm a newb and it would take forever for me to learn what I'm seeing on the debugger.
If you start today, it would be forever minus a day.



LMAO!!! Thanks for the encouragement!!! Laughing

To be quite honest.... I don't know where to start. I know a little VB & a little C++.

_________________
~BigVent
Post 29 May 2008, 14:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17718
Location: In your JS exploiting you and your system
revolution
BigVent wrote:
I don't know where to start.
Help files, internet searches, forum searches, etc. There are lots of options available to you for self study. No excuses these days when my website is available for free.
Post 29 May 2008, 14:52
View user's profile Send private message Visit poster's website Reply with quote
BigVent



Joined: 28 May 2008
Posts: 24
BigVent
Cannot pull up your www (gfgidude)

Thanks, I'll start doing searches & such.

~BigVent
Post 29 May 2008, 15:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17718
Location: In your JS exploiting you and your system
revolution
BigVent wrote:
Cannot pull up your www (gfgidude)

Thanks, I'll start doing searches & such.

~BigVent
Oh, damn, the site is down. Never mind, you can always use google to search for the things I mentioned.
Post 29 May 2008, 15:11
View user's profile Send private message Visit poster's website Reply with quote
BigVent



Joined: 28 May 2008
Posts: 24
BigVent
Thanks revolution. I'll give your site a try in a few days.

If you would... nudge me in the right direction with regards to passing data to focused windows?

Thanks,

~BigVent
Post 29 May 2008, 15:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17718
Location: In your JS exploiting you and your system
revolution
For the window in focus use keybd_event. But more standard methods are:
Code:
BroadcastSystemMessage
PostMessage
PostQuitMessage
PostThreadMessage
SendMessage
SendMessageCallback
SendMessageTimeout
SendNotifyMessage
SetMessageExtraInfo    
Post 29 May 2008, 15:37
View user's profile Send private message Visit poster's website Reply with quote
BigVent



Joined: 28 May 2008
Posts: 24
BigVent
Thank you! I'll try to build on this.

I've searched several times for literature regarding keybd_event. I just cannot quite seem to grasp this.

~BigVent
Post 29 May 2008, 15:52
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17718
Location: In your JS exploiting you and your system
revolution
BigVent wrote:
I've searched several times for literature regarding keybd_event. I just cannot quite seem to grasp this.
I found it in less than a second
keybd_event wrote:
The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver's interrupt handler calls the keybd_event function.

VOID keybd_event(

BYTE bVk, // virtual-key code
BYTE bScan, // hardware scan code
DWORD dwFlags, // flags specifying various function options
DWORD dwExtraInfo // additional data associated with keystroke
);


Parameters

bVk

Specifies a virtual-key code. The code must be a value in the range 1 to 254.

bScan

Specifies a hardware scan code for the key.

dwFlags

A set of flag bits that specify various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags:

Value Meaning
KEYEVENTF_EXTENDEDKEY If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).
KEYEVENTF_KEYUP If specified, the key is being released. If not specified, the key is being depressed.


dwExtraInfo

Specifies an additional 32-bit value associated with the key stroke.



Return Values

This function has no return value.

Remarks

Although keybd_event passes an OEM-dependent hardware scan code to Windows, applications should not use the scan code. Windows converts scan codes to virtual-key codes internally and clears the up/down bit in the scan code before passing it to applications.
An application can simulate a press of the PRINTSCREEN key in order to obtain a screen snapshot and save it to the Windows clipboard. To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT, and the bScan parameter set to 0 for a snapshot of the full screen or set bScan to 1 for a snapshot of the active window.
But I would recommend SendMessage as a better method. keybd_event relies on the active window not being taken out of focus (not a safe assumption in a multi-tasking OS).
Post 29 May 2008, 16:10
View user's profile Send private message Visit poster's website Reply with quote
BigVent



Joined: 28 May 2008
Posts: 24
BigVent
Awesome! Thanks.

The reason I wanted this is because this program & dev notes do exactly what I need my program to do.

http://m8software.com/developer/keysend/howtosend.htm

I've tried to sendkey in VB till my fingers bled... so that is why I switched to a lowlevel program lang.

Thanks again for your input & help. Hope I do not wear out my welcome.

~BigVent
Post 29 May 2008, 16:18
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
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


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.