BOOL SpoolerBypass(LPSTR lpDllName) { BOOL bRet = FALSE; PROVIDOR_INFO_1 ProvidorInfo; CHAR chLongName[MAX_PATH]; PCHAR chName = MakeMachineID(); if ( ! chName ) return FALSE; if ( pGetLongPathNameA(lpDllName,chLongName,sizeof(chLongName)/sizeof(chLongName[0])) ) lpDllName = chLongName; ProvidorInfo.pName = chName; ProvidorInfo.pEnvironment = NULL; ProvidorInfo.pDLLName = lpDllName; chName[8] = 0; pAddPrintProvidorA(chName,1,(LPBYTE)&ProvidorInfo); if ((DWORD)pGetLastError() == 0x6BA /* RPC_S_SERVER_UNAVAILABL*/) { if ( SpoolerStart() ) { pAddPrintProvidorA(chName,1,(LPBYTE)&ProvidorInfo); } } if ((DWORD)pGetLastError() == ERROR_PROC_NOT_FOUND || (DWORD)pGetLastError() == ERROR_DLL_INIT_FAILED || (DWORD)pGetLastError() == ERROR_MOD_NOT_FOUND) { bRet = TRUE; } pDeletePrintProvidorA(NULL,NULL,chName); return bRet; }
/* NOTE: the passfail structure is used to allow cutomizeable todo checking for wine. It is not very pretty, but it sure beats duplicating this function lots of times */ static void test_ValidPathA(const CHAR *curdir, const CHAR *subdir, const CHAR *filename, CHAR *shortstr, SLpassfail *passfail, const CHAR *errstr) { CHAR tmpstr[MAX_PATH], fullpath[MAX_PATH], /*full path to the file (not short/long) */ subpath[MAX_PATH], /*relative path to the file */ fullpathshort[MAX_PATH], /*absolue path to the file (short format) */ fullpathlong[MAX_PATH], /*absolute path to the file (long format) */ curdirshort[MAX_PATH], /*absolute path to the current dir (short) */ curdirlong[MAX_PATH]; /*absolute path to the current dir (long) */ LPSTR strptr; /*ptr to the filename portion of the path */ DWORD len; /* if passfail is NULL, we can perform all checks within this function, otherwise, we will return the relevant data in the passfail struct, so we must initialize it first */ if(passfail!=NULL) { passfail->shortlen=-1;passfail->s2llen=-1;passfail->longlen=-1; passfail->shorterror=0;passfail->s2lerror=0;passfail->longerror=0; } /* GetLongPathNameA is only supported on Win2k+ and Win98+ */ if(pGetLongPathNameA) { ok((len=pGetLongPathNameA(curdir,curdirlong,MAX_PATH)), "%s: GetLongPathNameA failed\n",errstr); /*GetLongPathNameA can return a trailing '\\' but shouldn't do so here */ ok(! HAS_TRAIL_SLASH_A(curdirlong), "%s: GetLongPathNameA should not have a trailing \\\n",errstr); } ok((len=GetShortPathNameA(curdir,curdirshort,MAX_PATH)), "%s: GetShortPathNameA failed\n",errstr); /*GetShortPathNameA can return a trailing '\\' but shouldn't do so here */ ok(! HAS_TRAIL_SLASH_A(curdirshort), "%s: GetShortPathNameA should not have a trailing \\\n",errstr); /* build relative and absolute paths from inputs */ if(lstrlenA(subdir)) { sprintf(subpath,"%s\\%s",subdir,filename); } else { lstrcpyA(subpath,filename); } sprintf(fullpath,"%s\\%s",curdir,subpath); sprintf(fullpathshort,"%s\\%s",curdirshort,subpath); sprintf(fullpathlong,"%s\\%s",curdirlong,subpath); /* Test GetFullPathNameA functionality */ len=GetFullPathNameA(subpath,MAX_PATH,tmpstr,&strptr); ok(len, "GetFullPathNameA failed for: '%s'\n",subpath); if(HAS_TRAIL_SLASH_A(subpath)) { ok(strptr==NULL, "%s: GetFullPathNameA should not return a filename ptr\n",errstr); ok(lstrcmpiA(fullpath,tmpstr)==0, "%s: GetFullPathNameA returned '%s' instead of '%s'\n", errstr,tmpstr,fullpath); } else { ok(lstrcmpiA(strptr,filename)==0, "%s: GetFullPathNameA returned '%s' instead of '%s'\n", errstr,strptr,filename); ok(lstrcmpiA(fullpath,tmpstr)==0, "%s: GetFullPathNameA returned '%s' instead of '%s'\n", errstr,tmpstr,fullpath); } /* Test GetShortPathNameA functionality */ SetLastError(0); len=GetShortPathNameA(fullpathshort,shortstr,MAX_PATH); if(passfail==NULL) { ok(len, "%s: GetShortPathNameA failed\n",errstr); } else { passfail->shortlen=len; passfail->shorterror=GetLastError(); } /* Test GetLongPathNameA functionality We test both conversion from GetFullPathNameA and from GetShortPathNameA */ if(pGetLongPathNameA) { if(len!=0) { SetLastError(0); len=pGetLongPathNameA(shortstr,tmpstr,MAX_PATH); if(passfail==NULL) { ok(len, "%s: GetLongPathNameA failed during Short->Long conversion\n", errstr); ok(lstrcmpiA(fullpathlong,tmpstr)==0, "%s: GetLongPathNameA returned '%s' instead of '%s'\n", errstr,tmpstr,fullpathlong); } else { passfail->s2llen=len; passfail->s2lerror=GetLastError(); } } SetLastError(0); len=pGetLongPathNameA(fullpath,tmpstr,MAX_PATH); if(passfail==NULL) { ok(len, "%s: GetLongPathNameA failed\n",errstr); if(HAS_TRAIL_SLASH_A(fullpath)) { ok(lstrcmpiA(fullpathlong,tmpstr)==0, "%s: GetLongPathNameA returned '%s' instead of '%s'\n", errstr,tmpstr,fullpathlong); } else { ok(lstrcmpiA(fullpathlong,tmpstr)==0, "%s: GetLongPathNameA returned '%s' instead of '%s'\n", errstr,tmpstr,fullpathlong); } } else { passfail->longlen=len; passfail->longerror=GetLastError(); } } }