How to interpret the "code" passed to CallNextHookEx - winapi

I'm wondering which values the 2nd parameter (code) of the CallNextHookEx function may take, Unfortunately the MSDN documentation is quite vague about that parameter:
The hook code passed to the current hook procedure. The next hook procedure uses this code to determine how to process the hook information.
I assume the values the code parameter may take are defined somwhere among the "Hook Structures"
How can I interpret the values correctly?
Am I allowed to manipulate that value or am I expected to just pass the code as I originally received it?

The value is explained in the documentation of the hook procedure.
e.g. GetMsgProc:
Specifies whether the hook procedure must process the message. If code
is HC_ACTION, the hook procedure must process the message. If code is
less than zero, the hook procedure must pass the message to the
CallNextHookEx function without further processing and should return
the value returned by CallNextHookEx.
The documentation for the code parameter is similar to the above for most (all?) procedures.
That means that you should process only calls for which code is equal to HC_ACTION. Otherwise, you should just call CallNextHookEx with original parameters, and return the result.

Related

Power Automate: Run a child flow by GUID

I'm trying to call a child flow from a Power Automate flow by it's guid (by using an Expression in the Child Flow dropdown), instead of hardcoding the child flow selection.
However, whenever I try to save the parent flow, I get the following error:
Request to XRM API failed with error: 'Message: Flow client error returned with status code "BadRequest" and details "{"error":{"code":"ChildFlowIdNotValid","message":"The workflow id '[[expression]]' is not a valid child flow id. The id must be a valid GUID."}}". Code: 0x80060467
I tried various expression, even simple stuff like #guid() (which is definitely a valid guid), but to no avail.
It seems like the platform performs a "compile time" check on the value, which makes using any dynamic value impossible.
Any ideas?
I think that Run Child flow action is designed to be more interactive than programmable, unfortunately. Interacting with the Run Child Flow action calls an API, and the response is used to modify the action definition. Whatever is the "custom value" expression - it is not evaluated, but instead read as string, and used in a call to retrieve the sample header. That sample is then used to re-format the Run Child Flow action to show the appropriate headers.
Having an undetermined target would mean the call body is not defined, which could be a problem. Interestingly, it does pop a spot for a body when initially trying to look for a hard-coded GUID.
You can see the after-effect of this behavior in how even hardcoded GUIDs get replaced with the flow names once saved/reopened.
As a workaround, I stack Run Child flows in a Switch action checking an expression result. I.e.:
Switch workaround
Side note - GUID() in Azure Logic Apps (and powerautomate) does not format an arbitrary string as GUID.

When should one pass data to a template and when call a function?

When having passed functions to a template via Funcs, these can be called directly in the template. Data can also be passed via Execute.
So far, I've passed general data to the template and only called functions when for example I had to format a Time or some String. See below.
Combining both:
{{range .AssignedTickets}}
<p>FormatDate .Date</p>
<p>{{FormatEditorName .EditorID}}</p>
{{end}}
Mostly using functions, assuming only EditorID was passed as data:
{{$assignedTickets := GetAssignedTickets .EditorID}}
{{range $assignedTickets}}
<p>FormatDate .Date</p>
<p>{{FormatEditorName .EditorID}}</p>
{{end}}
When should I pass data and when should I call a function? Are there performance reasons as to avoid one of these (I'd guess I should avoid calling functions inside the template?)
The big advantage of data passed in is: It is constant. If you call a functions twice (e.g. current date) it might return two different values (e.g. if one call happened right before midnight and the other after midnight).
Also: Functions which may fail are best handled outside the template.
Calling formatting functions (display logic): yes as these functions are deterministic and do not fail.
Calling business logic: No.

How do I call a c function on each occurrence in LoadRunner?

So there is this HUGE JSON that I am loading from a file and than I run it through lr_eval_string and save it to a parameter. This parameter is later used as a body in one of my REST calls.
I use lr_eval_string to dynamically replace different values in that JSON.
Now here is the problem, one of the values that I replace is unique and generated by a c function. This value appears numerous times in that JSON and needs to be unique each time, yet I am only able to call that c function once at the beginning of the action. The result is that all values end up being equal...
So my question is: how can I call my function each time this unique value appears? I am talking about functionality similar to "Update value on: Each occurrence" that is available on the Parameters section.
I see an option called "User Defined Function" in parameters which I guess could do what I am looking for yet I couldn't find any good tutorial on how to actually use this functionality. Is user defined action the way to go, is there any other solution?
Any help would be highly appreciated! :)

matlab GUI pushbutton call back event handling [duplicate]

I'm trying to programmatically create a click event in MATLAB that will mimic the user clicking on a GUI object. The callback function for the object is a subfunction, so I can't call it directly. However, I am able to get the callback property from the object, which ends up being a 3-by-1 cell array with the following contents:
#uiBlockFn/callback_til [ 188.0011] [1x1 struct]
How can I invoke this callback function in code such that it mimics what would happen when a user clicks the GUI object?
Let's say you have a graphics object with handle hObject, and you got the callback for the object like so:
callbackCell = get(hObject,'Callback');
As you mentioned, the cell array callbackCell that you get ends up being a 3 element cell array with a function handle in the first cell and other data in the other two cells. When the callback for an object is defined as a cell array (like it is in your case), the callback function handle (or string name) is stored in the first cell and additional input arguments you want passed to the callback function are in the remaining cells.
However, when this callback is invoked when the object is activated, there will actually be 2 additional arguments automatically inserted by MATLAB at the beginning of the input argument list. These are:
hObject: The handle to the object whose callback is now being called.
eventData: A structure of data related to the user-activated event, which is often just the empty matrix [] (except in a few cases).
So, if you want to mimic the action of the object being activated by the user, you would want to invoke your callback function as follows (assuming there is no event data needed):
callbackCell{1}(hObject,[],callbackCell{2:end});
This is what the built-in hgfeval function is for:
http://undocumentedmatlab.com/blog/hgfeval/

Using Moq how do you verify function was called without specifying parameters?

Sometimes I want to just verify that a function was called rather than have to test the function was called with specific parameters.
The reason for this that there is a complex object being passed in as a parameter, but the later call inside that function makes a database fetch. Since this will be mocked, it will just have nulls & 0s.
I just want to verify the call without testing against the passed in parameters. How can I do this?
You may find the following blog post useful. Quote:
myMockedClass.Verify(
x => x.Connect(It.IsAny<MyArgumentType>())
);

Resources