📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  Brainstorms - General  >>  Opening Pagefile.sys

Topic created on: June 3, 2008 00:10 CDT by FILEOBJECT .

Ok, im trying to open the pagefile.sys file from kernel land, and am getting STATUS_SHARING_VIOLATION which seems right considering.  In the FILE_OBJECT structure i know there is a flag you can use to adjust the sharing privileges directly, which some software like "unlocker" and a few others can manipulate in order to grant access to the file.  

I suppose my question is, how would you get to the FILE_OBJECT struct for pagefile.sys.   Or better yet, is there a simple way to get access to this file without using any 3rd party applications?

This is the code im currently messing around with that is failing with the sharing violation.

void * PK_OpenPagefile(){

// ----------- log file declarations ----------------
// outfile
HANDLE fHandle = NULL;
LPWSTR fName = L"\\DosDevices\\c:\\pagefile.sys";

UNICODE_STRING uFName;

// file attributes
OBJECT_ATTRIBUTES ObjectAttributes;

// set access mask
ACCESS_MASK DesiredAccess = GENERIC_READ;

// IO Status Block (reports file status)
IO_STATUS_BLOCK IoStatusBlock;

// Return Value for all NTSTATUS functions
NTSTATUS retVal = 0;

// buffer representing the size of a page
char *writeBuff = (char *) malloc(PAGE_SIZE);

// ---- end declarations -----

RtlInitUnicodeString(&uFName, fName);

InitializeObjectAttributes(&ObjectAttributes, &uFName, OBJ_CASE_INSENSITIVE, NULL, NULL);

retVal = ZwCreateFile(&fHandle,
DesiredAccess,
&ObjectAttributes,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE,
NULL,
0);
// etc etc goes here

return NULL;
}

  Aram     June 3, 2008 05:33.20 CDT
I believe that FILE_SHARE_WRITE is needed... But i'm not sure you can open it. Maybe duplicating the handle in system process or finding the FILE_OBJECT and using the opened FILE_OBJECT.

  evilcry     June 6, 2008 04:59.24 CDT
Pagefile.sys is not a common file, so you need a more deep low level access.

As already reported you can work with FILE_OBJECT, or by a more raw attempt, by direct disk access (read about FSCTL_GET_RETRIEVAL_POINTERS, STARTING_VCN_INPUT_BUFFER) implement a Get File Cluster and Copy File function.

You can also look on how WinHex works..

Regards,
Evilcry

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit