Annotation of parser3/src/targets/isapi/parser3isapi.C, revision 1.92.8.2
1.29 paf 1: /** @file
2: Parser: IIS extension.
3:
1.92.8.1 paf 4: Copyright (c) 2000,2001-2005 ArtLebedev Group (http://www.artlebedev.com)
1.63 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.77 paf 6: */
1.29 paf 7:
1.92.8.2! paf 8: static const char * const IDENT_PARSER3ISAPI_C="$Date: 2005/08/05 13:03:03 $";
1.29 paf 9:
1.1 paf 10: #ifndef _MSC_VER
1.10 paf 11: # error compile ISAPI module with MSVC [no urge for now to make it autoconf-ed (PAF)]
1.1 paf 12: #endif
1.43 parser 13:
14: #include "pa_config_includes.h"
1.1 paf 15:
1.9 paf 16: #include "pa_sapi.h"
1.1 paf 17: #include "pa_globals.h"
18: #include "pa_request.h"
19: #include "pa_version.h"
1.24 paf 20: #include "pa_socks.h"
1.1 paf 21:
1.64 paf 22: #include <windows.h>
23: #include <process.h>
24:
25: #include <httpext.h>
1.51 parser 26:
1.92 paf 27: // defines
28:
29: #if _MSC_VER && !defined(_DEBUG)
30: # define PA_SUPPRESS_SYSTEM_EXCEPTION
31: #endif
32:
33:
1.1 paf 34: #define MAX_STATUS_LENGTH sizeof("xxxx LONGEST STATUS DESCRIPTION")
1.44 parser 35:
36: // consts
1.1 paf 37:
1.83 paf 38: const char* IIS51vars[]={
1.73 paf 39: "APPL_MD_PATH", "APPL_PHYSICAL_PATH",
40: "AUTH_PASSWORD", "AUTH_TYPE", "AUTH_USER",
41: "CERT_COOKIE", "CERT_FLAGS", "CERT_ISSUER", "CERT_KEYSIZE", "CERT_SECRETKEYSIZE",
42: "CERT_SERIALNUMBER", "CERT_SERVER_ISSUER", "CERT_SERVER_SUBJECT", "CERT_SUBJECT",
43: "CONTENT_LENGTH", "CONTENT_TYPE",
44: "LOGON_USER",
45: "HTTPS", "HTTPS_KEYSIZE", "HTTPS_SECRETKEYSIZE", "HTTPS_SERVER_ISSUER", "HTTPS_SERVER_SUBJECT",
46: "INSTANCE_ID", "INSTANCE_META_PATH",
47: "PATH_INFO", "PATH_TRANSLATED",
48: "QUERY_STRING",
49: "REMOTE_ADDR", "REMOTE_HOST", "REMOTE_USER", "REQUEST_METHOD",
50: "SCRIPT_NAME",
51: "SERVER_NAME", "SERVER_PORT", "SERVER_PORT_SECURE", "SERVER_PROTOCOL", "SERVER_SOFTWARE",
52: "URL",
53: };
54: const int IIS51var_count=sizeof(IIS51vars)/sizeof(*IIS51vars);
55:
1.65 paf 56: // globals
57:
1.92.8.2! paf 58: char argv0buf[MAX_STRING]="";
! 59: const char* argv0;
1.65 paf 60:
1.18 paf 61: // SAPI
62:
1.38 parser 63: #ifndef DOXYGEN
64: /*
1.18 paf 65: ISAPI SAPI functions receive this context information.
1.38 parser 66: see Pool::set_context
1.18 paf 67: */
1.83 paf 68: class SAPI_Info {
69: public:
1.3 paf 70: LPEXTENSION_CONTROL_BLOCK lpECB;
71: String *header;
72: DWORD http_response_code;
73: };
1.38 parser 74: #endif
1.3 paf 75:
1.26 paf 76: // goes to 'cs-uri-query' log file field. webmaster: switch it ON[default OFF].
1.83 paf 77: void SAPI::log(SAPI_Info& SAPI_info, const char* fmt, ...) {
1.26 paf 78: va_list args;
79: va_start(args,fmt);
80: char buf[MAX_STRING];
1.83 paf 81: const char* prefix="PARSER_ERROR:";
1.26 paf 82: strcpy(buf, prefix);
1.47 parser 83: char *start=buf+strlen(prefix);
1.51 parser 84: DWORD size=vsnprintf(start, MAX_STRING-strlen(prefix), fmt, args);
1.47 parser 85: remove_crlf(start, start+size);
86:
1.83 paf 87: SAPI_info.lpECB->ServerSupportFunction(SAPI_info.lpECB->ConnID,
1.26 paf 88: HSE_APPEND_LOG_PARAMETER, buf, &size, 0);
1.55 parser 89: }
90:
91: /// @todo event log
1.85 paf 92: static void abort(const char* fmt, va_list args) {
1.83 paf 93: if(FILE *log=fopen("c:\\parser3die.log", "at")) {
1.65 paf 94: vfprintf(log, fmt, args);
95: fclose(log);
96: }
1.81 paf 97: // exit & try to produce core dump
98: abort();
1.26 paf 99: }
1.83 paf 100: void SAPI::die(const char* fmt, ...) {
101: va_list args;
102: va_start(args, fmt);
1.85 paf 103: ::abort(fmt, args);
1.90 paf 104: // va_end(args);
1.83 paf 105: }
1.26 paf 106:
1.83 paf 107: void SAPI::abort(const char* fmt, ...) {
108: va_list args;
109: va_start(args, fmt);
1.85 paf 110: ::abort(fmt, args);
1.90 paf 111: // va_end(args);
1.83 paf 112: }
1.1 paf 113:
1.83 paf 114: char* SAPI::get_env(SAPI_Info& SAPI_info, const char* name) {
115: char *variable_buf=new(PointerFreeGC) char[MAX_STRING];
1.1 paf 116: DWORD variable_len = MAX_STRING-1;
117:
1.83 paf 118: if(SAPI_info.lpECB->GetServerVariable(SAPI_info.lpECB->ConnID, const_cast<char *>(name),
1.1 paf 119: variable_buf, &variable_len)) {
1.73 paf 120: if(*variable_buf) { // saw returning len=1 && *buf=0 :(
121: variable_buf[variable_len]=0;
122: return variable_buf;
123: }
1.7 paf 124: } else if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) {
1.83 paf 125: variable_buf=new(PointerFreeGC) char[variable_len+1];
1.7 paf 126:
1.83 paf 127: if(SAPI_info.lpECB->GetServerVariable(SAPI_info.lpECB->ConnID, const_cast<char *>(name),
1.7 paf 128: variable_buf, &variable_len)) {
1.73 paf 129: if(*variable_buf) {
130: variable_buf[variable_len]=0;
131: return variable_buf;
132: }
1.7 paf 133: }
1.1 paf 134: }
1.7 paf 135:
1.1 paf 136: return 0;
137: }
138:
1.83 paf 139: static int grep_char(const char* s, char c) {
1.72 paf 140: int result=0;
141: if(s) {
142: while(s=strchr(s, c)) {
143: s++; // skip found c
144: result++;
145: }
146: }
147: return result;
148: }
1.83 paf 149: static const char* mk_env_pair(const char* key, const char* value) {
150: char *result=new(PointerFreeGC) char[strlen(key)+1/*=*/+strlen(value)+1/*0*/];
1.72 paf 151: strcpy(result, key); strcat(result, "="); strcat(result, value);
152: return result;
153: }
1.83 paf 154: const char* const *SAPI::environment(SAPI_Info& info) {
1.72 paf 155: // we know this buf is writable
1.83 paf 156: char* all_http_vars=SAPI::get_env(info, "ALL_HTTP");
1.72 paf 157: const int http_var_count=grep_char(all_http_vars, '\n')+1/*\n for theoretical(never saw) this \0*/;
1.90 paf 158:
1.92 paf 159: const char* *result=new(PointerFreeGC) const char*[IIS51var_count+http_var_count+1/*0*/];
1.83 paf 160: const char* *cur=result;
1.72 paf 161:
162: // IIS5.1 vars
163: for(int i=0; i<IIS51var_count; i++) {
1.83 paf 164: const char* key=IIS51vars[i];
165: if(const char* value=SAPI::get_env(info, key))
166: *cur++=mk_env_pair(key, value);
1.72 paf 167: }
168:
169: // HTTP_* vars
170: if(char *s=all_http_vars) {
171: while(char *key=lsplit(&s, '\n'))
172: if(char *value=lsplit(key, ':'))
1.83 paf 173: *cur++=mk_env_pair(key, value);
1.72 paf 174: }
175:
176: // mark EOE
177: *cur=0;
178:
179: return result;
180: }
181:
1.83 paf 182: size_t SAPI::read_post(SAPI_Info& SAPI_info, char *buf, size_t max_bytes) {
1.1 paf 183: DWORD read_from_buf=0;
184: DWORD read_from_input=0;
185: DWORD total_read=0;
186:
1.83 paf 187: read_from_buf=min(SAPI_info.lpECB->cbAvailable, max_bytes);
188: memcpy(buf, SAPI_info.lpECB->lpbData, read_from_buf);
1.1 paf 189: total_read+=read_from_buf;
190:
191: if(read_from_buf<max_bytes &&
1.83 paf 192: read_from_buf<SAPI_info.lpECB->cbTotalBytes) {
1.1 paf 193: DWORD cbRead=0, cbSize;
194:
1.3 paf 195: read_from_input=min(max_bytes-read_from_buf,
1.83 paf 196: SAPI_info.lpECB->cbTotalBytes-read_from_buf);
1.1 paf 197: while(cbRead < read_from_input) {
198: cbSize=read_from_input - cbRead;
1.83 paf 199: if(!SAPI_info.lpECB->ReadClient(SAPI_info.lpECB->ConnID,
1.3 paf 200: buf+read_from_buf+cbRead, &cbSize) ||
1.1 paf 201: cbSize==0)
202: break;
203: cbRead+=cbSize;
204: }
205: total_read+=cbRead;
206: }
207: return total_read;
208: }
209:
1.83 paf 210: void SAPI::add_header_attribute(SAPI_Info& SAPI_info,
211: const char* dont_store_key, const char* dont_store_value) {
212: if(strcasecmp(dont_store_key, "location")==0)
213: SAPI_info.http_response_code=302;
214:
215: if(strcasecmp(dont_store_key, "status")==0)
216: SAPI_info.http_response_code=atoi(dont_store_value);
217: else
218: (*SAPI_info.header) << pa_strdup(dont_store_key) << ": " << pa_strdup(dont_store_value) << "\r\n";
1.1 paf 219: }
220:
1.23 paf 221: /// @todo intelligent cache-control
1.83 paf 222: void SAPI::send_header(SAPI_Info& SAPI_info) {
1.64 paf 223: HSE_SEND_HEADER_EX_INFO header_info;
1.1 paf 224:
225: char status_buf[MAX_STATUS_LENGTH];
1.83 paf 226: switch(SAPI_info.http_response_code) {
1.1 paf 227: case 200:
228: header_info.pszStatus="200 OK";
229: break;
230: case 302:
231: header_info.pszStatus="302 Moved Temporarily";
232: break;
1.8 paf 233: case 401:// useless untill parser auth mech
1.1 paf 234: header_info.pszStatus="401 Authorization Required";
1.8 paf 235: break;
1.1 paf 236: default:
1.3 paf 237: snprintf(status_buf, MAX_STATUS_LENGTH,
1.83 paf 238: "%d Undescribed", SAPI_info.http_response_code);
1.1 paf 239: header_info.pszStatus=status_buf;
240: break;
241: }
242: header_info.cchStatus=strlen(header_info.pszStatus);
1.83 paf 243: *SAPI_info.header << "\r\n"; // ISAPI v<5 did quite well without it
244: header_info.pszHeader=SAPI_info.header->cstr();
245: header_info.cchHeader=SAPI_info.header->length();
1.5 paf 246: header_info.fKeepConn=true;
1.1 paf 247:
1.83 paf 248: SAPI_info.lpECB->dwHttpStatusCode=SAPI_info.http_response_code;
1.1 paf 249:
1.83 paf 250: SAPI_info.lpECB->ServerSupportFunction(SAPI_info.lpECB->ConnID,
1.3 paf 251: HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL);
1.1 paf 252: }
253:
1.91 paf 254: size_t SAPI::send_body(SAPI_Info& SAPI_info, const void *buf, size_t size) {
1.1 paf 255: DWORD num_bytes=size;
1.91 paf 256: if(!SAPI_info.lpECB->WriteClient(SAPI_info.lpECB->ConnID,
257: const_cast<void *>(buf), &num_bytes, HSE_IO_SYNC))
258: return 0;
259: return (size_t)num_bytes;
1.1 paf 260: }
1.16 paf 261:
1.1 paf 262:
1.15 paf 263: static bool parser_init() {
1.1 paf 264: static bool globals_inited=false;
265: if(globals_inited)
1.15 paf 266: return true;
1.1 paf 267: globals_inited=true;
268:
1.53 parser 269: try {
1.27 paf 270: // init socks
1.89 paf 271: pa_socks_init();
1.1 paf 272: // init global variables
1.83 paf 273: pa_globals_init();
1.65 paf 274:
1.15 paf 275: // successful finish
276: return true;
1.53 parser 277: } catch(const Exception& e) { // global problem
1.85 paf 278: //const char* body=e.comment();
1.15 paf 279:
280: // unsuccessful finish
281: return false;
1.1 paf 282: }
283: }
284:
1.89 paf 285: static void parser_done() {
286: // finalize global variables
287: pa_globals_done();
288:
289: //
290: pa_socks_done();
291: }
292:
1.1 paf 293: /// ISAPI //
294: BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer) {
295: pVer->dwExtensionVersion = HSE_VERSION;
1.36 parser 296: strncpy(pVer->lpszExtensionDesc, "Parser "PARSER_VERSION, HSE_MAX_EXT_DLL_NAME_LEN-1);
297: pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1]=0;
1.15 paf 298: return parser_init();
1.89 paf 299: }
300: // dwFlags & HSE_TERM_MUST_UNLOAD means we can't return false
301: BOOL WINAPI TerminateExtension(
302: DWORD /*dwFlags*/
303: )
304: {
305: parser_done();
306:
307: return TRUE;
1.1 paf 308: }
309:
1.6 paf 310: /**
311: ISAPI // main workhorse
312:
1.23 paf 313: @todo
1.10 paf 314: IIS: remove trailing default-document[index.html] from $request.uri.
315: to do that we need to consult metabase,
1.12 paf 316: wich is tested&works but seems slow runtime
317: and not could-be-quickly-implemented if prepared.
1.37 parser 318: @test
319: PARSER_VERSION from outside
1.6 paf 320: */
1.53 parser 321:
1.83 paf 322: void real_parser_handler(SAPI_Info& SAPI_info, bool header_only) {
1.88 paf 323: // collect garbage from prev request
324: #ifndef PA_DEBUG_DISABLE_GC
325: {
326: int saved=GC_dont_gc;
327: GC_dont_gc=0;
328: GC_gcollect();
329: GC_dont_gc=saved;
330: }
331: #endif
332:
1.83 paf 333: SAPI_info.header=new String;
334: LPEXTENSION_CONTROL_BLOCK lpECB=SAPI_info.lpECB;
1.53 parser 335:
336: // Request info
1.83 paf 337: Request_info request_info; memset(&request_info, 0, sizeof(request_info));
1.53 parser 338:
339: size_t path_translated_buf_size=strlen(lpECB->lpszPathTranslated)+1;
1.83 paf 340: char *filespec_to_process=pa_strdup(lpECB->lpszPathTranslated, path_translated_buf_size);
1.53 parser 341: #ifdef WIN32
342: back_slashes_to_slashes(filespec_to_process);
343: #endif
344:
1.83 paf 345: if(const char* path_info=SAPI::get_env(SAPI_info, "PATH_INFO")) {
1.53 parser 346: // IIS
347: size_t len=strlen(filespec_to_process)-strlen(path_info);
1.83 paf 348: char *buf=new(PointerFreeGC) char[len+1];
1.53 parser 349: strncpy(buf, filespec_to_process, len); buf[len]=0;
350: request_info.document_root=buf;
351: } else
1.67 paf 352: throw Exception("parser.runtime",
1.53 parser 353: 0,
354: "ISAPI: no PATH_INFO defined (in reinventing DOCUMENT_ROOT)");
355:
356: request_info.path_translated=filespec_to_process;
357: request_info.method=lpECB->lpszMethod;
358: request_info.query_string=lpECB->lpszQueryString;
359: if(lpECB->lpszQueryString && *lpECB->lpszQueryString) {
1.83 paf 360: char *reconstructed_uri=new(PointerFreeGC) char[
1.53 parser 361: strlen(lpECB->lpszPathInfo)+1/*'?'*/+
1.83 paf 362: strlen(lpECB->lpszQueryString)+1/*0*/];
1.53 parser 363: strcpy(reconstructed_uri, lpECB->lpszPathInfo);
364: strcat(reconstructed_uri, "?");
365: strcat(reconstructed_uri, lpECB->lpszQueryString);
366: request_info.uri=reconstructed_uri;
367: } else
368: request_info.uri=lpECB->lpszPathInfo;
369:
370: request_info.content_type=lpECB->lpszContentType;
371: request_info.content_length=lpECB->cbTotalBytes;
1.83 paf 372: request_info.cookie=SAPI::get_env(SAPI_info, "HTTP_COOKIE");
1.76 paf 373: request_info.mail_received=false;
1.53 parser 374:
375: // prepare to process request
1.83 paf 376: Request request(SAPI_info,
1.53 parser 377: request_info,
1.83 paf 378: String::Language(String::L_HTML|String::L_OPTIMIZE_BIT),
379: true /* status_allowed */);
1.53 parser 380:
1.65 paf 381: // beside by binary
1.75 paf 382: static char beside_binary_path[MAX_STRING];
383: strncpy(beside_binary_path, argv0, MAX_STRING-1); beside_binary_path[MAX_STRING-1]=0; // filespec of my binary
1.65 paf 384: if(!(
1.75 paf 385: rsplit(beside_binary_path, '/') ||
386: rsplit(beside_binary_path, '\\'))) { // strip filename
1.65 paf 387: // no path, just filename
1.75 paf 388: beside_binary_path[0]='.'; beside_binary_path[1]=0;
1.65 paf 389: }
1.74 paf 390: char config_filespec[MAX_STRING];
391: snprintf(config_filespec, MAX_STRING,
1.65 paf 392: "%s/%s",
1.75 paf 393: beside_binary_path, AUTO_FILE_NAME);
1.79 paf 394: bool fail_on_config_read_problem=entry_exists(config_filespec);
1.65 paf 395:
1.53 parser 396: // process the request
397: request.core(
1.79 paf 398: config_filespec, fail_on_config_read_problem, // /path/to/first/auto.p
1.53 parser 399: header_only);
400: }
401:
1.92 paf 402: #ifdef PA_SUPPRESS_SYSTEM_EXCEPTION
403: static const Exception
404: call_real_parser_handler__do_PEH_return_it(
405: SAPI_Info& SAPI_info, bool header_only)
406: {
407: try {
408: real_parser_handler(SAPI_info, header_only);
409: } catch(const Exception& e) {
410: return e;
411: }
412:
413: return Exception();
414: }
415: static void call_real_parser_handler__supress_system_exception(
416: SAPI_Info& SAPI_info, bool header_only)
417: {
418: Exception parser_exception;
1.53 parser 419: LPEXCEPTION_POINTERS system_exception=0;
1.92 paf 420:
1.53 parser 421: __try {
1.92 paf 422: parser_exception=call_real_parser_handler__do_PEH_return_it(
423: SAPI_info, header_only);
1.53 parser 424: } __except (
425: (system_exception=GetExceptionInformation()),
1.92 paf 426: EXCEPTION_EXECUTE_HANDLER)
427: {
428:
1.53 parser 429: if(system_exception)
430: if(_EXCEPTION_RECORD *er=system_exception->ExceptionRecord)
1.92 paf 431: throw Exception("system",
432: 0,
433: "0x%08X at 0x%08X", er->ExceptionCode, er->ExceptionAddress);
1.53 parser 434: else
1.92 paf 435: throw Exception("system",
436: 0,
437: "<no exception record>");
438: else
439: throw Exception("system",
440: 0,
441: "<no exception information>");
1.53 parser 442: }
1.92 paf 443:
444: if(parser_exception)
445: throw Exception(parser_exception);
446: }
1.53 parser 447: #endif
448:
1.83 paf 449: DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) {
450: //_asm int 3;
451: SAPI_Info SAPI_info={
1.15 paf 452: lpECB,
1.83 paf 453: 0, // filling later: so that if there would be error pool would have SAPI_info
1.80 paf 454: 200 // default http_response_code [lpECB->dwHttpStatusCode seems to be always 0, even on 404 redirect to /404.html]
1.15 paf 455: };
1.71 paf 456:
1.1 paf 457: bool header_only=strcasecmp(lpECB->lpszMethod, "HEAD")==0;
1.53 parser 458: try { // global try
1.92 paf 459: #ifdef PA_SUPPRESS_SYSTEM_EXCEPTION
460: call_real_parser_handler__supress_system_exception(
461: #else
462: real_parser_handler(
463: #endif
464: SAPI_info, header_only);
1.2 paf 465: // successful finish
1.53 parser 466: } catch(const Exception& e) { // global problem
1.12 paf 467: // don't allocate anything on pool here:
468: // possible pool' exception not catch-ed now
1.31 paf 469: // and there could be out-of-memory exception
1.83 paf 470: const char* body=e.comment();
1.16 paf 471: // log it
1.83 paf 472: SAPI::log(SAPI_info, "exception in request exception handler: %s", body);
1.16 paf 473:
474: //
1.1 paf 475: int content_length=strlen(body);
476:
1.12 paf 477: // prepare header // not using SAPI func wich allocates on pool
478: char header_buf[MAX_STRING];
479: int header_len=snprintf(header_buf, MAX_STRING,
1.30 paf 480: "content-type: text/plain\r\n"
1.86 paf 481: "content-length: %u\r\n"
1.69 paf 482: // "expires: Fri, 23 Mar 2001 09:32:23 GMT\r\n"
1.30 paf 483: "\r\n",
1.12 paf 484: content_length);
485:
486: HSE_SEND_HEADER_EX_INFO header_info;
487: header_info.pszStatus="200 OK";
488: header_info.cchStatus=strlen(header_info.pszStatus);
489: header_info.pszHeader=header_buf;
490: header_info.cchHeader=header_len;
491: header_info.fKeepConn=true;
492:
1.1 paf 493: // send header
1.12 paf 494: lpECB->dwHttpStatusCode=200;
495: lpECB->ServerSupportFunction(lpECB->ConnID,
496: HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL);
1.1 paf 497:
498: // send body
499: if(!header_only)
1.83 paf 500: SAPI::send_body(SAPI_info, body, content_length);
1.1 paf 501:
502: // unsuccessful finish
503: }
1.65 paf 504: /*
1.83 paf 505: const char* body="test";
1.65 paf 506:
507: //
508: int content_length=strlen(body);
509:
510: // prepare header // not using SAPI func wich allocates on pool
511: char header_buf[MAX_STRING];
512: int header_len=snprintf(header_buf, MAX_STRING,
513: "content-type: text/plain\r\n"
1.86 paf 514: "content-length: %u\r\n"
1.65 paf 515: "expires: Fri, 23 Mar 2001 09:32:23 GMT\r\n"
516: "\r\n",
517: content_length);
518: HSE_SEND_HEADER_EX_INFO header_info;
519: header_info.pszStatus="200 OK";
520: header_info.cchStatus=strlen(header_info.pszStatus);
521: header_info.pszHeader=header_buf;
522: header_info.cchHeader=header_len;
523: header_info.fKeepConn=true;
524:
525: // send header
526: lpECB->dwHttpStatusCode=200;
527: lpECB->ServerSupportFunction(lpECB->ConnID,
528: HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL);
529:
530: // send body
531: DWORD num_bytes=content_length;
532: lpECB->WriteClient(lpECB->ConnID,
533: (void *)body, &num_bytes, HSE_IO_SYNC);
534: */
1.71 paf 535: return HSE_STATUS_SUCCESS_AND_KEEP_CONN;
1.1 paf 536: }
1.65 paf 537:
538: BOOL WINAPI DllMain(
539: HINSTANCE hinstDLL, // handle to the DLL module
1.85 paf 540: DWORD /*fdwReason*/, // reason for calling function
541: LPVOID /*lpvReserved*/ // reserved
1.65 paf 542: ) {
543:
544: GetModuleFileName(
545: hinstDLL, // handle to module
1.92.8.2! paf 546: argv0buf, // file name of module
! 547: sizeof(argv0buf) // size of buffer
1.65 paf 548: );
1.92.8.2! paf 549:
! 550: argv0=argv0buf;
! 551: if(strncmp(argv0buf, "\\\\?\\", 4)==0)
! 552: argv0+=4;
1.65 paf 553:
554: return TRUE;
555: }
E-mail: