Hi there,
I’ve been struggling with this for the past couple of days, and I’m reaching out here as a last resort. I hope I’m just missing something simple.
Context:
I’m running Windows 10 (build 19045.4894). The precompiled DynamoRIO samples run fine for me, but I’m having trouble compiling my own tools.
For example, when I run the precompiled bbsize.dll sample:
.\drrun.exe -c "C:\Program Files\DynamoRIO\samples\bin64\bbsize.dll" -- notepad
I get the expected output:
Client bbsize is running
So far, so good. Since this worked, I thought I’d try copying the entire bbsize.c source code to start writing my own tool. Here’s where the trouble begins.
What I’ve Tried:
Compiling with CMake (Visual Studio 2022):
It compiles successfully, and I get a bbsize.dll, but when I try to run it:
- .\drrun.exe -verbose -c "C:\Users\toofy-windoze\source\repos\DynamoRIO_Client\bbsize.dll" -- notepad
Notepad either doesn’t launch or launches and immediately exits. No instrumentation output, no errors, and no indication that the client is running. Judging from other experiments later, this seems to be related to the address of the dll not being fixed, although I'm not really sure about this.
Switching to 32-bit Compilation:
I then tried compiling for 32-bit. This allowed Notepad to launch, but none of the DynamoRIO API (drapi) code executed. No instrumentation, no output related to bbsize.dll.
Switching to Visual Studio 2019 and Compiling with cl:
I read that using Visual Studio 2019 could help, so I tried that. Instead of CMake, I switched to directly compiling with the MSVC cl command.
Here’s the cl command I used (Note I had to hard link to an older version of windows SDK to get around some random bug):
- cl /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\winrt" /I"C:\Program Files\DynamoRIO\include" /I"C:\Program Files\DynamoRIO\ext\include" /DWINDOWS /DX86_64 /GS- bbsize.c /MT /link /libpath:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64" /libpath:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64" /libpath:"C:\Program Files\DynamoRIO\lib64\release" /libpath:"C:\Program Files\DynamoRIO\ext\lib64\release" dynamorio.lib drmgr.lib drx.lib /dll /out:bbsize.dll /base:0x72000000 /opt:ref /opt:icf /dynamicbase:no
This compiles successfully, but I still have the same behavior with drrun. Notepad launches, but none of the actual code in the DLL executes. There’s no indication that any instrumentation is happening.
Can someone please help me understand what I might be doing wrong? I’m running out of ideas and would greatly appreciate any guidance!