@@ -52,7 +52,7 @@ DECLSPEC_EXPORT APIENTRY BOOL
52
52
DllMain (HANDLE hModule , DWORD ul_reason_for_call , LPVOID lpReserved );
53
53
54
54
FILE * hFile = NULL ;
55
- LPCSTR cstrInstallJournal = "\\Windows\\" APPNAME "-install.txt" ;
55
+ LPCSTR cstrInstallJournal = APPNAME "-install.txt" ;
56
56
DWORD keepFiles = 0 ;
57
57
58
58
#define SHORT_BUFFER_SIZE 16
@@ -281,6 +281,12 @@ Install_Init(HWND hwndparent, BOOL bFirstcall, BOOL IsInstalled,
281
281
LPCTSTR pszinstalldir )
282
282
{
283
283
HKEY hKey = NULL ;
284
+ LPSTR logpath = NULL ;
285
+
286
+ logpath = malloc (MAX_PATH );
287
+ wcstombs (logpath , pszinstalldir , MAX_PATH );
288
+ strcat (logpath , "\\" );
289
+ strcat (logpath , cstrInstallJournal );
284
290
285
291
// Initializes OS informations
286
292
os .dwOSVersionInfoSize = sizeof (OSVERSIONINFO );
@@ -297,7 +303,7 @@ Install_Init(HWND hwndparent, BOOL bFirstcall, BOOL IsInstalled,
297
303
if (hFile != NULL )
298
304
{
299
305
fclose (hFile );
300
- hFile = freopen ( cstrInstallJournal , "w" , stdout );
306
+ hFile = freopen ( logpath , "w" , stdout );
301
307
}
302
308
303
309
#ifdef TEST
@@ -362,6 +368,8 @@ Install_Init(HWND hwndparent, BOOL bFirstcall, BOOL IsInstalled,
362
368
Log ("Installing " APPNAME " v" VERSION "..." );
363
369
}
364
370
371
+ free (logpath );
372
+
365
373
return codeINSTALL_INIT_CONTINUE ;
366
374
}
367
375
@@ -493,8 +501,6 @@ Install_Exit(HWND hwndparent, LPCTSTR pszinstalldir, WORD cfaileddirs,
493
501
Log ("Can't try to set VarDir in registry" );
494
502
DumpError ();
495
503
}
496
- free (wPath );
497
- free (path );
498
504
499
505
// TODO: Update DLLs file attributes as protected system file
500
506
@@ -637,12 +643,13 @@ Install_Exit(HWND hwndparent, LPCTSTR pszinstalldir, WORD cfaileddirs,
637
643
638
644
// Set Dll in registry
639
645
dwType = REG_SZ ;
640
- wData = L" glpi-agent.dll" ;
641
- dwDataSize = sizeof (TCHAR )* (wcslen (wData )+ 1 );
646
+ swprintf ( wPath , L"%s%hs" , pszinstalldir , "\\ glpi-agent.dll") ;
647
+ dwDataSize = sizeof (TCHAR )* (wcslen (wPath )+ 1 );
642
648
if (RegSetValueEx (hKey , L"Dll" , 0 , dwType ,
643
- (LPBYTE )wData , dwDataSize ) == ERROR_SUCCESS )
649
+ (LPBYTE )wPath , dwDataSize ) == ERROR_SUCCESS )
644
650
{
645
- Log ("Service Dll set in registry" );
651
+ wcstombs (path , wPath , MAX_PATH );
652
+ Log ("Service Dll set in registry to '%s'" , path );
646
653
}
647
654
else
648
655
{
@@ -800,6 +807,9 @@ Install_Exit(HWND hwndparent, LPCTSTR pszinstalldir, WORD cfaileddirs,
800
807
DebugRegistry ();
801
808
#endif
802
809
810
+ free (wPath );
811
+ free (path );
812
+
803
813
return codeINSTALL_EXIT_DONE ;
804
814
}
805
815
@@ -988,6 +998,9 @@ BOOL APIENTRY
988
998
DllMain (HANDLE hModule , DWORD dwReason , LPVOID lpReserved )
989
999
{
990
1000
LPCSTR hdr = APPNAME "-Setup (Built: " __DATE__ ", " __TIME__ ")" ;
1001
+ #ifndef TEST
1002
+ LPTSTR wPath = NULL ;
1003
+ #endif
991
1004
992
1005
if (hFile == NULL )
993
1006
{
@@ -1015,6 +1028,13 @@ DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
1015
1028
Log ("%s: unloading" , hdr );
1016
1029
if (hFile != NULL )
1017
1030
fclose (hFile );
1031
+ #ifndef TEST
1032
+ // Remove first cstrInstallJournal created file
1033
+ wPath = malloc (2 * MAX_PATH );
1034
+ swprintf ( wPath , L"\\%hs" , cstrInstallJournal );
1035
+ DeleteFile (wPath );
1036
+ free (wPath );
1037
+ #endif
1018
1038
break ;
1019
1039
}
1020
1040
0 commit comments