node-ctypes - v2.10.0
    Preparing search index...

    Interface PointerTypeDef<T>

    A pointer type created by POINTER.

    const IntPtr = POINTER(c_int32);

    // From existing buffer
    const p = IntPtr.fromBuffer(buf);
    console.log(p.contents.value); // 42
    console.log(p[0]); // 42

    // From raw address (e.g., from a struct's c_void_p field)
    const pValues = POINTER(MyStruct).fromAddress(someStruct.pData);
    console.log(pValues[0].field1);
    interface PointerTypeDef<T = any> {
        _pointerTo: T;
        _type_: T;
        _baseSize: number;
        size: number;
        create(
            value?: number | bigint | Buffer<ArrayBufferLike>,
        ): PointerInstance<T>;
        fromBuffer(targetBuf: Buffer): PointerInstance<T>;
        fromAddress(address: number | bigint): PointerInstance<T>;
        deref(ptrBuf: Buffer): bigint;
        set(ptrBuf: Buffer, value: bigint | Buffer<ArrayBufferLike>): void;
        toString(): string;
    }

    Type Parameters

    • T = any
    Index
    _pointerTo: T

    The resolved base type, including for lazy pointer declarations.

    _type_: T

    Python ctypes alias for the resolved base type.

    _baseSize: number

    Size of the pointed-to type.

    size: number

    Pointer size (always 8 on 64-bit).

    • Create a NULL pointer instance.

      Parameters

      • Optionalvalue: number | bigint | Buffer<ArrayBufferLike>

      Returns PointerInstance<T>

      const p = POINTER(c_int32).create();
      console.log(p.isNull); // true
    • Create a pointer from an existing buffer (points to that buffer's memory).

      Parameters

      • targetBuf: Buffer

        Buffer to point to

      Returns PointerInstance<T>

      const buf = Buffer.alloc(4);
      buf.writeInt32LE(42, 0);
      const p = POINTER(c_int32).fromBuffer(buf);
      console.log(p.contents.value); // 42
    • Create a pointer from a raw memory address.

      Use this to create typed access to native memory, especially useful with c_void_p struct fields that point to arrays of structs.

      Parameters

      • address: number | bigint

        Memory address as BigInt or number

      Returns PointerInstance<T>

      // Access array of structs from a c_void_p field
      const pValues = POINTER(ADSVALUE).fromAddress(col.pADsValues);
      for (let i = 0; i < col.dwNumValues; i++) {
      console.log(pValues[i].dwType);
      }
    • Parameters

      • ptrBuf: Buffer

      Returns bigint

      Use pointer instance .contents instead. Legacy API: Dereferences a pointer buffer.

    • Parameters

      • ptrBuf: Buffer
      • value: bigint | Buffer<ArrayBufferLike>

      Returns void

      Use pointer instance .set() instead. Legacy API: Sets pointer buffer value.