a few asm ?
Posted: Fri May 07, 2010 1:29 pm
question 1
I am wondering how I would get the address of the currently executing instruction?
I don't think you can do
question 2
how can I get a functions address in eax or something register?
What I mean is if I have a function
How can I get the address of where to jump to to go to that function.
Note it is easy if I just modify the function1 to return the value in one of the registers like eax or something by doing mov [eax] ,esp ...etc but I don't want to modify the function at all by adding mov eax , [esp] in it.
I know in c/c++ you can just use &function1 which will return the address of the function.
But in asm I don't know how to get the address of the function without calling it and mov esp into eax and returning the value which takes modifying the function1 which I don't want to do....
How does call know where to jump to after it pushes the return address on the stack?
is it vaild to just do mov eax, function1 or mov eax,[function1] don't know what these would do or what the difference between them is .... (if that is the way to get the equivalent to '&' in asm then I am being stupid)
I have only used [] on varibles to get the exact value but I am wondering if [] used on function names give their address.
So may all call command is doing is
this
push varibles
jmp [function1]
If that is it then I am all set with this question
Question 3
For registers
I have pretty much tried reading and writing to all these register at one time or another.
Leaving out the debuging registers and test register (because these are the ones I never used before so I have no comment on DR0-DR7 TR3-TR7 )
I am just wondering if the only read only register is EIP or IP instruction pointer or can you modify the instruction pointer to run code at a specific address by mov eip , ax,..etc
Also on an operating system like windows when you create an .exe file are you only allowed 1 code segment cs or can you have many code segment that you can switch from.
I know you can do mov cs , ax and say the original cs segment address on the stack but How can you get eip to point at the correct offset of where the starting instruction begins..
usually cs:0x00000000 this would mean you would have to beable to change/modify the eip pointer ???
I am wondering how I would get the address of the currently executing instruction?
I don't think you can do
Code: Select all
mov eax , eip
how can I get a functions address in eax or something register?
What I mean is if I have a function
Code: Select all
function1:
;my code
ret
Note it is easy if I just modify the function1 to return the value in one of the registers like eax or something by doing mov [eax] ,esp ...etc but I don't want to modify the function at all by adding mov eax , [esp] in it.
I know in c/c++ you can just use &function1 which will return the address of the function.
But in asm I don't know how to get the address of the function without calling it and mov esp into eax and returning the value which takes modifying the function1 which I don't want to do....
How does call know where to jump to after it pushes the return address on the stack?
is it vaild to just do mov eax, function1 or mov eax,[function1] don't know what these would do or what the difference between them is .... (if that is the way to get the equivalent to '&' in asm then I am being stupid)
I have only used [] on varibles to get the exact value but I am wondering if [] used on function names give their address.
So may all call command is doing is
this
push varibles
jmp [function1]
If that is it then I am all set with this question
Question 3
For registers
Code: Select all
General registers
EAX EBX ECX EDX
Segment registers
CS DS ES FS GS SS
Index and pointers
ESI EDI EBP EIP ESP
Indicator
EFLAGS
Undocumented or special purpose registers
Control registers are CR0 to CR4, Debug registers are DR0 to DR7, test registers are TR3 to TR7 and the protected mode segmentation registers are GDTR (Global Descriptor Table Register), IDTR (Interrupt Descriptor Table Register), LDTR (Local DTR), and TR(task register).
I have pretty much tried reading and writing to all these register at one time or another.
Leaving out the debuging registers and test register (because these are the ones I never used before so I have no comment on DR0-DR7 TR3-TR7 )
I am just wondering if the only read only register is EIP or IP instruction pointer or can you modify the instruction pointer to run code at a specific address by mov eip , ax,..etc
Also on an operating system like windows when you create an .exe file are you only allowed 1 code segment cs or can you have many code segment that you can switch from.
I know you can do mov cs , ax and say the original cs segment address on the stack but How can you get eip to point at the correct offset of where the starting instruction begins..
usually cs:0x00000000 this would mean you would have to beable to change/modify the eip pointer ???