gpt4 book ai didi

windows - MapViewOfFile 返回什么?

转载 作者:可可西里 更新时间:2023-11-01 10:38:57 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Why won't the loader load at the desired location

“MapViewOfFile”,这个函数是否将一个文件映射到虚拟内存中,并返回映射内存的基地址??如果是,那么下面的代码应该输出 0X400000,因为默认情况下,exe 是在这个位置加载的,但输出是 0X360000。为什么??

#include<iostream>
#include<Windows.h>
#include<stdio.h>
#include<WinNT.h>


int main()
{


HANDLE hFile,hFileMapping;
LPVOID lpFileBase;


if((hFile = CreateFile(TEXT("c:\\linked list.exe"),GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)) == INVALID_HANDLE_VALUE)
std::cout<<"unable to open";

if((hFileMapping = CreateFileMapping(hFile,NULL,PAGE_READONLY,0,0,NULL)) == 0)
{
CloseHandle(hFile);
std::cout<<"unable to open for mapping";
}

if((lpFileBase = MapViewOfFile(hFileMapping,FILE_MAP_READ,0,0,0))== 0)
{
CloseHandle(hFile);
CloseHandle(hFileMapping);
std::cout<<"couldn't map view of file";
}

printf("%x\n",lpFileBase);

}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com