-1

if in Vs2019 release Od/O1 will get the following error:

    Severity Code Description Project File Line Suppression State
    error LNK2019 Unresolved external symbol _enable, referenced in function "long __cdecl ReadR3MemoryToR3ByCR3(void *,void *,unsigned __int64,void *)"
    Severity Code Description Project File Line Suppression State
    error LNK2019 Unresolved external symbol _disable, referenced in function "long __cdecl ReadR3MemoryToR3ByCR3(void *,void *,unsigned __int64,void *)"
void foo()
{
    _disable();
    __writecr3(targetCR3);
    if (!MmIsAddressValid(readAddr))
    {
        __writecr3(currentCR3);
        _enable();
        KeLeaveCriticalRegion();
        ExFreePoolWithTag(tempBuffer, 'buFF');
        status = STATUS_INVALID_PARAMETER_2;
        break;
    }
    memcpy(tempBuffer, readAddr, readSize);
    __writecr3(currentCR3);
    _enable();
}

But under vs2019, this does not happen with debug and release 02.

Question: why is this

SnA1lGo
  • 21
  • 2
  • Don't post images of text. Post the actual *text*. – Jesper Juhl Sep 28 '22 at 03:01
  • It's the first time that I don't know the process, sorry – SnA1lGo Sep 28 '22 at 03:13
  • Possible duplicate: [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Jesper Juhl Sep 28 '22 at 03:23
  • I think this is not the answer I need, my problem is that Windows Kernel Project In Release Dd and D1 cannot be compiled, but can be compiled normally in debug and release D2 and other versions. – SnA1lGo Sep 28 '22 at 03:45
  • Thanks a lot for your help, but I got the correct answer from somewhere else. The link is as follows: https://learn.microsoft.com/zh-cn/cpp/intrinsics/compiler-intrinsics?view=msvc-170 – SnA1lGo Sep 28 '22 at 03:53

1 Answers1

1

__disable() and __enalbe() are inline functions, which need to be turned on in vs2019's project configuration

properties->C/C++->Optimization->Enable inline functions.

The O1 and Od optimizations under Release do not enable this function, so the compilation fails.

Reference link: https://learn.microsoft.com/en-gb/cpp/intrinsics/compiler-intrinsics?view=msvc-170

Jarod42
  • 203,559
  • 14
  • 181
  • 302
SnA1lGo
  • 21
  • 2