15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file.
45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <windows.h>
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome_elf/chrome_elf_types.h"
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// A CreateFileW replacement that will call NTCreateFile directly when the
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// criteria defined in ShouldBypass() are satisfied for |lp_file_name|.
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)extern "C" HANDLE WINAPI CreateFileWRedirect(
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    LPCWSTR file_name,
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    DWORD desired_access,
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    DWORD share_mode,
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    LPSECURITY_ATTRIBUTES security_attributes,
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    DWORD creation_disposition,
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    DWORD flags_and_attributes,
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    HANDLE template_file);
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Returns the count of CreateFile calls redirected so far.
24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)extern "C" int GetRedirectCount();
25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Partial reimplementation of kernel32!CreateFile (very partial: only handles
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// reading and writing to files in the User Data directory).
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)HANDLE CreateFileNTDLL(
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    LPCWSTR file_name,
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    DWORD desired_access,
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    DWORD share_mode,
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    LPSECURITY_ATTRIBUTES security_attributes,
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    DWORD creation_disposition,
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    DWORD flags_and_attributes,
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    HANDLE template_file);
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Determines whether or not we should use our version of CreateFile, or the
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// system version (only uses ours if we're writing to the user data directory).
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShouldBypass(LPCWSTR file_name);
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif  // CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_
42