Re: why my program segmentation fault?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Star Liu wrote:
> I wrote a program to copy the memory content of FFFF0000-FFFFFFFF to a
> file, but it says "Segmentation fault", (i use AMD64 lenny, so the
> address is long), how could i fix it? thanks!
>
> #include <string.h>
> #include <stdio.h>
>
>
> void CopyMemoryToFile(char* FilePath, long StartAddress, long OffSet)
> {
> FILE* Memory;
> Memory=fopen (FilePath, "w");
> if(Memory!=NULL)
> {
> void* Start;
> Start=StartAddress;
> fwrite(Start, 1, OffSet, Memory);
> }
> fclose(Memory);
>
> }
> int main (void)
> {
> CopyMemoryToFile("~/cgi-bin_d/Memory",0xFFFF0000,0xFFFF);
> return 0;
> }
>
这个cross post也太那个啥啥了吧。
原因在于你这个程序根本就无法寻址0xFFFF0000.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkh7IC8ACgkQJo9Njjkvy34YUwCeNRpApBdfrihAEJK/Ywdz8xre
hokAnjix0bgugE/WUX6mgzvZLyMAo/kv
=plM6
-----END PGP SIGNATURE-----
Reply to: