Re: why my program segmentation fault?
在 2008-07-14一的 17:31 +0800,Star Liu写道:
> 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;
> }
每个程序都有自己的地址域,这样的程序不会得到实际地址,也就无法写出真正的
内容。
--
Regards,
Deng Xiyue, a.k.a. manphiz
Reply to: