stack-frame

explanation about push ebp and pop ebp instruction in assembly

放肆的年华 提交于 2020-06-24 02:34:08
问题 i used stack in assembly but i didn't got idea about push ebp and pop ebp. .intel_syntax noprefix .include "console.i" .text askl: .asciz "Enter length: " askb: .asciz "Enter breadth: " ans: .asciz "Perimeter = " _entry: push ebp # establishing stack-frame mov ebp, esp sub esp, 12 Prompt askl GetInt [ebp-4] # length Prompt askb GetInt [ebp-8] # breadth mov eax, [ebp-4] # eax = l add eax, [ebp-8] # eax = l + b add eax, eax # eax = 2 * (l + b) mov [ebp-12], eax Prompt ans PutInt [ebp-12] PutEoL

GetEntryAssembly for web applications

若如初见. 提交于 2020-03-30 04:37:08
问题 Assembly.GetEntryAssembly() does not work for web applications. But... I really need something like that. I work with some deeply-nested code that is used in both web and non-web applications. My current solution is to browse the StackTrace to find the first called assembly. /// <summary> /// Version of 'GetEntryAssembly' that works with web applications /// </summary> /// <returns>The entry assembly, or the first called assembly in a web application</returns> public static Assembly

How to work with FP in C

我是研究僧i 提交于 2020-03-05 04:05:08
问题 I am trying to learn and better understand FP(BP), which according to my textbook is "FP(BP): point to the stack frame of current active function". I have learned that the stack frame link list ends in 0. Therefore, in order to print out the stack frame link list, I have written this function: int a = 1; int b = 2; int c = 3; asm("movl %ebp, FP"); //Sets FP int *i = FP; while(i != 0) { printf("Value: %d \n", i); //Not working printf("Hex Address: %#X \n", i); i = *i; } So I think the hex line

Obtaining references to function objects on the execution stack from the frame object?

风流意气都作罢 提交于 2020-01-14 03:39:17
问题 Given the output of inspect.stack() , is it possible to get the function objects from anywhere from the stack frame and call these? If so, how? (I already know how to get the names of the functions.) Here is what I'm getting at: Let's say I'm a function and I'm trying to determine if my caller is a generator or a regular function? I need to call inspect.isgeneratorfunction() on the function object. And how do you figure out who called you? inspect.stack() , right? So if I can somehow put

HOWTO get the correct Frame Pointer of an arbitrary thread in iOS?

只谈情不闲聊 提交于 2020-01-13 04:44:30
问题 Way to get the Frame Pointer On a Demo App running on iPhone 5s Device / Xcode 7, I tried to get the frame pointer of an arbitrary thread using thread_get_state , but always result in an incorrect one : - (BOOL)fillThreadState:(thread_t)thread intoMachineContext:(_STRUCT_MCONTEXT *)machineContext { mach_msg_type_number_t state_count = MACHINE_THREAD_STATE_COUNT; kern_return_t kr = thread_get_state(thread, MACHINE_THREAD_STATE, (thread_state_t)&machineContext->__ss, &state_count); if (kr !=

Is there a simple way to obtain all the local variables in the current stack frame in C# (or CIL)

落爺英雄遲暮 提交于 2020-01-09 21:17:43
问题 Following my previous question, in which I wanted to dump all the variables in the stack (from the current and all the previous frame) that can be seen here: Is there a way to examine the stack variables at runtime in C#? I was suggested to intercept the calls manually or use AOP framework like PostSharp to simplify such a task. I looked at PostSharp and the interception arguments don't include the variables in the current stack frame. I wonder if there is a simple way to automatically get

Print the stack frame link list and Hex contents of stack from FP to stack frame

醉酒当歌 提交于 2020-01-06 05:59:09
问题 I'm given the following code: #include <stdio.h> #include <stdlib.h> int A(int x, int y); int B(int x, int y); int *FP; int main(int argc, char *argv[], char *env[]){ int a, b, c; printf("enter main\n"); A(a,b); printf("exit main\n"); return 0; } int A(int x, int y) { int d, e, f; printf("enter A\n"); d = 4; e = 5; f = 6; B(d,e); printf("exit A\n"); } int B(int x, int y) { int u, v, w; printf("enter B\n"); u = 7; v = 8; w = 9; asm("movl %ebp, FP"); // set FP = CPU's %ebp register //Write C