Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 20161018memorydump.cpp : 定義主控台應用程式的進入點。
- //
- #include "stdio.h"
- #include<stdlib.h>
- #include<string.h>
- int main()
- {
- while (1)
- {
- int address;
- char end[10] = { '\0' }, sp;
- long long memory[1000];
- int i = 0,n=0;
- int which[50];
- char style[50][10];
- if (scanf("%x", &address) == EOF)return 0;
- do
- {
- for (int time = 0; time < 50; time++)
- {
- scanf("%llx ", &memory[i]);
- i++;
- }
- scanf("%s",end);
- } while (strcmp(end,"EndMemDump"));
- scanf("%d", &n);
- for (int x = 0; x < n; x++)
- {
- scanf("%x", &which[x]);
- sp = getchar();
- gets(style[x]);
- }
- for (int x = 0; x < n; x++)
- {
- int whrer = which[x] - address;
- if (!strcmp(style[x], "int"))
- {
- int loong = 4;
- printf("%d\n", memory[whrer+3] * 16777216 + memory[whrer +2] *65536 + memory[whrer +1] *256 + memory[whrer] * 1);
- }
- else if (!strcmp(style[x], "short"))
- {
- int loong = 2;
- printf("%hd\n", memory[whrer + 1] * 256 + memory[whrer] * 1);
- }
- else if (!strcmp(style[x], "long long"))
- {
- int loong = 8;
- //puts("------------------");
- 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);
- /*printf("ans= %lld\n", answer);
- printf("%llx\t%lld\n", memory[whrer + 10],memory[whrer + 10] << 56);
- printf("%llx\t%lld\n", memory[whrer + 9], memory[whrer + 9] << 48);
- printf("%llx\t%lld\n", memory[whrer + 8],memory[whrer + 8] << 40);
- printf("%llx\t%lld\n", memory[whrer + 7],memory[whrer + 7] << 32);
- printf("%llx\t%lld\n", memory[whrer + 3],memory[whrer + 3] << 24);
- printf("%llx\t%lld\n", memory[whrer + 2],memory[whrer + 2] << 16);
- printf("%llx\t%lld\n", memory[whrer + 1],memory[whrer + 1] << 8);
- printf("%llx\t%lld\n", memory[whrer + 0],memory[whrer + 0]*1);
- puts("------------------");*/
- printf("%lld\n", answer);
- }
- else if (!strcmp(style[x], "char"))
- {
- int loong = 1;
- printf("%c\n", memory[whrer]);
- }
- else if (!strcmp(style[x], "String"))
- {
- int now = 0;
- while (memory[whrer + now] !=199 && memory[whrer + now] != 00)
- {
- printf("%c", memory[whrer + now]);
- now++;
- }
- puts("");
- }
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment