Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How do I form structure dymaically?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Wed Aug 20, 2008 1:46 am    Post subject: How do I form structure dymaically? Reply with quote

I got this atm.. but i get a ton of compiler errors

Code:

struct Packet{
   char d6; //D6
   short Size; //XX XX
   char Keys[7];
   char ServerKeys[1];
   char data[2000];
};



Code:


                Packet packet;
                  packet.d6 = 0xD6;
                  packet.Size = 0x1e;
                  packet.Keys = "\x0b\x00\x00\x00\x00\x00\x07\x00";
                  packet.ServerKeys = serverKeys;
                  packet.data = "\x00\x00\x0b\x00\x07";
                  strncat(packet.data, DBId, 4);
                  strncat(packet.data, "\x00\x63\x00\x00\x7d\x00\x00\x6b", 8);
                  SendPacket(&packet);



atm im doing the only way i know how.. and its not looking pretty

Code:

char* packet = new char[0x1e];
                  packet[0] = 0xd6;
                  packet[1] = 0x1e;
                  packet[2] = 0x00;
                  packet[3] = 0x0b;




Well help me out u smart peepz lol.

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Wed Aug 20, 2008 2:36 am    Post subject: Reply with quote

You forgot to set access point to your structure:
try now

Code:
struct _Packet{
   char d6; //D6
   short Size; //XX XX
   char Keys[7];
   char ServerKeys[1];
   char data[2000];
}Packet;
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Wed Aug 20, 2008 2:44 am    Post subject: Reply with quote

Na its not that lol I remember that what u just wrote from a typedef tutorial but naw im talking about

errors like char[9] is not char[7] etc.. stupid errors

seems i can't even use strncat on it..

in the end I want to take the packet structure and pass it as a address hopefully it should look like a stream of a real packet..

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Wed Aug 20, 2008 3:29 am    Post subject: Reply with quote

pkedpker wrote:
errors like char[9] is not char[7] etc.. stupid errors
Dynamically also allocate the length too? I mean
Code:
struct Packet{
   ..
   char *Keys;
   ..
}

unsigned char src[] = "\x00\x01";
Packet p;
p.Keys = new char [ sizeof(src) ];
::memcpy( p.Keys, Src, sizeof( src ) );
delete [] p.Keys;

or something


pkedpker wrote:
seems i can't even use strncat on it..
::memcpy / ::memcpy_s.
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Thu Aug 21, 2008 12:37 am    Post subject: Reply with quote

thanks memcpy_s doesn't exist

but memcpy is powerful o_O man thats all i need really memcpy..

i could use any offest I want..

packet[4] = blahblah
memcpy(packet+5, whatIwantToCopy, sizeOf(WhatIwantToCopy;

all good.. thanks

rep++

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Aug 21, 2008 1:27 am    Post subject: Reply with quote

pkedpker wrote:
thanks memcpy_s doesn't exist

but memcpy is powerful o_O man thats all i need really memcpy..

i could use any offest I want..

packet[4] = blahblah
memcpy(packet+5, whatIwantToCopy, sizeOf(WhatIwantToCopy;

all good.. thanks

rep++


memcpy_s does indeed exist.
Back to top
View user's profile Send private message
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Thu Aug 21, 2008 1:58 am    Post subject: Reply with quote

So the question was how do I dynamically allocate a string, not actually related to structs.
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Aug 21, 2008 3:09 pm    Post subject: Reply with quote

Code:
TCHAR* tszString = new TCHAR[ SizeNeeded ];

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Thu Aug 21, 2008 3:18 pm    Post subject: Reply with quote

If you new something, will it get deleted after the function ends? I know you can use mallocs created from a function call, but what about news?
_________________
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Thu Aug 21, 2008 3:42 pm    Post subject: Reply with quote

I t hink any pointer u create from a packet has to be added into a pointerBuffer and clear when it reaches 100 pointers or so.. thats how i got it right now... so i dont know!


nog_lorp wrote:
So the question was how do I dynamically allocate a string, not actually related to structs.


dud this has everything related to structs and allocation..

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Aug 21, 2008 3:44 pm    Post subject: Reply with quote

HalfPrime wrote:
If you new something, will it get deleted after the function ends? I know you can use mallocs created from a function call, but what about news?


No. The memory that holds the buffer is still valid after the function ends. You need to use delete to remove it after you are done with it.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites