command function replacement

command function replacement

Anonymous
Not applicable
594 Views
5 Replies
Message 1 of 6

command function replacement

Anonymous
Not applicable
I was going through arx reference and found, that if I use the
lookupGlobalCmd function of the AcEdCommandStack class, I can obtain the
pointer to the AcEdCommand object that corresponds to the string i passed to
the function. From there I can go on extracting the target function address
and such. There does not seem to be a way of temporarily swapping the
address field for a different address (custom function that will on arx
unload restore the original address).

So, how should I go about patching into a currently existing command?
0 Likes
595 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
If the output AcEdCommand* is typed as 'const' then it was done
so with the specific intent that it not be modified.


"Alex Parshikov" wrote in message
news:[email protected]...
> I was going through arx reference and found, that if I use the
> lookupGlobalCmd function of the AcEdCommandStack class, I can obtain the
> pointer to the AcEdCommand object that corresponds to the string i passed
to
> the function. From there I can go on extracting the target function
address
> and such. There does not seem to be a way of temporarily swapping the
> address field for a different address (custom function that will on arx
> unload restore the original address).
>
> So, how should I go about patching into a currently existing command?
>
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
Well, does the obtained function address remain valid while the module it
originates from is loaded independently on whether the command is removed
from the stack or not? Would it be possible to retrieve the address and
save flags and all the other good stuff from the obtained AcEdCommand*
object and store them and then use them when my ARX unloads to restore the
original functionality (add commands again)?


"Tony Tanzillo" wrote in message
news:[email protected]...
> If the output AcEdCommand* is typed as 'const' then it was done
> so with the specific intent that it not be modified.
>
>
> "Alex Parshikov" wrote in message
> news:[email protected]...
> > I was going through arx reference and found, that if I use the
> > lookupGlobalCmd function of the AcEdCommandStack class, I can obtain the
> > pointer to the AcEdCommand object that corresponds to the string i
passed
> to
> > the function. From there I can go on extracting the target function
> address
> > and such. There does not seem to be a way of temporarily swapping the
> > address field for a different address (custom function that will on arx
> > unload restore the original address).
> >
> > So, how should I go about patching into a currently existing command?
> >
> >
>
>
0 Likes
Message 4 of 6

Anonymous
Not applicable
Why not just use addCommand() when you want to restore the
original functionality ?

"Alex Parshikov" wrote in message
news:[email protected]...
> Well, does the obtained function address remain valid while the module it
> originates from is loaded independently on whether the command is removed
> from the stack or not? Would it be possible to retrieve the address and
> save flags and all the other good stuff from the obtained AcEdCommand*
> object and store them and then use them when my ARX unloads to restore the
> original functionality (add commands again)?
>
>
> "Tony Tanzillo" wrote in message
> news:[email protected]...
> > If the output AcEdCommand* is typed as 'const' then it was done
> > so with the specific intent that it not be modified.
> >
> >
> > "Alex Parshikov" wrote in message
> > news:[email protected]...
> > > I was going through arx reference and found, that if I use the
> > > lookupGlobalCmd function of the AcEdCommandStack class, I can obtain
the
> > > pointer to the AcEdCommand object that corresponds to the string i
> passed
> > to
> > > the function. From there I can go on extracting the target function
> > address
> > > and such. There does not seem to be a way of temporarily swapping the
> > > address field for a different address (custom function that will on
arx
> > > unload restore the original address).
> > >
> > > So, how should I go about patching into a currently existing command?
> > >
> > >
> >
> >
>
>
0 Likes
Message 5 of 6

Anonymous
Not applicable
That's exactly what I meant. I wanted to remove command after having stored
it's vitals and then add my command in its place and if my command detects
that the selection set it gets was meant for the previous command, it will
just call function address. When my arx goes into the unloadApp section, it
would remove its own group and add the old command again. That's the idea.
What I was wondering about, is whether the function pointer remains valid
independently of whether the command that referred to it is removed from the
stack or not.

It's a question of volatility.

Thank you.
Sincerely, Alex.

"Tony Tanzillo" wrote in message
news:[email protected]...
> Why not just use addCommand() when you want to restore the
> original functionality ?
>
> "Alex Parshikov" wrote in message
> news:[email protected]...
> > Well, does the obtained function address remain valid while the module
it
> > originates from is loaded independently on whether the command is
removed
> > from the stack or not? Would it be possible to retrieve the address and
> > save flags and all the other good stuff from the obtained AcEdCommand*
> > object and store them and then use them when my ARX unloads to restore
the
> > original functionality (add commands again)?
> >
> >
> > "Tony Tanzillo" wrote in
message
> > news:[email protected]...
> > > If the output AcEdCommand* is typed as 'const' then it was done
> > > so with the specific intent that it not be modified.
> > >
> > >
> > > "Alex Parshikov" wrote in message
> > > news:[email protected]...
> > > > I was going through arx reference and found, that if I use the
> > > > lookupGlobalCmd function of the AcEdCommandStack class, I can obtain
> the
> > > > pointer to the AcEdCommand object that corresponds to the string i
> > passed
> > > to
> > > > the function. From there I can go on extracting the target function
> > > address
> > > > and such. There does not seem to be a way of temporarily swapping
the
> > > > address field for a different address (custom function that will on
> arx
> > > > unload restore the original address).
> > > >
> > > > So, how should I go about patching into a currently existing
command?
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 6 of 6

Anonymous
Not applicable
I really don't know whether it is possible, but it
certainly would be dangerous, because the other ARX
application could be unloaded, and in that case the
function handler pointer would become invalid.

Have you looked at AcEdCommandStack::popGroupToTop ?

"Alex Parshikov" wrote in message
news:[email protected]...
> That's exactly what I meant. I wanted to remove command after having
stored
> it's vitals and then add my command in its place and if my command detects
> that the selection set it gets was meant for the previous command, it will
> just call function address. When my arx goes into the unloadApp section,
it
> would remove its own group and add the old command again. That's the
idea.
> What I was wondering about, is whether the function pointer remains valid
> independently of whether the command that referred to it is removed from
the
> stack or not.
>
> It's a question of volatility.
>
> Thank you.
> Sincerely, Alex.
>
> "Tony Tanzillo" wrote in message
> news:[email protected]...
> > Why not just use addCommand() when you want to restore the
> > original functionality ?
> >
> > "Alex Parshikov" wrote in message
> > news:[email protected]...
> > > Well, does the obtained function address remain valid while the module
> it
> > > originates from is loaded independently on whether the command is
> removed
> > > from the stack or not? Would it be possible to retrieve the address
and
> > > save flags and all the other good stuff from the obtained AcEdCommand*
> > > object and store them and then use them when my ARX unloads to restore
> the
> > > original functionality (add commands again)?
> > >
> > >
> > > "Tony Tanzillo" wrote in
> message
> > > news:[email protected]...
> > > > If the output AcEdCommand* is typed as 'const' then it was done
> > > > so with the specific intent that it not be modified.
> > > >
> > > >
> > > > "Alex Parshikov" wrote in message
> > > > news:[email protected]...
> > > > > I was going through arx reference and found, that if I use the
> > > > > lookupGlobalCmd function of the AcEdCommandStack class, I can
obtain
> > the
> > > > > pointer to the AcEdCommand object that corresponds to the string i
> > > passed
> > > > to
> > > > > the function. From there I can go on extracting the target
function
> > > > address
> > > > > and such. There does not seem to be a way of temporarily swapping
> the
> > > > > address field for a different address (custom function that will
on
> > arx
> > > > > unload restore the original address).
> > > > >
> > > > > So, how should I go about patching into a currently existing
> command?
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes