juinda

Untitled

Oct 19th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. // 20161018memorydump.cpp : 定義主控台應用程式的進入點。
  2. //
  3.  
  4. #include "stdio.h"
  5. #include<stdlib.h>
  6. #include<string.h>
  7. int main()
  8. {
  9. while (1)
  10. {
  11. int address;
  12. char end[10] = { '\0' }, sp;
  13. long long memory[1000];
  14. int i = 0,n=0;
  15. int which[50];
  16. char style[50][10];
  17. if (scanf("%x", &address) == EOF)return 0;
  18. do
  19. {
  20. for (int time = 0; time < 50; time++)
  21. {
  22. scanf("%llx ", &memory[i]);
  23. i++;
  24. }
  25. scanf("%s",end);
  26. } while (strcmp(end,"EndMemDump"));
  27. scanf("%d", &n);
  28. for (int x = 0; x < n; x++)
  29. {
  30. scanf("%x", &which[x]);
  31. sp = getchar();
  32. gets(style[x]);
  33. }
  34. for (int x = 0; x < n; x++)
  35. {
  36. int whrer = which[x] - address;
  37. if (!strcmp(style[x], "int"))
  38. {
  39. int loong = 4;
  40. printf("%d\n", memory[whrer+3] * 16777216 + memory[whrer +2] *65536 + memory[whrer +1] *256 + memory[whrer] * 1);
  41. }
  42. else if (!strcmp(style[x], "short"))
  43. {
  44. int loong = 2;
  45. printf("%hd\n", memory[whrer + 1] * 256 + memory[whrer] * 1);
  46. }
  47. else if (!strcmp(style[x], "long long"))
  48. {
  49. int loong = 8;
  50. //puts("------------------");
  51. long long answer = (memory[whrer + 10] << 56) + (memory[whrer + 9] << 48)+(memory[whrer + 8] << 40) +(memory[whrer + 7] << 32) + (memory[whrer + 3] << 24) + (memory[whrer + 2] << 16) + (memory[whrer + 1] << 8) + (memory[whrer + 0] * 1);
  52. /*printf("ans= %lld\n", answer);
  53. printf("%llx\t%lld\n", memory[whrer + 10],memory[whrer + 10] << 56);
  54. printf("%llx\t%lld\n", memory[whrer + 9], memory[whrer + 9] << 48);
  55. printf("%llx\t%lld\n", memory[whrer + 8],memory[whrer + 8] << 40);
  56. printf("%llx\t%lld\n", memory[whrer + 7],memory[whrer + 7] << 32);
  57. printf("%llx\t%lld\n", memory[whrer + 3],memory[whrer + 3] << 24);
  58. printf("%llx\t%lld\n", memory[whrer + 2],memory[whrer + 2] << 16);
  59. printf("%llx\t%lld\n", memory[whrer + 1],memory[whrer + 1] << 8);
  60. printf("%llx\t%lld\n", memory[whrer + 0],memory[whrer + 0]*1);
  61. puts("------------------");*/
  62. printf("%lld\n", answer);
  63. }
  64. else if (!strcmp(style[x], "char"))
  65. {
  66. int loong = 1;
  67. printf("%c\n", memory[whrer]);
  68. }
  69. else if (!strcmp(style[x], "String"))
  70. {
  71. int now = 0;
  72. while (memory[whrer + now] !=199 && memory[whrer + now] != 00)
  73. {
  74. printf("%c", memory[whrer + now]);
  75. now++;
  76. }
  77. puts("");
  78. }
  79. }
  80. }
  81. system("pause");
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment