Skip to content

Commit

Permalink
test(api): update 2001.GetModuleHandleExW.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Jul 2, 2024
1 parent 451f8bb commit 7266706
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
})

Expand Down

0 comments on commit 7266706

Please sign in to comment.