티스토리 뷰
The Microsoft Windows executive represents files by file objects, which are executive objects that are managed by the object manager. (Directories are also represented by file objects.)
Kernel-mode components refer to a file by its object name, which is \DosDevices concatenated to the file's full path. (On Microsoft Windows 2000 and later versions of the operating system, \?? is equivalent to \DosDevices.) For example, the object name of the C:\WINDOWS\example.txt file is \DosDevices\C:\WINDOWS\example.txt. You use the object name to open a handle to a file. For more information about object names, see Object Names.
To use a file
- Open a handle to the file.
For more information, see Opening a Handle to a File.
- Perform the intended operations by calling the appropriate ZwXxxFile routines.
For more information, see Using a File Handle.
- Close the handle by calling ZwClose.
Every time that you open a handle to a file, the Windows executive creates a file object that represents the file, and it returns an open handle to that object. Therefore, multiple file objects can exist for a single file. (Because a user-mode application can copy a handle, multiple handles can also exist for the same file object.) After all the open handles to a file object are closed, the Windows executive deletes the file object.
To open a handle to a file, perform the following steps:
- Create an OBJECT_ATTRIBUTES structure, and call the InitializeObjectAttributes routine to initialize the structure. You specify the file's object name as the ObjectName parameter to InitializeObjectAttributes.
- Open a handle to the file by passing the OBJECT_ATTRIBUTES structure to IoCreateFile, ZwCreateFile, or ZwOpenFile.
If the file does not exist, IoCreateFile and ZwCreateFile will create it, whereas ZwOpenFile will return STATUS_OBJECT_NAME_NOT_FOUND.
Note that drivers almost always use ZwCreateFile or ZwOpenFile rather than IoCreateFile.
When you call IoCreateFile, ZwCreateFile, or ZwOpenFile, the Windows executive creates a new file object to represent the file, and it provides an open handle to the object. This file object persists until you close all the open handles to it.
Whichever routine you call, you must pass the access rights you need as the DesiredAccess parameter. These rights must cover all the operations that your driver will perform. The following table lists these operations and the corresponding access right to request.
Operation | Required Access Right |
---|---|
Read from the file | FILE_READ_DATA or GENERIC_READ |
Write to the file | FILE_WRITE_DATA or GENERIC_WRITE |
Write only to the end of the file | FILE_APPEND_DATA |
Read the file's metadata, such as the file's creation time | FILE_READ_ATTRIBUTES or GENERIC_READ |
Write the file's metadata, such as the file's creation time | FILE_WRITE_ATTRIBUTES or GENERIC_WRITE |
For more information about the values available for DesiredAccess, see ZwCreateFile.
The following table lists the operations that drivers can perform on a file handle and the corresponding routines that carry out those operations.
Operation | Routine to Call |
---|---|
Read data from the file | ZwReadFile |
Write data to the file | ZwWriteFile |
Read metadata for the file or file handle | ZwQueryInformationFile |
Write metadata for the file or file handle | ZwSetInformationFile |
To indicate where in the file to begin reading or writing data, you pass a ByteOffset parameter to ZwReadFile or ZwWriteFile, respectively.
If you opened the handle with FILE_APPEND_DATA access, all data is written to the end of the file, and the ByteOffset parameter is ignored.
Under certain conditions, the I/O manager maintains a current file-position pointer for the file. You can begin a read or write operation at that position by specifying NULL for ByteOffset. For more information about when the current file-position pointer exists, see Using the Current File Position later in this section.
To examine or change information about a file, call ZwQueryInformationFile or ZwSetInformationFile, respectively. You specify the particular type of information as the FileInformationClass parameter to each routine. For example, setting FileInformationClass to FileBasicInformation allows you to examine or change a FILE_BASIC_INFORMATION structure, which contains members for the file-creation time and the last-access time, among others. For information about all the possible values for FileInformationClass, see ZwQueryInformationFile and ZwSetInformationFile.
'보안 > 분석' 카테고리의 다른 글
Defeating Kernel Native API Hookers by Direct Service Dispatch Table Restoration (by SIG^2) (1) | 2008.04.12 |
---|---|
SDT Hooking 무력화에 대한 연구 (By Dual5651, dualpage.muz.ro) (0) | 2008.04.11 |
HOOK the ZwDeleteFile is Not Work -> How to?? [펌 www.rohitab.com] (1) | 2008.04.08 |
PhantOm Plugin 1.20 (0) | 2008.04.04 |
Windows syscall lister (0) | 2008.04.04 |
- Total
- Today
- Yesterday
- 지루박멸연구센타
- 열정의 힘을 믿는다
- Le4rN TO Cr4cK
- 디버깅에관한모든것(DebugLab)
- sysinternals
- FoundStone
- hashtab
- 보안-coderant
- 디바이스드라이버 개발자 포럼
- dualpage.muz.ro
- osronline.com - 드라이버 관련 정보 사이트
- NtInternals - NativeAPI Refere…
- pcthreat - spyware 정보 제공
- rootkit.com - 루트킷 관련 정보
- www.ntinternals.net
- WINE CrossRef. - source.winehq…
- tuts4you
- hex-rays
- idapalace
- idefense
- immunityinc
- threatexpert
- hdp.null2root.org
- www.crackstore.com
- crackmes.de
- www.who.is
- www.cracklab.ru
- community.reverse-engineering.…
- video.reverse-engineering.net
- SnD
- 클레이 키위
- reversengineering.wordpress.co…
- www.openrce.org
- www.woodmann.com
- PEID.Plusins.BobSoft
- roxik.com/pictaps/
- regexlib.com
- spyware-browser.com
- www.usboffice.kr
- regulator
- www.txt2re.com
- ietab.mozdev.org
- zesrever.xstone.org
- www.heaventools.com/PE-file-he…
- www.heaventools.com
- www.innomp3.com
- 울지않는벌새
- exetools.com-forum
- exetools.com
- utf8 conv
- robtex - IP trace
- onsamehost - same IP sites
- JpopSuki
- jsunpack.jeek.org
- wepawet.iseclab.org
- www.jswiff.com
- www.hackeroo.com
- winesearcher.co.kr
- khpga.org
- malwareurl.com
- anubis.iseclab.org
- www.crummy.com-eautifulSoup
- malwarebytes.org/forums
- bbs.janmeng.com
- blackip.ustc.edu.cn
- eureka.cyber-ta.org
- exploit-db.com
- 다올저축은행
- 피봇
- INVOICE
- Pivot
- ElasticSearch
- 주식
- O365
- 신한저축은행
- SBI저축은행
- 맥쿼리인프라
- 주식트래이딩
- ChatGPT
- ubuntu
- 주택구매력지수
- logrotate
- PIR
- CriticalSection
- 군함도
- ROA
- systemd
- 레고랜드
- 매매가격지수
- 공공인프라
- 전세매매지수
- hai
- 사회간접자본
- 시스템트래이딩
- 미국주식
- 실시간트래이딩
- 자동트래이딩
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |