Ошибка lnk2026 небезопасный модуль для образа safeseh

I got this error when building a sample visual C++ project.
First I downloaded 3 sample projects, all solve the same problem, print out all the prime numbers less than N (you may know these sample projects ?). I built the pure-C project without any problem. But when I tried to build the assembly-based project one, I got this error.

Thank you.

CloudyMarble's user avatar

CloudyMarble

36.8k70 gold badges96 silver badges130 bronze badges

asked Feb 5, 2013 at 15:06

Hoai Dam's user avatar

2

In Visual Studio 2012 Express Edition:

Right-click on your project ->
Properties -> 
Configuration Properties ->
Linker ->
Advanced and changed "Image Has Safe Exception Handlers" to "No (/SAFESEH:NO)"

answered Mar 13, 2014 at 2:34

kungfooman's user avatar

kungfoomankungfooman

4,4231 gold badge43 silver badges33 bronze badges

A picture is worth 0x3e8 words for the /SAFESEH:NO linker setting:

enter image description here

Or you can tell MASM to provide a guarantee that the object contains no exception handlers or that any exception handlers are defined with .SAFESEH, if you know that to be correct for your assembly code:

enter image description here

This will allow you to keep /SAFESEH enabled for the project’s linking. But is it correct? You are making the guarantee! Be sure or use the first option.

answered Feb 10, 2015 at 22:36

chappjc's user avatar

chappjcchappjc

30.3k6 gold badges75 silver badges132 bronze badges

Try to disable SAFESEH.

From spec: /SAFESEH was specified, but a module was not compatible with the safe exception handling feature.

answered Feb 5, 2013 at 15:21

Leo Chapiro's user avatar

Leo ChapiroLeo Chapiro

13.6k7 gold badges61 silver badges92 bronze badges

3

I got this error when building a sample visual C++ project.
First I downloaded 3 sample projects, all solve the same problem, print out all the prime numbers less than N (you may know these sample projects ?). I built the pure-C project without any problem. But when I tried to build the assembly-based project one, I got this error.

Thank you.

CloudyMarble's user avatar

CloudyMarble

36.8k70 gold badges96 silver badges130 bronze badges

asked Feb 5, 2013 at 15:06

Hoai Dam's user avatar

2

In Visual Studio 2012 Express Edition:

Right-click on your project ->
Properties -> 
Configuration Properties ->
Linker ->
Advanced and changed "Image Has Safe Exception Handlers" to "No (/SAFESEH:NO)"

answered Mar 13, 2014 at 2:34

kungfooman's user avatar

kungfoomankungfooman

4,4231 gold badge43 silver badges33 bronze badges

A picture is worth 0x3e8 words for the /SAFESEH:NO linker setting:

enter image description here

Or you can tell MASM to provide a guarantee that the object contains no exception handlers or that any exception handlers are defined with .SAFESEH, if you know that to be correct for your assembly code:

enter image description here

This will allow you to keep /SAFESEH enabled for the project’s linking. But is it correct? You are making the guarantee! Be sure or use the first option.

answered Feb 10, 2015 at 22:36

chappjc's user avatar

chappjcchappjc

30.3k6 gold badges75 silver badges132 bronze badges

Try to disable SAFESEH.

From spec: /SAFESEH was specified, but a module was not compatible with the safe exception handling feature.

answered Feb 5, 2013 at 15:21

Leo Chapiro's user avatar

Leo ChapiroLeo Chapiro

13.6k7 gold badges61 silver badges92 bronze badges

3

  • Remove From My Forums
  • Question

  • Hi

    I am migrating my application from vc++6.0 to vc++2013

    I have copied sql10forcompile in my machine from older machine were vc++6.0 was there, Sql10Compile is using to build the embedded cp code to cpp file.

    I am getting this error after i copy it in my current machine and this error directs to a lib file libcs.lib(libcs.dll)

    can anyone help me

    Thanks Ankush

Answers

  • Hi Ankush,

    Thank you for your feedback!

    I feel it is strange. Please check as below:

    right-click your project -> properties

    configuration properties -> linker -> advanced

    Best regards,

    Sunny

    • Marked as answer by

      Thursday, January 30, 2014 5:41 AM

  • Hi,

    Actually we have to click on command line right. I have resolved the syntax issue by the way.

    And i checked the linker->advanced option .. for me it was Yes(/SAFESEH) tahts it. Is it fine coz it is not showing any error now

    Thanks Ankush

    • Marked as answer by
      Anna Cc
      Thursday, January 30, 2014 5:43 AM

Да возможно не в этих разделах надо было тему делать, но я просто подумал что раз Dll эта читерская с ассемблерным кодом, то вполне подойдёт раздел «Вопросов по созданию читов»))))

