Solved

Undocumented functions

Posted on 1998-05-15
20
308 Views
Last Modified: 2012-05-04
I saw mention of the VarPtr and StrPtr here. Anyone got a list of other hidden functions. Especially a function to tell vb where a variable is.
0
Comment
Question by:chris_a
  • 11
  • 8
20 Comments
 
LVL 3

Expert Comment

by:ESI
ID: 1450261
VarAdr, AddressOf, ProcPtr, aso
0
 
LVL 2

Author Comment

by:chris_a
ID: 1450262
ESI,

Are these guesses, none of these (except addressof which is not hidden) do anything in VB5.0 SP3. Is 'aso' a typo for also?

If they do something on your VB please post an small eg.
0
 
LVL 4

Expert Comment

by:zsi
ID: 1450263
chris,

ESI's answer is, in fact, a guess.  The only "undocumented" functions in VB5 are VarPtr, StrPtr, and ObjPtr.  AddressOf is a documented function.  A quick look through the VB documentation or help file illustrates this.

Please let me know if you have any other questions.

Hope this helps!
zsi
0
 
LVL 2

Author Comment

by:chris_a
ID: 1450264
How do you know there are no other functions, I will keep this open a bit longer and I will try out the ObjPtr function.

If the programmers of VB put in a function to get a pointer, then there may be functions to set the address of a function, maybe peek and poke work also.


0
 
LVL 4

Expert Comment

by:zsi
ID: 1450265
I know that there are no other functions for three reasons:

First, I have personally examined the exported function list of VB and VBA;

Second, there have been several articles on undocumented functions and these are the only ones that have been cited;

Third, I know one of the people who wrote VB.

You cannot set the address of a function (why would you want to?) and there is no such thing as peek and poke.  You can only work within the memory space of your own application as doing otherwise would cause a General Protection Fault, an intentional feature of the Windows operating system.

Is there any reason that you are tyring to relocate functions within VB?
0
 
LVL 4

Expert Comment

by:zsi
ID: 1450266
If your mind is really set on trying to move functions around, you can use AddressOf to determine the address of a function, and then try using the RtlMoveMemory API function in Kernel32.

I don't recommend it, tho.
0
 
LVL 4

Expert Comment

by:zsi
ID: 1450267
If your mind is really set on trying to move functions around, you can use AddressOf to determine the address of a function, and then try using the RtlMoveMemory API function in Kernel32.

I don't recommend it, tho.
0
 
LVL 4

Expert Comment

by:zsi
ID: 1450268
As I spend more time thinking about this (and taking a peek at your bio), I think I might have an idea of what you are looking for.

By any chance, are you considering trying virtual-functions or redirection in VB?  If so, I can tell you where to look for information on it.

zsi
0
 
LVL 2

Author Comment

by:chris_a
ID: 1450269
Well thats not quite right, there are other functions yet to be found, for instance what does the 'MacScript' function do?

I have no particular aim in this question, except I like to get under the hood a little.

I use the Move/Fill mem functions all over the place, they are reliable and fast (so long as you remember to use byval with strings). Most of the programming I do is where VB is the front end to C modules that pass binary structures around sockets and pipes.

Your missing the point a little trying to 'answer' this, i'll pass the point on to you later if you like.
0
 
LVL 4

Expert Comment

by:zsi
ID: 1450270
MacScript executes an AppleScript script.  The following information is from the Visual Basic Language Reference:

---------------------------------------------------------------------------------------
MacScript Function

Description

Executes an AppleScript script and returns a value returned by the script, if any.

Syntax

MacScript script

The script argument is a String expression. The String expression either can be a series of AppleScript commands or can specify the name of an AppleScript script or a script file.

Remarks

Multiline scripts can be created by embedding carriage-return characters (Chr(13)).

See Also

Chr Function.

Example

This example uses the MacScript function to open the Choose File dialog box (the Macintosh standard-file dialog). The full path of the file chosen by the user is returned. If appropriate, the path specification is preceded by the type of the file.

ThePath$ = Macscript("ChooseFile")
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Expert Comment

by:zsi
ID: 1450271
As far as Peeking and Poking, you can check out SoftCircuit's VB-ASM. http://www.beadsandbaubles.com/coolvb/download/vbasm.zip

It is a DLL that provides some of the low-level functionality that you are looking for.  In addition to reading/writing memory, it will allow you to get to some of the internal structures in VB, conduct bit-level operations, call interrupts, create controls and more.

The library is free.
0
 
LVL 2

Author Comment

by:chris_a
ID: 1450272
Any more suggestions anybody

(PS why is everyone so obsessed with the points, what can you do with them?)
0
 
LVL 4

Expert Comment

by:zsi
ID: 1450273
Well, for one thing, the points encourage people to spend time that would otherwise be spent on more enjoyable things (such as root canal) answering questions such as this one.

Additionally, the points assist us in our neverending pursuit for world domination, high-fashion, chicks seem to dig them, wealth, fame, power, the knowledge that we are helping people and the satisfaction of a job well done.

It also permits us to guage our progress and to assert our claims that, perhaps, we do know what we are talking about.

Mostly, however, the points are a reward for our volunteering our time.

Abe Froeman


0
 
LVL 2

Author Comment

by:chris_a
ID: 1450274
So thats what the points are for, shame they dont seem to transfer into points you can use to ask questions.

ZSI, the redirection and virtual functions sound good.

I would like to have the option to allocate a chunk of memory and put what I want where I want in it. When passing a struct to C I would like to be sure that the alignments are correct (like pragma pack in MSVC).

I know VB has collections now, but they are no match for a hand crafted ring buffer. I know this stuff is best done in C, but I hate typing all the spaghetti (or wading thru wizard code) before you can write any code.

0
 
LVL 4

Expert Comment

by:zsi
ID: 1450275
There are trade-offs with any language.  VB gives you the ability to develop an application at a very (abnormally) quick rate.  You sacrifice certain functionality for that ability, however.  For the most part, memory management is left to the VB run-time.

Using the Windows API, you do have some measure of control (see VirtualAlloc and HeapAlloc), but the API cannot really be considered part of VB.  

Another trade-off is control over the execution of your application.  Yes, you can now use the AddressOf operator to control your own application, but you are still limited in what you can do with it.  And you can forget about subclassing other applications using native VB.

Still, 98% of the time, a business application does not need this advanced functionality.  My experience has been that VB is a good language for business application development.

Given the mindset of most business users (I want it yesterday) who don't understand the issues involved in developing an application of any size, I am more than willing to trade flexibility for decreased development time.

However, I still use C for my graphical programming (though I am leaning towards Symantec's Native Java more and more).
0
 
LVL 2

Author Comment

by:chris_a
ID: 1450276
ZSI Post another answer, and i'll grade it a pass
0
 
LVL 4

Accepted Solution

by:
zsi earned 20 total points
ID: 1450277
The best way to determine what (if any) hidden functions might exist in VB, use the Object Browser to examine the run-time library.  Just remember to set the option to Show Hidden members.

zsi
0
 
LVL 2

Author Comment

by:chris_a
ID: 1450278
Never found the hidden fx option in browser before, I shall hack some more now, TA
0
 
LVL 4

Expert Comment

by:zsi
ID: 1450279
It's in the context menu.
0
 
LVL 2

Author Comment

by:chris_a
ID: 1450280
Found it, TA.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now