Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ========================================
- // 將有 記憶體禁訪 失敗問題
- #include <stdio.h>
- #include <stdlib.h>
- // ======================================
- #define FFLUSH() {while(getchar()!='\n');}
- #define YES 'y'
- #define NO 'n'
- // ======================================
- // typedef variable
- typedef unsigned char byte;
- typedef unsigned short ushort;
- typedef unsigned int uint;
- typedef unsigned long long ulong;
- typedef unsigned char *addr1;
- typedef unsigned short *addr2;
- typedef /*unsigned*/ int *addr4;
- typedef unsigned long long *addr8;
- // ======================================
- // global variable , save for key address
- #define MAX 2000
- #define LOW 0x00010000
- #define UP 0x7fffffff
- addr4 addr_rec[MAX]={NULL};
- // ======================================
- // show addr_rec
- void show_addr()
- {
- uint i=0;
- addr4 ptr=addr_rec[0];
- while(ptr!=NULL){
- printf("%x:%8x(%d)\n",ptr, *ptr, *ptr);
- ++ptr;
- }
- }
- // ======================================
- // search for target
- void search_target(int target)
- {
- static int first = 1; // first to find
- static int cur_cnt=0; // the addr_rec's count
- uint i=0, cur_cnt2=0;
- addr4 ptr=(addr4)LOW;
- if(first){
- while(ptr!=(addr4)UP && cur_cnt!=MAX){
- if(*ptr==target) {
- addr_rec[cur_cnt] = ptr, ++cur_cnt;
- }
- ++ptr;
- printf("%u\n", cur_cnt);
- }
- }
- }
- // ======================================
- // main function
- int main()
- {
- int target=0;
- char again=NO;
- do{
- printf("input target:");
- scanf("%d", &target);
- search_target(target);
- show_addr();
- printf("search again(y to again)? ");
- again = getchar();
- FFLUSH();
- }while(again==YES);
- return 0;
- }
Add Comment
Please, Sign In to add comment