|
VB Decompiler Hosted by TheAutomaters.com
|
Author |
Message |
stickleprojects New User
Joined: 14 Mar 2008 Posts: 4
|
Posted: Fri Mar 14, 2008 10:16 am
Post subject: Scripted execution of VB
|
|
Hi guys,
I'm writing a testing app to run my VB application and click the buttons and so forth.
The only stumbling block i have found that I cannot do with Win API is reading the value off labels (no hwnd) on forms and I've tried Heapwalk (it crashes), Heap32Next (it's slow) then I spotted your forum.
It looks like the disassemblers have this sort of information (ie. the values of the controls on a form, etc.) but I want to do this at runtime.
Any pointers or thoughts would be very much appreciated.
Thanks in advance.
Kieron
PS. I did get hold of some C code that mimics heapwalk using RtlCreateQueryDebugBuffer, but cannot convert it to VB or c#
|
|
Back to top |
|
|
|
_aLfa_ Site Admin
Joined: 21 Sep 2002 Posts: 233 Location: Aveiro, Portugal
|
Posted: Sat Mar 15, 2008 12:30 am
Post subject: Re: Scripted execution of VB
|
|
I suppose you are talking about Native code "emulation"?
I'd like you to elaborate a little bit more, maybe with a small sample or something that would help me/us see what you really need?
I know how VB gets to object properties either in p-code or n-code, but I can't really understand what you really need, since you can already do that for some properties. _________________ One thing only I know, and that is that I know nothing. (Socrates)
|
|
Back to top |
|
|
|
stickleprojects New User
Joined: 14 Mar 2008 Posts: 4
|
Posted: Mon Mar 17, 2008 7:44 am
Post subject: Re: Scripted execution of VB
|
|
Hi,
Thanks for the response.
What i'm trying to do is write code to enter text in textboxes and click the buttons/menu items, etc and to check the results.
For example:
My core application stores names and address, the user is prompted to log in, enter pwd, etc.
I am writing a seperate application to:
Launch the core app
When the login screen appears
Enter "Stickle" into the user textbox (txtUserName), and "Projects" into the pwd (txtPWD), then click the cmdOk button.
Wait for 30 seconds for the application (frmMain) to appear, if this fails, to write "Failed" into a text file.
The core application is writted in VB6, I have control over the source code and can recompile it into either pcode or native.
This is for automating the testing and recording the results - it's a fairly large application and I will evolve various other scripts from login to change pwd, to add customer, etc.. you get the idea?
I have already tried adding code to my application to do this but my testing needs to be outside of the main app thread, and none of the threading i've tried actually does this (startthread or timer), and my C++ is ok, but my windows c++ is too light for com and stuff so I can't use c++ to do this.
My research so far has found:
Given a process id, i can get the active window.
given an active window (hwnd), I can use API to retrieve the hwnd of the child windows, then use WM_GetText and SendMessage to update the text in the textboxes and click the buttons.
This is ok, but I need to use WM_GetText to identify the each textbox and can't use the control name from VB, and labels don't appear in the enumchildwindows list.
so,
more research found that the control stuff is placed on the Heap for the application, and by interrogating the heap, I can get the control properties and names at runtime
I've attached all the stuff I have so far (this has been collated from an article in Experts-Exchange and various other web-searches)
The routine enumvbcontrols is the basis for all of my research and it does actually work and get's me the control names and runtime properties of a form.
However, it takes minutes to run against a large-ish application per form!!! (I think something to do with the number of controls and menus and stuff)
Google came up with a number of people having the same problem - it stems from Heap32Next being slow, and I found someone who had a solution (http://securityxploded.com/enumheaps.php) but I can't interpet his code into VB or c#.
I have tried the HeapWalk API - which also works and gets me the heap details required (see doHeapWalk in my code) but it crashes when running against my application with memory exception.
I know this is a long post, but wanted to let you know everything i've tried.
I'd be grateful if you have any advice for me - or a completely different solution - i don't mind.
Thanks
Kieron
|
|
Back to top |
|
|
|
_aLfa_ Site Admin
Joined: 21 Sep 2002 Posts: 233 Location: Aveiro, Portugal
|
Posted: Tue Mar 18, 2008 9:57 am
Post subject: Re: Scripted execution of VB
|
|
Well, I don't understand why do you need to know the Labels content or name for that matter, but I'll have a look at it at the weekend. That heapwalk method seems very translatable, but you might have to use pointers though (; _________________ One thing only I know, and that is that I know nothing. (Socrates)
|
|
Back to top |
|
|
|
stickleprojects New User
Joined: 14 Mar 2008 Posts: 4
|
Posted: Tue Mar 18, 2008 10:04 am
Post subject: Re: Scripted execution of VB
|
|
Thanks so much ! I've been looking at this for ages now
The reason i need the label is (for example)..
The test script adds a new product and the application shows a messagebox "Product 123456 added" and the form now shows the product id in a label on the screen. As the user cannot change it, this is displayed in a label rather than a groovy textbox.
I'm off for a few weeks so please bear with me if I don't respond immediately.
Thanks again
|
|
Back to top |
|
|
|
stickleprojects New User
Joined: 14 Mar 2008 Posts: 4
|
Posted: Mon Apr 07, 2008 7:29 am
Post subject: Re: Scripted execution of VB
|
|
Hi
I was wondering if you got anywhere with this heapwalk stuff? As I'm back from hols now
Thanks
|
|
Back to top |
|
|
|
|
|
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|