#include <windows.h>#include <stdio.h>Include dependency graph for SetupAtlas.c:

Go to the source code of this file.
Defines | |
| #define | KeyCpuIdentifer "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0" |
| #define | LenLine 255 |
| #define | LogName "SetupAtlas.log" |
| #define | LineMaxSize 512 |
| #define | MaxCPU 64 |
| #define | DefaultDllName "ATLAS_PIII.DLL" |
| #define | ATLASSPEC "atlas.spec" |
| #define | PathAtlas "Atlas" |
| #define | PathAtlas "Atlas" |
| #define | AtlasFilename "atlas.dll" |
Functions | |
| char * | GetWhereIsThisExe (void) |
| BOOL | AppendMessageToLog (char *Message) |
| char * | GetRegKeyIdentifier (void) |
| char * | GetRegKeyVendorIdentifier (void) |
| BOOL | FileExist (char *filename) |
| BOOL | LoadArrayCPUFromFile (char *path) |
| char * | GetLocalCPU (void) |
| BOOL | GetInfoCPUfromLine (char *line, BOOL FromFile, char *Vendor, int *Family, int *Model, int *Step, char *DLLName) |
| char * | GetDLLFilenameAtlas (void) |
| BOOL | CopyAtlas (char *AtlasSourceFilename) |
| int WINAPI | WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) |
Variables | |
| char | ArrayLinesCPU [MaxCPU][LineMaxSize] |
| int | NbrLinesCPU = 0 |
| #define AtlasFilename "atlas.dll" |
Referenced by CopyAtlas().
| #define ATLASSPEC "atlas.spec" |
Referenced by LoadArrayCPUFromFile().
| #define DefaultDllName "ATLAS_PIII.DLL" |
| #define KeyCpuIdentifer "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0" |
Definition at line 9 of file SetupAtlas.c.
Referenced by GetRegKeyIdentifier(), and GetRegKeyVendorIdentifier().
| #define LenLine 255 |
Definition at line 10 of file SetupAtlas.c.
Referenced by CutLineForDisplay(), GetRegKeyIdentifier(), and GetRegKeyVendorIdentifier().
| #define LineMaxSize 512 |
Definition at line 12 of file SetupAtlas.c.
| #define LogName "SetupAtlas.log" |
| #define MaxCPU 64 |
| #define PathAtlas "Atlas" |
| #define PathAtlas "Atlas" |
Referenced by CopyAtlas().
| BOOL AppendMessageToLog | ( | char * | Message | ) |
Definition at line 21 of file SetupAtlas.c.
References FALSE, free(), GetWhereIsThisExe(), LogName, MAX_PATH, NULL, and TRUE.
Referenced by CopyAtlas(), GetDLLFilenameAtlas(), LoadArrayCPUFromFile(), and WinMain().
00022 { 00023 BOOL bOK=FALSE; 00024 FILE *pFile; 00025 char *Path=NULL; 00026 char PathAndFilename[MAX_PATH]; 00027 00028 Path=GetWhereIsThisExe(); 00029 wsprintf(PathAndFilename,"%s%s",Path,LogName); 00030 free(Path); 00031 Path=NULL; 00032 00033 pFile=fopen(PathAndFilename,"at"); 00034 if (pFile) 00035 { 00036 fprintf(pFile,"%s\n",Message); 00037 fclose(pFile); 00038 bOK=TRUE; 00039 } 00040 00041 return bOK; 00042 }
Here is the call graph for this function:

Here is the caller graph for this function:

