-
Notifications
You must be signed in to change notification settings - Fork 97
Report 【error LNK2019: unresolved external symbol __EH_epilog3】 in build mode "Release x86". #3
Comments
Yes, SAFESEH is not supported temporarily. |
Hi, apparently I have closed SAFESEH, but the error still persists. The zip file of my Visual Studio project is provided below for reference. Please click here to get project code: Visual Studio Project Demo |
Hi, class A {
public:
A() { DbgPrint("Construct \n");
}
~A() { DbgPrint("Destruct \n");}
};
__try {
A a;
ProbeForWrite(0x00000000, 4, 4);
} __except (EXCEPTION_EXECUTE_HANDLER) {
DbgPrint("Throw Exception !!!");
} |
Hi, SAFESEH is supported. |
Hi, when use
Code demo: std::map<std::string, ULONG_PTR> global_api = {
{"ZwMapViewOfSection", NULL},
{"ZwCreateFile", NULL}
} |
Great! I think this should be a relatively complete C++ Runtime library 👍 . By the way, would you like to research about how to implement
Code demo#include <ntifs.h>
#include <eh.h>
class CSEHException
{
public :
CSEHException(UINT code , PEXCEPTION_POINTERS pep) {
m_exceptionCode = code ;
m_exceptionRecord = *pep->ExceptionRecord ;
m_context = *pep->ContextRecord ;
}
operator unsigned int() { return m_exceptionCode ; }
UINT m_exceptionCode ;
EXCEPTION_RECORD m_exceptionRecord ;
CONTEXT m_context ;
} ;
// SEH translator function
void __cdecl TranslateSEHtoCE( UINT code , PEXCEPTION_POINTERS pep ) {
throw CSEHException( code , pep ) ;
}
EXTERN_C
NTSTATUS DriverEntry(PDRIVER_OBJECT pDrvObj, PUNICODE_STRING pRegPath) {
UNREFERENCE_PARAMETER(pDrvObj);
UNREFERENCE_PARAMETER(pRegPath);
//TODO: Init cpp runtime
// xxxxxxx
// Install SEH translator
_set_se_translator(TranslateSEHtoCE) ;
try {
ProbeForWrite(0x00000000, 4, 4);
} catch(const CSEHException& e) {
printf("SEH exception code: %u \n", e.m_exceptionCode);
}
return STATUS_SUCCESS;
} |
Don't support, The system won't call me. |
Hi, in the newly refactored version of the code I found that it will cause BSOD on Windows7 x86 when I load driver of your code demo. Have you tested it, including loading and unloading drivers? BSOD Info:
Code#ifdef __KERNEL_MODE
#include <ntddk.h>
#include <wdm.h>
#else
#include <windows.h>
#include <assert.h>
#endif
#include <ucxxrt.h>
#include <string>
#include <random>
#include <vector>
#include <functional>
#include <unordered_map>
#ifdef _KERNEL_MODE
#define LOG(_0, _1, ...) DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__)
#else
#define LOG(_0, _1, ...) printf(__VA_ARGS__)
#endif
#ifdef _KERNEL_MODE
EXTERN_C NTSTATUS DriverMain(PDRIVER_OBJECT aDriverObject, PUNICODE_STRING /*aRegistry*/)
#else
EXTERN_C int main()
#endif
{
#ifdef _KERNEL_MODE
aDriverObject->DriverUnload = [](PDRIVER_OBJECT)
{
LOG(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, "Exit ucxxrt-test.\n");
};
#endif
return 0;
} |
You need set: unittest - Properties - Driver Settings - Target OS Version - Windows 7 |
And, I don't plan to support Windows 7 😄 |
Alright, thanks. |
OS: Windows 10 Enterprise LTSC (Build 17763.1809)
IDE: Visual Studio 2019
WDK: WDK10 (10.0.19041.0)
Build mode: Kernel, Release x86
Details: When I compile the driver with the already compiled ucxxrt.lib, the LNK2019 error is reported only when I set the compile mode to Release x86. And the project's UnitTest does not compile through in this mode either, with the same LNK2019 error.
The text was updated successfully, but these errors were encountered: