Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Pretty hard to verify that you got the address correct, it is unusually low. I just wrote another program to test this. It enumerates the regions in kernel32.dll and calls VirtualProtect() on them:</p> <pre><code>#include &lt;Windows.h&gt; #include &lt;assert.h&gt; #include &lt;iostream&gt; int main() { HMODULE hmod = GetModuleHandle(L"kernel32.dll"); MEMORY_BASIC_INFORMATION info; // Start at PE32 header SIZE_T len = VirtualQuery(hmod, &amp;info, sizeof(info)); assert(len &gt; 0); BYTE* dllBase = (BYTE*)info.AllocationBase; BYTE* address = dllBase; for (;;) { len = VirtualQuery(address, &amp;info, sizeof(info)); assert(len &gt; 0); if (info.AllocationBase != dllBase) break; std::cout &lt;&lt; "Address: " &lt;&lt; std::hex &lt;&lt; info.BaseAddress; std::cout &lt;&lt; " (" &lt;&lt; std::hex &lt;&lt; info.RegionSize &lt;&lt; ") "; std::cout &lt;&lt; " protect = " &lt;&lt; std::hex &lt;&lt; info.Protect; DWORD oldprotect; if (info.Protect == 0) std::cout &lt;&lt; ", VirtualProtect skipped" &lt;&lt; std::endl; else { BOOL ok = VirtualProtect(info.BaseAddress, info.RegionSize, PAGE_EXECUTE_READWRITE, &amp;oldprotect); std::cout &lt;&lt; ", VirtualProtect = " &lt;&lt; (ok ? "okay" : "Failed!") &lt;&lt; std::endl; } address = (BYTE*)info.BaseAddress + info.RegionSize; } return 0; } </code></pre> <p>Output of this program on my machine, running Windows 8.1 x64:</p> <pre><code>Address: 77470000 (1000) protect = 2, VirtualProtect = okay Address: 77471000 (f000) protect = 0, VirtualProtect skipped Address: 77480000 (62000) protect = 20, VirtualProtect = okay Address: 774E2000 (e000) protect = 0, VirtualProtect skipped Address: 774F0000 (7e000) protect = 2, VirtualProtect = okay Address: 7756E000 (2000) protect = 0, VirtualProtect skipped Address: 77570000 (1000) protect = 4, VirtualProtect = okay Address: 77571000 (f000) protect = 0, VirtualProtect skipped Address: 77580000 (1000) protect = 2, VirtualProtect = okay Address: 77581000 (f000) protect = 0, VirtualProtect skipped Address: 77590000 (1a000) protect = 2, VirtualProtect = okay Address: 775AA000 (6000) protect = 0, VirtualProtect skipped </code></pre> <p>Running it in 64-bit mode:</p> <pre><code>Address: 00007FFC4F870000 (1000) protect = 2, VirtualProtect = okay Address: 00007FFC4F871000 (112000) protect = 20, VirtualProtect = okay Address: 00007FFC4F983000 (1000) protect = 4, VirtualProtect = okay Address: 00007FFC4F984000 (1000) protect = 8, VirtualProtect = okay Address: 00007FFC4F985000 (24000) protect = 2, VirtualProtect = okay </code></pre> <p>Clearly you have a different Windows version so be sure to run this program on your machine to get comparable results.</p> <p>The conclusion I draw is there is no fundamental reason for this kind of code to fail. And if it does on your machine then that's likely to be environmental. With a very obvious candidate to be your anti-malware software, which of course has a great stake in preventing code from messing with kernel32.dll. I'm running minimal protection on my machine.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload