From 7266706287cad9f4c6f927870c9bb2ba84ed7ea8 Mon Sep 17 00:00:00 2001 From: waiting <1661926154@qq.com> Date: Tue, 2 Jul 2024 10:45:26 +0800 Subject: [PATCH] test(api): update 2001.GetModuleHandleExW.test.ts --- .../lib/kernel32/2001.GetModuleHandleExW.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/win32-api/test/lib/kernel32/2001.GetModuleHandleExW.test.ts b/packages/win32-api/test/lib/kernel32/2001.GetModuleHandleExW.test.ts index 2a68fb5a..cbfe3cd9 100644 --- a/packages/win32-api/test/lib/kernel32/2001.GetModuleHandleExW.test.ts +++ b/packages/win32-api/test/lib/kernel32/2001.GetModuleHandleExW.test.ts @@ -3,33 +3,37 @@ import assert from 'node:assert/strict' import { fileShortPath } from '@waiting/shared-core' import { ucsBufferFrom } from 'win32-def' -import { Kernel32 as Lib, DllNames } from '##/index.js' +import { Kernel32 as Lib, DllNames, ffi } from '##/index.js' describe(fileShortPath(import.meta.url), () => { describe('GetModuleHandleExW()', () => { const name = DllNames.kernel32 + '.dll' - it('string', () => { + it.only('string', () => { const lib = Lib.load() assert(lib) - const buf = Buffer.alloc(256) + const buf = Buffer.alloc(8) const ret = lib.GetModuleHandleExW(0, name, buf) assert(ret) const hModule = buf.readBigUint64LE() assert(hModule) + const h2 = ffi.decode(buf, 'uintptr') as number + assert(h2.toString() === hModule.toString()) }) it('buffer', () => { const lib = Lib.load() assert(lib) - const buf = Buffer.alloc(256) + const buf = Buffer.alloc(8) const ret = lib.GetModuleHandleExW(0, ucsBufferFrom(name), buf) assert(ret) const hModule = buf.readBigUint64LE() assert(hModule) + const h2 = ffi.decode(buf, 'uintptr') as number + assert(h2.toString() === hModule.toString()) }) })