Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8284659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:11:16+00:00 2026-06-08T11:11:16+00:00

I have the following code void PacketEncrypt(Packet* packet, int sizeofpacket) { int* pointer; pointer

  • 0

I have the following code

void PacketEncrypt(Packet* packet, int sizeofpacket)
{
    int* pointer;
    pointer = ((int*)packet+sizeofpacket)-2;
    (int)*pointer = packet->PacketSize^0x1A3C;
    packet->Type += 0x0FFF7;
}

Problem is when i debug it compiler set it as:

0041585E   8B45 0C          MOV EAX,DWORD PTR SS:[EBP+C]
00415861   8B4D 08          MOV ECX,DWORD PTR SS:[EBP+8]
00415864   8D5481 F8        LEA EDX,DWORD PTR DS:[ECX+EAX*4-8]

But what i really want is:

0041585E   8B45 0C          MOV EAX,DWORD PTR SS:[EBP+C]
00415861   8B4D 08          MOV ECX,DWORD PTR SS:[EBP+8]
00415864   8D5481 F8        LEA EDX,DWORD PTR DS:[ECX+EAX-2]

I am kind of new into C++, so can you help me on what i am doing wrong, or why the compiler is adding scalar *4? thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:11:18+00:00Added an answer on June 8, 2026 at 11:11 am

    int pointer has size of 4 bytes on your machine and can be shifted only by 4*n bytes. If you need to move pointer by 2 bytes cast it to char, since sizeof(char) = 1

    char *ptr = (char*)otherPtr;
    ptr += 2; //shift by 2 bytes
    
    int *ptr = (int*)otherPtr;
    ptr += 2; //shift by 8 bytes. (2 * sizeof(int))
    

    EDIT

    (short*)pointer = something. – You can’t assign to rvalue. I think you meant:

    pointer = (char*) something
    

    Or if you need short pointer:

    short *someOtherPointer = something 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have following pseudo code : void siftup(int n) pre condition n>0 && heap(1,n-1)
I Have the following code: -(void) changeAnimation:(NSString*)name forTime:(int) times { if(currentAnimation != @attack) {
I have the following code: void Foo() { static std::vector<int>(3); // Vector object is
I have the following code -(void) animate:(UIButton*) b withState: (int) state andLastState:(int) last_state {
I have the following code: void set_fl(int fd, int flags) /* flags are file
I have the following code: void testme(Object a) { # printing the type of
SO I have the following code public void rand(int N){ double[]x=new double[N]; double[]y=new double[N];
I have the following code: - (void)updateServerList { [crazyStuff reloadData]; NSLog(@Hi); } - (int)numberOfRowsInTableView:(NSTableView
I currently have the following code: -(void) inputNumber:(int)number { NSString *str; str = [NSString
I have the following code: void readFile(BST *tree) { ifstream infile(input.txt); long int sid,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.