Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 10:41

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C Function Problem

Discussion on C Function Problem within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2011
Posts: 367
Received Thanks: 199
C Function Problem

Hi community,
today i convert C++ function to C for my friend..

this is C++ function

Code:
std::string decrypt(std::string str,int size)
{
    std::string decrypted_string;

    for (int i = 0; i < size; i++) { decrypted_string += str[i] - 0xF ^ 0xC3; }

    return decrypted_string;
}
and this is the function in C

Code:
char *decrypt(char *packet, int size)
{
     char *decrypted;
     for(int i = 0; i < size; i++)
     {
           decrypted[i] = packet[i] - 0xF ^ 0xC3;
     }
     return decrypted;
}
i use function C in this mode..

Code:
char recvdata[255];
int bytes = recv(client,recvdata,255,0);
char *data = decrypt(recvdata,bytes);
printf("%s",data);
i don't know because this don't work.. è.é

error: 0xC0000005 Access violation in writing of location 0xC0000000.

help me please
Kingrap is offline  
Old 03/05/2013, 19:57   #2

 
snow's Avatar
 
elite*gold: 724
Join Date: Mar 2011
Posts: 10,479
Received Thanks: 3,318
Where does ist crash? If it's within your decrypt-Function:

Try allocating the memory for your char-Pointer:
char *decrypted = (char *)malloc(size * sizeof(char));
snow is offline  
Old 03/05/2013, 20:13   #3


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
Of course it crashes. decrypted is not a valid pointer.
MrSm!th is offline  
Old 03/05/2013, 21:12   #4
 
elite*gold: 0
Join Date: Dec 2011
Posts: 367
Received Thanks: 199
thanks now it work
Kingrap is offline  
Reply


Similar Threads Similar Threads
[?] Function Problem
10/26/2012 - .NET Languages - 1 Replies
Heyho liebe Epvp Community, habe hier ein kleines Problem mit meiner cvn-Pattern Function. Function cvnGenerate(ByVal Muster As String) Dim Ausgabe As String = vbEmpty Muster = Muster.ToArray Dim Vokale As String = "aeiou" Dim Konso As String = "bcdfghjklmnpqrstvwxyz" Vokale = Vokale.ToArray Konso = Konso.ToArray
[PHP] Problem - Warning: session_start() [function.session-start]
05/06/2012 - Web Development - 8 Replies
Hallo ich möchte ein polnisches Script ins deutsche übersetzen damit ich ein Projekt weiterführen kann, allerdings ergibt sich das ziemlich schwer, egal bei welcher PHP Datei ich den Text veränder tritt dieser Fehler auf: "Warning: session_start() : Cannot send session cache limiter - headers already sent (output started at /users/test/www/poczekalnia.php:1) in /users/test/www/poczekalnia.php on line 21" Hier zum Beispiel ist es: "Brak obiektów do wyświetlenia" Änder ich es in: "Es gibt...
[C++]Hook all Recv function Problem
08/21/2010 - C/C++ - 5 Replies
Hi Leute wenn ich send hooke egal welches läuft das alles super nur wenn ich irgendein recv hooke habe ich immer eine Packet size von 1000 bis 10000. sry das ich schon wieder nerve #include "WinSock2.h" #include <cstdio> #include <ctime> #include <fstream> #include <iomanip>
problem in the function of anti hacking
03/30/2010 - Kal Online - 8 Replies
also ich hab das problem das immer mein kal abkack wenn ich es starten will mit dieser meldung ... was kann es sein ???!! hab schon unter prozesse geguckt -.- aber nix gefunden danke im vorraus
PROBLEM Agbot & Loop function
01/28/2009 - Silkroad Online - 6 Replies
ok i have this problem i make a script whit Agdev , i name it default i do everything need for Agbot but when i start Sro, on Agbot the button of "Start Walkscript" looks like when u click it and my char just walk to one to other point doing nothing and the button get normal and thats it! then the "Start Bot" button gets clicked and my char start goint to the shout and hits a wall u____u i dont know what im doing wrong but i can make the loop function work :/ extra information: im...



All times are GMT +1. The time now is 10:41.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.