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