calling-convention

The value of ESP was not saved properly

淺唱寂寞╮ 提交于 2019-12-02 11:48:49
问题 From the above image you can see that an error occurs when the function setAttribute returns from its call. Does anyone know how to resolve this error shown in the picture? I know that it is an error between calling conventions, but how do I find out what the calling convention for setAttribute is? 回答1: This error indicates that your stack is corrupted. There are many ways to get there. As mentioned in the error message a different calling convention is possible but this is not often the case

printf float in nasm assembly 64-bit

家住魔仙堡 提交于 2019-12-02 10:57:32
问题 I want to print a float value with printf global main extern printf section .data string: db `%f\n`, 0 section .bss rs: resq 1 [...] movq xmm0, [rs] mov rdi, string mov rax, 0 call printf rs contains the floating value 1.6 (gdb) x/fg &rs 0x600ad8 <rs>: 1.6000000000000001 but the program prints [username@localhost folder]$ ./programname 0.000000 who can I get the program to print 1.6? what am I doing wrong? 回答1: I suspect the problem has something to do with your code setting rax to 0 whereas

How is the stack pointer changed in this program with call and ret

回眸只為那壹抹淺笑 提交于 2019-12-02 09:25:03
问题 My questions pertain to the actions that seem to happen between the line when context is changed especially concerning RSP and RBP . Given this very simple program: Reading symbols from ./function_call...done. (gdb) disass main Dump of assembler code for function main: 0x00000000004004d6 <+0>: push rbp 0x00000000004004d7 <+1>: mov rbp,rsp 0x00000000004004da <+4>: mov esi,0x2 0x00000000004004df <+9>: mov edi,0x1 0x00000000004004e4 <+14>: call 0x4004b6 <add_and_7> 0x00000000004004e9 <+19>: mov

The value of ESP was not saved properly

拟墨画扇 提交于 2019-12-02 07:04:28
From the above image you can see that an error occurs when the function setAttribute returns from its call. Does anyone know how to resolve this error shown in the picture? I know that it is an error between calling conventions, but how do I find out what the calling convention for setAttribute is? This error indicates that your stack is corrupted. There are many ways to get there. As mentioned in the error message a different calling convention is possible but this is not often the case. It is much more likely that your stack has been overwritten by writing to memory pointed to by an invalid

How is the stack pointer changed in this program with call and ret

半腔热情 提交于 2019-12-02 05:20:21
My questions pertain to the actions that seem to happen between the line when context is changed especially concerning RSP and RBP . Given this very simple program: Reading symbols from ./function_call...done. (gdb) disass main Dump of assembler code for function main: 0x00000000004004d6 <+0>: push rbp 0x00000000004004d7 <+1>: mov rbp,rsp 0x00000000004004da <+4>: mov esi,0x2 0x00000000004004df <+9>: mov edi,0x1 0x00000000004004e4 <+14>: call 0x4004b6 <add_and_7> 0x00000000004004e9 <+19>: mov eax,0x0 0x00000000004004ee <+24>: pop rbp 0x00000000004004ef <+25>: ret End of assembler dump. (gdb)

printf float in nasm assembly 64-bit

牧云@^-^@ 提交于 2019-12-02 05:19:13
I want to print a float value with printf global main extern printf section .data string: db `%f\n`, 0 section .bss rs: resq 1 [...] movq xmm0, [rs] mov rdi, string mov rax, 0 call printf rs contains the floating value 1.6 (gdb) x/fg &rs 0x600ad8 <rs>: 1.6000000000000001 but the program prints [username@localhost folder]$ ./programname 0.000000 who can I get the program to print 1.6? what am I doing wrong? szx I suspect the problem has something to do with your code setting rax to 0 whereas it must be 1 because you pass a floating point argument (see here for details). Basically rax should

Assembly pass pointer to function

五迷三道 提交于 2019-12-02 02:18:55
问题 I'm trying to sent DWORD variable into function as pointer paramater variable1 dd 1 ... push [variable1] ; push variable adress call _InitPoiner ... _InitPoiner: ; push ebp mov ebp, esp ; lea eax, [ebp+8] ; load address mov dword [eax], 10 ; move value 10 into that address pop ebp ret ... push [variable1] push sdigit ; where sdigit db '%d', 0x0D, 0x0A, 0 call [printf] but variable1 is 1, not 11 , why? 回答1: You are making sure that you pop your vars when done? Looking at your example, I see no

Unable to understand example of cdecl calling convention where caller doesnt need to clean the stack

流过昼夜 提交于 2019-12-01 20:56:04
I am reading the IDA Pro Book . On page 86 while discussing calling conventions, the author shows an example of cdecl calling convention that eliminates the need for the caller to clean arguments off the stack. I am reproducing the code snippet below: ; demo_cdecl(1, 2, 3, 4); //programmer calls demo_cdecl mov [esp+12], 4 ; move parameter z to fourth position on stack mov [esp+8], 3 ; move parameter y to third position on stack mov [esp+4], 2 ; move parameter x to second position on stack mov [esp], 1 ; move parameter w to top of stack call demo_cdecl ; call the function The author goes on to

Behaviour of ebp and esp in stacks using function with parameter

橙三吉。 提交于 2019-12-01 11:27:11
i want to learn more about stack. Especially, what happens when a function with parameter are called. For this, i write the following code: #include <stdio.h> int sum(int d, int e, int f){ int result = d + e + f; return result; } int main(void){ int a = 5; int b = 4; int c = 2; int erg = sum(a,b,c); printf("Result is: %d", erg); } and I get the following Assembly-Code(I will only add the part of the main function, because first I want to understand this section): push ebp, mov ebp, esp and esp, -16 sub esp, 32 mov DWORD PTR[esp+28], 5 mov DWORD PTR[esp+24], 4 mov DWORD PTR[esp+20], 2 mov eax,

Why does GObject method still get called even if callback arguments don't match those in XML?

两盒软妹~` 提交于 2019-12-01 09:26:47
Suppose I have a method like this <interface name="org.Test.ChildTest"> <!-- set_age(guint32 new_age): sets new age --> <method name="set_age"> <arg type="u" name="new_age" direction="in"/> </method> In my table of methods I have: { (GCallback) child_test_set_age, dbus_glib_marshal_child_test_BOOLEAN__UINT_POINTER, 0 } and the right GObject method signature is: gboolean child_test_set_age (ChildTest *childTest, guint ageIn, GError** error) Why does my method, child_test_set_age() , still get called on DBus even if the callback arguments don't match the one specified in my XML? For example if I