Author |
Message |
MrUnleaded Site Admin
Joined: 21 Sep 2002 Posts: 385 Location: California
|
Posted: Thu Oct 17, 2002 3:50 pm
Post subject: Control
|
|
Parent:
Optional Object Info
[vb:2vsjtqib]- Type tControl
- FlagImplement As Integer ' 0x00 (0d)
- EventCount As Integer ' 0x02 (2d)
- Flag2 As Long ' 0x04 (4d)
- aGUID As Long ' 0x08 (8d)
- Index As Integer ' 0x0C (12d)
- Const1 As Integer ' 0x0E (14d)
- Null1 As Long ' 0x10 (16d)
- Null2 As Long ' 0x14 (20d)
- aEventTable As Long ' 0x18 (24d)
- Flag3 As Byte ' 0x1C (28d)
- Const2 As Byte ' 0x1D (29d)
- Const3 As Integer ' 0x1E (30d)
- aName As Long ' 0x20 (32d)
- Index2 As Integer ' 0x24 (36d)
- Const1Copy As Integer ' 0x26 (38d)
- ' 0x28 (40d) <-- Structure Size
- End Type
[/vb:2vsjtqib]
Related Items:
Event Table
Last edited by MrUnleaded on Mon Aug 02, 2004 7:22 pm; edited 3 times in total
|
|
Back to top |
|
|
|
_aLfa_ Site Admin
Joined: 21 Sep 2002 Posts: 233 Location: Aveiro, Portugal
|
Posted: Fri Oct 18, 2002 6:29 pm
Post subject:
|
|
I've been busy with college stuff. (;
That's why I haven't been posting, but thank you MrU for taking me some work off.
Well, I've a little correction here:
values of flag1 = If not 40h (64) then it's an "Implements" instruction, like we use for subclassing (e.g. "Implements ISubclass" where ISubclass is a class module)
flag2 = I use the name "TableOffsets", dont ask me why d: _________________ One thing only I know, and that is that I know nothing. (Socrates)
|
|
Back to top |
|
|
|
MrUnleaded Site Admin
Joined: 21 Sep 2002 Posts: 385 Location: California
|
Posted: Sat Oct 19, 2002 5:47 pm
Post subject: ?
|
|
[="_aLfa_":2som6ji1]
Well, I've a little correction here:
values of flag1 = If not 40h (64) then it's an "Implements" instruction, like we use for subclassing (e.g. "Implements ISubclass" where ISubclass is a class module)
[/:2som6ji1]
can you elaborate a little??
|
|
Back to top |
|
|
|
_aLfa_ Site Admin
Joined: 21 Sep 2002 Posts: 233 Location: Aveiro, Portugal
|
Posted: Mon Oct 21, 2002 12:12 pm
Post subject:
|
|
Have you ever used the Implements instruction in VB?
It's something like this:
You make a class and put some events there, then in a form (for example) put in the general section "Implements <that class>";
compile the project and watch this flag (;
I hope you understood, for more info check my decompiler, or see VB help for the Implements instruction. (: _________________ One thing only I know, and that is that I know nothing. (Socrates)
|
|
Back to top |
|
|
|
Anonymous New User
Joined: 10 Feb 2008 Posts: 0
|
Posted: Mon Oct 21, 2002 1:03 pm
Post subject:
|
|
Implements is a fundamental part of OOP. The Implements keyword was MS's attempt at making VB a true OOP. But it failed because its still missing some stuff. Nevertheless, Implementing a class basically means stealing all the methods et al from a class and using it as methods of the class that implemented it. Say you have a base class clsMoney with methods Buy() and Sell(). You could have two classes clsFish and clsShares that both implement clsMoney
|
|
Back to top |
|
|
|
MrUnleaded Site Admin
Joined: 21 Sep 2002 Posts: 385 Location: California
|
Posted: Tue Oct 22, 2002 1:39 am
Post subject: but whats it for??
|
|
[="_aLfa_":3mxqkkz4]Have you ever used the Implements instruction in VB?
It's something like this:
You make a class and put some events there, then in a form (for example) put in the general section "Implements <that class>";
compile the project and watch this flag (;
I hope you understood, for more info check my decompiler, or see VB help for the Implements instruction. (:[/:3mxqkkz4]
I understand how to Implement Classes and why....what i dont understand is how "Implements" pertains to this structure...
|
|
Back to top |
|
|
|
_aLfa_ Site Admin
Joined: 21 Sep 2002 Posts: 233 Location: Aveiro, Portugal
|
Posted: Tue Oct 22, 2002 6:49 pm
Post subject:
|
|
Try to make an executable with an Implements instruction and see what happens to that flag (;
Maybe it's easier for both _________________ One thing only I know, and that is that I know nothing. (Socrates)
|
|
Back to top |
|
|
|
_aLfa_ Site Admin
Joined: 21 Sep 2002 Posts: 233 Location: Aveiro, Portugal
|
Posted: Sun Aug 01, 2004 11:32 am
Post subject:
|
|
I've corrected the links and changed Flag1 to FlagImplement to reflect the meaning (so far) of this flag.
If someone doens't agree, you are free to argue _________________ One thing only I know, and that is that I know nothing. (Socrates)
|
|
Back to top |
|
|
|
MrUnleaded Site Admin
Joined: 21 Sep 2002 Posts: 385 Location: California
|
Posted: Mon Aug 02, 2004 7:26 pm
Post subject:
|
|
i dont remember for sure but in vb6 is there other modifiers like Implements...suchas Inherits, OverLoads,shadows etc like in other langauges? we might want to try it out and see if the "ImplementsFlag" also represents other bit-properties of the class _________________ -MrU
|
|
Back to top |
|
|
|
_aLfa_ Site Admin
Joined: 21 Sep 2002 Posts: 233 Location: Aveiro, Portugal
|
Posted: Mon Aug 02, 2004 7:30 pm
Post subject:
|
|
VB6 isn't that OOP directed, all it has is Implement _________________ One thing only I know, and that is that I know nothing. (Socrates)
|
|
Back to top |
|
|
|
MrUnleaded Site Admin
Joined: 21 Sep 2002 Posts: 385 Location: California
|
Posted: Mon Aug 02, 2004 7:34 pm
Post subject:
|
|
i guess thats why that was all i could remember...8 bits to represent 1....what a waste _________________ -MrU
|
|
Back to top |
|
|
|
Welf Wiest New User
Joined: 15 Dec 2007 Posts: 4
|
Posted: Mon Dec 17, 2007 10:14 am
Post subject:
|
|
in my experience Flag2 is the offset from the this pointer of the complete object to the this pointer of the control (site), implemented interface or base form/designer
|
|
Back to top |
|
|
|
_aLfa_ Site Admin
Joined: 21 Sep 2002 Posts: 233 Location: Aveiro, Portugal
|
Posted: Sat Feb 16, 2008 10:25 am
Post subject:
|
|
[="Welf Wiest":2gb0gswn]in my experience Flag2 is the offset from the this pointer of the complete object to the this pointer of the control (site), implemented interface or base form/designer[/:2gb0gswn]
Can you please elaborate?
And can anyone confirm? _________________ One thing only I know, and that is that I know nothing. (Socrates)
|
|
Back to top |
|
|
|
Welf Wiest New User
Joined: 15 Dec 2007 Posts: 4
|
Posted: Sat Feb 16, 2008 7:20 pm
Post subject: Re: Control
|
|
Hello,
it's a bit difficult.
We are joining at the moment vb6 and java code together in code.
So I decoded the components of a class or form.
The base Item for a simple class is "Class" or "Form". Especially a form can also have controls. All these item have an offset relativ to the main object.
I needed a hook to the class_initialize Event to initialize native Code (in the java manner) that is merged to a basic class.
So class_initialize has a this Pointer that internal is IUnknown and in real it's Virtual Table (VTBL) are the inner members of the struct EventTable.
From this I can Obtain the ObjectInfo and the offset to the main Object
Sorry I have for this only some C++ code (but it's workin stable and well in producttion code)
HRESULT __stdcall TIClass::_Thunk_Class_Initialize(IUnknown *pThis)
{ USES_ERRORINFO;
//pThis points to begin of Instanzvariable/Controlsite
//Objektinstanz: pThis contains Flag in least significant Bit, daher ausmaskieren (Bit0 scheint Public Item zu markieren)
void *pThis_ = reinterpret_cast<void*>(reinterpret_cast<DWORD>(pThis) & 0xFFFFFFFE);
void *pVTBL = *reinterpret_cast<void **>(pThis_);
EventTable &rEventTable = *MakePtr<EventTable *>(pVTBL, -offsetof(EventTable, aQueryInterface));
_ObjectInstance &rInstance = *MakePtr<_ObjectInstance *>(pThis_, - rEventTable.aControl->dwOffsetThis);
CComPtr2<TIClass> ptrMe;
ptrMe = TIClass::_from_instance_impl(rInstance);
if(!ptrMe)
HR_CALL_ERRORINFO(getOrCreateTypeInfo(*rInstance.getObjectInfo(), ptrMe));
HR_CALL(ptrMe->_onInitInstance(rInstance));
//call base method, if defines
if(SUCCEEDED(hr) && (*ptrMe).m_ptrClass_Initialize_base != 0)
HR_ASSIGN(reinterpret_cast<HRESULT (__stdcall *)(void *)>((*ptrMe).m_ptrClass_Initialize_base)(pThis));
HR_FINISH_ERRORINFO;
return hr;
}
Sorry there some helper functions
I think most intersting, is _ObjectInstance.
It is the generic struct of a VB Object Instance, commonly used for alls Items with OptionalObjectInfo (class,form, designer)
I want to translate it to ab VB6 Struct in the format used on this board
//binärkompatibel zu ObjectInstance, für Implementationszwecke
class _ObjectInstance : public IDispatch
{ public:
typedef _ObjectInstance _my_type;
//aus VBA-Default-Interface wandeln (kein Check)
static _my_type &_from_default_interface(IDispatch *oVBA) { return *static_cast<_my_type*>(oVBA); }
ObjectInfo *getObjectInfo() const { return reinterpret_cast<ObjectInfo *>(_pVTBL_DefaultInterface()[-1]); }
USHORT _structSize() const { return getObjectInfo()->aObjectHeader->aPublicBytes[1]; }
//VTBL des Hauptinterfaces, an Index [-1] liegt Zeiger auf ObjectInfo / Klasseninformation
void **_pVTBL_DefaultInterface() const { return *reinterpret_cast<void** const *>(this); }
IUnknown *_Unknown_Private() { return reinterpret_cast<IUnknown*>(&m_pVTBL_Unknown_Private); }
void **_pVTBL_Unknown_Private() const { return m_pVTBL_Unknown_Private; }
DWORD _RefCount() const { return m_nRefCount; }
DWORD &_RefCount() { return m_nRefCount; }
static unsigned _OFFSET_VTBL_PRIVATE_UNKNOWN()
{ return offsetof(_ObjectInstance, m_pVTBL_Unknown_Private); };
static unsigned _OFFSET_TAG()
{ return offsetof(_ObjectInstance, m_tag); };
static unsigned _OFFSET_CONTROLLING_UNKNOWN()
{ return offsetof(_ObjectInstance, m_pControllingUnknown); };
IUnknown *&_ControllingUnknown() { return m_pControllingUnknown; }
DWORD &_tag() { return m_tag; }
private:
_ObjectInstance() {} //keine Konstruktion
public:
_ObjectInstance *m_pNextInstance; //Verweis auf nächste Instanz
IUnknown *m_pControllingUnknown; //falls aggregiert: Zeiger auf Controlling Unknown, nicht aggregiert: Zeiger in diese Struktur auf Label_Unknown_Private
void *m_p1;
void *m_p2;
DWORD m_dw0[2];
//Marke Label_Unknown_Private
void **m_pVTBL_Unknown_Private; //für BASIC_CLASS_XXX, liegt in Runtime Dll, privates IUnknown, steuert QueryInterface, AddRef, Release, zuständig für Aggregation
DWORD m_nRefCount; //Referenzzähler dieses Objekts
DWORD m_dw2[3];
DWORD m_tag; //Test !!!!!
};
|
|
Back to top |
|
|
|
|
|