Да на счёт гугла, я сразу же прогуглил, так же наткнулся на тему которую ты первую указал (в нгей я нефига не понял), но 2 тему я не находил к сожалению(( Спасибо к стате что нашёл мою проблему))) Щас попробую сделать как ты написал.

Ура!)) Собрался наконец мой файлик))

Да к стате, 1 вопросик чуть не по теме, как для этого скрипта сделать правильный pattern и вообще как правильно найти все эти байты? А то я дак не оч пока понимаю от куда это всё берётся.

Да… вот скрипт на всякий:

Скрипт я делал по подобию скипта Coder’а.

#include <Windows.h>#include <fcntl.h>#include <stdio.h>#include <io.h>#include <Psapi.h>#include <detours.h>#pragma comment (lib, "psapi.lib")DWORD WINAPI SpinTires_thread(LPVOID);DWORD retn_addr = 0;DWORD ohk = false;DWORD APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved){	switch (ul_reason_for_call)	{	case DLL_PROCESS_ATTACH:		CreateThread(NULL, NULL, SpinTires_thread, NULL, NULL, NULL);	case DLL_THREAD_ATTACH:	case DLL_THREAD_DETACH:	case DLL_PROCESS_DETACH:		break;	}	return true;}MODULEINFO GetModuleData(char*module_name){	MODULEINFO moduleInf = { 0 };	HMODULE hModule = GetModuleHandle(module_name);	if (hModule == NULL)		return moduleInf;	GetModuleInformation(GetCurrentProcess(), hModule, &moduleInf, sizeof(MODULEINFO));	return moduleInf;}bool DataCompare(const BYTE*pData, const BYTE*pattern, const char*mask){	for (; *mask; ++mask, ++pData, ++pattern)		if (*mask == 'x' && *pData != *pattern)			return false;	return (*mask) == NULL;}DWORD FindPattern(DWORD start_address, DWORD lenght, BYTE*pattern, char*mask){	for (DWORD i = 0; i < lenght; i++)		if (DataCompare((BYTE*)(start_address + i), pattern, mask))			return (DWORD)(start_address + i);	return NULL;}void InfinityHealth(){	_asm	{		mov dword ptr[ecx + 0xF0], 0x0		jmp retn_addr	}}DWORD WINAPI SpinTires_thread(LPVOID){	MODULEINFO moduleInf = GetModuleData("SpinTires.exe");	DWORD old_prot = 0;	DWORD ohk_address = FindPattern((DWORD)moduleInf.lpBaseOfDll, moduleInf.SizeOfImage,		(PBYTE)"x8Bx91xF0x00x00x00xDB", "xxxxxxxxxxx");	ohk_address += 0x3;	retn_addr = ohk_address + 0x6;	BYTE nops[3] = { 0x90, 0x90, 0x90 };	BYTE original[6] = { 0x8B, 0x91, 0xF0, 0x00, 0x00, 0x00 };	for (;; Sleep(75))	{		if (GetAsyncKeyState(VK_NUMPAD2) & 0x8000)		{			if (!ohk)			{				DetourFunction((PBYTE)ohk_address, (PBYTE)InfinityHealth);				VirtualProtect(InfinityHealth, 3, PAGE_EXECUTE_READWRITE, &old_prot);				memcpy(InfinityHealth, nops, 3);				VirtualProtect(InfinityHealth, 3, old_prot, &old_prot);				ohk = true;			}			else			{				VirtualProtect((void*)ohk_address, sizeof(original), PAGE_EXECUTE_READWRITE, &old_prot);				memcpy((void*)ohk_address, original, sizeof(original));				VirtualProtect((void*)ohk_address, sizeof(original), old_prot, &old_prot);				ohk = false;			}		}	}}


Изменено 28 октября, 2014 пользователем Xipho

DATE: 2018.12.21


1. Ссылка

http://www.cnblogs.com/hanxi/archive/2012/06/10/2544230.html

2. Описание проблемы

При использовании VS2013 для компиляции фабрики я столкнулся со следующими проблемами:

ошибка LNK2026: модуль небезопасен для изображений SAFESEH
 фатальная ошибка LNK1281: невозможно создать образ SAFESEH.
3. Решение

Эта схема на самом деле является схемой обхода, которая запрещает создание образа SAFESEH.

1. Откройте диалоговое окно «Страница свойств» проекта.

2. Щелкните папку «Linker».

3. Щелкните страницу свойств «Командная строка».

4. Введите / SAFESEH: NO в поле «Дополнительные параметры (другие параметры)», а затем нажмите «Применить».


THE END!

  • Ошибка lnk2019 visual studio
  • Ошибка lnk2001 неразрешенный внешний символ static
  • Ошибка lnk2001 неразрешенный внешний символ maincrtstartup
  • Ошибка lnk2001 неразрешенный внешний символ main
  • Ошибка lnk1181 не удается открыть входной файл