2

我利用了很久以前在互联网上发布的一个项目。细节来了,为了简洁明了,所有不相关的东西都被剥离了。


一个二进制文件,其内容如下所述

十六进制转储:

55 89 E5 83 EC 08 C7 45 FC 00 00 00 00 8B 45 FC 
3B 45 10 72 02 EB 19 8B 45 FC 8B 55 0C 01 C2 8B 
45 FC 03 45 08 8A 00 88 02 8D 45 FC FF 00 EB DD 
C6 45 FA 00 83 7D 10 01 76 6C 80 7D FA 00 74 02 
EB 64 C6 45 FA 01 C7 45 FC 00 00 00 00 8B 45 10 
48 39 45 FC 72 02 EB E2 8B 45 FC 8B 4D 0C 01 C1 
8B 45 FC 03 45 0C 8D 50 01 8A 01 3A 02 73 30 8B 
45 FC 03 45 0C 8A 00 88 45 FB 8B 45 FC 8B 55 0C 
01 C2 8B 45 FC 03 45 0C 40 8A 00 88 02 8B 45 FC 
03 45 0C 8D 50 01 8A 45 FB 88 02 C6 45 FA 00 8D 
45 FC FF 00 EB A7 C9 C2 0C 00 90 90 90 90 90 90

被加载到内存中并使用以下方法片段执行

var
  MySrcArray,
  MyDestArray: array [1 .. 15] of Byte;

  // ...

  MyBuffer: Pointer;

  TheProc: procedure;
  SortIt: procedure(ASrc, ADest: Pointer; ASize: LongWord); stdcall;
begin
  // Initialization of MySrcArray with random Bytes and display here ...

  // Instructions of loading of the binary file into MyBuffer using merely **GetMem** here ...

  @SortIt := MyBuffer;

  try
      SortIt(@MySrcArray, @MyDestArray, 15);

      // Display of MyDestArray (The outcome of the processing !)
  except
    // Invalid code error handling
  end;

  // Cleaning code here ...  
end;

在我的盒子上就像一个魅力。


我的问题:

不使用VirtualAlloc和/或如何工作VirtualProtect

4

1 回答 1

4

我假设您在问为什么这不会被数据执行保护阻止?对于 32 位程序,DEP 默认选择加入,这意味着应用程序必须显式启用它。

If you change the DEP setting to "Turn on DEP for all programs and services except those I select" then your application will trigger a DEP warning and crash.

于 2012-04-01T05:47:58.937 回答