| BOOL CopyAtlas | ( | char * | AtlasSourceFilename | ) |
Definition at line 316 of file SetupAtlas.c.
References AppendMessageToLog(), AtlasFilename, FALSE, FileExist(), free(), GetWhereIsThisExe(), malloc(), PathAtlas, and TRUE.
Referenced by WinMain().
00317 { 00318 #define PathAtlas "Atlas" 00319 #define AtlasFilename "atlas.dll" 00320 BOOL bOK=FALSE; 00321 char *PathOfThisExe=NULL; 00322 char *FullDestinationFilenameAtlas=NULL; 00323 char *FullSourceFilenameAtlas=NULL; 00324 00325 PathOfThisExe=GetWhereIsThisExe(); 00326 00327 FullSourceFilenameAtlas=malloc( sizeof(char) * (strlen(PathOfThisExe)+strlen(PathAtlas)+strlen(AtlasSourceFilename)+2) ); 00328 wsprintf(FullSourceFilenameAtlas,"%s%s\\%s",PathOfThisExe,PathAtlas,AtlasSourceFilename); 00329 AppendMessageToLog(FullSourceFilenameAtlas); 00330 00331 FullDestinationFilenameAtlas=malloc( sizeof(char) * (strlen(PathOfThisExe)+strlen(AtlasSourceFilename)+2) ); 00332 wsprintf(FullDestinationFilenameAtlas,"%s%s",PathOfThisExe,AtlasFilename); 00333 AppendMessageToLog(FullDestinationFilenameAtlas); 00334 00335 if ( FileExist(FullSourceFilenameAtlas) ) 00336 { 00337 if ( !CopyFile(FullSourceFilenameAtlas,FullDestinationFilenameAtlas,FALSE) ) 00338 { 00339 char msg[512]; 00340 00341 wsprintf(msg,"Impossible to copy %s.",FullDestinationFilenameAtlas); 00342 // MessageBox(NULL,msg,"Error",MB_ICONWARNING|MB_OK); 00343 AppendMessageToLog(msg); 00344 } 00345 else bOK=TRUE; 00346 } 00347 else 00348 { 00349 char msg[512]; 00350 wsprintf(msg,"File %s not found.",FullSourceFilenameAtlas); 00351 // MessageBox(NULL,msg,"Error",MB_ICONWARNING|MB_OK); 00352 AppendMessageToLog(msg); 00353 } 00354 00355 if (FullDestinationFilenameAtlas) 00356 { 00357 free(FullDestinationFilenameAtlas); 00358 FullDestinationFilenameAtlas=NULL; 00359 } 00360 00361 if (FullSourceFilenameAtlas) 00362 { 00363 free(FullSourceFilenameAtlas); 00364 FullSourceFilenameAtlas=NULL; 00365 } 00366 00367 free(PathOfThisExe); 00368 PathOfThisExe=NULL; 00369 00370 return bOK; 00371 }
Here is the call graph for this function:

Here is the caller graph for this function:

| BOOL FileExist | ( | char * | filename | ) |
Definition at line 114 of file SetupAtlas.c.
00115 { 00116 BOOL retour=FALSE; 00117 00118 WIN32_FIND_DATA FindFileData; 00119 HANDLE handle = FindFirstFile (filename, &FindFileData); 00120 if (handle != INVALID_HANDLE_VALUE) 00121 { 00122 FindClose (handle); 00123 retour=TRUE; 00124 } 00125 else retour=FALSE; 00126 00127 return retour; 00128 }
| char* GetDLLFilenameAtlas | ( | void | ) |
Definition at line 245 of file SetupAtlas.c.
References AppendMessageToLog(), ArrayLinesCPU, DefaultDllName, F, FALSE, free(), GetInfoCPUfromLine(), GetLocalCPU(), GetWhereIsThisExe(), i, LoadArrayCPUFromFile(), M, malloc(), NbrLinesCPU, S, and TRUE.
Referenced by WinMain().
00246 { 00247 #define PathAtlas "Atlas" 00248 char *PathOfThisExe=NULL; 00249 char *FilenameAtlasDLL=NULL; 00250 BOOL FindCPU=FALSE; 00251 00252 FilenameAtlasDLL=malloc(sizeof(char)*MAX_PATH); 00253 wsprintf(FilenameAtlasDLL,"%s",DefaultDllName); 00254 00255 PathOfThisExe=GetWhereIsThisExe(); 00256 00257 if ( LoadArrayCPUFromFile(PathOfThisExe) ) 00258 { 00259 char *LocalCPU=NULL; 00260 char LocalVendor[32]; 00261 char LocalFilenameNotUse[32]; 00262 int LocalFamily,LocalModel,LocalStep; 00263 00264 LocalCPU=GetLocalCPU(); 00265 AppendMessageToLog(LocalCPU); 00266 GetInfoCPUfromLine(LocalCPU,FALSE,LocalVendor,&LocalFamily,&LocalModel,&LocalStep,LocalFilenameNotUse); 00267 if ( strcmp(LocalCPU,"ERROR")!=0 ) 00268 { 00269 int i=0; 00270 for (i=0;i<NbrLinesCPU;i++) 00271 { 00272 int F,M,S; 00273 char Vendor[32]; 00274 char Filename[MAX_PATH]; 00275 00276 if ( GetInfoCPUfromLine(ArrayLinesCPU[i],TRUE,Vendor,&F,&M,&S,Filename) ) 00277 { 00278 if ( (!FindCPU) && (strcmp(LocalVendor,Vendor)==0) ) 00279 { 00280 if ( LocalFamily == F ) 00281 { 00282 if ( (LocalModel == M) || (M == -1) || (LocalModel == -1) ) 00283 { 00284 FindCPU=TRUE; 00285 wsprintf(FilenameAtlasDLL,"%s",Filename); 00286 AppendMessageToLog(ArrayLinesCPU[i]); 00287 } 00288 } 00289 } 00290 } 00291 else 00292 { 00293 AppendMessageToLog("Error in Atlas.spec"); 00294 } 00295 } 00296 } 00297 else 00298 { 00299 AppendMessageToLog("Error Detection CPU from Registry key."); 00300 } 00301 free(LocalCPU); 00302 LocalCPU=NULL; 00303 } 00304 00305 if (!FindCPU) 00306 { 00307 AppendMessageToLog("Use default Atlas library for Pentium"); 00308 } 00309 00310 free(PathOfThisExe); 00311 PathOfThisExe=NULL; 00312 00313 return (char*)FilenameAtlasDLL; 00314 }
Here is the call graph for this function:

Here is the caller graph for this function:

| BOOL GetInfoCPUfromLine | ( | char * | line, | |
| BOOL | FromFile, | |||
| char * | Vendor, | |||
| int * | Family, | |||
| int * | Model, | |||
| int * | Step, | |||
| char * | DLLName | |||
| ) |
Definition at line 186 of file SetupAtlas.c.
References F, FALSE, int, M, S, and TRUE.
Referenced by GetDLLFilenameAtlas().
00187 { 00188 BOOL vOK=FALSE; 00189 00190 char Architecture[32]; 00191 char wFamily[32]; 00192 char wModel[32]; 00193 char wStep[32]; 00194 char wRemark[32]; 00195 00196 if (FromFile) 00197 { 00198 char F[32],M[32]; 00199 00200 sscanf(line,"%s %s %s %s %s %s %s",Vendor,wFamily,F,wModel,M,DLLName,wRemark); 00201 00202 if (strcmp(F,"*")==0) 00203 { 00204 *Family=-1; 00205 } 00206 else *Family=(int)strtol(F, (char **)NULL, 10); 00207 00208 if (strcmp(M,"*")==0) 00209 { 00210 *Model=-1; 00211 } 00212 else *Model=(int)strtol(M, (char **)NULL, 10); 00213 00214 *Step=-1; 00215 00216 if ( (strcmp(wFamily,"Family")==0) && 00217 (strcmp(wModel,"Model")==0) ) 00218 { 00219 vOK=TRUE; 00220 } 00221 } 00222 else 00223 { 00224 char F[32],M[32],S[32]; 00225 00226 sscanf(line,"%s %s %s %s %s %s %s %s", 00227 Vendor,Architecture,wFamily,F,wModel,M,wStep,S); 00228 00229 *Family=(int)strtol(F, (char **)NULL, 10); 00230 *Model=(int)strtol(M, (char **)NULL, 10); 00231 *Step=(int)strtol(S, (char **)NULL, 10); 00232 00233 if ( (strcmp(wFamily,"Family")==0) && 00234 (strcmp(wModel,"Model")==0) && 00235 (strcmp(wStep,"Stepping")==0) ) 00236 { 00237 vOK=TRUE; 00238 } 00239 wsprintf(DLLName,"EMPTY"); 00240 } 00241 00242 return vOK; 00243 }
Here is the caller graph for this function:

| char* GetLocalCPU | ( | void | ) |
Definition at line 167 of file SetupAtlas.c.
References GetRegKeyIdentifier(), GetRegKeyVendorIdentifier(), LineMaxSize, and malloc().
Referenced by GetDLLFilenameAtlas().
00168 { 00169 char *CPUString=NULL; 00170 char *Vendor=NULL; 00171 char *Identifier=NULL; 00172 00173 Identifier=GetRegKeyIdentifier(); 00174 Vendor=GetRegKeyVendorIdentifier(); 00175 CPUString=(char *)malloc(sizeof(char)*LineMaxSize); 00176 00177 if ( (strcmp(Identifier,"ERROR")!=0) && (strcmp(Vendor,"ERROR")!=0) ) 00178 { 00179 wsprintf(CPUString,"%s %s",Vendor,Identifier); 00180 } 00181 else wsprintf(CPUString,"ERROR"); 00182 00183 return (char*)CPUString; 00184 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* GetRegKeyIdentifier | ( | void | ) |
Definition at line 44 of file SetupAtlas.c.
References KeyCpuIdentifer, LenLine, malloc(), and result.
Referenced by GetLocalCPU().
00045 { 00046 HKEY key; 00047 DWORD result; 00048 char *LineIdentifier; 00049 ULONG length = LenLine,Type; 00050 00051 result=RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyCpuIdentifer, 0, KEY_QUERY_VALUE , &key); 00052 00053 LineIdentifier=(char*)malloc(sizeof(char)*length); 00054 00055 if ( RegQueryValueEx(key, "Identifier", 0, &Type, (LPBYTE)LineIdentifier, &length) != ERROR_SUCCESS ) 00056 { 00057 wsprintf(LineIdentifier,"ERROR"); 00058 } 00059 00060 if( Type != REG_SZ ) 00061 { 00062 wsprintf(LineIdentifier,"ERROR"); 00063 } 00064 00065 if ( result == ERROR_SUCCESS ) RegCloseKey(key); 00066 00067 return (char *)LineIdentifier; 00068 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* GetRegKeyVendorIdentifier | ( | void | ) |
Definition at line 70 of file SetupAtlas.c.
References KeyCpuIdentifer, LenLine, malloc(), and result.
Referenced by GetLocalCPU().
00071 { 00072 HKEY key; 00073 DWORD result; 00074 ULONG length = LenLine,Type; 00075 00076 char *LineVendorIdentifier; 00077 00078 result=RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyCpuIdentifer, 0, KEY_QUERY_VALUE , &key); 00079 00080 LineVendorIdentifier=(char*)malloc(sizeof(char)*length); 00081 00082 if ( RegQueryValueEx(key, "VendorIdentifier", 0, &Type, (LPBYTE)LineVendorIdentifier, &length) != ERROR_SUCCESS ) 00083 { 00084 wsprintf(LineVendorIdentifier,"ERROR"); 00085 } 00086 00087 if( Type != REG_SZ ) 00088 { 00089 wsprintf(LineVendorIdentifier,"ERROR"); 00090 } 00091 00092 if ( result == ERROR_SUCCESS ) RegCloseKey(key); 00093 00094 return (char *)LineVendorIdentifier; 00095 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* GetWhereIsThisExe | ( | void | ) |
| BOOL LoadArrayCPUFromFile | ( | char * | path | ) |
Definition at line 130 of file SetupAtlas.c.
References AppendMessageToLog(), ArrayLinesCPU, ATLASSPEC, FALSE, FileExist(), free(), LineMaxSize, malloc(), MaxCPU, NbrLinesCPU, and TRUE.
Referenced by GetDLLFilenameAtlas().
00131 { 00132 #define ATLASSPEC "atlas.spec" 00133 BOOL vOK=FALSE; 00134 char *fullfilename=NULL; 00135 FILE *pFile; 00136 00137 fullfilename=(char*)malloc(sizeof(char)*(strlen(path)+strlen(ATLASSPEC)+2)); 00138 wsprintf(fullfilename,"%s\\%s",path,ATLASSPEC); 00139 if (FileExist(fullfilename)) 00140 { 00141 char Line[LineMaxSize]; 00142 int nbrLines=0; 00143 pFile=fopen(fullfilename,"rt"); 00144 while (fgets(Line, LineMaxSize,pFile)) 00145 { 00146 if (nbrLines >= MaxCPU) 00147 { 00148 AppendMessageToLog("See LoadArrayCPUFromFile function in SetupAtlas.c"); 00149 return FALSE; 00150 } 00151 Line[strlen(Line)-1]='\0'; 00152 wsprintf(ArrayLinesCPU[nbrLines],"%s",Line); 00153 nbrLines++; 00154 NbrLinesCPU=nbrLines; 00155 } 00156 fclose(pFile); 00157 vOK=TRUE; 00158 } 00159 00160 free(fullfilename); 00161 fullfilename=NULL; 00162 00163 return vOK; 00164 00165 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 373 of file SetupAtlas.c.
References AppendMessageToLog(), CopyAtlas(), free(), and GetDLLFilenameAtlas().
00374 { 00375 char *DLLFilename=NULL; 00376 00377 AppendMessageToLog("**************************************************"); 00378 DLLFilename=GetDLLFilenameAtlas(); 00379 AppendMessageToLog(DLLFilename); 00380 if ( CopyAtlas(DLLFilename) ) AppendMessageToLog("Copy file OK"); 00381 else AppendMessageToLog("Copy file Not OK"); 00382 AppendMessageToLog("**************************************************"); 00383 00384 free(DLLFilename); 00385 DLLFilename=NULL; 00386 return 0; 00387 }
Here is the call graph for this function:

| char ArrayLinesCPU[MaxCPU][LineMaxSize] |
Definition at line 16 of file SetupAtlas.c.
Referenced by GetDLLFilenameAtlas(), and LoadArrayCPUFromFile().
| int NbrLinesCPU = 0 |
Definition at line 17 of file SetupAtlas.c.
Referenced by GetDLLFilenameAtlas(), and LoadArrayCPUFromFile().
1.5.1