Relative Content

Tag Archive for cassembly

Why does the first code cause a segmentaion fault while the later one doesn’t?

I’m self-studying csapp, and currently stuck at level-3 of Attack Lab. This lab requires you to
inject some code by a 40-byte input string. The basic idea is that you input a 48-byte string,
with the first 40-byte as your injection code and the last 8-byte
corresponding to the injection code starting address.
So after you input this string, original return address would be replaced by your code address.

Determine if Processor is in Protected Mode using Mixed C and Assembly in Win OS

Research has revealed that machine status for 386+ processors is stored in the cr0 ( C, R, Zero ) register, and that the low bit being set will indicate protected mode is enabled. The dirt-simple method is to copy cr0 into eax, and then in turn copy eax into a local C variable of the same size (32 bits). We can then query the local C variable using the C language in any way we like.