滴水c

c汇编

  1. #include <stdio.h>
  2. int main() {
  3. __asm {
  4. mov eax,eax
  5. mov eax,eax
  6. mov eax, eax
  7. mov eax, eax
  8. mov eax, eax
  9. mov eax, eax
  10. }
  11. return 0;
  12. }
  1. #include <stdio.h>
  2. int main() {
  3. 00681740 push ebp
  4. 00681741 mov ebp,esp
  5. 00681743 sub esp,0C0h
  6. 00681749 push ebx
  7. 0068174A push esi
  8. 0068174B push edi
  9. 0068174C lea edi,[ebp-0C0h]
  10. 00681752 mov ecx,30h
  11. 00681757 mov eax,0CCCCCCCCh
  12. 0068175C rep stos dword ptr es:[edi]
  13. __asm {
  14. mov eax,eax
  15. 0068175E mov eax,eax
  16. mov eax,eax
  17. 00681760 mov eax,eax
  18. mov eax, eax
  19. 00681762 mov eax,eax
  20. mov eax, eax
  21. 00681764 mov eax,eax
  22. mov eax, eax
  23. 00681766 mov eax,eax
  24. mov eax, eax
  25. 00681768 mov eax,eax
  26. }
  27. return 0;
  28. 0068176A xor eax,eax
  29. }
  30. 0068176C pop edi
  31. 0068176D pop esi
  32. 0068176E pop ebx
  33. 0068176F add esp,0C0h
  34. 00681775 cmp ebp,esp
  35. 00681777 call __RTC_CheckEsp (0681230h)
  36. 0068177C mov esp,ebp
  37. 0068177E pop ebp
  38. 0068177F ret

c汇编调用

  1. #include <stdio.h>
  2. int plus(int x, int y){
  3. return 0;
  4. }
  5. int main() {
  6. __asm {
  7. mov eax,eax
  8. mov eax,eax
  9. }
  10. //调用函数
  11. plus(1,2);
  12. return 0;
  13. }
  1. int main() {
  2. 00B21750 push ebp
  3. 00B21751 mov ebp,esp
  4. 00B21753 sub esp,0C0h
  5. 00B21759 push ebx
  6. 00B2175A push esi
  7. 00B2175B push edi
  8. 00B2175C lea edi,[ebp-0C0h]
  9. 00B21762 mov ecx,30h
  10. 00B21767 mov eax,0CCCCCCCCh
  11. 00B2176C rep stos dword ptr es:[edi]
  12. __asm {
  13. mov eax,eax
  14. 00B2176E mov eax,eax
  15. mov eax,eax
  16. 00B21770 mov eax,eax
  17. }
  18. //调用函数
  19. plus(1,2);
  20. 00B21772 push 2
  21. 00B21774 push 1
  22. 00B21776 call _plus (0B211B3h)
  23. 00B2177B add esp,8
  24. return 0;
  25. 00B2177E xor eax,eax
  26. }
  27. 00B21780 pop edi
  28. 00B21781 pop esi
  29. 00B21782 pop ebx
  30. 00B21783 add esp,0C0h
  31. 00B21789 cmp ebp,esp
  32. 00B2178B call __RTC_CheckEsp (0B21235h)
  33. 00B21790 mov esp,ebp
  34. 00B21792 pop ebp
  35. 00B21793 ret
  36. 00B211B3 jmp plus (0B217B0h)
  37. #include <stdio.h>
  38. int plus(int x, int y){
  39. 00B217B0 push ebp
  40. 00B217B1 mov ebp,esp
  41. 00B217B3 sub esp,0C0h
  42. 00B217B9 push ebx
  43. 00B217BA push esi
  44. 00B217BB push edi
  45. 00B217BC lea edi,[ebp-0C0h]
  46. 00B217C2 mov ecx,30h
  47. 00B217C7 mov eax,0CCCCCCCCh
  48. 00B217CC rep stos dword ptr es:[edi]
  49. 00B217CE mov ecx,offset _8392E4F9_main@c (0B2C003h)
  50. 00B217D3 call @__CheckForDebuggerJustMyCode@4 (0B2130Ch)
  51. return 0;
  52. 00B217D8 xor eax,eax
  53. }
  54. 00B217DA pop edi
  55. 00B217DB pop esi
  56. 00B217DC pop ebx
  57. 00B217DD add esp,0C0h
  58. 00B217E3 cmp ebp,esp
  59. 00B217E5 call __RTC_CheckEsp (0B21235h)
  60. 00B217EA mov esp,ebp
  61. 00B217EC pop ebp
  62. 00B217ED ret

c参数传递与返回值

  1. #include <stdio.h>
  2. int plus(int x, int y){
  3. 002A17B0 push ebp
  4. 002A17B1 mov ebp,esp
  5. 002A17B3 sub esp,0C0h
  6. 002A17B9 push ebx
  7. 002A17BA push esi
  8. 002A17BB push edi
  9. 002A17BC lea edi,[ebp-0C0h]
  10. 002A17C2 mov ecx,30h
  11. 002A17C7 mov eax,0CCCCCCCCh
  12. 002A17CC rep stos dword ptr es:[edi]
  13. 002A17CE mov ecx,offset _8392E4F9_main@c (02AC003h)
  14. 002A17D3 call @__CheckForDebuggerJustMyCode@4 (02A130Ch)
  15. return x+y;
  16. 002A17D8 mov eax,dword ptr [x]
  17. 002A17DB add eax,dword ptr [y]
  18. }
  19. 002A17DE pop edi
  20. 002A17DF pop esi
  21. 002A17E0 pop ebx
  22. 002A17E1 add esp,0C0h
  23. 002A17E7 cmp ebp,esp
  24. 002A17E9 call __RTC_CheckEsp (02A1235h)
  25. 002A17EE mov esp,ebp
  26. 002A17F0 pop ebp
  27. 002A17F1 ret

c 变量

  • 全局变量

image.png

  1. #include <stdio.h>
  2. #include <Windows.h>
  3. int y;//全局变量
  4. int plus(){
  5. int x;
  6. x=1234567;
  7. return 0;
  8. }
  9. int main() {//入口函数
  10. plus();//函数瞬间执行完很难找到函数中的局部变量 1234567
  11. //想找到只能人为延长函数执行时间
  12. // int plus(){
  13. // int x;
  14. // x=1234567;
  15. // while (1)
  16. // {
  17. // Sleep(3000);
  18. // printf("%d\n", x);
  19. // }
  20. // return 0;
  21. // }
  22. while (1)
  23. {
  24. Sleep(3000);
  25. printf("%d\n", x);
  26. }
  27. return 0;
  28. }

变量与参数