# include & lt; windows.h>
#include
#include
Typedef struct
{
DWORD dwParameter;//DWORD parameter to fiber (unused)
DWORD dwFiberResultCode;//GetLastError () the result code
HANDLE hFile;//handle to operate on
DWORD dwBytesProcessed;//number of bytes processed
PFIBERDATASTRUCT} FIBERDATASTRUCT, * and * LPFIBERDATASTRUCT;
# define RTN_OK 0
# define RTN_USAGE 1
# define RTN_ERROR 13
# define FIBER_COUNT 3
1//# define READ_FIBER array index to read fiber
2//# define WRITE_FIBER array index to write fiber
Int __cdecl _tmain (int arg c, TCHAR * argv [])
{
LPFIBERDATASTRUCT fs.
if (argc !
=3){
Usage: printf (" % ls & lt; SourceFile>\ n ", argv [0]);
Return RTN_USAGE;
}
Fs=(LPFIBERDATASTRUCT) HeapAlloc (
GetProcessHeap (), 0,
Sizeof (FIBERDATASTRUCT) * FIBER_COUNT);
If (fs==NULL)
{
Printf (" HeapAlloc error (% d) \ n ", GetLastError ());
Return RTN_ERROR;
}
Fs [READ_FIBER] hFile=CreateFile (
Argv [1],
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN.
NULL
);
If (fs) [r]. READ_FIBER hFile==INVALID_HANDLE_VALUE)
{
Printf (" CreateFile error (% d) \ n ", GetLastError ());
Return RTN_ERROR;
}
Fs [WRITE_FIBER] hFile=CreateFile (
Argv [2],
GENERIC_WRITE,
0,
NULL,
CREATE_NEW.
FILE_FLAG_SEQUENTIAL_SCAN.
NULL
);
If (fs) [r]. WRITE_FIBER hFile==INVALID_HANDLE_VALUE)
{
Printf (" CreateFile error (% d) \ n ", GetLastError ());
Return RTN_ERROR;
}
Fs [READ_FIBER] dwParameter=0 x12345678;
Fs [WRITE_FIBER] dwParameter=0 x54545454;
The CloseHandle (fs) [r]. READ_FIBER hFile);
The CloseHandle (fs) [r]. WRITE_FIBER hFile);
HeapFree (GetProcessHeap (), and 0, fs);
Return RTN_OK;
}
Line 78, vc2019 suggest the use of an uninitialized memory problems
Code should be how to change?
CodePudding user response:
LPFIBERDATASTRUCT fs.Is a pointer?