@@ -6036,120 +6036,6 @@ namespace Detours {
60366036 return true;
60376037 }
60386038
6039- bool Page::CloneFrom(Page* pSourcePage) {
6040- if (!m_pPageAddress || !m_unPageCapacity || !pSourcePage) {
6041- return false;
6042- }
6043-
6044- if (m_unPageCapacity != pSourcePage->GetPageCapacity()) {
6045- return false;
6046- }
6047-
6048- DWORD unProtection = 0;
6049- if (!pSourcePage->GetProtection(&unProtection)) {
6050- return false;
6051- }
6052-
6053- if (!pSourcePage->ChangeProtection(PAGE_READONLY)) {
6054- return false;
6055- }
6056-
6057- if (!ChangeProtection(PAGE_READWRITE)) {
6058- return false;
6059- }
6060-
6061- memcpy(m_pPageAddress, pSourcePage->GetPageAddress(), pSourcePage->GetPageCapacity());
6062-
6063- if (!ChangeProtection(unProtection)) {
6064- return false;
6065- }
6066-
6067- if (!pSourcePage->RestoreProtection()) {
6068- return false;
6069- }
6070-
6071- return true;
6072- }
6073-
6074- bool Page::CloneTo(Page* pDestinationPage) {
6075- if (!m_pPageAddress || !m_unPageCapacity || !pDestinationPage) {
6076- return false;
6077- }
6078-
6079- if (m_unPageCapacity != pDestinationPage->GetPageCapacity()) {
6080- return false;
6081- }
6082-
6083- DWORD unProtection = 0;
6084- if (!GetProtection(&unProtection)) {
6085- return false;
6086- }
6087-
6088- if (!ChangeProtection(PAGE_READONLY)) {
6089- return false;
6090- }
6091-
6092- if (!pDestinationPage->ChangeProtection(PAGE_READWRITE)) {
6093- return false;
6094- }
6095-
6096- memcpy(pDestinationPage->GetPageAddress(), m_pPageAddress, m_unPageCapacity);
6097-
6098- if (!pDestinationPage->ChangeProtection(unProtection)) {
6099- return false;
6100- }
6101-
6102- if (!RestoreProtection()) {
6103- return false;
6104- }
6105-
6106- return true;
6107- }
6108-
6109- bool Page::CloneFrom(void* pSourceBaseAddress, size_t unSize) {
6110- if (!m_pPageAddress || !m_unPageCapacity || !pSourceBaseAddress) {
6111- return false;
6112- }
6113-
6114- PAGE_INFO pi;
6115- if (!__get_page_info(pSourceBaseAddress, &pi)) {
6116- return false;
6117- }
6118-
6119- if (pi.m_pBaseAddress != pSourceBaseAddress) {
6120- return false;
6121- }
6122-
6123- if (unSize && (pi.m_unSize != unSize)) {
6124- return false;
6125- }
6126-
6127- Page SourcePage(pSourceBaseAddress, pi.m_unSize);
6128- return SourcePage.CloneTo(this);
6129- }
6130-
6131- bool Page::CloneTo(void* pDestinationBaseAddress, size_t unSize) {
6132- if (!m_pPageAddress || !m_unPageCapacity || !pDestinationBaseAddress) {
6133- return false;
6134- }
6135-
6136- PAGE_INFO pi;
6137- if (!__get_page_info(pDestinationBaseAddress, &pi)) {
6138- return false;
6139- }
6140-
6141- if (pi.m_pBaseAddress != pDestinationBaseAddress) {
6142- return false;
6143- }
6144-
6145- if (unSize && (pi.m_unSize != unSize)) {
6146- return false;
6147- }
6148-
6149- Page DestinationPage(pDestinationBaseAddress, pi.m_unSize);
6150- return DestinationPage.CloneFrom(this);
6151- }
6152-
61536039 void* Page::Alloc(size_t unSize, size_t unSizeAlign, size_t unAddressAlign) {
61546040 if (!m_pPageAddress || !m_unPageCapacity || !unSize || !unSizeAlign || !unAddressAlign) {
61556041 return nullptr;
0 commit comments