Ignore:
Timestamp:
Jan 15, 2011, 6:04:58 PM (14 years ago)
Author:
イグトランス (egtra)
Message:

セキュリティ対策の機能を有効化

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/ab_common/src/Environment.cpp

    r763 r773  
    3535    }
    3636    throw;
    37 }
    38 
    39 BOOL EnableLFH(HANDLE hHeap)
    40 {
    41     ULONG enableLFH = 2;
    42     return HeapSetInformation(hHeap, HeapCompatibilityInformation, &enableLFH, sizeof enableLFH);
    4337}
    4438
     
    8478    return E_NOTIMPL;
    8579}
     80
     81BOOL ActiveBasic::Common::EnableNX()
     82{
     83    typedef BOOL (WINAPI* PFNSETDEP)(DWORD);
     84
     85    HMODULE hmodKernel = GetModuleHandle(TEXT("KERNEL32.DLL"));
     86    if (PFNSETDEP pfnSetDEP = reinterpret_cast<PFNSETDEP>(GetProcAddress(hmodKernel, "SetProcessDEPPolicy")))
     87    {
     88        return pfnSetDEP(PROCESS_DEP_ENABLE);
     89    }
     90    else
     91    {
     92        return FALSE;
     93    }
     94}
     95
     96void ActiveBasic::Common::SetHeapOptions()
     97{
     98//  SetDllDirectory(_T(""));
     99    HMODULE hmodKernel = GetModuleHandle(TEXT("KERNEL32.DLL"));
     100
     101    typedef BOOL (WINAPI* HSI)(HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
     102    HSI pHsi = reinterpret_cast<HSI>(GetProcAddress(hmodKernel, "HeapSetInformation"));
     103    if (!pHsi)
     104    {
     105        return;
     106    }
     107
     108    ULONG enableLFH = 2;
     109    pHsi(GetProcessHeap(), HeapCompatibilityInformation, &enableLFH, sizeof enableLFH);
     110
     111#ifndef HeapEnableTerminationOnCorruption
     112#   define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
     113#endif
     114
     115    pHsi(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
     116}
Note: See TracChangeset for help on using the changeset viewer.