Pass function as a parameter

I’m not sure this is the best, but: function A{ Param([scriptblock]$FunctionToCall) Write-Host “I’m calling $($FunctionToCall.Invoke(4))” } function B($x){ Write-Output “Function B with $x” } Function C{ Param($x) Write-Output “Function C with $x” } PS C:\WINDOWS\system32> A -FunctionToCall $function:B I’m calling Function B with 4 PS C:\WINDOWS\system32> A -FunctionToCall $function:C I’m calling Function C with 4 … Read more

Weird MSC 8.0 error: “The value of ESP was not properly saved across a function call…”

This debug error means that the stack pointer register is not returned to its original value after the function call, i.e. that the number of pushes before the function call were not followed by the equal number of pops after the call. There are 2 reasons for this that I know (both with dynamically loaded … Read more

What are callee and caller saved registers?

Caller-saved registers (AKA volatile registers, or call-clobbered) are used to hold temporary quantities that need not be preserved across calls. For that reason, it is the caller’s responsibility to push these registers onto the stack or copy them somewhere else if it wants to restore this value after a procedure call. It’s normal to let … Read more

__cdecl or __stdcall on Windows?

I just did some real-world testing (compiling DLLs and applications with MSVC++ and MinGW, then mixing them). As it appears, I had better results with the cdecl calling convention. More specifically: the problem with stdcall is that MSVC++ mangles names in the DLL export table, even when using extern “C”. For example foo becomes _foo@4. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)