Win32 API 日本語リファレンス
ホームSystem.Threading › Wow64SuspendThread

Wow64SuspendThread

関数
WOW64上の32ビットスレッドを一時停止する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

DWORD Wow64SuspendThread(
    HANDLE hThread
);

パラメーター

名前方向説明
hThreadHANDLEinサスペンドする対象のWOW64スレッドのハンドル。THREAD_SUSPEND_RESUMEが必要である。

戻り値の型: DWORD

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

DWORD Wow64SuspendThread(
    HANDLE hThread
);
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern uint Wow64SuspendThread(
    IntPtr hThread   // HANDLE
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function Wow64SuspendThread(
    hThread As IntPtr   ' HANDLE
) As UInteger
End Function
' hThread : HANDLE
Declare PtrSafe Function Wow64SuspendThread Lib "kernel32" ( _
    ByVal hThread As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

Wow64SuspendThread = ctypes.windll.kernel32.Wow64SuspendThread
Wow64SuspendThread.restype = wintypes.DWORD
Wow64SuspendThread.argtypes = [
    wintypes.HANDLE,  # hThread : HANDLE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
Wow64SuspendThread = Fiddle::Function.new(
  lib['Wow64SuspendThread'],
  [
    Fiddle::TYPE_VOIDP,  # hThread : HANDLE
  ],
  -Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn Wow64SuspendThread(
        hThread: *mut core::ffi::c_void  // HANDLE
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern uint Wow64SuspendThread(IntPtr hThread);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_Wow64SuspendThread' -Namespace Win32 -PassThru
# $api::Wow64SuspendThread(hThread)
#uselib "KERNEL32.dll"
#func global Wow64SuspendThread "Wow64SuspendThread" sptr
; Wow64SuspendThread hThread   ; 戻り値は stat
; hThread : HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global Wow64SuspendThread "Wow64SuspendThread" sptr
; res = Wow64SuspendThread(hThread)
; hThread : HANDLE -> "sptr"
; DWORD Wow64SuspendThread(HANDLE hThread)
#uselib "KERNEL32.dll"
#cfunc global Wow64SuspendThread "Wow64SuspendThread" intptr
; res = Wow64SuspendThread(hThread)
; hThread : HANDLE -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procWow64SuspendThread = kernel32.NewProc("Wow64SuspendThread")
)

// hThread (HANDLE)
r1, _, err := procWow64SuspendThread.Call(
	uintptr(hThread),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function Wow64SuspendThread(
  hThread: THandle   // HANDLE
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'Wow64SuspendThread';
result := DllCall("KERNEL32\Wow64SuspendThread"
    , "Ptr", hThread   ; HANDLE
    , "UInt")   ; return: DWORD
●Wow64SuspendThread(hThread) = DLL("KERNEL32.dll", "dword Wow64SuspendThread(void*)")
# 呼び出し: Wow64SuspendThread(hThread)
# hThread : HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "kernel32" fn Wow64SuspendThread(
    hThread: ?*anyopaque // HANDLE
) callconv(std.os.windows.WINAPI) u32;
proc Wow64SuspendThread(
    hThread: pointer  # HANDLE
): uint32 {.importc: "Wow64SuspendThread", stdcall, dynlib: "KERNEL32.dll".}
pragma(lib, "kernel32");
extern(Windows)
uint Wow64SuspendThread(
    void* hThread   // HANDLE
);
ccall((:Wow64SuspendThread, "KERNEL32.dll"), stdcall, UInt32,
      (Ptr{Cvoid},),
      hThread)
# hThread : HANDLE -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t Wow64SuspendThread(
    void* hThread);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.Wow64SuspendThread(hThread)
-- hThread : HANDLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const Wow64SuspendThread = lib.func('__stdcall', 'Wow64SuspendThread', 'uint32_t', ['void *']);
// Wow64SuspendThread(hThread)
// hThread : HANDLE -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("KERNEL32.dll", {
  Wow64SuspendThread: { parameters: ["pointer"], result: "u32" },
});
// lib.symbols.Wow64SuspendThread(hThread)
// hThread : HANDLE -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t Wow64SuspendThread(
    void* hThread);
C, "KERNEL32.dll");
// $ffi->Wow64SuspendThread(hThread);
// hThread : HANDLE
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Kernel32 extends StdCallLibrary {
    Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
    int Wow64SuspendThread(
        Pointer hThread   // HANDLE
    );
}
@[Link("kernel32")]
lib LibKERNEL32
  fun Wow64SuspendThread = Wow64SuspendThread(
    hThread : Void*   # HANDLE
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef Wow64SuspendThreadNative = Uint32 Function(Pointer<Void>);
typedef Wow64SuspendThreadDart = int Function(Pointer<Void>);
final Wow64SuspendThread = DynamicLibrary.open('KERNEL32.dll')
    .lookupFunction<Wow64SuspendThreadNative, Wow64SuspendThreadDart>('Wow64SuspendThread');
// hThread : HANDLE -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function Wow64SuspendThread(
  hThread: THandle   // HANDLE
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'Wow64SuspendThread';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "Wow64SuspendThread"
  c_Wow64SuspendThread :: Ptr () -> IO Word32
-- hThread : HANDLE -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wow64suspendthread =
  foreign "Wow64SuspendThread"
    ((ptr void) @-> returning uint32_t)
(* hThread : HANDLE -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)

(cffi:defcfun ("Wow64SuspendThread" wow64-suspend-thread :convention :stdcall) :uint32
  (h-thread :pointer))   ; HANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $Wow64SuspendThread = Win32::API::More->new('KERNEL32',
    'DWORD Wow64SuspendThread(HANDLE hThread)');
# my $ret = $Wow64SuspendThread->Call($hThread);
# hThread : HANDLE -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。