-/* compat.c - High Memory for Windows CE
- Copyright (C) 2010 g10 Code GmbH
- Written by Marcus Brinkmann <marcus@g10code.com>
-
- This file is part of HiMemCE.
-
- HiMemCE is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- HiMemCE is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#include "himemce.h"
-
-struct _PEB _peb;
-
-size_t
-pread (HANDLE handle, char *buffer, size_t len, off_t offset)
-{
- DWORD out = -1;
- if (SetFilePointer (handle, offset, NULL, SEEK_SET) == -1)
- return -1;
- if (!ReadFile (handle, buffer, len, &out, NULL))
- return -1;
- return out;
-}
-
-
-int get_prot_flags (int vprot)
-{
- int rwx = vprot & (VPROT_READ | VPROT_WRITE | VPROT_WRITECOPY | VPROT_EXEC);
- int res = 0;
-
- switch(rwx)
- {
- case VPROT_READ:
- res = PAGE_READONLY;
- break;
- case VPROT_READ | VPROT_WRITE:
- res = PAGE_READWRITE;
- break;
- case VPROT_READ | VPROT_WRITECOPY:
- // res = PAGE_WRITECOPY;
- res = PAGE_READWRITE;
- break;
- case VPROT_EXEC:
- res = PAGE_EXECUTE;
- break;
- case VPROT_EXEC | VPROT_READ:
- res = PAGE_EXECUTE_READ;
- break;
- case VPROT_EXEC | VPROT_READ | VPROT_WRITE:
- res = PAGE_EXECUTE_READWRITE;
- break;
- case VPROT_EXEC | VPROT_READ | VPROT_WRITECOPY:
- // res = PAGE_EXECUTE_WRITECOPY;
- res = PAGE_EXECUTE_READWRITE;
- break;
- default:
- res = PAGE_NOACCESS;
- }
- if (vprot & VPROT_GUARD) res |= PAGE_GUARD;
- if (vprot & VPROT_NOCACHE) res |= PAGE_NOCACHE;
- return res;
-}
+/* compat.c - High Memory for Windows CE\r
+ Copyright (C) 2010 g10 Code GmbH\r
+ Written by Marcus Brinkmann <marcus@g10code.com>\r
+\r
+ This file is part of HiMemCE.\r
+ \r
+ HiMemCE is free software; you can redistribute it and/or modify it\r
+ under the terms of the GNU Lesser General Public License as\r
+ published by the Free Software Foundation; either version 2.1 of\r
+ the License, or (at your option) any later version.\r
+ \r
+ HiMemCE is distributed in the hope that it will be useful, but\r
+ WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ Lesser General Public License for more details.\r
+ \r
+ You should have received a copy of the GNU Lesser General Public\r
+ License along with this program; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\r
+ 02111-1307, USA. */\r
+\r
+#include "wine.h"\r
+\r
+struct _PEB _peb;\r
+\r
+size_t\r
+pread (HANDLE handle, char *buffer, size_t len, off_t offset)\r
+{\r
+ DWORD out = -1;\r
+ if (SetFilePointer (handle, offset, NULL, SEEK_SET) == -1)\r
+ return -1;\r
+ if (!ReadFile (handle, buffer, len, &out, NULL))\r
+ return -1;\r
+ return out;\r
+}\r
+\r
+\r
+int get_prot_flags (int vprot)\r
+{\r
+ int rwx = vprot & (VPROT_READ | VPROT_WRITE | VPROT_WRITECOPY | VPROT_EXEC);\r
+ int res = 0;\r
+\r
+ switch(rwx)\r
+ {\r
+ case VPROT_READ:\r
+ res = PAGE_READONLY;\r
+ break;\r
+ case VPROT_READ | VPROT_WRITE:\r
+ res = PAGE_READWRITE;\r
+ break;\r
+ case VPROT_READ | VPROT_WRITECOPY:\r
+ // res = PAGE_WRITECOPY;\r
+ res = PAGE_READWRITE;\r
+ break;\r
+ case VPROT_EXEC:\r
+ res = PAGE_EXECUTE;\r
+ break;\r
+ case VPROT_EXEC | VPROT_READ:\r
+ res = PAGE_EXECUTE_READ;\r
+ break;\r
+ case VPROT_EXEC | VPROT_READ | VPROT_WRITE:\r
+ res = PAGE_EXECUTE_READWRITE;\r
+ break;\r
+ case VPROT_EXEC | VPROT_READ | VPROT_WRITECOPY:\r
+ // res = PAGE_EXECUTE_WRITECOPY;\r
+ res = PAGE_EXECUTE_READWRITE;\r
+ break;\r
+ default:\r
+ res = PAGE_NOACCESS;\r
+ }\r
+ if (vprot & VPROT_GUARD) res |= PAGE_GUARD;\r
+ if (vprot & VPROT_NOCACHE) res |= PAGE_NOCACHE;\r
+ return res;\r
+}\r