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 8266361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:07:58+00:00 2026-06-08T05:07:58+00:00

I recently moved from inline assembly to high level language (C++) where I want

  • 0

I recently moved from inline assembly to high level language (C++) where I want to set the result from a value^0x1A3C into a short type pointer (WORD PTR) but I am getting the following error:

A value of type int cannot be used to initialize an entity of type short*

I got the problem when passing an int type to a short*:

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

What I want the compiler to make:

0041585E   8B45 0C          MOV EAX,DWORD PTR SS:[EBP+C]
00415861   8B4D 08          MOV ECX,DWORD PTR SS:[EBP+8]
00415864   8D5401 FE        LEA EDX,DWORD PTR DS:[ECX+EAX-2]
00415868   8955 F8          MOV DWORD PTR SS:[EBP-8],EDX
0041586B   8B45 08          MOV EAX,DWORD PTR SS:[EBP+8]
0041586E   0FBF08           MOVSX ECX,WORD PTR DS:[EAX]
00415871   81F1 3C1A0000    XOR ECX,1A3C
00415877   8B55 F8          MOV EDX,DWORD PTR SS:[EBP-8]
0041587A   880A             MOV WORD PTR DS:[EDX],CX
  • 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-08T05:08:00+00:00Added an answer on June 8, 2026 at 5:08 am

    Assuming you want to write the calculated value to the location that pointer points to:

    *reinterpret_cast<short*>(pointer) = packet->PacketSize^0x1A3C;
    

    reinterpret_cast means “take an object of one type and force it into another type”, and is the cast used to convert between pointers to unrelated types; the value is assigned as if pointer pointed to short. Note that this might cause undefined behaviour if the pointer doesn’t have the correct alignment for short. In general, reinterpret_cast removes compile-time type checks, leaving the onus on the programmer to make sure the result is used correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently moved from vim to Emacs because I want to use org-mode .
I recently moved a bunch of tables from an existing database into a new
We recently moved the value of a column from an existing table to a
I am currently using ASP.NET MVC 2.0 RC2, having recently moved from version 1.0.
We recently moved our github from one account owner to another, and now all
I've recently moved my project from sourceforge to Google code. I'm intrigued by the
We have recently moved some data from an SQL Database instance to another one
I am using cfwheels (coldfusion orm framework). I recently moved some data from my
I recently moved my asp.net appliaction from windows 2003 / IIS 6 to windows
I recently moved from NetBeans to Eclipse and I very much miss one great

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.