file-mapping

How to CreateFileMapping in C++?

杀马特。学长 韩版系。学妹 提交于 2019-12-08 12:54:27
问题 I am coding a game preloader (a simple program that loads certain files [maps] into cache before starting the program. I was told to use CreateFileMapping which I am still unsure whether it loads it into the physical or virtual memory... Anyway, where would I put what files I need to load? Here is my code (actually coded by someone else on stack overflow who told me to use it) #include <windows.h> #include <cstdio> void pf(const char* name) { HANDLE file = CreateFile(name, GENERIC_READ, FILE

Mapping large files using MapViewOfFile

末鹿安然 提交于 2019-12-07 08:23:55
问题 I have a very large file and I need to read it in small pieces and then process each piece. I'm using MapViewOfFile function to map a piece in memory, but after reading first part I can't read the second. It throws when I'm trying to map it. char *tmp_buffer = new char[bufferSize]; LPCWSTR input = L"input"; OFSTRUCT tOfStr; tOfStr.cBytes = sizeof tOfStr; HANDLE inputFile = (HANDLE)OpenFile(inputFileName, &tOfStr, OF_READ); HANDLE fileMap = CreateFileMapping(inputFile, NULL, PAGE_READONLY, 0,

Mapping large files using MapViewOfFile

孤人 提交于 2019-12-05 18:18:28
I have a very large file and I need to read it in small pieces and then process each piece. I'm using MapViewOfFile function to map a piece in memory, but after reading first part I can't read the second. It throws when I'm trying to map it. char *tmp_buffer = new char[bufferSize]; LPCWSTR input = L"input"; OFSTRUCT tOfStr; tOfStr.cBytes = sizeof tOfStr; HANDLE inputFile = (HANDLE)OpenFile(inputFileName, &tOfStr, OF_READ); HANDLE fileMap = CreateFileMapping(inputFile, NULL, PAGE_READONLY, 0, 0, input); while (offset < fileSize) { long k = 0; bool cutted = false; offset -= tempBufferSize; if

Trouble passing _EXCEPTION_POINTERS * using FileMapping

眉间皱痕 提交于 2019-12-02 06:32:49
问题 I wanted to do a out-of-process exception handler and i had created a watch-dog process which does dedicated exception handling when child process raises exception. I had successfully invoked the watchdog process through events . The problem i am facing is while trying to pass the exception information pointers to the other process . I landed here Passing a pointer to process spawned with exec() and came to know that passing pointers in shared memory has this issue : "If you use shared memory

Trouble passing _EXCEPTION_POINTERS * using FileMapping

邮差的信 提交于 2019-12-01 23:45:29
I wanted to do a out-of-process exception handler and i had created a watch-dog process which does dedicated exception handling when child process raises exception. I had successfully invoked the watchdog process through events . The problem i am facing is while trying to pass the exception information pointers to the other process . I landed here Passing a pointer to process spawned with exec() and came to know that passing pointers in shared memory has this issue : "If you use shared memory, you can't pass the pointer. The pointer will contain the virtual address, which is different from one