310 questions
1
vote
1
answer
70
views
x86: How to obtain return address from %ebp?
Similar question: Assembly return address
I want to write a function to print the return address of the current function. This is code that prints %ebp+4:
void backtrace() {
int ebp;
asm ("movl %%...
2
votes
1
answer
165
views
What is the order of the stack frame when parameters are passed in?
I have been reading a c++ textbook and have come across stack frames and how they work. The book outlines how stack frames are created, what they consist of and the order in which they are created.
...
1
vote
1
answer
97
views
Assembly function makes the call stack incomprehensible in Visual Studio
I am developing a scripting language VM. The main application is written in C++, it calls script functions that can call native function back through the native interface API, similar to JNI - Java ...
0
votes
0
answers
78
views
IDA Pro: Assembly Patching - Stack Manipulation for Non-Local Access
In IDA Pro, I'm trying to patch assembly to manipulate the stack/display array and allow a function to access non-local variables from an outer scope.
My core question: How to calculate the correct ...
1
vote
0
answers
106
views
Stack frame contents, pointer to another address within stack frame
I'm trying to learn more about memory and trying to dissect a stack frame. For reference here is the source code that I'm running through gdb.
#include <stdio.h>
void test_function(int a, int b,...
1
vote
0
answers
237
views
Ghidra and IDA addresses not aligned
I'm loading the same binary to both ghidra and IDA. When looking at main(), here's what both of them show:
ghidra
undefined main()
undefined AL:1 ...
0
votes
1
answer
68
views
Assembly code is crashing when passing parameters to a function
Hello I am trying to learn assembly (NASM). I watched some videos out there and now I am trying to do some codes. The code is to take a string and calculate the length of it, then pass it to a system ...
0
votes
1
answer
313
views
What advantages does StackWalkEx have over StackWalk64?
The Microsoft Windows DbgHelp library provides three functions for walking the stack:
the original StackWalk function
the newer StackWalk64 function
the even newer StackWalkEx function
Unfortunately,...
6
votes
1
answer
220
views
Use of Stack-Local Variables in Naked Function
While browsing some vendor-supplied startup code for a commodity MCU and reading this excellent SO post about GCC's naked attribute, I seem to have come to a contradiction. The linked GCC ...
2
votes
1
answer
252
views
Arm64 Assembly: How to properly manage frame pointer?
I implemented recursive fibonacci as an exercise, and the program seems to work perfectly except for one thing: when stepping through the function with gdb, the "backtrace" command just ...
0
votes
1
answer
113
views
How does array padding works in Stack?
The following question refers to x86 assembly, and little endianness.
Suppose I have the following code in C:
unsigned char myID[10] = "211866744";
How will this array be saved in memory?
...
1
vote
1
answer
78
views
Stack frame and value pointer
I am unsure as to why i is set to 1234 during the second run of f()? I thought that when the first f() was executed to completion the stack frame for the first f() will be "popped", which I ...
0
votes
0
answers
100
views
I can't use RSP to reference the end of the stack
in my system (x86_64), when I'm using GDB, both RBP and RSP point to the same memory address after pushing a new stack frame, therefore I can't reference the end of the stack with the register RSP ...
0
votes
1
answer
204
views
Is there a way to calculate the bytes allocated to the stack frame of a function?
I have been given this code in C and I need to calculate the bytes allocated to the stack frame of function arith. I looked everywhere for a way to do it but everyone has a different answer.
long ...
0
votes
0
answers
107
views
How to trace Stack Frame manually with just raw program memory record?
I have a memory dump of a program, and I am aware of the range of the stack memory. My question revolves around identifying the stack frame within this chunk of memory. In simpler terms, how can I ...