DynamoRIO / DynamoRIO/dynamorio
CRASH the drwrap extension crash
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
**What version of DynamoRIO are you using?**
DynamoRIO-Windows-7.0.0-RC1
**Does the latest build from
https://github.com/DynamoRIO/dynamorio/wiki/Latest-Build solve the problem?**
This is the latest
**What operating system version are you running on?**
Windows XP SP3 EN 32Bit
**What application are you running?**
The OS svchost.exe process.
**Is your application 32-bit or 64-bit?**
32-bit svchost.exe OS process.
**How are you running the application under DynamoRIO?**
bin32\drconfig.exe -reg winlogon.exe -syswide_on -debug -global -c samples\bin32\wrap.dll
**What happens when you run without any client?**
Without the drwrap extension, every process runs ok.
**What happens when you run with debug build ("-debug" flag to
drrun/drconfig/drinject)?**
The svchost.exe process crashes as well.
**What steps will reproduce the problem?**
1.In a clean windows xp sp3 virtual machine with DR deployed, run the following command:
bin32\drconfig.exe -reg winlogon.exe -syswide_on -debug -global -c samples\bin32\wrap.dll
2.Reboot the OS.
3.After the desktop have showed, wait for the crash message box to be shown.
**What is the expected output? What do you see instead? Is this an
application crash, a DynamoRIO crash, a DynamoRIO assert, or a hang (see
https://github.com/DynamoRIO/dynamorio/wiki/Bug-Reporting and set the title
appropriately)?**
All process running under DR should runs ok. The drwrap extension crash.
**Please provide any additional information below.**
I want to put all processes in the opeating system running under DR, so I config the winlogon.exe as system wide to running under DR. Without the drwrap extension, everything seems ok.
I modify the "wrap" sample client's source code to following
`
#include "dr_api.h"
#include "drmgr.h"
#include "drwrap.h"
static app_pc app_base = NULL;
static app_pc app_end = NULL;
static void
wrap_pre(void *wrapcxt, OUT void **user_data)
{
}
static void
wrap_post(void *wrapcxt, void *user_data)
{
}
static void
iterate_exports(const module_data_t *info, bool add)
{
dr_symbol_export_iterator_t *exp_iter =
dr_symbol_export_iterator_start(info->handle);
while (dr_symbol_export_iterator_hasnext(exp_iter)) {
dr_symbol_export_t *sym = dr_symbol_export_iterator_next(exp_iter);
app_pc func = NULL;
if (sym->is_code)
func = sym->addr;
if (func)
{
if (add)
{
drwrap_wrap(func, wrap_pre, wrap_post);
}
else
{
drwrap_unwrap(func, wrap_pre, wrap_post);
}
}
}
dr_symbol_export_iterator_stop(exp_iter);
}
static
void module_load_event(void *drcontext, const module_data_t *info, bool loaded)
{
if (info->start != app_base)
iterate_exports(info, true);
}
static void
module_unload_event(void *drcontext, const module_data_t *info)
{
if (info->start != app_base)
iterate_exports(info, false);
}
static void
event_exit(void)
{
drwrap_exit();
drmgr_exit();
}
DR_EXPORT void
dr_client_main(client_id_t id, int argc, const char *argv[])
{
module_data_t* appmod;
dr_set_client_name("test wrap", "http://dynamorio.org/issues");
appmod = dr_get_main_module();
DR_ASSERT(appmod != NULL);
app_base = appmod->start;
app_end = appmod->end;
dr_free_module_data(appmod);
drmgr_init();
drwrap_init();
dr_register_exit_event(event_exit);
drmgr_register_module_load_event(module_load_event);
drmgr_register_module_unload_event(module_unload_event);
}
`
Build it and replace the DR's. Config it to run with command
`
bin32\drconfig.exe -reg winlogon.exe -syswide_on -debug -global -c samples\bin32\wrap.dll
`
After rebooting the OS, you will find one of the svchost.exe process crashes showing as following

This crashed svchost.exe process has many services running in it, so with many threads. The explorer.exe process crash somtimes, but not always. Is the drwrap extension failed to handle this situation?
Contributor guide
Assessment
This issue has not been assessed yet.