Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

win32-def

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

win32-def - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

109

dist/index.cjs.js

@@ -5,3 +5,3 @@ /**

*
* @version 2.1.0
* @version 2.1.1
* @author waiting

@@ -94,4 +94,6 @@ * @license MIT

const macroSrc = prepare_macro(macroMap, settings);
const ret = prepare_windef_ref(ww, macroSrc);
return prepare_windef_ref(ww, macroSrc)
validateWinData(ret, windefSet);
return ret
}

@@ -160,4 +162,8 @@ /**

}
// parse const HANDLE = 'PVOID' to the realy FFIParam (like 'uint32*')
/**
* parse const HANDLE = 'PVOID' to the realy FFIParam (like 'uint32*')
* macroMap <['PVOID', 'uint32*'], ...>
*/
function prepare_windef_ref(ww, macroSrc) {
const ret = {};
const map = new Map();

@@ -175,7 +181,6 @@

if (vv) {
validDataDef(vv, windefSet);
map.set(x, vv);
}
else {
throw new Error(`value of "${vv}" blank`)
throw new Error(`Value of macroSrc item "${x}" blank`)
}

@@ -187,14 +192,28 @@ }

}
// 2nd loop paser key , maybe value ref other key
for (const x of Object.keys(ww)) {
// 2nd loop paser key , maybe value refer other key
for (const [k, v] of Object.entries(ww)) {
/* istanbul ignore next */
if (map.has(x)) {
if (map.has(k)) {
continue
}
const value = retrieve_ref_value(ww, x, map);
if (typeof v === 'string') {
if (windefSet.has(v)) {
map.set(k, v);
}
else {
const value = lookupRef(v, ww, macroSrc);
value && windefSet.has(value) && map.set(x, value);
// tslint:disable-next-line
if (typeof value === 'string' && value) {
map.set(k, value);
}
else {
map.set(k, v); // maybe invalid for windefSet, will validateWinData() later
}
}
}
else {
throw new Error(`prepare_windef_ref() missing entry for k/v: ${k}/${v}`)
}
}
const ret = {};
map.forEach((v, k) => {

@@ -231,30 +250,52 @@ ret[k] = v;

}
function retrieve_ref_value(ww, key, srcMap) {
const mapValue = srcMap.get(key);
function lookupRef(key, ww, macroSrc) {
let ret = _lookupRef(key, ww, macroSrc);
if (mapValue) {
return mapValue
}
if (typeof ww[key] === 'undefined') {
if (!ret) {
return ''
}
const value = ww[key];
for (let i = 0, len = 3; i < len; i++) {
const tmp = _lookupRef(ret, ww, macroSrc);
/* istanbul ignore next */
if (!value) {
return ''
if (tmp) {
ret = tmp;
}
else {
break
}
}
// check whether ww has element value as key
const refValue = retrieve_ref_value(ww, value, srcMap);
return ret
}
function _lookupRef(key, ww, macroSrc) {
if (macroSrc.has(key)) {
return macroSrc.get(key)
}
// key is not valid FFIParam such 'int/uint...', like HMODULE: 'HANDLE'
if (typeof ww[key] === 'string') {
// parse HANDLE: 'PVOID' , PVOID already parsed
const ret = ww[key];
return refValue ? refValue : value
if (ret && macroSrc.has(ret)) { // HANDLE:PVOID, macroSrc has PVOID
return macroSrc.get(ret)
}
return ret
}
return ''
}
// valid parsed value exists in windefSet
function validDataDef(str, srcSet) {
if (!str || typeof str !== 'string') {
throw new Error(`value of param invalid: ${str}`)
function isValidDataDef(key, srcSet) {
return srcSet.has(key) ? true : false
}
function validateWinData(windef, srcSet) {
for (const [k, v] of Object.entries(windef)) {
if (!k || !v) {
throw new Error(`validateWinData() k or v empty: "${k}"/"${v}"`)
}
if (typeof v !== 'string') {
throw new Error(`validateWinData() v not typeof string: "${k}"/"${v}"`)
}
if (!isValidDataDef(v, srcSet)) {
throw new Error(`validateWinData() value is invalid ffi param value: "${k}"/"${v}"`)
}
}
if (!srcSet.has(str)) {
throw new Error(`conifig.windefSet not contains element of ${str}`)
}
}

@@ -445,3 +486,3 @@

const UNICODE_STRING = 'pointer';
const USN = 'LONGLONG';
const USN = LONGLONG;
// export const WINAPI;

@@ -776,7 +817,7 @@ const WINEVENTPROC = 'pointer';

/**
* node-win32-api
* node-win32-def
*
* @author waiting
* @license MIT
* @link https://github.com/waitingsong/node-win32-api
* @link https://github.com/waitingsong/node-win32-def
*/

@@ -783,0 +824,0 @@ const DTypes = parse_windef(windef, macroMap);

/**
* node-win32-api
* node-win32-def
*
* @author waiting
* @license MIT
* @link https://github.com/waitingsong/node-win32-api
* @link https://github.com/waitingsong/node-win32-def
*/

@@ -8,0 +8,0 @@ import * as Config from './lib/config';

@@ -5,3 +5,3 @@ /**

*
* @version 2.1.0
* @version 2.1.1
* @author waiting

@@ -90,4 +90,6 @@ * @license MIT

const macroSrc = prepare_macro(macroMap, settings);
const ret = prepare_windef_ref(ww, macroSrc);
return prepare_windef_ref(ww, macroSrc)
validateWinData(ret, windefSet);
return ret
}

@@ -156,4 +158,8 @@ /**

}
// parse const HANDLE = 'PVOID' to the realy FFIParam (like 'uint32*')
/**
* parse const HANDLE = 'PVOID' to the realy FFIParam (like 'uint32*')
* macroMap <['PVOID', 'uint32*'], ...>
*/
function prepare_windef_ref(ww, macroSrc) {
const ret = {};
const map = new Map();

@@ -171,7 +177,6 @@

if (vv) {
validDataDef(vv, windefSet);
map.set(x, vv);
}
else {
throw new Error(`value of "${vv}" blank`)
throw new Error(`Value of macroSrc item "${x}" blank`)
}

@@ -183,14 +188,28 @@ }

}
// 2nd loop paser key , maybe value ref other key
for (const x of Object.keys(ww)) {
// 2nd loop paser key , maybe value refer other key
for (const [k, v] of Object.entries(ww)) {
/* istanbul ignore next */
if (map.has(x)) {
if (map.has(k)) {
continue
}
const value = retrieve_ref_value(ww, x, map);
if (typeof v === 'string') {
if (windefSet.has(v)) {
map.set(k, v);
}
else {
const value = lookupRef(v, ww, macroSrc);
value && windefSet.has(value) && map.set(x, value);
// tslint:disable-next-line
if (typeof value === 'string' && value) {
map.set(k, value);
}
else {
map.set(k, v); // maybe invalid for windefSet, will validateWinData() later
}
}
}
else {
throw new Error(`prepare_windef_ref() missing entry for k/v: ${k}/${v}`)
}
}
const ret = {};
map.forEach((v, k) => {

@@ -227,30 +246,52 @@ ret[k] = v;

}
function retrieve_ref_value(ww, key, srcMap) {
const mapValue = srcMap.get(key);
function lookupRef(key, ww, macroSrc) {
let ret = _lookupRef(key, ww, macroSrc);
if (mapValue) {
return mapValue
}
if (typeof ww[key] === 'undefined') {
if (!ret) {
return ''
}
const value = ww[key];
for (let i = 0, len = 3; i < len; i++) {
const tmp = _lookupRef(ret, ww, macroSrc);
/* istanbul ignore next */
if (!value) {
return ''
if (tmp) {
ret = tmp;
}
else {
break
}
}
// check whether ww has element value as key
const refValue = retrieve_ref_value(ww, value, srcMap);
return ret
}
function _lookupRef(key, ww, macroSrc) {
if (macroSrc.has(key)) {
return macroSrc.get(key)
}
// key is not valid FFIParam such 'int/uint...', like HMODULE: 'HANDLE'
if (typeof ww[key] === 'string') {
// parse HANDLE: 'PVOID' , PVOID already parsed
const ret = ww[key];
return refValue ? refValue : value
if (ret && macroSrc.has(ret)) { // HANDLE:PVOID, macroSrc has PVOID
return macroSrc.get(ret)
}
return ret
}
return ''
}
// valid parsed value exists in windefSet
function validDataDef(str, srcSet) {
if (!str || typeof str !== 'string') {
throw new Error(`value of param invalid: ${str}`)
function isValidDataDef(key, srcSet) {
return srcSet.has(key) ? true : false
}
function validateWinData(windef, srcSet) {
for (const [k, v] of Object.entries(windef)) {
if (!k || !v) {
throw new Error(`validateWinData() k or v empty: "${k}"/"${v}"`)
}
if (typeof v !== 'string') {
throw new Error(`validateWinData() v not typeof string: "${k}"/"${v}"`)
}
if (!isValidDataDef(v, srcSet)) {
throw new Error(`validateWinData() value is invalid ffi param value: "${k}"/"${v}"`)
}
}
if (!srcSet.has(str)) {
throw new Error(`conifig.windefSet not contains element of ${str}`)
}
}

@@ -441,3 +482,3 @@

const UNICODE_STRING = 'pointer';
const USN = 'LONGLONG';
const USN = LONGLONG;
// export const WINAPI;

@@ -772,7 +813,7 @@ const WINEVENTPROC = 'pointer';

/**
* node-win32-api
* node-win32-def
*
* @author waiting
* @license MIT
* @link https://github.com/waitingsong/node-win32-api
* @link https://github.com/waitingsong/node-win32-def
*/

@@ -779,0 +820,0 @@ const DTypes = parse_windef(windef, macroMap);

@@ -5,3 +5,3 @@ /**

*
* @version 2.1.0
* @version 2.1.1
* @author waiting

@@ -12,3 +12,3 @@ * @license MIT

const _WIN64_HOLDER="_WIN64_HOLDER_",_UNICODE_HOLDER="_UNICODE_HOLDER_",windefSkipKeys=new Set(["macroMap"]),_WIN64="x64"===process.arch,_UNICODE=!0,settingsDefault={singleton:!0,_UNICODE:!0,_WIN64:_WIN64},windefSet=new Set(["bool","bool*","byte","byte*","char","uchar","char*","float","float*","int","int8","int16","int32","int64","int*","int8*","int16*","int32*","int64*","uint","uint8","uint16","uint32","uint64","uint*","uint8*","uint16*","uint32*","uint64*","int**","uint**","uint32**","uint64**","long","longlong","long*","longlong*","pointer","ushort","void","void*"]);var config=Object.freeze({_WIN64_HOLDER:_WIN64_HOLDER,_UNICODE_HOLDER:_UNICODE_HOLDER,windefSkipKeys:windefSkipKeys,_WIN64:_WIN64,_UNICODE:!0,settingsDefault:settingsDefault,windefSet:windefSet}),ffi_model=Object.freeze({});function parse_windef(O,N,L){const T=clone_filter_windef(O),R=prepare_macro(N,L);return prepare_windef_ref(T,R)}function parse_param_placeholder(O,N){if("string"==typeof O)return O;if(!O)throw new Error("parse_param_placeholder(ps, settings) value of ps invalid");if(!Array.isArray(O)||3!==O.length)throw new Error("parse_param_placeholder(ps, settings) value of ps must Array and has THREE elements");const L=parse_settings(N);let T="";switch(O[0]){case _WIN64_HOLDER:T=parse_placeholder_arch(O,L._WIN64);break;case _UNICODE_HOLDER:T=parse_placeholder_unicode(O,L._UNICODE);break;default:throw new Error("the value of param placeholder invlaid:"+O[0])}return T}function parse_placeholder_arch(O,N){if("string"==typeof O)return O;if(!O||3!==O.length)throw new Error("_WIN64 macro should be Array and has 3 items");return N?O[1]:O[2]}function parse_placeholder_unicode(O,N){if("string"==typeof O)return O;if(!O||3!==O.length)throw new Error("_UNICODE macro should be Array and has 3 items");return N?O[1]:O[2]}function prepare_macro(O,N){const L=new Map;for(const[T,R]of O.entries())L.set(T,parse_param_placeholder(R,N));return L}function prepare_windef_ref(O,N){const L=new Map;for(const T of Object.keys(O))if(!L.has(T)&&N.has(T)){const O=N.get(T);if(!O)throw new Error(`value of "${O}" blank`);validDataDef(O,windefSet),L.set(T,O)}for(const N of Object.keys(O)){if(L.has(N))continue;const T=retrieve_ref_value(O,N,L);T&&windefSet.has(T)&&L.set(N,T)}const T={};return L.forEach((O,N)=>{T[N]=O}),T}function clone_filter_windef(O){const N={};for(const L of Object.keys(O)){if("string"!=typeof O[L])throw new Error(`typeof value of ${L} NOT string`);Object.defineProperty(N,L,{value:O[L],writable:!0,enumerable:!0,configurable:!0})}return N}function parse_settings(O){const N=Object.assign({},settingsDefault);return"undefined"!=typeof O&&O&&Object.keys(O).length&&Object.assign(N,O),N}function retrieve_ref_value(O,N,L){const T=L.get(N);if(T)return T;if("undefined"==typeof O[N])return"";const R=O[N];if(!R)return"";const t=retrieve_ref_value(O,R,L);return t||R}function validDataDef(O,N){if(!O||"string"!=typeof O)throw new Error(`value of param invalid: ${O}`);if(!N.has(O))throw new Error(`conifig.windefSet not contains element of ${O}`)}const ATOM="uint16",DWORD="uint32",PVOID=_WIN64_HOLDER,HANDLE="PVOID",LONG_PTR=_WIN64_HOLDER,ULONG_PTR=_WIN64_HOLDER,VOID="void",WCHAR="uint16",WORD="int16",BOOL="int",BOOLEAN="bool",BYTE="byte",CALLBACK="pointer",CCHAR="char",CHAR="char",COLORREF="DWORD",DWORDLONG="uint64",DWORD_PTR="ULONG_PTR",DWORD32="uint32",DWORD64="uint64",FLOAT="float",HACCEL="HANDLE",HALF_PTR=_WIN64_HOLDER,HBITMAP="HANDLE",HBRUSH="HANDLE",HCOLORSPACE="HANDLE",HCONV="HANDLE",HCONVLIST="HANDLE",HCURSOR="HANDLE",HDC="HANDLE",HDDEDATA="HANDLE",HDESK="HANDLE",HDROP="HANDLE",HDWP="HANDLE",HENHMETAFILE="HANDLE",HFILE="HANDLE",HFONT="HANDLE",HGDIOBJ="HANDLE",HGLOBAL="HANDLE",HHOOK="HANDLE",HICON="HANDLE",HINSTANCE="HANDLE",HKEY="HANDLE",HKL="HANDLE",HLOCAL="HANDLE",HMENU="HANDLE",HMETAFILE="HANDLE",HMODULE="HANDLE",HMONITOR="HANDLE",HPALETTE="HANDLE",HPEN="HANDLE",HRESULT="long",HRGN="HANDLE",HRSRC="HANDLE",HSZ="HANDLE",HWINEVENTHOOK="HANDLE",HWINSTA="HANDLE",HWND="HANDLE",INT="int",INT_PTR=_WIN64_HOLDER,INT8="int8",INT16="int16",INT32="int32",INT64="int64",LANGID="WORD",LCID="DWORD",LCTYPE="DWORD",LGRPID="DWORD",LONG="long",LONGLONG="longlong",LONG32="int32",LONG64="int64",LPARAM="LONG_PTR",LPBOOL="BOOL",LPBYTE="byte*",LPCOLORREF="DWORD",LPCSTR="uint8*",LPCWSTR="uint16*",LPCTSTR=_UNICODE_HOLDER,LPVOID="void*",LPCVOID="LPVOID",LPDWORD="uint16*",LPHANDLE=_WIN64_HOLDER,LPINT="int*",LPLONG="int32*",LPMSG="pointer",LPSTR="char*",LPWSTR="uint16*",LPTSTR=_UNICODE_HOLDER,LPWORD="uint16*",LRESULT="LONG_PTR",NTSTATUS="uint32",PBOOL="int*",PBOOLEAN="bool*",PBYTE="byte*",PCHAR="char*",PCSTR="uint8*",PCTSTR=_WIN64_HOLDER,PCWSTR="uint16*",PDWORD="uint32*",PDWORDLONG="uint64*",PDWORD_PTR="DWORD_PTR",PDWORD32="uint32*",PDWORD64="uint64*",PFLOAT="float*",PHALF_PTR="pointer",PHANDLE=_WIN64_HOLDER,PHKEY=_WIN64_HOLDER,PINT="int*",PINT_PTR="int**",PINT8="int8*",PINT16="int16*",PINT32="int32*",PINT64="int64*",PLCID="uint32*",PLONG="long*",PLONGLONG="int64*",PLONG_PTR="LONG_PTR",PLONG32="int32*",PLONG64="int64*",POINTER_32=_WIN64_HOLDER,POINTER_64=_WIN64_HOLDER,POINTER_SIGNED="pointer",POINTER_UNSIGNED="pointer",PSHORT="int16*",PSIZE_T="ULONG_PTR",PSSIZE_T="pointer",PSTR="char*",PTBYTE=_UNICODE_HOLDER,PTCHAR=_UNICODE_HOLDER,PTSTR=_UNICODE_HOLDER,PUCHAR="pointer",PUHALF_PTR="pointer",PUINT="uint*",PUINT_PTR="uint**",PUINT8="uint8*",PUINT16="uint16*",PUINT32="uint32*",PUINT64="uint64*",PULONG="uint*",PULONGLONG="uint64*",PULONG_PTR="uint64**",PULONG32="uint*",PULONG64="uint64*",PUSHORT="uint16*",PWCHAR="uint16*",PWORD="uint16*",PWSTR="uint16*",QWORD="uint64",SC_HANDLE="HANDLE",SC_LOCK="LPVOID",SERVICE_STATUS_HANDLE="HANDLE",SHORT="int16",SIZE_T="ULONG_PTR",SSIZE_T="LONG_PTR",TBYTE=_UNICODE_HOLDER,TCHAR=_UNICODE_HOLDER,UCHAR="uchar",UHALF_PTR=_WIN64_HOLDER,UINT="uint",UINT_PTR="uint",UINT8="uint8",UINT16="uint16",UINT32="uint32",UINT64="uint64",ULONG="uint",ULONGLONG="uint64",ULONG32="uint32",ULONG64="uint64",USHORT="ushort",UNICODE_STRING="pointer",USN="LONGLONG",WINEVENTPROC="pointer",WNDENUMPROC="pointer",WNDPROC="pointer",WPARAM="LONG_PTR",LPINITCOMMONCONTROLSEX="pointer",LPWNDCLASSEX="pointer",PWINDOWINFO="pointer",va_list="char*",INITCOMMONCONTROLSEX="pointer",MSG="pointer",POINT="pointer",WNDCLASSEX="pointer",WINDOWINFO="pointer",RECT="pointer";var windef=Object.freeze({ATOM:ATOM,DWORD:DWORD,PVOID:PVOID,HANDLE:HANDLE,LONG_PTR:LONG_PTR,ULONG_PTR:ULONG_PTR,VOID:VOID,WCHAR:WCHAR,WORD:WORD,BOOL:BOOL,BOOLEAN:"bool",BYTE:BYTE,CALLBACK:CALLBACK,CCHAR:CCHAR,CHAR:CHAR,COLORREF:"DWORD",DWORDLONG:"uint64",DWORD_PTR:DWORD_PTR,DWORD32:DWORD32,DWORD64:DWORD64,FLOAT:FLOAT,HACCEL:HACCEL,HALF_PTR:HALF_PTR,HBITMAP:HBITMAP,HBRUSH:HBRUSH,HCOLORSPACE:"HANDLE",HCONV:HCONV,HCONVLIST:"HANDLE",HCURSOR:HCURSOR,HDC:HDC,HDDEDATA:"HANDLE",HDESK:HDESK,HDROP:HDROP,HDWP:HDWP,HENHMETAFILE:"HANDLE",HFILE:HFILE,HFONT:HFONT,HGDIOBJ:HGDIOBJ,HGLOBAL:HGLOBAL,HHOOK:HHOOK,HICON:HICON,HINSTANCE:"HANDLE",HKEY:HKEY,HKL:HKL,HLOCAL:HLOCAL,HMENU:HMENU,HMETAFILE:"HANDLE",HMODULE:HMODULE,HMONITOR:"HANDLE",HPALETTE:"HANDLE",HPEN:HPEN,HRESULT:"long",HRGN:HRGN,HRSRC:HRSRC,HSZ:HSZ,HWINEVENTHOOK:"HANDLE",HWINSTA:HWINSTA,HWND:HWND,INT:INT,INT_PTR:INT_PTR,INT8:INT8,INT16:INT16,INT32:INT32,INT64:INT64,LANGID:"WORD",LCID:LCID,LCTYPE:LCTYPE,LGRPID:LGRPID,LONG:LONG,LONGLONG:LONGLONG,LONG32:LONG32,LONG64:LONG64,LPARAM:LPARAM,LPBOOL:"BOOL",LPBYTE:LPBYTE,LPCOLORREF:"DWORD",LPCSTR:LPCSTR,LPCWSTR:LPCWSTR,LPCTSTR:LPCTSTR,LPVOID:LPVOID,LPCVOID:LPCVOID,LPDWORD:LPDWORD,LPHANDLE:LPHANDLE,LPINT:LPINT,LPLONG:LPLONG,LPMSG:LPMSG,LPSTR:LPSTR,LPWSTR:LPWSTR,LPTSTR:LPTSTR,LPWORD:LPWORD,LRESULT:LRESULT,NTSTATUS:"uint32",PBOOL:PBOOL,PBOOLEAN:"bool*",PBYTE:PBYTE,PCHAR:PCHAR,PCSTR:PCSTR,PCTSTR:PCTSTR,PCWSTR:PCWSTR,PDWORD:PDWORD,PDWORDLONG:"uint64*",PDWORD_PTR:PDWORD_PTR,PDWORD32:PDWORD32,PDWORD64:PDWORD64,PFLOAT:PFLOAT,PHALF_PTR:"pointer",PHANDLE:PHANDLE,PHKEY:PHKEY,PINT:PINT,PINT_PTR:"int**",PINT8:PINT8,PINT16:PINT16,PINT32:PINT32,PINT64:PINT64,PLCID:PLCID,PLONG:PLONG,PLONGLONG:"int64*",PLONG_PTR:PLONG_PTR,PLONG32:PLONG32,PLONG64:PLONG64,POINTER_32:POINTER_32,POINTER_64:POINTER_64,POINTER_SIGNED:"pointer",POINTER_UNSIGNED:"pointer",PSHORT:PSHORT,PSIZE_T:PSIZE_T,PSSIZE_T:PSSIZE_T,PSTR:PSTR,PTBYTE:PTBYTE,PTCHAR:PTCHAR,PTSTR:PTSTR,PUCHAR:PUCHAR,PUHALF_PTR:"pointer",PUINT:PUINT,PUINT_PTR:"uint**",PUINT8:PUINT8,PUINT16:PUINT16,PUINT32:PUINT32,PUINT64:PUINT64,PULONG:PULONG,PULONGLONG:"uint64*",PULONG_PTR:"uint64**",PULONG32:"uint*",PULONG64:PULONG64,PUSHORT:PUSHORT,PWCHAR:PWCHAR,PWORD:PWORD,PWSTR:PWSTR,QWORD:QWORD,SC_HANDLE:"HANDLE",SC_LOCK:SC_LOCK,SERVICE_STATUS_HANDLE:"HANDLE",SHORT:SHORT,SIZE_T:SIZE_T,SSIZE_T:SSIZE_T,TBYTE:TBYTE,TCHAR:TCHAR,UCHAR:UCHAR,UHALF_PTR:UHALF_PTR,UINT:UINT,UINT_PTR:"uint",UINT8:UINT8,UINT16:UINT16,UINT32:UINT32,UINT64:UINT64,ULONG:ULONG,ULONGLONG:"uint64",ULONG32:ULONG32,ULONG64:ULONG64,USHORT:USHORT,UNICODE_STRING:"pointer",USN:USN,WINEVENTPROC:"pointer",WNDENUMPROC:"pointer",WNDPROC:WNDPROC,WPARAM:WPARAM,LPINITCOMMONCONTROLSEX:"pointer",LPWNDCLASSEX:"pointer",PWINDOWINFO:"pointer",va_list:"char*",INITCOMMONCONTROLSEX:"pointer",MSG:MSG,POINT:POINT,WNDCLASSEX:"pointer",WINDOWINFO:"pointer",RECT:RECT});const macroMap=new Map([["PVOID",[_WIN64_HOLDER,"uint64*","uint32*"]],["LONG_PTR",[_WIN64_HOLDER,"int64","int32"]],["ULONG_PTR",[_WIN64_HOLDER,"uint64","uint32"]],["HALF_PTR",[_WIN64_HOLDER,"int32","int16"]],["INT_PTR",[_WIN64_HOLDER,"int64","int32"]],["LPCTSTR",[_UNICODE_HOLDER,LPCWSTR,LPCSTR]],["LPHANDLE",[_WIN64_HOLDER,"uint64*","uint32*"]],["LPTSTR",[_UNICODE_HOLDER,LPWSTR,"uint8*"]],["PCTSTR",[_WIN64_HOLDER,LPCWSTR,LPCSTR]],["PHANDLE",[_WIN64_HOLDER,"uint64**","uint32**"]],["PHKEY",[_WIN64_HOLDER,"uint64*","uint32*"]],["POINTER_32",[_WIN64_HOLDER,"uint64*","uint32*"]],["POINTER_64",[_WIN64_HOLDER,"uint64*","uint32*"]],["PTBYTE",[_UNICODE_HOLDER,"int16*","int8*"]],["PTCHAR",[_UNICODE_HOLDER,"uint16*","uint8*"]],["PTSTR",[_UNICODE_HOLDER,LPWSTR,LPSTR]],["TBYTE",[_UNICODE_HOLDER,"int16","int8"]],["TCHAR",[_UNICODE_HOLDER,WCHAR,"uint8"]],["UHALF_PTR",[_WIN64_HOLDER,"uint32","uint16"]]]),INITCOMMONCONTROLSEX$1={dwSize:DWORD,dwICC:DWORD},MSG$1={hwnd:HWND,message:UINT,wParam:WPARAM,lParam:LPARAM,time:DWORD,pt:POINT},POINT$1={x:LONG,y:LONG},PROCESS_BASIC_INFORMATION={Reserved1:PVOID,PebBaseAddress:PVOID,Reserved2:PVOID,UniqueProcessId:ULONG_PTR,InheritedFromUniqueProcessId:PVOID},UNICODE_STRING$1={Length:USHORT,MaximumLength:USHORT,Buffer:PWSTR},WINDOWINFO$1={cbSize:DWORD,rcWindow:RECT,rcClient:RECT,dwStyle:DWORD,dwExStyle:DWORD,dwWindowStatus:DWORD,cxWindowBorders:UINT,cyWindowBorders:UINT,atomWindowType:ATOM,wCreatorVersion:WORD},WNDCLASSEX$1={cbSize:UINT,style:UINT,lpfnWndProc:WNDPROC,cbClsExtra:INT,cbWndExtra:INT,hInstance:"HANDLE",hIcon:HICON,hCursor:HCURSOR,hbrBackground:HBRUSH,lpszMenuName:LPCTSTR,lpszClassName:LPCTSTR,hIconSm:HICON},RECT$1={left:LONG,top:LONG,right:LONG,bottom:LONG};var struct=Object.freeze({INITCOMMONCONTROLSEX:INITCOMMONCONTROLSEX$1,MSG:MSG$1,POINT:POINT$1,PROCESS_BASIC_INFORMATION:PROCESS_BASIC_INFORMATION,UNICODE_STRING:UNICODE_STRING$1,WINDOWINFO:WINDOWINFO$1,WNDCLASSEX:WNDCLASSEX$1,RECT:RECT$1,_RECT:RECT$1}),win_model=Object.freeze({});const DTypes=parse_windef(windef,macroMap);export{config as Config,ffi_model as FModel,win_model as DModel,struct as DStruct,DTypes};
const _WIN64_HOLDER="_WIN64_HOLDER_",_UNICODE_HOLDER="_UNICODE_HOLDER_",windefSkipKeys=new Set(["macroMap"]),_WIN64="x64"===process.arch,_UNICODE=!0,settingsDefault={singleton:!0,_UNICODE:!0,_WIN64:_WIN64},windefSet=new Set(["bool","bool*","byte","byte*","char","uchar","char*","float","float*","int","int8","int16","int32","int64","int*","int8*","int16*","int32*","int64*","uint","uint8","uint16","uint32","uint64","uint*","uint8*","uint16*","uint32*","uint64*","int**","uint**","uint32**","uint64**","long","longlong","long*","longlong*","pointer","ushort","void","void*"]);var config=Object.freeze({_WIN64_HOLDER:_WIN64_HOLDER,_UNICODE_HOLDER:_UNICODE_HOLDER,windefSkipKeys:windefSkipKeys,_WIN64:_WIN64,_UNICODE:!0,settingsDefault:settingsDefault,windefSet:windefSet}),ffi_model=Object.freeze({});function parse_windef(O,N,L){const t=clone_filter_windef(O),T=prepare_macro(N,L),R=prepare_windef_ref(t,T);return validateWinData(R,windefSet),R}function parse_param_placeholder(O,N){if("string"==typeof O)return O;if(!O)throw new Error("parse_param_placeholder(ps, settings) value of ps invalid");if(!Array.isArray(O)||3!==O.length)throw new Error("parse_param_placeholder(ps, settings) value of ps must Array and has THREE elements");const L=parse_settings(N);let t="";switch(O[0]){case _WIN64_HOLDER:t=parse_placeholder_arch(O,L._WIN64);break;case _UNICODE_HOLDER:t=parse_placeholder_unicode(O,L._UNICODE);break;default:throw new Error("the value of param placeholder invlaid:"+O[0])}return t}function parse_placeholder_arch(O,N){if("string"==typeof O)return O;if(!O||3!==O.length)throw new Error("_WIN64 macro should be Array and has 3 items");return N?O[1]:O[2]}function parse_placeholder_unicode(O,N){if("string"==typeof O)return O;if(!O||3!==O.length)throw new Error("_UNICODE macro should be Array and has 3 items");return N?O[1]:O[2]}function prepare_macro(O,N){const L=new Map;for(const[t,T]of O.entries())L.set(t,parse_param_placeholder(T,N));return L}function prepare_windef_ref(O,N){const L={},t=new Map;for(const L of Object.keys(O))if(!t.has(L)&&N.has(L)){const O=N.get(L);if(!O)throw new Error(`Value of macroSrc item "${L}" blank`);t.set(L,O)}for(const[L,T]of Object.entries(O))if(!t.has(L)){if("string"!=typeof T)throw new Error(`prepare_windef_ref() missing entry for k/v: ${L}/${T}`);if(windefSet.has(T))t.set(L,T);else{const R=lookupRef(T,O,N);"string"==typeof R&&R?t.set(L,R):t.set(L,T)}}return t.forEach((O,N)=>{L[N]=O}),L}function clone_filter_windef(O){const N={};for(const L of Object.keys(O)){if("string"!=typeof O[L])throw new Error(`typeof value of ${L} NOT string`);Object.defineProperty(N,L,{value:O[L],writable:!0,enumerable:!0,configurable:!0})}return N}function parse_settings(O){const N=Object.assign({},settingsDefault);return"undefined"!=typeof O&&O&&Object.keys(O).length&&Object.assign(N,O),N}function lookupRef(O,N,L){let t=_lookupRef(O,N,L);if(!t)return"";for(let O=0,T=3;O<T;O++){const O=_lookupRef(t,N,L);if(!O)break;t=O}return t}function _lookupRef(O,N,L){if(L.has(O))return L.get(O);if("string"==typeof N[O]){const t=N[O];return t&&L.has(t)?L.get(t):t}return""}function isValidDataDef(O,N){return!!N.has(O)}function validateWinData(O,N){for(const[L,t]of Object.entries(O)){if(!L||!t)throw new Error(`validateWinData() k or v empty: "${L}"/"${t}"`);if("string"!=typeof t)throw new Error(`validateWinData() v not typeof string: "${L}"/"${t}"`);if(!isValidDataDef(t,N))throw new Error(`validateWinData() value is invalid ffi param value: "${L}"/"${t}"`)}}const ATOM="uint16",DWORD="uint32",PVOID=_WIN64_HOLDER,HANDLE="PVOID",LONG_PTR=_WIN64_HOLDER,ULONG_PTR=_WIN64_HOLDER,VOID="void",WCHAR="uint16",WORD="int16",BOOL="int",BOOLEAN="bool",BYTE="byte",CALLBACK="pointer",CCHAR="char",CHAR="char",COLORREF="DWORD",DWORDLONG="uint64",DWORD_PTR="ULONG_PTR",DWORD32="uint32",DWORD64="uint64",FLOAT="float",HACCEL="HANDLE",HALF_PTR=_WIN64_HOLDER,HBITMAP="HANDLE",HBRUSH="HANDLE",HCOLORSPACE="HANDLE",HCONV="HANDLE",HCONVLIST="HANDLE",HCURSOR="HANDLE",HDC="HANDLE",HDDEDATA="HANDLE",HDESK="HANDLE",HDROP="HANDLE",HDWP="HANDLE",HENHMETAFILE="HANDLE",HFILE="HANDLE",HFONT="HANDLE",HGDIOBJ="HANDLE",HGLOBAL="HANDLE",HHOOK="HANDLE",HICON="HANDLE",HINSTANCE="HANDLE",HKEY="HANDLE",HKL="HANDLE",HLOCAL="HANDLE",HMENU="HANDLE",HMETAFILE="HANDLE",HMODULE="HANDLE",HMONITOR="HANDLE",HPALETTE="HANDLE",HPEN="HANDLE",HRESULT="long",HRGN="HANDLE",HRSRC="HANDLE",HSZ="HANDLE",HWINEVENTHOOK="HANDLE",HWINSTA="HANDLE",HWND="HANDLE",INT="int",INT_PTR=_WIN64_HOLDER,INT8="int8",INT16="int16",INT32="int32",INT64="int64",LANGID="WORD",LCID="DWORD",LCTYPE="DWORD",LGRPID="DWORD",LONG="long",LONGLONG="longlong",LONG32="int32",LONG64="int64",LPARAM="LONG_PTR",LPBOOL="BOOL",LPBYTE="byte*",LPCOLORREF="DWORD",LPCSTR="uint8*",LPCWSTR="uint16*",LPCTSTR=_UNICODE_HOLDER,LPVOID="void*",LPCVOID="LPVOID",LPDWORD="uint16*",LPHANDLE=_WIN64_HOLDER,LPINT="int*",LPLONG="int32*",LPMSG="pointer",LPSTR="char*",LPWSTR="uint16*",LPTSTR=_UNICODE_HOLDER,LPWORD="uint16*",LRESULT="LONG_PTR",NTSTATUS="uint32",PBOOL="int*",PBOOLEAN="bool*",PBYTE="byte*",PCHAR="char*",PCSTR="uint8*",PCTSTR=_WIN64_HOLDER,PCWSTR="uint16*",PDWORD="uint32*",PDWORDLONG="uint64*",PDWORD_PTR="DWORD_PTR",PDWORD32="uint32*",PDWORD64="uint64*",PFLOAT="float*",PHALF_PTR="pointer",PHANDLE=_WIN64_HOLDER,PHKEY=_WIN64_HOLDER,PINT="int*",PINT_PTR="int**",PINT8="int8*",PINT16="int16*",PINT32="int32*",PINT64="int64*",PLCID="uint32*",PLONG="long*",PLONGLONG="int64*",PLONG_PTR="LONG_PTR",PLONG32="int32*",PLONG64="int64*",POINTER_32=_WIN64_HOLDER,POINTER_64=_WIN64_HOLDER,POINTER_SIGNED="pointer",POINTER_UNSIGNED="pointer",PSHORT="int16*",PSIZE_T="ULONG_PTR",PSSIZE_T="pointer",PSTR="char*",PTBYTE=_UNICODE_HOLDER,PTCHAR=_UNICODE_HOLDER,PTSTR=_UNICODE_HOLDER,PUCHAR="pointer",PUHALF_PTR="pointer",PUINT="uint*",PUINT_PTR="uint**",PUINT8="uint8*",PUINT16="uint16*",PUINT32="uint32*",PUINT64="uint64*",PULONG="uint*",PULONGLONG="uint64*",PULONG_PTR="uint64**",PULONG32="uint*",PULONG64="uint64*",PUSHORT="uint16*",PWCHAR="uint16*",PWORD="uint16*",PWSTR="uint16*",QWORD="uint64",SC_HANDLE="HANDLE",SC_LOCK="LPVOID",SERVICE_STATUS_HANDLE="HANDLE",SHORT="int16",SIZE_T="ULONG_PTR",SSIZE_T="LONG_PTR",TBYTE=_UNICODE_HOLDER,TCHAR=_UNICODE_HOLDER,UCHAR="uchar",UHALF_PTR=_WIN64_HOLDER,UINT="uint",UINT_PTR="uint",UINT8="uint8",UINT16="uint16",UINT32="uint32",UINT64="uint64",ULONG="uint",ULONGLONG="uint64",ULONG32="uint32",ULONG64="uint64",USHORT="ushort",UNICODE_STRING="pointer",USN=LONGLONG,WINEVENTPROC="pointer",WNDENUMPROC="pointer",WNDPROC="pointer",WPARAM="LONG_PTR",LPINITCOMMONCONTROLSEX="pointer",LPWNDCLASSEX="pointer",PWINDOWINFO="pointer",va_list="char*",INITCOMMONCONTROLSEX="pointer",MSG="pointer",POINT="pointer",WNDCLASSEX="pointer",WINDOWINFO="pointer",RECT="pointer";var windef=Object.freeze({ATOM:ATOM,DWORD:DWORD,PVOID:PVOID,HANDLE:HANDLE,LONG_PTR:LONG_PTR,ULONG_PTR:ULONG_PTR,VOID:VOID,WCHAR:WCHAR,WORD:WORD,BOOL:BOOL,BOOLEAN:"bool",BYTE:BYTE,CALLBACK:CALLBACK,CCHAR:CCHAR,CHAR:CHAR,COLORREF:"DWORD",DWORDLONG:"uint64",DWORD_PTR:DWORD_PTR,DWORD32:DWORD32,DWORD64:DWORD64,FLOAT:FLOAT,HACCEL:HACCEL,HALF_PTR:HALF_PTR,HBITMAP:HBITMAP,HBRUSH:HBRUSH,HCOLORSPACE:"HANDLE",HCONV:HCONV,HCONVLIST:"HANDLE",HCURSOR:HCURSOR,HDC:HDC,HDDEDATA:"HANDLE",HDESK:HDESK,HDROP:HDROP,HDWP:HDWP,HENHMETAFILE:"HANDLE",HFILE:HFILE,HFONT:HFONT,HGDIOBJ:HGDIOBJ,HGLOBAL:HGLOBAL,HHOOK:HHOOK,HICON:HICON,HINSTANCE:"HANDLE",HKEY:HKEY,HKL:HKL,HLOCAL:HLOCAL,HMENU:HMENU,HMETAFILE:"HANDLE",HMODULE:HMODULE,HMONITOR:"HANDLE",HPALETTE:"HANDLE",HPEN:HPEN,HRESULT:"long",HRGN:HRGN,HRSRC:HRSRC,HSZ:HSZ,HWINEVENTHOOK:"HANDLE",HWINSTA:HWINSTA,HWND:HWND,INT:INT,INT_PTR:INT_PTR,INT8:INT8,INT16:INT16,INT32:INT32,INT64:INT64,LANGID:"WORD",LCID:LCID,LCTYPE:LCTYPE,LGRPID:LGRPID,LONG:LONG,LONGLONG:LONGLONG,LONG32:LONG32,LONG64:LONG64,LPARAM:LPARAM,LPBOOL:"BOOL",LPBYTE:LPBYTE,LPCOLORREF:"DWORD",LPCSTR:LPCSTR,LPCWSTR:LPCWSTR,LPCTSTR:LPCTSTR,LPVOID:LPVOID,LPCVOID:LPCVOID,LPDWORD:LPDWORD,LPHANDLE:LPHANDLE,LPINT:LPINT,LPLONG:LPLONG,LPMSG:LPMSG,LPSTR:LPSTR,LPWSTR:LPWSTR,LPTSTR:LPTSTR,LPWORD:LPWORD,LRESULT:LRESULT,NTSTATUS:"uint32",PBOOL:PBOOL,PBOOLEAN:"bool*",PBYTE:PBYTE,PCHAR:PCHAR,PCSTR:PCSTR,PCTSTR:PCTSTR,PCWSTR:PCWSTR,PDWORD:PDWORD,PDWORDLONG:"uint64*",PDWORD_PTR:PDWORD_PTR,PDWORD32:PDWORD32,PDWORD64:PDWORD64,PFLOAT:PFLOAT,PHALF_PTR:"pointer",PHANDLE:PHANDLE,PHKEY:PHKEY,PINT:PINT,PINT_PTR:"int**",PINT8:PINT8,PINT16:PINT16,PINT32:PINT32,PINT64:PINT64,PLCID:PLCID,PLONG:PLONG,PLONGLONG:"int64*",PLONG_PTR:PLONG_PTR,PLONG32:PLONG32,PLONG64:PLONG64,POINTER_32:POINTER_32,POINTER_64:POINTER_64,POINTER_SIGNED:"pointer",POINTER_UNSIGNED:"pointer",PSHORT:PSHORT,PSIZE_T:PSIZE_T,PSSIZE_T:PSSIZE_T,PSTR:PSTR,PTBYTE:PTBYTE,PTCHAR:PTCHAR,PTSTR:PTSTR,PUCHAR:PUCHAR,PUHALF_PTR:"pointer",PUINT:PUINT,PUINT_PTR:"uint**",PUINT8:PUINT8,PUINT16:PUINT16,PUINT32:PUINT32,PUINT64:PUINT64,PULONG:PULONG,PULONGLONG:"uint64*",PULONG_PTR:"uint64**",PULONG32:"uint*",PULONG64:PULONG64,PUSHORT:PUSHORT,PWCHAR:PWCHAR,PWORD:PWORD,PWSTR:PWSTR,QWORD:QWORD,SC_HANDLE:"HANDLE",SC_LOCK:SC_LOCK,SERVICE_STATUS_HANDLE:"HANDLE",SHORT:SHORT,SIZE_T:SIZE_T,SSIZE_T:SSIZE_T,TBYTE:TBYTE,TCHAR:TCHAR,UCHAR:UCHAR,UHALF_PTR:UHALF_PTR,UINT:UINT,UINT_PTR:"uint",UINT8:UINT8,UINT16:UINT16,UINT32:UINT32,UINT64:UINT64,ULONG:ULONG,ULONGLONG:"uint64",ULONG32:ULONG32,ULONG64:ULONG64,USHORT:USHORT,UNICODE_STRING:"pointer",USN:USN,WINEVENTPROC:"pointer",WNDENUMPROC:"pointer",WNDPROC:WNDPROC,WPARAM:WPARAM,LPINITCOMMONCONTROLSEX:"pointer",LPWNDCLASSEX:"pointer",PWINDOWINFO:"pointer",va_list:"char*",INITCOMMONCONTROLSEX:"pointer",MSG:MSG,POINT:POINT,WNDCLASSEX:"pointer",WINDOWINFO:"pointer",RECT:RECT});const macroMap=new Map([["PVOID",[_WIN64_HOLDER,"uint64*","uint32*"]],["LONG_PTR",[_WIN64_HOLDER,"int64","int32"]],["ULONG_PTR",[_WIN64_HOLDER,"uint64","uint32"]],["HALF_PTR",[_WIN64_HOLDER,"int32","int16"]],["INT_PTR",[_WIN64_HOLDER,"int64","int32"]],["LPCTSTR",[_UNICODE_HOLDER,LPCWSTR,LPCSTR]],["LPHANDLE",[_WIN64_HOLDER,"uint64*","uint32*"]],["LPTSTR",[_UNICODE_HOLDER,LPWSTR,"uint8*"]],["PCTSTR",[_WIN64_HOLDER,LPCWSTR,LPCSTR]],["PHANDLE",[_WIN64_HOLDER,"uint64**","uint32**"]],["PHKEY",[_WIN64_HOLDER,"uint64*","uint32*"]],["POINTER_32",[_WIN64_HOLDER,"uint64*","uint32*"]],["POINTER_64",[_WIN64_HOLDER,"uint64*","uint32*"]],["PTBYTE",[_UNICODE_HOLDER,"int16*","int8*"]],["PTCHAR",[_UNICODE_HOLDER,"uint16*","uint8*"]],["PTSTR",[_UNICODE_HOLDER,LPWSTR,LPSTR]],["TBYTE",[_UNICODE_HOLDER,"int16","int8"]],["TCHAR",[_UNICODE_HOLDER,WCHAR,"uint8"]],["UHALF_PTR",[_WIN64_HOLDER,"uint32","uint16"]]]),INITCOMMONCONTROLSEX$1={dwSize:DWORD,dwICC:DWORD},MSG$1={hwnd:HWND,message:UINT,wParam:WPARAM,lParam:LPARAM,time:DWORD,pt:POINT},POINT$1={x:LONG,y:LONG},PROCESS_BASIC_INFORMATION={Reserved1:PVOID,PebBaseAddress:PVOID,Reserved2:PVOID,UniqueProcessId:ULONG_PTR,InheritedFromUniqueProcessId:PVOID},UNICODE_STRING$1={Length:USHORT,MaximumLength:USHORT,Buffer:PWSTR},WINDOWINFO$1={cbSize:DWORD,rcWindow:RECT,rcClient:RECT,dwStyle:DWORD,dwExStyle:DWORD,dwWindowStatus:DWORD,cxWindowBorders:UINT,cyWindowBorders:UINT,atomWindowType:ATOM,wCreatorVersion:WORD},WNDCLASSEX$1={cbSize:UINT,style:UINT,lpfnWndProc:WNDPROC,cbClsExtra:INT,cbWndExtra:INT,hInstance:"HANDLE",hIcon:HICON,hCursor:HCURSOR,hbrBackground:HBRUSH,lpszMenuName:LPCTSTR,lpszClassName:LPCTSTR,hIconSm:HICON},RECT$1={left:LONG,top:LONG,right:LONG,bottom:LONG};var struct=Object.freeze({INITCOMMONCONTROLSEX:INITCOMMONCONTROLSEX$1,MSG:MSG$1,POINT:POINT$1,PROCESS_BASIC_INFORMATION:PROCESS_BASIC_INFORMATION,UNICODE_STRING:UNICODE_STRING$1,WINDOWINFO:WINDOWINFO$1,WNDCLASSEX:WNDCLASSEX$1,RECT:RECT$1,_RECT:RECT$1}),win_model=Object.freeze({});const DTypes=parse_windef(windef,macroMap);export{config as Config,ffi_model as FModel,win_model as DModel,struct as DStruct,DTypes};
//# sourceMappingURL=index.esm.min.js.map
/**
* node-win32-api
* node-win32-def
*
* @author waiting
* @license MIT
* @link https://github.com/waitingsong/node-win32-api
* @link https://github.com/waitingsong/node-win32-def
*/

@@ -8,0 +8,0 @@ import * as Config from './lib/config'

import { DataTypes, LoadSettings, MacroMap } from './ffi.model';
export declare function parse_windef(windefObj: DataTypes, macroMap: MacroMap, settings?: LoadSettings): DataTypes;
export declare function validDataDef(str: string, srcSet: Set<string>): void;
export declare function lookupRef(key: string, ww: DataTypes, macroSrc: Map<string, string>): string;
export declare function isValidDataDef(key: string, srcSet: Set<string>): boolean;
export declare function validateWinData(windef: DataTypes, srcSet: Set<string>): void;

@@ -6,4 +6,6 @@ import { settingsDefault, windefSet, _UNICODE_HOLDER, _WIN64_HOLDER, } from './config'

const macroSrc = prepare_macro(macroMap, settings)
const ret = prepare_windef_ref(ww, macroSrc)
return prepare_windef_ref(ww, macroSrc)
validateWinData(ret, windefSet)
return ret
}

@@ -72,4 +74,8 @@ /**

}
// parse const HANDLE = 'PVOID' to the realy FFIParam (like 'uint32*')
/**
* parse const HANDLE = 'PVOID' to the realy FFIParam (like 'uint32*')
* macroMap <['PVOID', 'uint32*'], ...>
*/
function prepare_windef_ref(ww, macroSrc) {
const ret = {}
const map = new Map()

@@ -87,7 +93,6 @@

if (vv) {
validDataDef(vv, windefSet)
map.set(x, vv)
}
else {
throw new Error(`value of "${vv}" blank`)
throw new Error(`Value of macroSrc item "${x}" blank`)
}

@@ -99,14 +104,28 @@ }

}
// 2nd loop paser key , maybe value ref other key
for (const x of Object.keys(ww)) {
// 2nd loop paser key , maybe value refer other key
for (const [k, v] of Object.entries(ww)) {
/* istanbul ignore next */
if (map.has(x)) {
if (map.has(k)) {
continue
}
const value = retrieve_ref_value(ww, x, map)
if (typeof v === 'string') {
if (windefSet.has(v)) {
map.set(k, v)
}
else {
const value = lookupRef(v, ww, macroSrc)
value && windefSet.has(value) && map.set(x, value)
// tslint:disable-next-line
if (typeof value === 'string' && value) {
map.set(k, value)
}
else {
map.set(k, v) // maybe invalid for windefSet, will validateWinData() later
}
}
}
else {
throw new Error(`prepare_windef_ref() missing entry for k/v: ${k}/${v}`)
}
}
const ret = {}
map.forEach((v, k) => {

@@ -143,30 +162,52 @@ ret[k] = v

}
function retrieve_ref_value(ww, key, srcMap) {
const mapValue = srcMap.get(key)
export function lookupRef(key, ww, macroSrc) {
let ret = _lookupRef(key, ww, macroSrc)
if (mapValue) {
return mapValue
}
if (typeof ww[key] === 'undefined') {
if (!ret) {
return ''
}
const value = ww[key]
for (let i = 0, len = 3; i < len; i++) {
const tmp = _lookupRef(ret, ww, macroSrc)
/* istanbul ignore next */
if (!value) {
return ''
if (tmp) {
ret = tmp
}
else {
break
}
}
// check whether ww has element value as key
const refValue = retrieve_ref_value(ww, value, srcMap)
return ret
}
function _lookupRef(key, ww, macroSrc) {
if (macroSrc.has(key)) {
return macroSrc.get(key)
}
// key is not valid FFIParam such 'int/uint...', like HMODULE: 'HANDLE'
if (typeof ww[key] === 'string') {
// parse HANDLE: 'PVOID' , PVOID already parsed
const ret = ww[key]
return refValue ? refValue : value
if (ret && macroSrc.has(ret)) { // HANDLE:PVOID, macroSrc has PVOID
return macroSrc.get(ret)
}
return ret
}
return ''
}
// valid parsed value exists in windefSet
export function validDataDef(str, srcSet) {
if (!str || typeof str !== 'string') {
throw new Error(`value of param invalid: ${str}`)
export function isValidDataDef(key, srcSet) {
return srcSet.has(key) ? true : false
}
export function validateWinData(windef, srcSet) {
for (const [k, v] of Object.entries(windef)) {
if (!k || !v) {
throw new Error(`validateWinData() k or v empty: "${k}"/"${v}"`)
}
if (typeof v !== 'string') {
throw new Error(`validateWinData() v not typeof string: "${k}"/"${v}"`)
}
if (!isValidDataDef(v, srcSet)) {
throw new Error(`validateWinData() value is invalid ffi param value: "${k}"/"${v}"`)
}
}
if (!srcSet.has(str)) {
throw new Error(`conifig.windefSet not contains element of ${str}`)
}
}

@@ -178,3 +178,3 @@ /**

export declare const UNICODE_STRING = "pointer";
export declare const USN = "LONGLONG";
export declare const USN = "longlong";
export declare const WINEVENTPROC = "pointer";

@@ -181,0 +181,0 @@ export declare const WNDENUMPROC = "pointer";

@@ -186,3 +186,3 @@ // windows data types for ref module https://github.com/TooTallNate/ref

export const UNICODE_STRING = 'pointer'
export const USN = 'LONGLONG'
export const USN = LONGLONG
// export const WINAPI;

@@ -189,0 +189,0 @@ export const WINEVENTPROC = 'pointer'

{
"name": "win32-def",
"author": "waiting",
"version": "2.1.0",
"version": "2.1.1",
"description": "win32 definitions for node-ffi",

@@ -6,0 +6,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc