#include <stdio.h>
typedef struct __REGISTERS_
{
unsigned int EDI;
unsigned int ESI;
unsigned int EBP;
unsigned int ESP;
unsigned int EBX;
unsigned int EDX;
unsigned int ECX;
unsigned int EAX;
unsigned int EFlags;
unsigned int reg_return;
}REGISTERS;
/*
>>>>>> _declspec(naked) 使用 <<<<<<<<
*/
void ShowStruct(REGISTERS *Regs)
{
printf("Regs = :0x %x\n",Regs);
printf("Regs.EDI = :0x %x\n",*Regs);
printf("Regs.ESI = :0x %x\n",*(Regs+4));
printf("Regs.EBP = :0x %x\n",*(Regs+8));
printf("Regs.ESP = :0x %x\n",*(Regs+12));
printf("Regs.EBX = :0x %x\n",*(Regs+16));
printf("Regs.EDX = :0x %x\n",*(Regs+20));
printf("Regs.ECX = :0x %x\n",*(Regs+24));
printf("Regs.EAX = :0x %x\n",*(Regs+28));
printf("Regs.EFlags = :0x %x\n",*(Regs+32));
printf("Regs.reg_return = :0x %x\n",*(Regs+36));
}
void ShowRegisters(REGISTERS *Regs)
{
unsigned int temp;
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax]
__asm mov temp,ebx
printf("Regs.EDI = :0x %x\n",temp);
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax+4]
__asm mov temp,ebx
printf("Regs.ESI = :0x %x\n",temp);
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax+8]
__asm mov temp,ebx
printf("Regs.EBP = :0x %x\n",temp);
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax+12]
__asm mov temp,ebx
printf("Regs.ESP = :0x %x\n",temp);
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax+16]
__asm mov temp,ebx
printf("Regs.EBX = :0x %x\n",temp);
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax+20]
__asm mov temp,ebx
printf("Regs.EDX = :0x %x\n",temp);
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax+24]
__asm mov temp,ebx
printf("Regs.ECX = :0x %x\n",temp);
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax+28]
__asm mov temp,ebx
printf("Regs.EAX = :0x %x\n",temp);
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax+32]
__asm mov temp,ebx
printf("Regs.EFlags = :0x %x\n",temp);
__asm MOV eax,Regs
__asm mov ebx,dword ptr[eax+36]
__asm mov temp,ebx
printf("Regs.reg_return = :0x %x\n",temp);
}
int main()
{
REGISTERS Regs;
Regs.EDI=0x12345678;
Regs.ESI=0x23456789;
Regs.EBP=0x34567890;
Regs.ESP=0x45678901;
Regs.EBX=0x56789012;
Regs.EDX=0x67890123;
Regs.ECX=0x78901234;
Regs.EAX=0x89012345;
Regs.EFlags=0x90123456;
Regs.reg_return=0x01234567;
printf("Regs = :0x %x\n",&Regs);
printf("Regs.EDI = :0x %x\n",Regs.EDI);
printf("Regs.ESI = :0x %x\n",Regs.ESI);
printf("Regs.EBP = :0x %x\n",Regs.EBP);
printf("Regs.ESP = :0x %x\n",Regs.ESP);
printf("Regs.EBX = :0x %x\n",Regs.EBX);
printf("Regs.EDX = :0x %x\n",Regs.EDX);
printf("Regs.ECX = :0x %x\n",Regs.ECX);
printf("Regs.EAX = :0x %x\n",Regs.EAX);
printf("Regs.EFlags = :0x %x\n",Regs.EFlags);
printf("Regs.reg_return = :0x %x\n",Regs.reg_return);
ShowStruct(&Regs);
ShowRegisters(&Regs);
return 0;
}