Commit 323d285f authored by Will Harris's avatar Will Harris Committed by Commit Bot

Remove *Kernel32Loaded APIs from TargetServices.

This API can't be relied on as it needs the NtMapViewOfSection
intercept to be in place, which is not always the case.

There were no callers to this API anyway.

Also, tidy up the hardcoded values to make them more readable.

BUG=None

Change-Id: Ib45b524f465a2730f9164eac987ffa8b35181243
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1696526
Commit-Queue: Will Harris <wfh@chromium.org>
Reviewed-by: default avatarBruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676523}
parent 45d02bf5
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "sandbox/win/src/interception_agent.h" #include "sandbox/win/src/interception_agent.h"
#include "sandbox/win/src/sandbox_factory.h" #include "sandbox/win/src/sandbox_factory.h"
#include "sandbox/win/src/sandbox_nt_util.h" #include "sandbox/win/src/sandbox_nt_util.h"
#include "sandbox/win/src/target_services.h"
namespace sandbox { namespace sandbox {
...@@ -68,7 +67,6 @@ TargetNtMapViewOfSection(NtMapViewOfSectionFunction orig_MapViewOfSection, ...@@ -68,7 +67,6 @@ TargetNtMapViewOfSection(NtMapViewOfSectionFunction orig_MapViewOfSection,
if (ansi_module_name && if (ansi_module_name &&
(g_nt._strnicmp(ansi_module_name, KERNEL32_DLL_NAME, (g_nt._strnicmp(ansi_module_name, KERNEL32_DLL_NAME,
sizeof(KERNEL32_DLL_NAME)) == 0)) { sizeof(KERNEL32_DLL_NAME)) == 0)) {
SandboxFactory::GetTargetServices()->GetState()->SetKernel32Loaded();
s_state = kAfterKernel32; s_state = kAfterKernel32;
} }
} __except (EXCEPTION_EXECUTE_HANDLER) { } __except (EXCEPTION_EXECUTE_HANDLER) {
......
...@@ -215,37 +215,29 @@ bool TargetServicesBase::TestIPCPing(int version) { ...@@ -215,37 +215,29 @@ bool TargetServicesBase::TestIPCPing(int version) {
return true; return true;
} }
ProcessState::ProcessState() : process_state_(0), csrss_connected_(true) {} ProcessState::ProcessState()
: process_state_(ProcessStateInternal::NONE), csrss_connected_(true) {}
bool ProcessState::IsKernel32Loaded() const {
return process_state_ != 0;
}
bool ProcessState::InitCalled() const { bool ProcessState::InitCalled() const {
return process_state_ > 1; return process_state_ >= ProcessStateInternal::INIT_CALLED;
} }
bool ProcessState::RevertedToSelf() const { bool ProcessState::RevertedToSelf() const {
return process_state_ > 2; return process_state_ >= ProcessStateInternal::REVERTED_TO_SELF;
} }
bool ProcessState::IsCsrssConnected() const { bool ProcessState::IsCsrssConnected() const {
return csrss_connected_; return csrss_connected_;
} }
void ProcessState::SetKernel32Loaded() {
if (!process_state_)
process_state_ = 1;
}
void ProcessState::SetInitCalled() { void ProcessState::SetInitCalled() {
if (process_state_ < 2) if (process_state_ < ProcessStateInternal::INIT_CALLED)
process_state_ = 2; process_state_ = ProcessStateInternal::INIT_CALLED;
} }
void ProcessState::SetRevertedToSelf() { void ProcessState::SetRevertedToSelf() {
if (process_state_ < 3) if (process_state_ < ProcessStateInternal::REVERTED_TO_SELF)
process_state_ = 3; process_state_ = ProcessStateInternal::REVERTED_TO_SELF;
} }
void ProcessState::SetCsrssConnected(bool csrss_connected) { void ProcessState::SetCsrssConnected(bool csrss_connected) {
......
...@@ -14,8 +14,6 @@ namespace sandbox { ...@@ -14,8 +14,6 @@ namespace sandbox {
class ProcessState { class ProcessState {
public: public:
ProcessState(); ProcessState();
// Returns true if kernel32.dll has been loaded.
bool IsKernel32Loaded() const;
// Returns true if main has been called. // Returns true if main has been called.
bool InitCalled() const; bool InitCalled() const;
// Returns true if LowerToken has been called. // Returns true if LowerToken has been called.
...@@ -23,13 +21,14 @@ class ProcessState { ...@@ -23,13 +21,14 @@ class ProcessState {
// Returns true if Csrss is connected. // Returns true if Csrss is connected.
bool IsCsrssConnected() const; bool IsCsrssConnected() const;
// Set the current state. // Set the current state.
void SetKernel32Loaded();
void SetInitCalled(); void SetInitCalled();
void SetRevertedToSelf(); void SetRevertedToSelf();
void SetCsrssConnected(bool csrss_connected); void SetCsrssConnected(bool csrss_connected);
private: private:
int process_state_; enum class ProcessStateInternal { NONE = 0, INIT_CALLED, REVERTED_TO_SELF };
ProcessStateInternal process_state_;
bool csrss_connected_; bool csrss_connected_;
DISALLOW_COPY_AND_ASSIGN(ProcessState); DISALLOW_COPY_AND_ASSIGN(ProcessState);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment