File: README.wine.md

package info (click to toggle)
aflplusplus 4.21c-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,496 kB
  • sloc: ansic: 110,361; cpp: 16,725; sh: 4,855; python: 3,793; makefile: 963; javascript: 515; java: 43; sql: 3; xml: 1
file content (23 lines) | stat: -rw-r--r-- 1,055 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# How to troubleshoot AFL++'s wine mode

## 1) Debugging

To turn on wine debugging, use the `WINEDEBUG` environment variable, e.g.,
`WINEDEBUG=+timestamp,+tid,+loaddll`.

## 2) LoadLibraryA workaround

The forked process fails to load libraries loaded via `LoadLibrary` if the load
happens after the entry point (error code: 87). To resolve this issue, one needs
to load any external libraries before the fork happens.

An early DLL load can be achieved by adding the DLL name into the `Import
Directory` in the PE file. Such an entry can be added manually in any PE editor.

Alternatively, one can generate a `.lib` file from the DLL exports and link them
together with the harness to create an entry in the `Import Directory`. Use
`dumpbin /exports <filename>.dll` to extract the exports and paste the exported
function names into a `.def` file. Use `lib /def:<deffile> /OUT:<libfile>` to
generate a `.lib` and add the library to the linker options. Once the usage of
an export is detected (`__declspec(dllimport)`), the linker adds the early DLL
load.