Skip to content

Commit f5c561a

Browse files
committed
Add connection proxying support (#276)
* Add connection proxying support This adds support for connection proxying. HTTP, SOCKS4 and SOCKS5 (with local and remote namem resolution) are supported. Authenticated proxy access is also possible. (cherry picked from commit 5e7e052)
1 parent 4f18b10 commit f5c561a

File tree

9 files changed

+1154
-643
lines changed

9 files changed

+1154
-643
lines changed

driver/connect.c

+119-5
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,37 @@ static SQLRETURN dbc_curl_init(esodbc_dbc_st *dbc)
583583
INFOH(dbc, "no username provided: auth disabled.");
584584
}
585585

586+
/* proxy parameters */
587+
if (dbc->proxy_url.cnt) {
588+
dbc->curl_err = curl_easy_setopt(curl, CURLOPT_PROXY,
589+
dbc->proxy_url.str);
590+
if (dbc->curl_err != CURLE_OK) {
591+
ERRH(dbc, "libcurl: failed to set the proxy URL.");
592+
goto err;
593+
}
594+
if (dbc->proxy_uid.cnt) {
595+
dbc->curl_err = curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME,
596+
dbc->proxy_uid.str);
597+
if (dbc->curl_err != CURLE_OK) {
598+
ERRH(dbc, "libcurl: failed to set the proxy username.");
599+
goto err;
600+
}
601+
if (dbc->proxy_pwd.cnt) {
602+
dbc->curl_err = curl_easy_setopt(curl, CURLOPT_PROXYPASSWORD,
603+
dbc->proxy_pwd.str);
604+
if (dbc->curl_err != CURLE_OK) {
605+
ERRH(dbc, "libcurl: failed to set the proxy password.");
606+
goto err;
607+
}
608+
}
609+
}
610+
} else {
611+
dbc->curl_err = curl_easy_setopt(curl, CURLOPT_PROXY, "");
612+
if (dbc->curl_err != CURLE_OK) {
613+
WARNH(dbc, "libcurl: failed to generally disable proxying.");
614+
}
615+
}
616+
586617
/* set the write call-back for answers */
587618
dbc->curl_err = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
588619
write_callback);
@@ -1130,7 +1161,7 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
11301161
const static wstr_st http_prefix = WSTR_INIT("http://");
11311162
const static wstr_st https_prefix = WSTR_INIT("https://");
11321163
wstr_st prefix;
1133-
int cnt, ipv6;
1164+
int cnt, ipv6, n;
11341165
SQLBIGINT secure, timeout, max_body_size, max_fetch_size, varchar_limit;
11351166
SQLWCHAR buff_url[ESODBC_MAX_URL_LEN];
11361167
wstr_st url = (wstr_st) {
@@ -1191,7 +1222,7 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
11911222

11921223
if (secure) {
11931224
if (! wstr_to_utf8(&attrs->ca_path, &dbc->ca_path)) {
1194-
ERRNH(dbc, "failed to convert CA path `" LWPDL "` to UTF8.",
1225+
ERRH(dbc, "failed to convert CA path `" LWPDL "` to UTF8.",
11951226
LWSTR(&attrs->ca_path));
11961227
SET_HDIAG(dbc, SQL_STATE_HY000, "reading the CA file path "
11971228
"failed", 0);
@@ -1222,7 +1253,7 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
12221253
url.cnt = (size_t)cnt;
12231254
}
12241255
if (! wstr_to_utf8(&url, &dbc->close_url)) {
1225-
ERRNH(dbc, "failed to convert URL `" LWPDL "` to UTF8.", LWSTR(&url));
1256+
ERRH(dbc, "failed to convert URL `" LWPDL "` to UTF8.", LWSTR(&url));
12261257
SET_HDIAG(dbc, SQL_STATE_HY000, "server SQL URL's UTF8 conversion "
12271258
"failed", 0);
12281259
goto err;
@@ -1233,7 +1264,7 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
12331264
* dup'ed since libcurl needs the 0 terminator */
12341265
url.cnt -= sizeof(ELASTIC_SQL_CLOSE_SUBPATH) - /*\0*/1;
12351266
if (! wstr_to_utf8(&url, &dbc->url)) {
1236-
ERRNH(dbc, "failed to convert URL `" LWPDL "` to UTF8.", LWSTR(&url));
1267+
ERRH(dbc, "failed to convert URL `" LWPDL "` to UTF8.", LWSTR(&url));
12371268
SET_HDIAG(dbc, SQL_STATE_HY000, "server SQL URL's UTF8 conversion "
12381269
"failed", 0);
12391270
goto err;
@@ -1258,7 +1289,7 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
12581289
url.cnt = (size_t)cnt;
12591290
}
12601291
if (! wstr_to_utf8(&url, &dbc->root_url)) {
1261-
ERRNH(dbc, "failed to convert URL `" LWPDL "` to UTF8.", LWSTR(&url));
1292+
ERRH(dbc, "failed to convert URL `" LWPDL "` to UTF8.", LWSTR(&url));
12621293
SET_HDIAG(dbc, SQL_STATE_HY000, "server root URL's UTF8 conversion "
12631294
"failed", 0);
12641295
goto err;
@@ -1312,6 +1343,74 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
13121343
dbc->timeout = (SQLUINTEGER)timeout;
13131344
INFOH(dbc, "timeout: %lu.", dbc->timeout);
13141345

1346+
/*
1347+
* proxy settings
1348+
*/
1349+
if (wstr2bool(&attrs->proxy_enabled)) {
1350+
ipv6 = wcsnstr(attrs->proxy_host.str, attrs->proxy_host.cnt, L':') !=
1351+
NULL;
1352+
cnt = swprintf(url.str, sizeof(buff_url)/sizeof(*buff_url),
1353+
L"" WPFWP_LDESC "://" WPFCP_DESC WPFWP_LDESC WPFCP_DESC,
1354+
LWSTR(&attrs->proxy_type),
1355+
ipv6 ? "[" : "", LWSTR(&attrs->proxy_host), ipv6 ? "]" : "");
1356+
if (cnt > 0 && attrs->proxy_port.cnt) {
1357+
n = swprintf(url.str + cnt,
1358+
sizeof(buff_url)/sizeof(*buff_url) - cnt,
1359+
L":" WPFWP_LDESC, LWSTR(&attrs->proxy_port));
1360+
} else {
1361+
n = 0;
1362+
}
1363+
if (cnt <= 0 || n < 0) {
1364+
ERRNH(dbc, "failed to print proxy URL out of type: `" LWPDL "`, "
1365+
"host: `" LWPDL "` and port: `" LWPDL "`.",
1366+
LWSTR(&attrs->proxy_type), LWSTR(&attrs->proxy_host),
1367+
LWSTR(&attrs->proxy_port));
1368+
SET_HDIAG(dbc, SQL_STATE_HY000, "printing proxy URL failed", 0);
1369+
goto err;
1370+
} else {
1371+
url.cnt = cnt + n;
1372+
}
1373+
if (! wstr_to_utf8(&url, &dbc->proxy_url)) {
1374+
ERRH(dbc, "failed to convert URL `" LWPDL "` to UTF8.",
1375+
LWSTR(&url));
1376+
SET_HDIAG(dbc, SQL_STATE_HY000, "proxy URL's UTF8 conversion "
1377+
"failed", 0);
1378+
goto err;
1379+
}
1380+
INFOH(dbc, "proxy URL: `%s`.", dbc->proxy_url.str);
1381+
1382+
if (wstr2bool(&attrs->proxy_auth_enabled)) {
1383+
if (attrs->proxy_auth_uid.cnt) {
1384+
if (! wstr_to_utf8(&attrs->proxy_auth_uid, &dbc->proxy_uid)) {
1385+
ERRH(dbc, "failed to convert proxy user ID `" LWPDL "` to"
1386+
" UTF8.", LWSTR(&attrs->proxy_auth_uid));
1387+
SET_HDIAG(dbc, SQL_STATE_HY000, "proxy UID's UTF8 "
1388+
"conversion failed", 0);
1389+
goto err;
1390+
}
1391+
INFOH(dbc, "proxy UID: `%s`.", dbc->proxy_uid.str);
1392+
1393+
if (attrs->proxy_auth_pwd.cnt) {
1394+
if (! wstr_to_utf8(&attrs->proxy_auth_pwd,
1395+
&dbc->proxy_pwd)) {
1396+
ERRH(dbc, "failed to convert proxy password [%zu] `%s`"
1397+
" to UTF8", attrs->proxy_auth_pwd.cnt,
1398+
ESODBC_PWD_VAL_SUBST);
1399+
SET_HDIAG(dbc, SQL_STATE_HY000, "proxy password's "
1400+
"UTF8 conversion failed", 0);
1401+
goto err;
1402+
}
1403+
/* indicates the presence of a non-empty password */
1404+
INFOH(dbc, "proxy PWD: " ESODBC_PWD_VAL_SUBST ".");
1405+
}
1406+
}
1407+
} else {
1408+
INFOH(dbc, "proxy authentication disabled.");
1409+
}
1410+
} else {
1411+
INFOH(dbc, "proxy disabled.");
1412+
}
1413+
13151414
/*
13161415
* set max body size
13171416
*/
@@ -1513,6 +1612,21 @@ void cleanup_dbc(esodbc_dbc_st *dbc)
15131612
} else {
15141613
assert(dbc->pwd.cnt == 0);
15151614
}
1615+
if (dbc->proxy_url.str) {
1616+
free(dbc->proxy_url.str);
1617+
dbc->proxy_url.str = NULL;
1618+
dbc->proxy_url.cnt = 0;
1619+
}
1620+
if (dbc->proxy_uid.str) {
1621+
free(dbc->proxy_uid.str);
1622+
dbc->proxy_uid.str = NULL;
1623+
dbc->proxy_uid.cnt = 0;
1624+
}
1625+
if (dbc->proxy_pwd.str) {
1626+
free(dbc->proxy_pwd.str);
1627+
dbc->proxy_pwd.str = NULL;
1628+
dbc->proxy_pwd.cnt = 0;
1629+
}
15161630
if (dbc->fetch.str) {
15171631
free(dbc->fetch.str);
15181632
dbc->fetch.str = NULL;

driver/defs.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
#define ESODBC_MAX_URL_LEN 2048
127127
/* maximum DNS attribute value length (should be long enought to accomodate a
128128
* decently long FQ file path name) */
129-
#define ESODBC_DSN_MAX_ATTR_LEN 1024
129+
#define ESODBC_DSN_MAX_ATTR_LEN 768
130130

131131
/* SQL plugin's REST endpoint for SQL */
132132
#define ELASTIC_SQL_PATH "/_sql"
@@ -167,7 +167,7 @@
167167
/* default global request timeout (0: no timeout) */
168168
#define ESODBC_DEF_TIMEOUT "0"
169169
/* don't follow redirection from the server */
170-
#define ESODBC_DEF_FOLLOW "yes"
170+
#define ESODBC_DEF_FOLLOW "true"
171171
/* packing of REST bodies (JSON or CBOR) */
172172
#define ESODBC_DEF_PACKING ESODBC_DSN_PACK_CBOR
173173
/* zlib compression of REST bodies (auto/true/false) */
@@ -177,16 +177,18 @@
177177
/* default tracing level */
178178
#define ESODBC_DEF_TRACE_LEVEL "WARN"
179179
/* default TZ handling */
180-
#define ESODBC_DEF_APPLY_TZ "no"
180+
#define ESODBC_DEF_APPLY_TZ "false"
181181
/* default early execution flag */
182-
#define ESODBC_DEF_EARLY_EXEC "yes"
182+
#define ESODBC_DEF_EARLY_EXEC "true"
183183
/* default of scientific floats printing */
184184
#define ESODBC_DEF_SCI_FLOATS ESODBC_DSN_FLTS_DEF
185185
#define ESODBC_PWD_VAL_SUBST "<redacted>"
186186
#define ESODBC_DEF_MFIELD_LENIENT "true"
187187
#define ESODBC_DEF_ESC_PVA "true"
188188
#define ESODBC_DEF_IDX_INC_FROZEN "false"
189189
#define ESODBC_DEF_VARCHAR_LIMIT "0"
190+
#define ESODBC_DEF_PROXY_ENABLED "false"
191+
#define ESODBC_DEF_PROXY_AUTH_ENA "false"
190192

191193
/*
192194
*

driver/dsn.c

+57
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ int assign_dsn_attr(esodbc_dsn_attrs_st *attrs,
8282
{&MK_WSTR(ESODBC_DSN_MFIELD_LENIENT), &attrs->mfield_lenient},
8383
{&MK_WSTR(ESODBC_DSN_ESC_PVA), &attrs->auto_esc_pva},
8484
{&MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN), &attrs->idx_inc_frozen},
85+
{&MK_WSTR(ESODBC_DSN_PROXY_ENABLED), &attrs->proxy_enabled},
86+
{&MK_WSTR(ESODBC_DSN_PROXY_TYPE), &attrs->proxy_type},
87+
{&MK_WSTR(ESODBC_DSN_PROXY_HOST), &attrs->proxy_host},
88+
{&MK_WSTR(ESODBC_DSN_PROXY_PORT), &attrs->proxy_port},
89+
{&MK_WSTR(ESODBC_DSN_PROXY_AUTH_ENA), &attrs->proxy_auth_enabled},
90+
{&MK_WSTR(ESODBC_DSN_PROXY_AUTH_UID), &attrs->proxy_auth_uid},
91+
{&MK_WSTR(ESODBC_DSN_PROXY_AUTH_PWD), &attrs->proxy_auth_pwd},
8592
{&MK_WSTR(ESODBC_DSN_TRACE_ENABLED), &attrs->trace_enabled},
8693
{&MK_WSTR(ESODBC_DSN_TRACE_FILE), &attrs->trace_file},
8794
{&MK_WSTR(ESODBC_DSN_TRACE_LEVEL), &attrs->trace_level},
@@ -418,6 +425,13 @@ long TEST_API write_00_list(esodbc_dsn_attrs_st *attrs,
418425
{&MK_WSTR(ESODBC_DSN_MFIELD_LENIENT), &attrs->mfield_lenient},
419426
{&MK_WSTR(ESODBC_DSN_ESC_PVA), &attrs->auto_esc_pva},
420427
{&MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN), &attrs->idx_inc_frozen},
428+
{&MK_WSTR(ESODBC_DSN_PROXY_ENABLED), &attrs->proxy_enabled},
429+
{&MK_WSTR(ESODBC_DSN_PROXY_TYPE), &attrs->proxy_type},
430+
{&MK_WSTR(ESODBC_DSN_PROXY_HOST), &attrs->proxy_host},
431+
{&MK_WSTR(ESODBC_DSN_PROXY_PORT), &attrs->proxy_port},
432+
{&MK_WSTR(ESODBC_DSN_PROXY_AUTH_ENA), &attrs->proxy_auth_enabled},
433+
{&MK_WSTR(ESODBC_DSN_PROXY_AUTH_UID), &attrs->proxy_auth_uid},
434+
{&MK_WSTR(ESODBC_DSN_PROXY_AUTH_PWD), &attrs->proxy_auth_pwd},
421435
{&MK_WSTR(ESODBC_DSN_TRACE_ENABLED), &attrs->trace_enabled},
422436
{&MK_WSTR(ESODBC_DSN_TRACE_FILE), &attrs->trace_file},
423437
{&MK_WSTR(ESODBC_DSN_TRACE_LEVEL), &attrs->trace_level},
@@ -704,6 +718,35 @@ BOOL write_system_dsn(esodbc_dsn_attrs_st *new_attrs,
704718
&new_attrs->idx_inc_frozen,
705719
old_attrs ? &old_attrs->idx_inc_frozen : NULL
706720
},
721+
{
722+
&MK_WSTR(ESODBC_DSN_PROXY_ENABLED), &new_attrs->proxy_enabled,
723+
old_attrs ? &old_attrs->proxy_enabled : NULL
724+
},
725+
{
726+
&MK_WSTR(ESODBC_DSN_PROXY_TYPE), &new_attrs->proxy_type,
727+
old_attrs ? &old_attrs->proxy_type : NULL
728+
},
729+
{
730+
&MK_WSTR(ESODBC_DSN_PROXY_HOST), &new_attrs->proxy_host,
731+
old_attrs ? &old_attrs->proxy_host : NULL
732+
},
733+
{
734+
&MK_WSTR(ESODBC_DSN_PROXY_PORT), &new_attrs->proxy_port,
735+
old_attrs ? &old_attrs->proxy_port : NULL
736+
},
737+
{
738+
&MK_WSTR(ESODBC_DSN_PROXY_AUTH_ENA),
739+
&new_attrs->proxy_auth_enabled,
740+
old_attrs ? &old_attrs->proxy_auth_enabled : NULL
741+
},
742+
{
743+
&MK_WSTR(ESODBC_DSN_PROXY_AUTH_UID), &new_attrs->proxy_auth_uid,
744+
old_attrs ? &old_attrs->proxy_auth_uid : NULL
745+
},
746+
{
747+
&MK_WSTR(ESODBC_DSN_PROXY_AUTH_PWD), &new_attrs->proxy_auth_pwd,
748+
old_attrs ? &old_attrs->proxy_auth_pwd : NULL
749+
},
707750
{
708751
&MK_WSTR(ESODBC_DSN_TRACE_ENABLED), &new_attrs->trace_enabled,
709752
old_attrs ? &old_attrs->trace_enabled : NULL
@@ -797,6 +840,13 @@ long TEST_API write_connection_string(esodbc_dsn_attrs_st *attrs,
797840
{&attrs->mfield_lenient, &MK_WSTR(ESODBC_DSN_MFIELD_LENIENT)},
798841
{&attrs->auto_esc_pva, &MK_WSTR(ESODBC_DSN_ESC_PVA)},
799842
{&attrs->idx_inc_frozen, &MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN)},
843+
{&attrs->proxy_enabled, &MK_WSTR(ESODBC_DSN_PROXY_ENABLED)},
844+
{&attrs->proxy_type, &MK_WSTR(ESODBC_DSN_PROXY_TYPE)},
845+
{&attrs->proxy_host, &MK_WSTR(ESODBC_DSN_PROXY_HOST)},
846+
{&attrs->proxy_port, &MK_WSTR(ESODBC_DSN_PROXY_PORT)},
847+
{&attrs->proxy_auth_enabled, &MK_WSTR(ESODBC_DSN_PROXY_AUTH_ENA)},
848+
{&attrs->proxy_auth_uid, &MK_WSTR(ESODBC_DSN_PROXY_AUTH_UID)},
849+
{&attrs->proxy_auth_pwd, &MK_WSTR(ESODBC_DSN_PROXY_AUTH_PWD)},
800850
{&attrs->trace_enabled, &MK_WSTR(ESODBC_DSN_TRACE_ENABLED)},
801851
{&attrs->trace_file, &MK_WSTR(ESODBC_DSN_TRACE_FILE)},
802852
{&attrs->trace_level, &MK_WSTR(ESODBC_DSN_TRACE_LEVEL)},
@@ -909,6 +959,13 @@ void assign_dsn_defaults(esodbc_dsn_attrs_st *attrs)
909959
&MK_WSTR(ESODBC_DSN_IDX_INC_FROZEN),
910960
&MK_WSTR(ESODBC_DEF_IDX_INC_FROZEN), /*overwrite?*/FALSE);
911961

962+
res |= assign_dsn_attr(attrs,
963+
&MK_WSTR(ESODBC_DSN_PROXY_ENABLED),
964+
&MK_WSTR(ESODBC_DEF_PROXY_ENABLED), /*overwrite?*/FALSE);
965+
res |= assign_dsn_attr(attrs,
966+
&MK_WSTR(ESODBC_DSN_PROXY_AUTH_ENA),
967+
&MK_WSTR(ESODBC_DEF_PROXY_AUTH_ENA), /*overwrite?*/FALSE);
968+
912969
/* default: no trace file */
913970
res |= assign_dsn_attr(attrs,
914971
&MK_WSTR(ESODBC_DSN_TRACE_ENABLED),

driver/dsn.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
#define ESODBC_DSN_MFIELD_LENIENT "MultiFieldLenient"
4242
#define ESODBC_DSN_ESC_PVA "AutoEscapePVA"
4343
#define ESODBC_DSN_IDX_INC_FROZEN "IndexIncludeFrozen"
44+
#define ESODBC_DSN_PROXY_ENABLED "ProxyEnabled"
45+
#define ESODBC_DSN_PROXY_TYPE "ProxyType"
46+
#define ESODBC_DSN_PROXY_HOST "ProxyHost"
47+
#define ESODBC_DSN_PROXY_PORT "ProxyPort"
48+
#define ESODBC_DSN_PROXY_AUTH_ENA "ProxyAuthEnabled"
49+
#define ESODBC_DSN_PROXY_AUTH_UID "ProxyAuthUID"
50+
#define ESODBC_DSN_PROXY_AUTH_PWD "ProxyAuthPWD"
4451
#define ESODBC_DSN_TRACE_ENABLED "TraceEnabled"
4552
#define ESODBC_DSN_TRACE_FILE "TraceFile"
4653
#define ESODBC_DSN_TRACE_LEVEL "TraceLevel"
@@ -85,10 +92,18 @@ typedef struct {
8592
wstr_st mfield_lenient;
8693
wstr_st auto_esc_pva;
8794
wstr_st idx_inc_frozen;
95+
wstr_st proxy_enabled;
96+
wstr_st proxy_type;
97+
wstr_st proxy_host;
98+
wstr_st proxy_port;
99+
wstr_st proxy_auth_enabled;
100+
wstr_st proxy_auth_uid;
101+
wstr_st proxy_auth_pwd;
88102
wstr_st trace_enabled;
89103
wstr_st trace_file;
90104
wstr_st trace_level;
91-
#define ESODBC_DSN_ATTRS_COUNT 29
105+
#define ESODBC_DSN_ATTRS_COUNT 36
106+
92107
SQLWCHAR buff[ESODBC_DSN_ATTRS_COUNT * ESODBC_DSN_MAX_ATTR_LEN];
93108
/* DSN reading/writing functions are passed a SQLSMALLINT length param */
94109
#if SHRT_MAX < ESODBC_DSN_ATTRS_COUNT * ESODBC_DSN_MAX_ATTR_LEN

driver/handles.h

+5
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ typedef struct struct_dbc {
133133
wstr_st server; /* ~ name; requested with SQLGetInfo(SQL_SERVER_NAME) */
134134
wstr_st catalog; /* cached value; checked against if app setting it */
135135
wstr_st srv_ver; /* server version: SQLGetInfo(SQL_DBMS_VER) */
136+
137+
cstr_st proxy_url;
138+
cstr_st proxy_uid;
139+
cstr_st proxy_pwd;
136140
cstr_st url; /* SQL URL (posts) */
137141
cstr_st close_url; /* SQL close URL (posts) */
138142
cstr_st root_url; /* root URL (gets) */
@@ -145,6 +149,7 @@ typedef struct struct_dbc {
145149
ESODBC_SEC_MAX /* meta */
146150
} secure;
147151
cstr_st ca_path;
152+
148153
cstr_st uid;
149154
cstr_st pwd;
150155
SQLUINTEGER timeout;

driver/odbc.c

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ BOOL WINAPI DllMain(
6868
DWORD fdwReason, // reason for calling function
6969
LPVOID lpReserved) // reserved
7070
{
71+
SQLWCHAR path[MAX_PATH];
7172
// Perform actions based on the reason for calling.
7273
switch (fdwReason) {
7374
// Initialize once for each new process.
@@ -77,6 +78,10 @@ BOOL WINAPI DllMain(
7778
return FALSE;
7879
}
7980
INFO("process %u attached.", GetCurrentProcessId());
81+
if (GetModuleFileNameW(NULL, path, sizeof(path)/sizeof(*path))
82+
> 0) {
83+
INFO("process path: `" PFWP_DESC "`.", path);
84+
}
8085
break;
8186

8287
// Do thread-specific initialization.

driver/util.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ BOOL wstr2bool(wstr_st *val)
1919
case /*""*/0: return FALSE;
2020
case /*0*/1: return ! EQ_CASE_WSTR(val, &MK_WSTR("0"));
2121
case /*no*/2: return ! EQ_CASE_WSTR(val, &MK_WSTR("no"));
22-
case /*no*/3: return ! EQ_CASE_WSTR(val, &MK_WSTR("off"));
22+
case /*off*/3: return ! EQ_CASE_WSTR(val, &MK_WSTR("off"));
2323
case /*false*/5: return ! EQ_CASE_WSTR(val, &MK_WSTR("false"));
2424
}
2525
/*INDENT-ON*/

0 commit comments

Comments
 (0)