1
1
#include "main.h"
2
2
3
- static
4
- HANDLE
5
- ds_open_handle (
6
- PWCHAR pwPath
7
- )
3
+ static HANDLE ds_open_handle (PWCHAR pwPath )
8
4
{
9
- return CreateFile (pwPath , GENERIC_READ | SYNCHRONIZE | DELETE , FILE_SHARE_READ , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL );
5
+ return CreateFileW (pwPath , GENERIC_READ | SYNCHRONIZE | DELETE , FILE_SHARE_READ , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL );
10
6
}
11
7
12
- static
13
- BOOL
14
- ds_rename_handle (
15
- HANDLE hHandle
16
- )
8
+ static BOOL ds_rename_handle (HANDLE hHandle )
17
9
{
18
10
FILE_RENAME_INFO fRename ;
19
11
RtlSecureZeroMemory (& fRename , sizeof (fRename ));
@@ -26,11 +18,7 @@ ds_rename_handle(
26
18
return SetFileInformationByHandle (hHandle , FileRenameInfo , & fRename , sizeof (fRename ) + sizeof (lpwStream ));
27
19
}
28
20
29
- static
30
- BOOL
31
- ds_deposite_handle (
32
- HANDLE hHandle
33
- )
21
+ static BOOL ds_deposite_handle (HANDLE hHandle )
34
22
{
35
23
// set FILE_DISPOSITION_INFO::DeleteFile to TRUE
36
24
FILE_DISPOSITION_INFO fDelete ;
@@ -41,17 +29,13 @@ ds_deposite_handle(
41
29
return SetFileInformationByHandle (hHandle , FileDispositionInfo , & fDelete , sizeof (fDelete ));
42
30
}
43
31
44
- int
45
- main (
46
- int argc ,
47
- char * * argv
48
- )
32
+ int main (int argc , char * * argv )
49
33
{
50
34
WCHAR wcPath [MAX_PATH + 1 ];
51
35
RtlSecureZeroMemory (wcPath , sizeof (wcPath ));
52
36
53
37
// get the path to the current running process ctx
54
- if (GetModuleFileName (NULL , wcPath , MAX_PATH ) == 0 )
38
+ if (GetModuleFileNameW (NULL , wcPath , MAX_PATH ) == 0 )
55
39
{
56
40
DS_DEBUG_LOG (L"failed to get the current module handle" );
57
41
return 0 ;
83
67
return 0 ;
84
68
}
85
69
86
- // set deposition on HANDLE
87
70
if (!ds_deposite_handle (hCurrent ))
88
71
{
89
72
DS_DEBUG_LOG (L"failed to set delete deposition" );
95
78
CloseHandle (hCurrent );
96
79
97
80
// verify we've been deleted
98
- if (PathFileExists (wcPath ))
81
+ if (PathFileExistsW (wcPath ))
99
82
{
100
83
DS_DEBUG_LOG (L"failed to delete copy, file still exists" );
101
84
return 0 ;
0 commit comments