Skip to content

fix(x64): Fix pointer truncations and integer user data casts - #3459

Open
mirelle7 wants to merge 2 commits into
TheSuperHackers:mainfrom
mirelle7:fix/windowmsgdata-uintptr
Open

mirelle7 wants to merge 2 commits into
TheSuperHackers:mainfrom
mirelle7:fix/windowmsgdata-uintptr

Conversation

@mirelle7

@mirelle7 mirelle7 commented Oct 10, 2026 •

Copy link
Copy Markdown

Batch of x64 fixes.

Message data type, runtime truncations, cast-only sites, pointer differences, dead ntohl.

Something to do about x64 numbers being larger. Does not make x64 work.

Split into 2 commits.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • No new commits to review - use @coderabbitai full review for a full pass

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ffb5f7e5-e995-49a7-afa8-04da713095bd
📥 Commits

Reviewing files that changed from the base of the PR and between 343effc and eb8dabe.

📒 Files selected for processing (3)
  • Core/GameEngine/Include/Common/MapObject.h
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

The changes update pointer-related types and conversions across engine, GUI, library, and tool code. They also change multi-select list output handling, use pointer subtraction for address differences, and add tree identifiers to MapObject for World Builder updates.

Changes

Pointer-width and tree identifier updates

Layer / File(s) Summary
Engine and library pointer conversions
Core/GameEngine/Include/GameClient/*, Core/GameEngine/Source/*, Core/GameEngineDevice/Source/*, Core/Libraries/Source/*
Pointer-related values use pointer-sized conversions or direct pointer operations. The multi-select list output uses Int**. WindowMsgData and Compare_EXE_Version receive updated types.
Game GUI item-data conversions
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/*, GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/*, Generals/Code/GameNetwork/GUIUtil.cpp, GeneralsMD/Code/GameNetwork/GUIUtil.cpp
Menu callbacks convert item-data and user-data values through intptr_t or uintptr_t before narrowing them to integer values.
Tool pointer storage and tree identifiers
Core/Tools/W3DView/*, Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp, Generals/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp, Generals/Code/Tools/*, GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp, GeneralsMD/Code/Tools/*
Tool data types and pointer storage use pointer-sized types. Asset-name length calculations use pointer subtraction. MapObject assigns and exposes tree identifiers that World Builder uses for tree updates.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested reviewers: xezon

Merge Risk: ⚪ Minimal · up to eb8da

No actionable merge-blocking risk is established by the reviewed changes.

Pre-merge checks · Passed 4
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely identifies the main change: fixing x64 pointer truncations and integer user-data casts.
Description check Passed The description is related to the changeset and mentions the main x64 fixes, including message data types, truncations, pointer differences, and dead code.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The changes since the last review appear safe to merge.

Summary

This PR preserves pointer widths in window messages, stored pointers, and address calculations. It also updates integer casts used by callbacks and tools.

Since the last review:

  • Game and tool data keeps pointer-width values intact across x64-sensitive paths.
  • WorldBuilder uses each map object's own ID for its terrain trees.

Reviews (5) · Last reviewed commit: "fix(worldbuilder): Give map objects a un..." · Reviewed by Greptile

@mirelle7

Copy link
Copy Markdown
Author

@coderabbitai Yeah reviewing this stuff is important thanks for the warning but I've had to deal with this on my computer as well and can verify this is actually accurate and 19 others have come to the same conclusion. I can reduce my diff between TSH and my branches with this pr. And it does not affect RELEASE or CRC.

Nit: Scope might not be ideal. But the bug is real.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@mirelle7 Thanks for the clarification and guidance. You have reproduced the pointer-truncation bug locally and confirmed that this change does not affect RELEASE or CRC. The scope nit is separate from the bug’s validity; I won’t press it further.


✏️ Learnings added
Learnt from: mirelle7
URL: https://github.com/TheSuperHackers/GeneralsGameCode/pull/3459

Timestamp: 2026-10-10T05:30:45.707Z
Learning: For GeneralsGameCode PR #3459, which changes WindowMsgData from UnsignedInt to uintptr_t in Core/GameEngine/Include/GameClient/GameWindow.h, mirelle7 reports local verification of the pointer-truncation bug and confirms that this change does not affect RELEASE or CRC.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@mirelle7

mirelle7 commented Oct 10, 2026 •

Copy link
Copy Markdown
Author

Thank you. Please approve or close.

#404 it was for example found in this pr.

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very small change. Maybe can bunch a few more x64 fixes in Window/Gui? I expect there is more.

Comment thread Core/GameEngine/Include/GameClient/GameWindow.h Outdated
@bobtista

Copy link
Copy Markdown

I think there's another x64 truncation here - GLM_GET_SELECTION (GadgetListBox.cpp:1795) - could go in with this or as a follow up if I'm not mistaken

@mirelle7 mirelle7 changed the title fix(gamewindow): Make WindowMsgData pointer-sized fix(x64): Fix pointer truncations in window messages and integer user data casts Oct 12, 2026
@mirelle7 mirelle7 changed the title fix(x64): Fix pointer truncations in window messages and integer user data casts fix(x64): Fix pointer truncations and integer user data casts Oct 12, 2026
@mirelle7
mirelle7 marked this pull request as draft October 12, 2026 23:01
…ated casts

WindowMsgData is now pointer-sized, so window messages no longer truncate the
pointers passed through them.

Runtime fixes on 64-bit:
- Listbox multi-select returned its selection array through an Int (chat and lobby crash).
- IME candidate strings were located through a pointer truncated to 32 bits.
- Locked-surface pointer arithmetic ran in unsigned int.
- dbghelp function pointer tables were filled through 32-bit slots.
- W3DView stored texture and alpha-vector pointers in DWORD user data and passed
  its module handle as an int.

Compile fixes on 64-bit, identical on 32-bit:
- Integer user data read back from void* (gadget item data, window user data,
  INI and thread callbacks) is cast through intptr_t.
- Pointer differences are taken before narrowing.
- Tool handles and item data use LPARAM/uintptr_t.
- Removed a no-op ntohl on a truncated array address.

Co-authored-by: Joey de Haas <joey.dehaas1991@gmail.com>
Co-authored-by: Igor Pissolati <igo08an@hotmail.com>
Co-authored-by: Mahdi <mahdipoormirzaie@gmail.com>
Co-authored-by: Omar Aglan <omar.aglan91@yahoo.com>
Co-authored-by: hogandhound <hogandhound@github.com>
Co-authored-by: Okladnoj <dmytrijokladnoj@gmail.com>
Co-authored-by: Prof. Zsolt Zoltán Fehér Dr. <feher.zsolt@agr.unideb.hu>
Co-authored-by: Radim Vajchr <radim.vajchr@aaaauto.cz>
Co-authored-by: Bobby Battista <bobtista@gmail.com>
Co-authored-by: Felipe Keller Braz <fbraz3@gmail.com>
Co-authored-by: Kevan Ahlquist <ahlqu039@umn.edu>
Co-authored-by: dvcdsys <dvcdsys@gmail.com>
Co-authored-by: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
Co-authored-by: Zach Reizner <zach297@gmail.com>
Co-authored-by: DMJC <jcarthew@gmail.com>
Co-authored-by: Mohamad Aljadaan <zerwoone@gmail.com>
Co-authored-by: Sam Afshari <s_a@live.com>
Co-authored-by: Ekliptor <Ekliptor1@yandex.com>
Co-authored-by: Stephan Vedder <stephan.vedder@gmail.com>
Co-authored-by: Jason Kelly <jason-kelly@live.dk>
@mirelle7
mirelle7 force-pushed the fix/windowmsgdata-uintptr branch from 8c31ab4 to 343effc Compare October 12, 2026 23:17
@mirelle7

Copy link
Copy Markdown
Author

@greptile-apps review plz

@mirelle7
mirelle7 marked this pull request as ready for review October 12, 2026 23:35
Comment thread Core/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp
Comment thread GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp Outdated
Comment thread Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp
@mirelle7
mirelle7 marked this pull request as draft October 12, 2026 23:38
…ating their pointer

WorldBuilder identified optimized trees in the tree buffer by the MapObject
pointer narrowed to a 32-bit DrawableID. On 64-bit two objects could map to the
same id, so a tree move could update the wrong tree. Map objects now get a
unique id when they are created.
@mirelle7

Copy link
Copy Markdown
Author

@greptile-apps review this pr again you beautiful bag of tokens

@mirelle7
mirelle7 marked this pull request as ready for review October 13, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants