0Pricing
Reverse Engineering & Binary Analysis Basics · บทเรียน

การแทนข้อมูลในไบนารี

เรียนรู้วิธีจัดเก็บชนิดข้อมูล เช่น จำนวนเต็ม จำนวนทศนิยม และสตริงในหน่วยความจำและไฟล์ รวมถึงแนวคิดเรื่องลำดับไบต์

การแทนข้อมูลในไบนารี เป็นบทเรียน Reverse Engineering & Binary Analysis Basics ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Reverse Engineering & Binary Analysis Basics และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Reverse Engineering & Binary Analysis Basics มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

What is Binary Data?

When you reverse engineer, you're looking at a program's raw binary form. This means understanding how all kinds of data—numbers, text, and more—are stored as sequences of bits and bytes.

A bit is the smallest unit, either 0 or 1. Eight bits make a byte. Everything a computer does, from calculations to displaying text, relies on these fundamental units.

Numbers as Bits: Integers

Integers are whole numbers. They can be signed (positive or negative) or unsigned (only non-negative). The number of bytes used determines the range of values an integer can hold.

  • Byte (8-bit): 0 to 255 (unsigned) or -128 to 127 (signed).
  • Word (16-bit): Up to 65,535 (unsigned).
  • DWord (32-bit): Up to ~4 billion (unsigned).
  • QWord (64-bit): Much larger numbers!

Integer Size Matters

Let's see how different integer sizes affect the maximum value. This Python code shows the max value for an unsigned 8-bit integer (a byte) and a signed 8-bit integer.

# Max unsigned 8-bit integer
max_8_bit_unsigned = 2**8 - 1
print(f"Max 8-bit unsigned: {max_8_bit_unsigned}")

# Max signed 8-bit integer
max_8_bit_signed = 2**7 - 1
min_8_bit_signed = -2**7
print(f"Max 8-bit signed: {max_8_bit_signed}")
print(f"Min 8-bit signed: {min_8_bit_signed}")

Floating-Point Numbers (Floats)

Numbers with decimal points, like 3.14 or -0.5, are called floating-point numbers. They are stored differently from integers to handle their fractional parts.

Most systems use the IEEE 754 standard for floats. This standard defines how a number's sign, exponent, and fractional part are represented in bits. Common sizes are 32-bit (single-precision) and 64-bit (double-precision).

Text: Characters & Strings

Text characters are also stored as numbers. The most common mapping for English characters is ASCII, where each character (like 'A' or '!') corresponds to a specific 8-bit number.

For a wider range of characters (emojis, foreign languages), Unicode is used. UTF-8 is a popular Unicode encoding that uses 1 to 4 bytes per character, making it flexible and backward-compatible with ASCII.

A string is simply a sequence of these characters, often ending with a special null byte (0x00) to mark its end.

How Strings Become Bytes

Here's how a simple string is represented as bytes using UTF-8. Notice how each character gets a numerical value.

message = "Hello"
bytes_message = message.encode('utf-8')
print(f"String: '{message}'")
print(f"Bytes (UTF-8): {bytes_message}")

# Example with a non-ASCII character
smiley = "😊"
bytes_smiley = smiley.encode('utf-8')
print(f"String: '{smiley}'")
print(f"Bytes (UTF-8): {bytes_smiley}")

Endianness: Byte Order

When a piece of data, like a 32-bit integer, takes up more than one byte, there's a choice to be made: which byte comes first in memory? This order is called endianness.

  • Big-endian: The most significant byte (MSB) comes first. Think of reading numbers left-to-right, like "123" where '1' is the most significant digit.
  • Little-endian: The least significant byte (LSB) comes first. This is like writing "321" if '1' were the most significant.

Visualizing Endianness

Let's take the 32-bit hexadecimal number 0x12345678. This number has four bytes: 12, 34, 56, 78.

  • Big-endian: Stores bytes in memory as 12 34 56 78 (MSB first).
  • Little-endian: Stores bytes in memory as 78 56 34 12 (LSB first).

Most modern Intel/AMD CPUs (x86/x64) are little-endian. Network protocols often use big-endian.

Endianness & Reverse Engineering

Understanding endianness is crucial when you're working with raw binary data, especially across different systems or file formats.

  • If you read a 32-bit integer from a big-endian file on a little-endian system without conversion, the value will be incorrect.
  • Network packets often use big-endian, so analyzing network traffic requires awareness.
  • Many embedded systems (like ARM processors) can be configured for either, adding complexity.

Endianness Check

Imagine a 32-bit integer with the hexadecimal value 0xAABBCCDD is stored in memory. If the system is little-endian, what would be the order of bytes in memory, starting from the lowest address?

Data Representation Recap

Great job! In this lesson, we explored how data is represented in binaries:

  • Integers: Stored as signed or unsigned numbers, with size determining range.
  • Floating-points: Use standards like IEEE 754 for decimals.
  • Characters & Strings: Mapped to numbers (ASCII, UTF-8) and often null-terminated.
  • Endianness: The byte order (big-endian or little-endian) for multi-byte data, critical for correct interpretation.

Understanding these fundamentals is key to interpreting any binary file or memory dump. Next, we'll look at common binary file formats!

คำถามที่พบบ่อย

บทเรียน “การแทนข้อมูลในไบนารี” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การแทนข้อมูลในไบนารี” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Reverse Engineering & Binary Analysis Basics ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Reverse Engineering & Binary Analysis Basics มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การแทนข้อมูลในไบนารี”

เรียนรู้วิธีจัดเก็บชนิดข้อมูล เช่น จำนวนเต็ม จำนวนทศนิยม และสตริงในหน่วยความจำและไฟล์ รวมถึงแนวคิดเรื่องลำดับไบต์ คุณปฏิบัติ Reverse Engineering & Binary Analysis Basics ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Reverse Engineering & Binary Analysis Basics หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Reverse Engineering & Binary Analysis Basics บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน

บทเรียน “การแทนข้อมูลในไบนารี” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Reverse Engineering & Binary Analysis Basics นี้ได้ไหม

ได้ บทเรียน Reverse Engineering & Binary Analysis Basics ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ภาพรวมสถาปัตยกรรม CPU
  2. การแทนข้อมูลในไบนารี
  3. รูปแบบไฟล์ไบนารีทั่วไป
  4. ลำดับไบต์และการเรียงลำดับไบต์
← กลับไปที่ Reverse Engineering & Binary Analysis Basics