[ros-bugs] [Bug 2936] Overwrite a loaded dll.
ReactOS.Bugzilla at www.reactos.org
ReactOS.Bugzilla at www.reactos.org
Mon Feb 2 17:50:42 CET 2009
http://www.reactos.org/bugzilla/show_bug.cgi?id=2936
Christoph_vW <Christoph at ApiViewer.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Christoph at ApiViewer.de
--- Comment #4 from Christoph_vW <Christoph at ApiViewer.de> 2009-02-02 17:50:41 CET ---
ReactOS should deny opening a file which is mapped into memory regardless if it
is still opened or not. (1224 / ERROR_USER_MAPPED_FILE)
new testcase:
#include <windows.h>
#include <stdio.h>
int main()
{
HANDLE hFile, hFile2;
HANDLE hMapping = NULL;
LPVOID Addr = NULL;
DWORD dwBytes = 0;
BOOL RetVal;
CHAR Test[] = "Daten";
hFile = CreateFileA("test.txt", GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
printf("CreateFileA failed!\n");
return 0;
}
hMapping = CreateFileMappingA(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (hMapping == NULL)
{
printf("CreateFileMappingA failed! (%ld)\n", GetLastError());
return 0;
}
Addr = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
if (Addr == NULL)
{
printf("MapViewOfFile failed!\n");
return 0;
}
CloseHandle(hFile);
hFile2 = CreateFileA("test.txt", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, 0);
if (hFile2 == INVALID_HANDLE_VALUE)
{
UnmapViewOfFile(Addr);
printf("CreateFileA (2) failed (%ld)!\n", GetLastError());
return 0;
}
RetVal = WriteFile(hFile2, (LPCVOID) Test, sizeof(Test), &dwBytes,
NULL);
if (!RetVal)
{
printf("WriteFile failed (%ld)\n", GetLastError());
}
UnmapViewOfFile(Addr);
CloseHandle(hMapping);
CloseHandle(hFile2);
return 0;
}
--
Configure bugmail: http://www.reactos.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the Ros-bugs
mailing list