I am using the SDK for SELECTSeries 4 (111) against the explorer version 559. When my Action Hook returns AAHOOK_SUCCESS, I get a ProjectWise error [58002] - "Invalid argument passed to a dmsapi function." this is after it has left the hook function. This code has worked for several Select Series versiosn with no changes. I understood that for an Action Hook, AAHOOK_SUCCESS did not call next in chain. Is that still the case?
I think the cause may be related to not dealing with pResult in your code. According to the help (from SS3 docs) for "Hook Function Return Values", for AAHOOK_SUCCESS:
action hook: Function's action was performed by the action hook. The caller should skip its default action and call aaApi_CallHookChain() function for post hooks, if it is providing them. In this case the caller should return the value of the AARESULT buffer pointed by pResult as the return value.
Just a hunch, but it may be that there is some built in post hook that was added in SS4 that caused this to rear up on you now.
My gut reaction as well (set the value for pResult).
Also, since you are using the static buffer in your hook function, make sure that anything else that might get called along the way isn't changing the contents of the static buffer (or more likey, you are changing it and the other function isn't expecting it to change).. As a general design rule, I would suggest using a dynamic buffer whenever you can't control what might be using the static buffer(s). A bit more work, but more robust.
Dan, what should the pResult be set to in order to keep any other hooks in chain from exectuing? I would assume 0, but would like to be sure. I got the same error regardless of setting *pResult = 1 or *pResult = 0.
Dean,
From the best of what I can tell, most code will simply return AAHOOK_ERROR to prevent the hook chain from further being called. pResult can be used to provide a long value error code to the next in chain caller as input, so your hook code could react to a specific condition previouly set and could not reliably be passed between hook callees simply by using aaApi_GetLastError/aaApi_SetLastError. If pResult had a value passed to it, your hook could (possibly) react to that condition and clear the error code; in essence stating your code had handled that error:
if (pResult)
{
*pResult = 0L;
}
HTH
Bob
Answer Verified By: Dean Lyon
Thank you Bob. I changed all of my code to use HAADMSBUFFER local buffers and freed them appropriatly and I am still getting the error after the hook returns. I will return AAHOOK_ERROR to see if it achieves the functionality I am looking for because I am replacing the functionality, not adding to the functionality of COPY in this section of code
Changing my AAHOOK_SUCCESS to AAHOOK_ERROR stopped the next in chain from executing and erroring. I also set the pReturn to 0 in these cases as well. I had done so on previous attermps, but it alone had not stopped the error from occurring on the Bentley hook in the chain.