2 * Shell Ordinal Functions
4 * These are completely undocumented. The meaning of the functions changes
5 * between different OS versions (NT uses Unicode strings, 95 uses ASCII
8 * They are just here so that explorer.exe and iexplore.exe can be tested.
10 * Copyright 1997 Marcus Meissner
27 #include "cursoricon.h"
28 #include "interfaces.h"
34 /*************************************************************************
35 * SHELL32_2 [SHELL32.2]
37 DWORD WINAPI SHELL32_2(HWND32 hwnd,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6) {
38 fprintf(stderr,"SHELL32_2(0x%04x,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",
43 /*************************************************************************
44 * SHELL32_16 [SHELL32.16]
45 * find_lastitem_in_itemidlist()
47 LPSHITEMID WINAPI SHELL32_16(LPITEMIDLIST iil) {
48 LPSHITEMID lastsii,sii;
56 sii = (LPSHITEMID)(((char*)sii)+sii->cb);
60 /*************************************************************************
61 * SHELL32_29 [SHELL32.29]
62 * is_rootdir(const char*path)
64 BOOL32 WINAPI SHELL32_29(LPCSTR x) {
65 if (!lstrcmp32A(x+1,":\\")) /* "X:\" */
67 if (!lstrcmp32A(x,"\\")) /* "\" */
69 if (x[0]=='\\' && x[1]=='\\') { /* UNC "\\<xx>\" */
70 int foundbackslash = 0;
76 if (foundbackslash<=1) /* max 1 \ more ... */
82 /*************************************************************************
83 * SHELL32_30 [SHELL32.30]
84 * get_rootdir(char*path,int drive)
86 LPSTR WINAPI SHELL32_30(LPSTR root,BYTE drive) {
92 /*************************************************************************
93 * SHELL32_31 [SHELL32.31]
94 * returns pointer to last . in last pathcomponent or at \0.
96 LPSTR WINAPI SHELL32_31(LPSTR path) {
97 LPSTR lastpoint = NULL;
100 if (*path=='\\'||*path==' ')
106 return lastpoint?lastpoint:path;
109 /*************************************************************************
110 * SHELL32_32 [SHELL32.32]
111 * append \ if there is none
113 LPSTR WINAPI SHELL32_32(LPSTR path) {
116 len = lstrlen32A(path);
117 if (len && path[len-1]!='\\') {
125 /*************************************************************************
126 * SHELL32_33 [SHELL32.33]
127 * remove spaces from beginning and end of passed string
129 LPSTR WINAPI SHELL32_33(LPSTR str) {
146 /*************************************************************************
147 * SHELL32_34 [SHELL32.34]
148 * basename(char *fn);
150 LPSTR WINAPI SHELL32_34(LPSTR fn) {
155 if (((fn[0]=='\\') || (fn[0]==':')) && fn[1] && fn[1]!='\\')
162 /*************************************************************************
163 * SHELL32_35 [SHELL32.35]
164 * bool getpath(char *pathname); truncates passed argument to a valid path
165 * returns if the string was modified or not.
166 * "\foo\xx\foo"-> "\foo\xx"
170 DWORD WINAPI SHELL32_35(LPSTR fn) {
186 continue; /* already x++ed */
204 /*************************************************************************
205 * SHELL32_37 [SHELL32.37]
206 * concat_paths(char*target,const char*add);
207 * concats "target\\add" and writes them to target
209 LPSTR WINAPI SHELL32_37(LPSTR target,LPSTR x1,LPSTR x2) {
213 lstrcpy32A(target,x1);
217 SHELL32_32(buf); /* append \ if not there */
219 lstrcpy32A(target,buf);
223 /*************************************************************************
224 * SHELL32_36 [SHELL32.36]
225 * concat_paths(char*target,const char*add);
226 * concats "target\\add" and writes them to target
228 LPSTR WINAPI SHELL32_36(LPSTR x1,LPSTR x2) {
229 while (x2[0]=='\\') x2++;
230 return SHELL32_37(x1,x1,x2);
233 /*************************************************************************
234 * SHELL32_39 [SHELL32.39]
235 * isUNC(const char*path);
237 BOOL32 WINAPI SHELL32_39(LPCSTR path) {
238 if ((path[0]=='\\') && (path[1]=='\\'))
243 /*************************************************************************
244 * SHELL32_45 [SHELL32.45]
245 * file_exists(char *fn);
247 BOOL32 WINAPI SHELL32_45(LPSTR fn) {
248 if (GetFileAttributes32A(fn)==-1)
254 /*************************************************************************
255 * SHELL32_52 [SHELL32.52]
256 * look for next arg in string. handle "quoted" strings
257 * returns pointer to argument *AFTER* the space. Or to the \0.
259 LPSTR WINAPI SHELL32_52(LPSTR cmdline) {
260 BOOL32 qflag = FALSE;
263 if ((*cmdline==' ') && !qflag)
272 /*************************************************************************
273 * SHELL32_56 [SHELL32.56]
274 * unquote string (remove ")
276 VOID WINAPI SHELL32_56(LPSTR str) {
277 DWORD len = lstrlen32A(str);
279 if (*str!='"') return;
280 if (str[len-1]!='"') return;
282 lstrcpy32A(str,str+1);
286 /*************************************************************************
287 * SHELL32_58 [SHELL32.58]
289 DWORD WINAPI SHELL32_58(LPCSTR src,DWORD x2,LPSTR target,DWORD pathlen) {
290 fprintf(stderr,"SHELL32_58(%s,0x%08lx,%p,%ld),STUB!\n",
291 src,x2,target,pathlen
298 /*************************************************************************
299 * SHELL32_62 [SHELL32.62]
301 DWORD WINAPI SHELL32_62(DWORD x,DWORD y,DWORD z,DWORD a) {
302 fprintf(stderr,"SHELL32_62(%08lx,%08lx,%08lx,%08lx),stub!\n",x,y,z,a);
306 /*************************************************************************
307 * SHELL32_63 [SHELL32.63]
309 DWORD WINAPI SHELL32_63(HWND32 howner, LPSTR targetbuf, DWORD len, DWORD x, LPCSTR suffix, LPCSTR y, LPCSTR cmd) {
310 fprintf(stderr,"SHELL32_63(%04x,%p,%ld,%08lx,%s,%s,%s),stub!\n",
311 howner,targetbuf,len,x,suffix,y,cmd
313 /* puts up a Open Dialog and requests input into targetbuf */
314 /* OFN_HIDEREADONLY|OFN_NOCHANGEDIR|OFN_FILEMUSTEXIST|OFN_unknown */
315 lstrcpy32A(targetbuf,"x:\\s3.exe");
319 /*************************************************************************
320 * SHELL32_68 [SHELL32.68]
322 DWORD WINAPI SHELL32_68(DWORD x,DWORD y,DWORD z) {
323 fprintf(stderr,"SHELL32_68(0x%08lx,0x%08lx,0x%08lx),stub!\n",
328 /*************************************************************************
329 * SHELL32_71 [SHELL32.71]
330 * returns internal shell values in the passed pointers
332 BOOL32 WINAPI SHELL32_71(LPDWORD x,LPDWORD y) {
334 fprintf(stderr,"SHELL32_71(%p,%p),stub!\n",x,y);
338 /*************************************************************************
339 * SHELL32_72 [SHELL32.72]
340 * dunno. something with icons
342 void WINAPI SHELL32_72(LPSTR x,DWORD y,DWORD z) {
343 fprintf(stderr,"SHELL32_72(%s,%08lx,%08lx),stub!\n",x,y,z);
346 /*************************************************************************
347 * SHELL32_89 [SHELL32.89]
349 DWORD WINAPI SHELL32_89(DWORD x1,DWORD x2,DWORD x3) {
350 fprintf(stderr,"SHELL32_89(0x%08lx,0x%08lx,0x%08lx),stub!\n",
356 /*************************************************************************
357 * SHELL32_119 [SHELL32.119]
360 void WINAPI SHELL32_119(LPVOID x) {
361 fprintf(stderr,"SHELL32_119(%p(%s)),stub\n",x,(char *)x);
364 /*************************************************************************
365 * SHELL32_175 [SHELL32.175]
368 void WINAPI SHELL32_175(DWORD x1,DWORD x2,DWORD x3,DWORD x4) {
369 fprintf(stdnimp,"SHELL32_175(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",
374 /*************************************************************************
375 * SHELL32_181 [SHELL32.181]
378 void WINAPI SHELL32_181(DWORD x,DWORD y) {
379 fprintf(stderr,"SHELL32_181(0x%08lx,0x%08lx)\n",x,y);
382 /*************************************************************************
383 * SHELL32_75 [SHELL32.75]
386 BOOL32 WINAPI SHELL32_75(LPDWORD x,LPDWORD y) {
387 fprintf(stderr,"SHELL32_75(%p,%p),stub\n",x,y);
391 /*************************************************************************
392 * SHELL32_77 [SHELL32.77]
394 DWORD WINAPI SHELL32_77(DWORD x,DWORD y,DWORD z) {
395 fprintf(stderr,"SHELL32_77(%08lx,%08lx,%08lx),stub!\n",x,y,z);
399 /*************************************************************************
400 * SHELL32_79 [SHELL32.79]
401 * create_directory_and_notify(...)
403 DWORD WINAPI SHELL32_79(LPCSTR dir,LPVOID xvoid) {
404 fprintf(stderr,"mkdir %s,%p\n",dir,xvoid);
405 if (!CreateDirectory32A(dir,xvoid))
407 /* SHChangeNotify(8,1,dir,0); */
411 static FARPROC32 _find_moduleproc(LPSTR dllname,HMODULE32 *xhmod,LPSTR name) {
413 FARPROC32 dllunload,nameproc;
415 if (xhmod) *xhmod = 0;
416 if (!lstrcmpi32A(SHELL32_34(dllname),"shell32.dll"))
417 return (FARPROC32)SHELL32_DllGetClassObject;
419 hmod = LoadLibraryEx32A(dllname,0,LOAD_WITH_ALTERED_SEARCH_PATH);
422 dllunload = GetProcAddress32(hmod,"DllCanUnloadNow");
424 if (xhmod) *xhmod = hmod;
425 nameproc = GetProcAddress32(hmod,name);
430 /* register unloadable dll with unloadproc ... */
434 static DWORD _get_instance(REFCLSID clsid,LPSTR dllname,
435 LPVOID unknownouter,REFIID refiid,LPVOID inst
437 DWORD WINAPI (*dllgetclassob)(REFCLSID,REFIID,LPVOID);
440 LPCLASSFACTORY classfac;
443 dllgetclassob = (DWORD(*)(REFCLSID,REFIID,LPVOID))_find_moduleproc(dllname,NULL,"DllGetClassObject");
445 return 0x80070000|GetLastError();
448 hres = (*dllgetclassob)(clsid,(REFIID)&IID_IClassFactory,inst);
453 hres = (*dllgetclassob)(clsid,(REFIID)&IID_IClassFactory,&classfac);
456 classfac->lpvtbl->fnCreateInstance(classfac,unknownouter,refiid,inst);
457 classfac->lpvtbl->fnRelease(classfac);
461 /*************************************************************************
462 * SHELL32_102 [SHELL32.102]
465 LRESULT WINAPI SHELL32_102(
466 LPSTR aclsid,CLSID *clsid,LPUNKNOWN unknownouter,REFIID refiid,LPVOID inst
468 char buffer[256],xclsid[48],xiid[48],path[260],tmodel[100];
470 DWORD pathlen,type,tmodellen;
473 StringFromCLSID(refiid,xiid);
476 StringFromCLSID(clsid,xclsid);
480 strcpy(xclsid,aclsid);
482 fprintf(stderr,"SHELL32_102(%p,%s,%p,%s,%p)\n",
483 aclsid,xclsid,unknownouter,xiid,inst
486 sprintf(buffer,"CLSID\\%s\\InProcServer32",xclsid);
487 if (RegOpenKeyEx32A(HKEY_CLASSES_ROOT,buffer,0,0x02000000,&inprockey))
488 return _get_instance(clsid,"shell32.dll",unknownouter,refiid,inst);
489 pathlen=sizeof(path);
490 if (RegQueryValue32A(inprockey,NULL,path,&pathlen)) {
491 RegCloseKey(inprockey);
492 return _get_instance(clsid,"shell32.dll",unknownouter,refiid,inst);
494 fprintf(stderr," -> server dll is %s\n",path);
495 tmodellen=sizeof(tmodel);
497 if (RegQueryValueEx32A(inprockey,"ThreadingModel",NULL,&type,tmodel,&tmodellen)) {
498 RegCloseKey(inprockey);
499 return _get_instance(clsid,"shell32.dll",unknownouter,refiid,inst);
501 fprintf(stderr," -> threading model is %s\n",tmodel);
502 hres=_get_instance(clsid,path,unknownouter,refiid,inst);
504 hres=_get_instance(clsid,"shell32.dll",unknownouter,refiid,inst);
505 RegCloseKey(inprockey);
510 /*************************************************************************
511 * SHELL32_183 [SHELL32.183]
512 * Format and output errormessage.
514 void __cdecl SHELL32_183(HMODULE32 hmod,HWND32 hwnd,DWORD id,DWORD x,DWORD type,LPVOID arglist) {
515 char buf[100],buf2[100],*buf3;
516 LPVOID args = &arglist;
518 if (!LoadString32A(hmod,x,buf,100))
519 strcpy(buf,"Desktop");
520 LoadString32A(hmod,id,buf2,100);
521 /* FIXME: the varargs handling doesn't. */
522 FormatMessage32A(0x500,buf2,0,0,&buf3,256,&args);
524 fprintf(stderr,"SHELL32_183(%08lx,%08lx,%08lx(%s),%08lx(%s),%08lx,%p),stub!\n",
525 (DWORD)hmod,(DWORD)hwnd,id,buf2,x,buf,type,arglist
527 MessageBox32A(hwnd,buf3,buf,id|0x10000);
531 /*************************************************************************
532 * SHELL32_100 [SHELL32.100]
533 * walks through policy table, queries <app> key, <type> value, returns
534 * queried (DWORD) value.
535 * {0x00001,Explorer,NoRun}
536 * {0x00002,Explorer,NoClose}
537 * {0x00004,Explorer,NoSaveSettings}
538 * {0x00008,Explorer,NoFileMenu}
539 * {0x00010,Explorer,NoSetFolders}
540 * {0x00020,Explorer,NoSetTaskbar}
541 * {0x00040,Explorer,NoDesktop}
542 * {0x00080,Explorer,NoFind}
543 * {0x00100,Explorer,NoDrives}
544 * {0x00200,Explorer,NoDriveAutoRun}
545 * {0x00400,Explorer,NoDriveTypeAutoRun}
546 * {0x00800,Explorer,NoNetHood}
547 * {0x01000,Explorer,NoStartBanner}
548 * {0x02000,Explorer,RestrictRun}
549 * {0x04000,Explorer,NoPrinterTabs}
550 * {0x08000,Explorer,NoDeletePrinter}
551 * {0x10000,Explorer,NoAddPrinter}
552 * {0x20000,Explorer,NoStartMenuSubFolders}
553 * {0x40000,Explorer,MyDocsOnNet}
554 * {0x80000,WinOldApp,NoRealMode}
556 DWORD WINAPI SHELL32_100(DWORD pol) {
559 fprintf(stderr,"SHELL32_100(%08lx),stub!\n",pol);
560 if (RegOpenKey32A(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies",&xhkey))
562 /* FIXME: do nothing for now, just return 0 (== "allowed") */
568 /*************************************************************************
569 * SHELL32_152 [SHELL32.152]
572 DWORD WINAPI SHELL32_152(LPITEMIDLIST iil) {
580 si = (LPSHITEMID)(((char*)si)+si->cb);
585 /*************************************************************************
586 * SHELL32_158 [SHELL32.158]
588 LPSTR WINAPI SHELL32_158(LPSTR path,DWORD y,DWORD z) {
589 fprintf(stderr,"SHELL32_158(%s,%08lx,%08lx)\n",path,y,z);
590 path = SHELL32_31(path);
591 return *path?(path+1):path;
594 /*************************************************************************
595 * SHELL32_165 [SHELL32.165]
596 * create_path_and_notify(...)
598 DWORD WINAPI SHELL32_165(DWORD x,LPCSTR path) {
599 if (SHELL32_79(path,(LPVOID)x))
601 fprintf(stderr,"SHELL32_165(%08lx,%s),stub!\n",x,path);
605 /*************************************************************************
606 * SHELL32_195 [SHELL32.195]
607 * free_ptr() - frees memory using IMalloc
609 DWORD WINAPI SHELL32_195(LPVOID x) {
610 return LocalFree32((HANDLE32)x);
613 /*************************************************************************
614 * SHELL32_196 [SHELL32.196]
615 * void *task_alloc(DWORD len), uses SHMalloc allocator
617 LPVOID WINAPI SHELL32_196(DWORD len) {
618 return (LPVOID)LocalAlloc32(len,LMEM_ZEROINIT); /* FIXME */
621 /*************************************************************************
622 * SHELL32_18 [SHELL32.18]
625 LPITEMIDLIST WINAPI SHELL32_18(LPITEMIDLIST iil) {
629 len = SHELL32_152(iil);
630 newiil = (LPITEMIDLIST)SHELL32_196(len);
631 memcpy(newiil,iil,len);
635 /*************************************************************************
636 * SHELL32_25 [SHELL32.25]
639 LPITEMIDLIST WINAPI SHELL32_25(LPITEMIDLIST iil1,LPITEMIDLIST iil2) {
643 len1 = SHELL32_152(iil1)-2;
644 len2 = SHELL32_152(iil2);
645 newiil = SHELL32_196(len1+len2);
646 memcpy(newiil,iil1,len1);
647 memcpy(((char*)newiil)+len1,iil2,len2);
651 /*************************************************************************
652 * SHELL32_155 [SHELL32.155]
653 * free_check_ptr - frees memory (if not NULL) allocated by SHMalloc allocator
655 DWORD WINAPI SHELL32_155(LPVOID x) {
658 return SHELL32_195(x);