Well i have tried everything(and accidenetally discovered how u could make internal errors wich is by having a message box come up then have an "exit;") but i can not get this code to stop crashing the app it loads it
basically this is what happens
the createfilemapping function goes thru with no problem then the mapviewoffile(or map file to memory in stringtables) and writes a value to one of the mapped memory addresses but then when it comes to cleaning up and unmapping the file it just ends no error or anything just a crash and it does not give me a chance to handle the error
but anyway here is the source to the function(btw source to dll is free and open)
__declspec(dllexport) HWND newfilemap(LPSTR filename, DWORD size,int readonly,FILE *fileh,LPSTR name ) //did ghave HWND protect
{
HWND ret;
//HWND fileh;
if (readonly=0) {
fileh=fopen(filename,"wb");
if (fileh=NULL) {
ret=0;
//return ret;
//exit;
}
ret=CreateFileMapping(fileh,NULL,PAGE_READWRITE,0,size,name);
return ret;
//exit;
}
if (readonly=1) {
fileh=fopen(filename,"rb");
if (fileh=NULL) {
ret=0;
return ret;
//exit;
}
ret=CreateFileMapping(fileh,NULL,PAGE_READONLY,0,size,name);
//exit;
}
return ret;
}
__declspec(dllexport) BOOL closefilemap(HANDLE handle,FILE *fileh)
{
BOOL ret;
int tmp;
//tmp=fclose(fileh);
//if (tmp=EOF) {
//ret=0;
//return ret;
//exit;
ret=CloseHandle(handle);
return ret;
}
__declspec(dllexport) BOOL setpower(BOOL suspend,BOOL force)
{
BOOL ret;
ret=SetSystemPowerState(suspend,force);
}
__declspec(dllexport) HANDLE openfilemap(LPSTR name,int read_only)
{
HANDLE ret;
if (read_only=1) {
ret=OpenFileMapping(FILE_MAP_READ,FALSE,name);
}
if (read_only=0) {
ret=OpenFileMapping(FILE_MAP_WRITE,FALSE,name);
}
return ret;
}
__declspec(dllexport) DWORD geterror(VOID)
{
DWORD ret;
ret=GetLastError();
return ret;
}
__declspec(dllexport) LPVOID mapfile(HANDLE hdle,DWORD offset, DWORD num, int read_only)
{
LPVOID ret;
if (read_only=1) {
ret=MapViewOfFile(hdle,FILE_MAP_READ,0,offset,num);
}
if (read_only=0) {
ret=MapViewOfFile(hdle,FILE_MAP_WRITE,0,offset,num);
}
return ret;
}
__declspec(dllexport) BOOL unmapfile(LPVOID hndle)
{
BOOL ret;
ret=UnmapViewOfFile(hndle);
return ret;
}
btw this is C source not C++ but it should handle the same
edit:
stringtable
33, "CREATE FILE MAPPING[%DSDLDS%newfilemap"
34, "CLOSE FILE MAPPING[%DDD%closefilemap"
35, "SET STATE[%DDD%setpower"
36, "OPEN FILE MAP[%DSL%openfilemap"
37, "GET ERROR[%D%geterror"
38, "MAP FILE TO MEMORY[%DDDDL%mapfile"
39, "UNMAP FILE FROM MEMORY[%DD%unmapfile"
formerly shadows of emptiness