maandag 26 februari 2024

Everything about windows DLL's

This presentation from CppCon 2017 is really helpful for understanding how DLL's are loaded and functions are exported.

You can read the live debug log from the loader, by setting the SLS on an executable.

gflags /i PrintGreeting.exe +sls
cdb PrintGreeting.exe
gflags /i PrintGreeting.exe -sls

You can export data using:
extern "C" __declspec(dllimport) int const One = 1;
extern "C" __declspec(dllimport) int const Two = 2;

link Constants.obj /dll /out:Constants.dll /noentry /nodefaultlib /export:One,DATA /export:Two,DATA


You can have thread variables using:
Thread local storage:
__declspec(thread) int x = 10;

Geen opmerkingen:

Een reactie posten