trampolines

How to create a trampoline function for hook

和自甴很熟 提交于 2020-01-01 08:18:14
问题 I'm interested in hooking and I decided to see if I could hook some functions. I wasn't interested in using a library like detours because I want to have the experience of doing it on my own. With some sources I found on the internet, I was able to create the code below. It's basic, but it works alright. However when hooking functions that are called by multiple threads it proves to be extremely unstable. If two calls are made at nearly the same time, it'll crash. After some research I think

How to create a trampoline function for hook

独自空忆成欢 提交于 2020-01-01 08:18:06
问题 I'm interested in hooking and I decided to see if I could hook some functions. I wasn't interested in using a library like detours because I want to have the experience of doing it on my own. With some sources I found on the internet, I was able to create the code below. It's basic, but it works alright. However when hooking functions that are called by multiple threads it proves to be extremely unstable. If two calls are made at nearly the same time, it'll crash. After some research I think

Trampolining scalaz' Monad.whileM_ to prevent stack overflow

假装没事ソ 提交于 2019-12-24 11:25:58
问题 I'm using scalaz' Monad.whileM_ to implement a while loop in a functional way as follows: object Main { import scalaz._ import Scalaz._ import scala.language.higherKinds case class IState(s: Int) type IStateT[A] = StateT[Id, IState, A] type MTransT[S[_], A] = EitherT[S, String, A] type MTrans[A] = MTransT[IStateT, A] def eval(k: Int): MTrans[Int] = { for { state <- get[IState].liftM[MTransT] _ <- put(state.copy(s = (state.s + 1) % k)).liftM[MTransT] } yield (k + 1) } def evalCond(): MTrans

What is the standard way to optimise mutual recursion in F#/Scala?

北城余情 提交于 2019-12-21 04:17:15
问题 These languages do not support mutually recursive functions optimization 'natively', so I guess it must be trampoline or.. heh.. rewriting as a loop) Do I miss something? UPDATE: It seems that I did lie about FSharp, but I just didn't see an example of mutual tail-calls while googling 回答1: First of all, F# supports mutually recursive functions natively, because it can benefit from the tailcall instruction that's available in the .NET IL (MSDN). However, this is a bit tricky and may not work

MonoTouch SIGABRT “Ran out of trampolines of type 2” error

∥☆過路亽.° 提交于 2019-12-11 01:34:43
问题 I get a SIGABRT / ran out of trampolines error when running my MonoTouch app on a native device (iPad). This happens pretty early in my app - I'm constructing a section using MonoTouch.Dialog. ItemTypeRadio = new RootElement ("Type", new RadioGroup (0)) { new Section () { from it in App.ViewModel.ItemTypes select (Element) new RadioElement (it.Name) } }; Is there a compiler setting for increasing the number of trampolines? How do I profile this and find out why my app is running out? Ran out

How do I jump out of a function in Lisp?

蹲街弑〆低调 提交于 2019-12-10 17:47:00
问题 Is it possible in (Common) Lisp to jump to another function instead of call another? I mean, that the current function is broken and another is called, without jumping back through thousands of functions, as if I'd decide myself if tail call optimization is done, even if it is not the tail. I'm not sure if "(return-from fn x)" does, what I want. Example: (defun fn (x) (when x (princ x) (jump 'fn (cdr x))) (rest)) 'jump' should be like calling the following function without saving the position

How to make a Hook and Trampoline function in one for WinAPI hooking

有些话、适合烂在心里 提交于 2019-12-10 10:49:00
问题 So I have been learning about the concept of hooking and using trampolines in order to bypass/execute data in a WinAPI hook function (In a different executable file, using DLL injection). So far I know how to make it (the trampoline and hook) using a mixture of assembly and C, but I can't seem to do it with just using C, as I seem to be missing something. I'd appreciate if someone could tell me what I'm doing wrong and how to fix it up. Right now my code: #include <Windows.h> unsigned char*

How to make a Hook and Trampoline function in one for WinAPI hooking

只愿长相守 提交于 2019-12-06 07:26:59
So I have been learning about the concept of hooking and using trampolines in order to bypass/execute data in a WinAPI hook function (In a different executable file, using DLL injection). So far I know how to make it (the trampoline and hook) using a mixture of assembly and C, but I can't seem to do it with just using C, as I seem to be missing something. I'd appreciate if someone could tell me what I'm doing wrong and how to fix it up. Right now my code: #include <Windows.h> unsigned char* address = 0; __declspec(naked) int __stdcall MessageBoxAHookTrampoline(HWND Window, char* Message, char*

MonoDevelop settings to fix “ran out of trampolines type 2” error

自古美人都是妖i 提交于 2019-12-05 18:35:30
问题 we are developing an iOS app. When we tested the app on PC, everything works well but when we ran it on a iPad/iPhone4 we frequently receive the "Ran out of Trampolines type 2" error message and the app crash. We have been spending the last few days trying to identify the cause/fix it and tried all the suggestions we have find on the net, we still have not made any progress. The only solution we have found are from the posts/webpages talking about the adjusting the trampoline settings with