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.0.1 to 2.0.2

dist/index.cjs.js

29

dist/index.js

@@ -1,2 +0,1 @@

'use strict';
/**

@@ -9,15 +8,15 @@ * node-win32-api

*/
Object.defineProperty(exports, '__esModule', { value: true });
const Config = require('./lib/config');
exports.Config = Config;
const FModel = require('./lib/ffi.model');
exports.FModel = FModel;
const helper_1 = require('./lib/helper');
const marcomap_1 = require('./lib/marcomap');
const DStruct = require('./lib/struct');
exports.DStruct = DStruct;
const DModel = require('./lib/win.model');
exports.DModel = DModel;
const windef = require('./lib/windef');
const DTypes = helper_1.parse_windef(windef, marcomap_1.macroMap);
exports.DTypes = DTypes;
import * as Config from './lib/config'
import * as FModel from './lib/ffi.model'
import { parse_windef } from './lib/helper'
import { macroMap } from './lib/marcomap'
import * as DStruct from './lib/struct'
import * as DModel from './lib/win.model'
import * as windef from './lib/windef'
const DTypes = parse_windef(windef, macroMap)
export { Config }
export { FModel } // ffi model
export { DModel } // model of window data types
export { DStruct } // window data types of structure
export { DTypes } // window data types

@@ -1,17 +0,15 @@

'use strict';
// dict of windef value
Object.defineProperty(exports, '__esModule', { value: true });
exports._WIN64_HOLDER = '_WIN64_HOLDER_';
exports._UNICODE_HOLDER = '_UNICODE_HOLDER_';
exports.windefSkipKeys = new Set(['macroMap']);
export const _WIN64_HOLDER = '_WIN64_HOLDER_'
export const _UNICODE_HOLDER = '_UNICODE_HOLDER_'
export const windefSkipKeys = new Set(['macroMap'])
/* istanbul ignore next */
exports._WIN64 = process.arch === 'x64' ? true : false;
export const _WIN64 = process.arch === 'x64' ? true : false
/* istanbul ignore next */
exports._UNICODE = true;
exports.settingsDefault = {
_UNICODE: exports._UNICODE,
_WIN64: exports._WIN64,
};
export const _UNICODE = true
export const settingsDefault = {
_UNICODE,
_WIN64,
}
// for validation
exports.windefSet = new Set([
export const windefSet = new Set([
'bool',

@@ -58,2 +56,2 @@ 'bool*',

'void*',
]);
])

@@ -1,11 +0,9 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const config_1 = require('./config');
import { settingsDefault, windefSet, _UNICODE_HOLDER, _WIN64_HOLDER, } from './config'
// convert macro variable of windef
function parse_windef(windefObj, macroMap, settings) {
const ww = clone_filter_windef(windefObj); // output without macroMap
const macroSrc = prepare_macro(macroMap, settings);
return prepare_windef_ref(ww, macroSrc);
export function parse_windef(windefObj, macroMap, settings) {
const ww = clone_filter_windef(windefObj) // output without macroMap
const macroSrc = prepare_macro(macroMap, settings)
return prepare_windef_ref(ww, macroSrc)
}
exports.parse_windef = parse_windef;
/**

@@ -17,23 +15,24 @@ * convert typeof array of param to string

if (typeof param === 'string') {
return param;
return param
}
else if (!param) {
throw new Error('parse_param_placeholder(ps, settings) value of ps invalid');
throw new Error('parse_param_placeholder(ps, settings) value of ps invalid')
}
else if (!Array.isArray(param) || param.length !== 3) {
throw new Error('parse_param_placeholder(ps, settings) value of ps must Array and has THREE elements');
throw new Error('parse_param_placeholder(ps, settings) value of ps must Array and has THREE elements')
}
const st = parse_settings(settings);
let p = '';
const st = parse_settings(settings)
let p = ''
switch (param[0]) {
case config_1._WIN64_HOLDER:
p = parse_placeholder_arch(param, st._WIN64);
break;
case config_1._UNICODE_HOLDER:
p = parse_placeholder_unicode(param, st._UNICODE);
break;
case _WIN64_HOLDER:
p = parse_placeholder_arch(param, st._WIN64)
break
case _UNICODE_HOLDER:
p = parse_placeholder_unicode(param, st._UNICODE)
break
default:
throw new Error('the value of param placeholder invlaid:' + param[0]);
throw new Error('the value of param placeholder invlaid:' + param[0])
}
return p;
return p
}

@@ -43,8 +42,8 @@ // convert param like ['_WIN64_HOLDER_', 'int64', 'int32] to 'int64' or 'int32'

if (typeof param === 'string') {
return param;
return param
}
else if (!param || param.length !== 3) {
throw new Error('_WIN64 macro should be Array and has 3 items');
throw new Error('_WIN64 macro should be Array and has 3 items')
}
return _WIN64 ? param[1] : param[2];
return _WIN64 ? param[1] : param[2]
}

@@ -54,8 +53,8 @@ // convert param like ['_UNICODE_HOLDER_', 'uint16*', 'uint8*'] to 'uint16*' or 'uint8*'

if (typeof param === 'string') {
return param;
return param
}
else if (!param || param.length !== 3) {
throw new Error('_UNICODE macro should be Array and has 3 items');
throw new Error('_UNICODE macro should be Array and has 3 items')
}
return _UNICODE ? param[1] : param[2];
return _UNICODE ? param[1] : param[2]
}

@@ -67,12 +66,14 @@ /**

function prepare_macro(macroMap, settings) {
const ret = new Map();
const ret = new Map()
// v string|array
for (const [k, v] of macroMap.entries()) {
ret.set(k, parse_param_placeholder(v, settings));
ret.set(k, parse_param_placeholder(v, settings))
}
return ret;
return ret
}
// parse const HANDLE = 'PVOID' to the realy FFIParam (like 'uint32*')
function prepare_windef_ref(ww, macroSrc) {
const map = new Map();
const map = new Map()
// first loop paser keys which exists in macroSrc

@@ -82,16 +83,17 @@ for (const x of Object.keys(ww)) {

if (map.has(x)) {
continue;
continue
}
if (macroSrc.has(x)) {
const vv = macroSrc.get(x);
if (macroSrc.has(x)) { // PVOID:_WIN64_HOLDER -> PVOID:'uint64*'
const vv = macroSrc.get(x)
if (vv) {
validDataDef(vv, config_1.windefSet);
map.set(x, vv);
validDataDef(vv, windefSet)
map.set(x, vv)
}
else {
throw new Error(`value of "${vv}" blank`);
throw new Error(`value of "${vv}" blank`)
}
}
else {
continue; // not throw error
continue // not throw error
}

@@ -103,15 +105,18 @@ }

if (map.has(x)) {
continue;
continue
}
const value = retrieve_ref_value(ww, x, map);
value && config_1.windefSet.has(value) && map.set(x, value);
const value = retrieve_ref_value(ww, x, map)
value && windefSet.has(value) && map.set(x, value)
}
const ret = {};
const ret = {}
map.forEach((v, k) => {
ret[k] = v;
});
return ret;
ret[k] = v
})
return ret
}
function clone_filter_windef(windef) {
const ret = {};
const ret = {}
for (const x of Object.keys(windef)) {

@@ -124,43 +129,46 @@ if (typeof windef[x] === 'string') {

configurable: true,
});
})
}
else {
throw new Error(`typeof value of ${x} NOT string`);
throw new Error(`typeof value of ${x} NOT string`)
}
}
return ret;
return ret
}
function parse_settings(settings) {
const st = Object.assign({}, config_1.settingsDefault);
const st = Object.assign({}, settingsDefault)
if (typeof settings !== 'undefined' && settings && Object.keys(settings).length) {
Object.assign(st, settings);
Object.assign(st, settings)
}
return st;
return st
}
function retrieve_ref_value(ww, key, srcMap) {
const mapValue = srcMap.get(key);
const mapValue = srcMap.get(key)
if (mapValue) {
return mapValue;
return mapValue
}
if (typeof ww[key] === 'undefined') {
return '';
return ''
}
const value = ww[key];
const value = ww[key]
/* istanbul ignore next */
if (!value) {
return '';
return ''
}
// check whether ww has element value as key
const refValue = retrieve_ref_value(ww, value, srcMap);
return refValue ? refValue : value;
const refValue = retrieve_ref_value(ww, value, srcMap)
return refValue ? refValue : value
}
// valid parsed value exists in windefSet
function validDataDef(str, srcSet) {
export function validDataDef(str, srcSet) {
if (!str || typeof str !== 'string') {
throw new Error(`value of param invalid: ${str}`);
throw new Error(`value of param invalid: ${str}`)
}
if (!srcSet.has(str)) {
throw new Error(`conifig.windefSet not contains element of ${str}`);
throw new Error(`conifig.windefSet not contains element of ${str}`)
}
}
exports.validDataDef = validDataDef;

@@ -1,25 +0,23 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const config_1 = require('./config');
const windef_1 = require('./windef');
exports.macroMap = new Map([
['PVOID', [config_1._WIN64_HOLDER, 'uint64*', 'uint32*']],
['LONG_PTR', [config_1._WIN64_HOLDER, 'int64', 'int32']],
['ULONG_PTR', [config_1._WIN64_HOLDER, 'uint64', 'uint32']],
['HALF_PTR', [config_1._WIN64_HOLDER, 'int32', 'int16']],
['INT_PTR', [config_1._WIN64_HOLDER, 'int64', 'int32']],
['LPCTSTR', [config_1._UNICODE_HOLDER, windef_1.LPCWSTR, windef_1.LPCSTR]],
['LPHANDLE', [config_1._WIN64_HOLDER, 'uint64*', 'uint32*']],
['LPTSTR', [config_1._UNICODE_HOLDER, windef_1.LPWSTR, 'uint8*']],
['PCTSTR', [config_1._WIN64_HOLDER, windef_1.LPCWSTR, windef_1.LPCSTR]],
['PHANDLE', [config_1._WIN64_HOLDER, 'uint64**', 'uint32**']],
['PHKEY', [config_1._WIN64_HOLDER, 'uint64*', 'uint32*']],
['POINTER_32', [config_1._WIN64_HOLDER, 'uint64*', 'uint32*']],
['POINTER_64', [config_1._WIN64_HOLDER, 'uint64*', 'uint32*']],
['PTBYTE', [config_1._UNICODE_HOLDER, 'int16*', 'int8*']],
['PTCHAR', [config_1._UNICODE_HOLDER, 'uint16*', 'uint8*']],
['PTSTR', [config_1._UNICODE_HOLDER, windef_1.LPWSTR, windef_1.LPSTR]],
['TBYTE', [config_1._UNICODE_HOLDER, 'int16', 'int8']],
['TCHAR', [config_1._UNICODE_HOLDER, windef_1.WCHAR, 'uint8']],
['UHALF_PTR', [config_1._WIN64_HOLDER, 'uint32', 'uint16']],
]);
import { _UNICODE_HOLDER, _WIN64_HOLDER, } from './config'
import { LPCSTR, LPCWSTR, LPSTR, LPWSTR, WCHAR, } from './windef'
export 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']],
])

@@ -1,5 +0,3 @@

'use strict';
// windows data types struct for ref-struct module https://github.com/TooTallNate/ref-struct
Object.defineProperty(exports, '__esModule', { value: true });
const W = require('./windef');
import * as W from './windef'
/**

@@ -16,7 +14,7 @@ * Struct usage:

*/
exports.INITCOMMONCONTROLSEX = {
export const INITCOMMONCONTROLSEX = {
dwSize: W.DWORD,
dwICC: W.DWORD,
};
exports.MSG = {
}
export const MSG = {
hwnd: W.HWND,

@@ -28,9 +26,9 @@ message: W.UINT,

pt: W.POINT,
};
}
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd162805(v=vs.85).aspx
exports.POINT = {
export const POINT = {
x: W.LONG,
y: W.LONG,
};
exports.PROCESS_BASIC_INFORMATION = {
}
export const PROCESS_BASIC_INFORMATION = {
Reserved1: W.PVOID,

@@ -41,9 +39,9 @@ PebBaseAddress: W.PVOID,

InheritedFromUniqueProcessId: W.PVOID,
};
exports.UNICODE_STRING = {
}
export const UNICODE_STRING = {
Length: W.USHORT,
MaximumLength: W.USHORT,
Buffer: W.PWSTR,
};
exports.WINDOWINFO = {
}
export const WINDOWINFO = {
cbSize: W.DWORD,

@@ -59,5 +57,5 @@ rcWindow: W.RECT,

wCreatorVersion: W.WORD,
};
}
// https://msdn.microsoft.com/zh-cn/library/windows/desktop/ms633577(v=vs.85).aspx
exports.WNDCLASSEX = {
export const WNDCLASSEX = {
cbSize: W.UINT,

@@ -76,4 +74,4 @@ style: W.UINT,

hIconSm: W.HICON,
};
exports.RECT = {
}
export const RECT = {
left: W.LONG,

@@ -83,3 +81,3 @@ top: W.LONG,

bottom: W.LONG,
};
exports._RECT = exports.RECT;
}
export { RECT as _RECT }

@@ -1,3 +0,1 @@

'use strict';
/* ---------- data types for TypeScript ----------- */
Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,6 +0,4 @@

'use strict';
// windows data types for ref module https://github.com/TooTallNate/ref
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751
Object.defineProperty(exports, '__esModule', { value: true });
const config_1 = require('./config');
import { _UNICODE_HOLDER, _WIN64_HOLDER, } from './config'
/**

@@ -12,183 +10,183 @@ * macro convert method

*/
exports.ATOM = 'uint16';
exports.DWORD = 'uint32';
exports.PVOID = config_1._WIN64_HOLDER;
exports.HANDLE = 'PVOID';
exports.LONG_PTR = config_1._WIN64_HOLDER;
exports.ULONG_PTR = config_1._WIN64_HOLDER;
exports.VOID = 'void';
exports.WCHAR = 'uint16';
exports.WORD = 'int16';
exports.BOOL = 'int';
exports.BOOLEAN = 'bool';
exports.BYTE = 'byte';
exports.CALLBACK = 'pointer'; // https://msdn.microsoft.com/en-us/library/windows/desktop/ms633573(v=vs.85).aspx
exports.CCHAR = 'char';
exports.CHAR = 'char';
exports.COLORREF = 'DWORD';
export const ATOM = 'uint16'
export const DWORD = 'uint32'
export const PVOID = _WIN64_HOLDER
export const HANDLE = 'PVOID'
export const LONG_PTR = _WIN64_HOLDER
export const ULONG_PTR = _WIN64_HOLDER
export const VOID = 'void'
export const WCHAR = 'uint16'
export const WORD = 'int16'
export const BOOL = 'int'
export const BOOLEAN = 'bool'
export const BYTE = 'byte'
export const CALLBACK = 'pointer' // https://msdn.microsoft.com/en-us/library/windows/desktop/ms633573(v=vs.85).aspx
export const CCHAR = 'char'
export const CHAR = 'char'
export const COLORREF = 'DWORD'
// export const CONST;
exports.DWORDLONG = 'uint64';
exports.DWORD_PTR = 'ULONG_PTR';
exports.DWORD32 = 'uint32';
exports.DWORD64 = 'uint64';
exports.FLOAT = 'float';
exports.HACCEL = 'HANDLE';
exports.HALF_PTR = config_1._WIN64_HOLDER;
exports.HBITMAP = 'HANDLE';
exports.HBRUSH = 'HANDLE';
exports.HCOLORSPACE = 'HANDLE';
exports.HCONV = 'HANDLE';
exports.HCONVLIST = 'HANDLE';
exports.HCURSOR = 'HANDLE';
exports.HDC = 'HANDLE';
exports.HDDEDATA = 'HANDLE';
exports.HDESK = 'HANDLE';
exports.HDROP = 'HANDLE';
exports.HDWP = 'HANDLE';
exports.HENHMETAFILE = 'HANDLE';
exports.HFILE = 'HANDLE'; // typedef int HFILE;
exports.HFONT = 'HANDLE';
exports.HGDIOBJ = 'HANDLE';
exports.HGLOBAL = 'HANDLE';
exports.HHOOK = 'HANDLE';
exports.HICON = 'HANDLE';
exports.HINSTANCE = 'HANDLE';
exports.HKEY = 'HANDLE';
exports.HKL = 'HANDLE';
exports.HLOCAL = 'HANDLE';
exports.HMENU = 'HANDLE';
exports.HMETAFILE = 'HANDLE';
exports.HMODULE = exports.HINSTANCE;
exports.HMONITOR = 'HANDLE';
exports.HPALETTE = 'HANDLE';
exports.HPEN = 'HANDLE';
exports.HRESULT = 'long';
exports.HRGN = 'HANDLE';
exports.HRSRC = 'HANDLE';
exports.HSZ = 'HANDLE';
exports.HWINEVENTHOOK = 'HANDLE';
exports.HWINSTA = 'HANDLE';
exports.HWND = 'HANDLE';
exports.INT = 'int';
exports.INT_PTR = config_1._WIN64_HOLDER;
exports.INT8 = 'int8';
exports.INT16 = 'int16';
exports.INT32 = 'int32';
exports.INT64 = 'int64';
exports.LANGID = 'WORD';
exports.LCID = 'DWORD';
exports.LCTYPE = 'DWORD';
exports.LGRPID = 'DWORD';
exports.LONG = 'long';
exports.LONGLONG = 'longlong';
exports.LONG32 = 'int32';
exports.LONG64 = 'int64';
exports.LPARAM = 'LONG_PTR';
exports.LPBOOL = 'BOOL';
exports.LPBYTE = 'byte*';
exports.LPCOLORREF = 'DWORD';
exports.LPCSTR = 'uint8*';
exports.LPCWSTR = 'uint16*';
exports.LPCTSTR = config_1._UNICODE_HOLDER;
exports.LPVOID = 'void*';
exports.LPCVOID = 'LPVOID';
exports.LPDWORD = 'uint16*';
exports.LPHANDLE = config_1._WIN64_HOLDER; // A pointer to a HANDLE.
exports.LPINT = 'int*';
exports.LPLONG = 'int32*';
exports.LPMSG = 'pointer'; // A pointer to a MSG
exports.LPSTR = 'char*';
exports.LPWSTR = 'uint16*';
exports.LPTSTR = config_1._UNICODE_HOLDER;
exports.LPWORD = 'uint16*';
exports.LRESULT = 'LONG_PTR';
exports.NTSTATUS = 'uint32';
exports.PBOOL = 'int*'; // ? 'bool*'
exports.PBOOLEAN = 'bool*';
exports.PBYTE = 'byte*';
exports.PCHAR = 'char*';
exports.PCSTR = 'uint8*';
exports.PCTSTR = config_1._WIN64_HOLDER;
exports.PCWSTR = 'uint16*';
exports.PDWORD = 'uint32*';
exports.PDWORDLONG = 'uint64*';
exports.PDWORD_PTR = 'DWORD_PTR';
exports.PDWORD32 = 'uint32*';
exports.PDWORD64 = 'uint64*';
exports.PFLOAT = 'float*';
exports.PHALF_PTR = 'pointer'; // ? A pointer to a HALF_PTR.
exports.PHANDLE = config_1._WIN64_HOLDER;
exports.PHKEY = config_1._WIN64_HOLDER;
exports.PINT = 'int*';
exports.PINT_PTR = 'int**';
exports.PINT8 = 'int8*';
exports.PINT16 = 'int16*';
exports.PINT32 = 'int32*';
exports.PINT64 = 'int64*';
exports.PLCID = 'uint32*';
exports.PLONG = 'long*';
exports.PLONGLONG = 'int64*';
exports.PLONG_PTR = 'LONG_PTR';
exports.PLONG32 = 'int32*';
exports.PLONG64 = 'int64*';
export const DWORDLONG = 'uint64'
export const DWORD_PTR = 'ULONG_PTR'
export const DWORD32 = 'uint32'
export const DWORD64 = 'uint64'
export const FLOAT = 'float'
export const HACCEL = 'HANDLE'
export const HALF_PTR = _WIN64_HOLDER
export const HBITMAP = 'HANDLE'
export const HBRUSH = 'HANDLE'
export const HCOLORSPACE = 'HANDLE'
export const HCONV = 'HANDLE'
export const HCONVLIST = 'HANDLE'
export const HCURSOR = 'HANDLE'
export const HDC = 'HANDLE'
export const HDDEDATA = 'HANDLE'
export const HDESK = 'HANDLE'
export const HDROP = 'HANDLE'
export const HDWP = 'HANDLE'
export const HENHMETAFILE = 'HANDLE'
export const HFILE = 'HANDLE' // typedef int HFILE;
export const HFONT = 'HANDLE'
export const HGDIOBJ = 'HANDLE'
export const HGLOBAL = 'HANDLE'
export const HHOOK = 'HANDLE'
export const HICON = 'HANDLE'
export const HINSTANCE = 'HANDLE'
export const HKEY = 'HANDLE'
export const HKL = 'HANDLE'
export const HLOCAL = 'HANDLE'
export const HMENU = 'HANDLE'
export const HMETAFILE = 'HANDLE'
export const HMODULE = HINSTANCE
export const HMONITOR = 'HANDLE'
export const HPALETTE = 'HANDLE'
export const HPEN = 'HANDLE'
export const HRESULT = 'long'
export const HRGN = 'HANDLE'
export const HRSRC = 'HANDLE'
export const HSZ = 'HANDLE'
export const HWINEVENTHOOK = 'HANDLE'
export const HWINSTA = 'HANDLE'
export const HWND = 'HANDLE'
export const INT = 'int'
export const INT_PTR = _WIN64_HOLDER
export const INT8 = 'int8'
export const INT16 = 'int16'
export const INT32 = 'int32'
export const INT64 = 'int64'
export const LANGID = 'WORD'
export const LCID = 'DWORD'
export const LCTYPE = 'DWORD'
export const LGRPID = 'DWORD'
export const LONG = 'long'
export const LONGLONG = 'longlong'
export const LONG32 = 'int32'
export const LONG64 = 'int64'
export const LPARAM = 'LONG_PTR'
export const LPBOOL = 'BOOL'
export const LPBYTE = 'byte*'
export const LPCOLORREF = 'DWORD'
export const LPCSTR = 'uint8*'
export const LPCWSTR = 'uint16*'
export const LPCTSTR = _UNICODE_HOLDER
export const LPVOID = 'void*'
export const LPCVOID = 'LPVOID'
export const LPDWORD = 'uint16*'
export const LPHANDLE = _WIN64_HOLDER // A pointer to a HANDLE.
export const LPINT = 'int*'
export const LPLONG = 'int32*'
export const LPMSG = 'pointer' // A pointer to a MSG
export const LPSTR = 'char*'
export const LPWSTR = 'uint16*'
export const LPTSTR = _UNICODE_HOLDER
export const LPWORD = 'uint16*'
export const LRESULT = 'LONG_PTR'
export const NTSTATUS = 'uint32'
export const PBOOL = 'int*' // ? 'bool*'
export const PBOOLEAN = 'bool*'
export const PBYTE = 'byte*'
export const PCHAR = 'char*'
export const PCSTR = 'uint8*'
export const PCTSTR = _WIN64_HOLDER
export const PCWSTR = 'uint16*'
export const PDWORD = 'uint32*'
export const PDWORDLONG = 'uint64*'
export const PDWORD_PTR = 'DWORD_PTR'
export const PDWORD32 = 'uint32*'
export const PDWORD64 = 'uint64*'
export const PFLOAT = 'float*'
export const PHALF_PTR = 'pointer' // ? A pointer to a HALF_PTR.
export const PHANDLE = _WIN64_HOLDER
export const PHKEY = _WIN64_HOLDER
export const PINT = 'int*'
export const PINT_PTR = 'int**'
export const PINT8 = 'int8*'
export const PINT16 = 'int16*'
export const PINT32 = 'int32*'
export const PINT64 = 'int64*'
export const PLCID = 'uint32*'
export const PLONG = 'long*'
export const PLONGLONG = 'int64*'
export const PLONG_PTR = 'LONG_PTR'
export const PLONG32 = 'int32*'
export const PLONG64 = 'int64*'
// ? A 32-bit pointer. On a 32-bit system, this is a native pointer.
// On a 64-bit system, this is a truncated 64-bit pointer.
exports.POINTER_32 = config_1._WIN64_HOLDER;
export const POINTER_32 = _WIN64_HOLDER
// ? A 64-bit pointer. On a 64-bit system, this is a native pointer.
// On a 32-bit system, this is a sign-extended 32-bit pointer.
exports.POINTER_64 = config_1._WIN64_HOLDER;
exports.POINTER_SIGNED = 'pointer'; // ? A signed pointer.
exports.POINTER_UNSIGNED = 'pointer'; // An unsigned pointer.
exports.PSHORT = 'int16*';
exports.PSIZE_T = 'ULONG_PTR'; // ?
exports.PSSIZE_T = 'pointer';
exports.PSTR = 'char*';
exports.PTBYTE = config_1._UNICODE_HOLDER;
exports.PTCHAR = config_1._UNICODE_HOLDER;
exports.PTSTR = config_1._UNICODE_HOLDER;
exports.PUCHAR = 'pointer';
exports.PUHALF_PTR = 'pointer';
exports.PUINT = 'uint*';
exports.PUINT_PTR = 'uint**';
exports.PUINT8 = 'uint8*';
exports.PUINT16 = 'uint16*';
exports.PUINT32 = 'uint32*';
exports.PUINT64 = 'uint64*';
exports.PULONG = 'uint*';
exports.PULONGLONG = 'uint64*';
exports.PULONG_PTR = 'uint64**';
exports.PULONG32 = 'uint*';
exports.PULONG64 = 'uint64*';
exports.PUSHORT = 'uint16*';
exports.PWCHAR = 'uint16*';
exports.PWORD = 'uint16*';
exports.PWSTR = 'uint16*';
exports.QWORD = 'uint64';
exports.SC_HANDLE = 'HANDLE';
exports.SC_LOCK = 'LPVOID';
exports.SERVICE_STATUS_HANDLE = 'HANDLE';
exports.SHORT = 'int16';
exports.SIZE_T = 'ULONG_PTR'; // ?
exports.SSIZE_T = 'LONG_PTR'; // ?
exports.TBYTE = config_1._UNICODE_HOLDER;
exports.TCHAR = config_1._UNICODE_HOLDER;
exports.UCHAR = 'uchar';
exports.UHALF_PTR = config_1._WIN64_HOLDER;
exports.UINT = 'uint';
exports.UINT_PTR = 'uint';
exports.UINT8 = 'uint8';
exports.UINT16 = 'uint16';
exports.UINT32 = 'uint32';
exports.UINT64 = 'uint64';
exports.ULONG = 'uint';
exports.ULONGLONG = 'uint64';
exports.ULONG32 = 'uint32';
exports.ULONG64 = 'uint64';
exports.USHORT = 'ushort';
exports.UNICODE_STRING = 'pointer';
exports.USN = 'LONGLONG';
export const POINTER_64 = _WIN64_HOLDER
export const POINTER_SIGNED = 'pointer' // ? A signed pointer.
export const POINTER_UNSIGNED = 'pointer' // An unsigned pointer.
export const PSHORT = 'int16*'
export const PSIZE_T = 'ULONG_PTR' // ?
export const PSSIZE_T = 'pointer'
export const PSTR = 'char*'
export const PTBYTE = _UNICODE_HOLDER
export const PTCHAR = _UNICODE_HOLDER
export const PTSTR = _UNICODE_HOLDER
export const PUCHAR = 'pointer'
export const PUHALF_PTR = 'pointer'
export const PUINT = 'uint*'
export const PUINT_PTR = 'uint**'
export const PUINT8 = 'uint8*'
export const PUINT16 = 'uint16*'
export const PUINT32 = 'uint32*'
export const PUINT64 = 'uint64*'
export const PULONG = 'uint*'
export const PULONGLONG = 'uint64*'
export const PULONG_PTR = 'uint64**'
export const PULONG32 = 'uint*'
export const PULONG64 = 'uint64*'
export const PUSHORT = 'uint16*'
export const PWCHAR = 'uint16*'
export const PWORD = 'uint16*'
export const PWSTR = 'uint16*'
export const QWORD = 'uint64'
export const SC_HANDLE = 'HANDLE'
export const SC_LOCK = 'LPVOID'
export const SERVICE_STATUS_HANDLE = 'HANDLE'
export const SHORT = 'int16'
export const SIZE_T = 'ULONG_PTR' // ?
export const SSIZE_T = 'LONG_PTR' // ?
export const TBYTE = _UNICODE_HOLDER
export const TCHAR = _UNICODE_HOLDER
export const UCHAR = 'uchar'
export const UHALF_PTR = _WIN64_HOLDER
export const UINT = 'uint'
export const UINT_PTR = 'uint'
export const UINT8 = 'uint8'
export const UINT16 = 'uint16'
export const UINT32 = 'uint32'
export const UINT64 = 'uint64'
export const ULONG = 'uint'
export const ULONGLONG = 'uint64'
export const ULONG32 = 'uint32'
export const ULONG64 = 'uint64'
export const USHORT = 'ushort'
export const UNICODE_STRING = 'pointer'
export const USN = 'LONGLONG'
// export const WINAPI;
exports.WINEVENTPROC = 'pointer';
exports.WNDENUMPROC = 'pointer';
exports.WNDPROC = 'pointer';
export const WINEVENTPROC = 'pointer'
export const WNDENUMPROC = 'pointer'
export const WNDPROC = 'pointer'
/**

@@ -200,13 +198,13 @@ * Caution: original be typedef UINT_PTR WPARAM;

// export const WPARAM = UINT_PTR;
exports.WPARAM = 'LONG_PTR';
exports.LPINITCOMMONCONTROLSEX = 'pointer'; // A pointer to an INITCOMMONCONTROLSEX
exports.LPWNDCLASSEX = 'pointer'; // A pointer to a WNDCLASSEX
exports.PWINDOWINFO = 'pointer'; // A pointer to a WINDOWINFO structure
exports.va_list = 'char*';
export const WPARAM = 'LONG_PTR'
export const LPINITCOMMONCONTROLSEX = 'pointer' // A pointer to an INITCOMMONCONTROLSEX
export const LPWNDCLASSEX = 'pointer' // A pointer to a WNDCLASSEX
export const PWINDOWINFO = 'pointer' // A pointer to a WINDOWINFO structure
export const va_list = 'char*'
/* ------------------ struct ---------------------- */
exports.INITCOMMONCONTROLSEX = 'pointer';
exports.MSG = 'pointer';
exports.POINT = 'pointer';
exports.WNDCLASSEX = 'pointer';
exports.WINDOWINFO = 'pointer';
exports.RECT = 'pointer'; // _RECT
export const INITCOMMONCONTROLSEX = 'pointer'
export const MSG = 'pointer'
export const POINT = 'pointer'
export const WNDCLASSEX = 'pointer'
export const WINDOWINFO = 'pointer'
export const RECT = 'pointer' // _RECT

@@ -1,4 +0,1 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const tslib_1 = require('tslib');
tslib_1.__exportStar(require('./utils'), exports);
export * from './utils'
/// <reference types="node" />
import { chmod, close, copyFile, mkdir, open, readdir, readFile, unlink, write, writeFile } from 'fs';
import { basename, join, normalize, resolve as pathResolve } from 'path';
import { chmod, close, copyFile, mkdir, open, readdir, readFile, rmdir, unlink, write, writeFile } from 'fs';
import { basename, dirname, join, normalize, resolve as pathResolve } from 'path';
import { promisify } from 'util';

@@ -12,6 +12,7 @@ export declare const closeAsync: typeof close.__promisify__;

export declare const readDirAsync: typeof readdir.__promisify__;
export declare const rmdirAsync: typeof rmdir.__promisify__;
export declare const unlinkAsync: typeof unlink.__promisify__;
export declare const writeAsync: typeof write.__promisify__;
export declare const writeFileAsync: typeof writeFile.__promisify__;
export { basename, join, normalize, pathResolve, promisify };
export { basename, dirname, join, normalize, pathResolve, promisify, };
export { tmpdir } from 'os';

@@ -41,1 +42,7 @@ export declare function isPathAcessible(path: string): Promise<boolean>;

}
export declare function assertNever(x: never): never;
/**
* Remove directory recursively
* @see https://stackoverflow.com/a/42505874/3027390
*/
export declare function rimraf(path: string): Promise<void>;

@@ -1,88 +0,120 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const fs_1 = require('fs');
const path_1 = require('path');
exports.basename = path_1.basename;
exports.join = path_1.join;
exports.normalize = path_1.normalize;
exports.pathResolve = path_1.resolve;
const util_1 = require('util');
exports.promisify = util_1.promisify;
exports.closeAsync = util_1.promisify(fs_1.close);
exports.chmodAsync = util_1.promisify(fs_1.chmod);
exports.copyFileAsync = util_1.promisify(fs_1.copyFile);
exports.mkdirAsync = util_1.promisify(fs_1.mkdir);
exports.openAsync = util_1.promisify(fs_1.open);
exports.readFileAsync = util_1.promisify(fs_1.readFile);
exports.readDirAsync = util_1.promisify(fs_1.readdir);
exports.unlinkAsync = util_1.promisify(fs_1.unlink);
exports.writeAsync = util_1.promisify(fs_1.write);
exports.writeFileAsync = util_1.promisify(fs_1.writeFile);
var os_1 = require('os');
exports.tmpdir = os_1.tmpdir;
import { access, chmod, close, copyFile, mkdir, open, readdir, readFile, rmdir, stat, unlink, write, writeFile, } from 'fs'
import { basename, dirname, join, normalize, resolve as pathResolve, sep, } from 'path'
import { promisify } from 'util'
export const closeAsync = promisify(close)
export const chmodAsync = promisify(chmod)
export const copyFileAsync = promisify(copyFile)
export const mkdirAsync = promisify(mkdir)
export const openAsync = promisify(open)
export const readFileAsync = promisify(readFile)
export const readDirAsync = promisify(readdir)
export const rmdirAsync = promisify(rmdir)
export const unlinkAsync = promisify(unlink)
export const writeAsync = promisify(write)
export const writeFileAsync = promisify(writeFile)
export { basename, dirname, join, normalize, pathResolve, promisify, }
export { tmpdir } from 'os'
// support relative file ('./foo')
function isPathAcessible(path) {
export function isPathAcessible(path) {
return path
? new Promise(resolve => fs_1.access(path, err => resolve(err ? false : true)))
: Promise.resolve(false);
? new Promise(resolve => access(path, err => resolve(err ? false : true)))
: Promise.resolve(false)
}
exports.isPathAcessible = isPathAcessible;
function isDirExists(path) {
return path ? isDirFileExists(path, 'DIR') : Promise.resolve(false);
export function isDirExists(path) {
return path ? isDirFileExists(path, 'DIR') : Promise.resolve(false)
}
exports.isDirExists = isDirExists;
function isFileExists(path) {
return path ? isDirFileExists(path, 'FILE') : Promise.resolve(false);
export function isFileExists(path) {
return path ? isDirFileExists(path, 'FILE') : Promise.resolve(false)
}
exports.isFileExists = isFileExists;
function isDirFileExists(path, type) {
return path
? new Promise(resolve => {
fs_1.stat(path, (err, stats) => (err ? resolve(false) : resolve(type === 'DIR' ? stats.isDirectory() : stats.isFile())));
stat(path, (err, stats) => {
err || !stats ? resolve(false) : resolve(type === 'DIR' ? stats.isDirectory() : stats.isFile())
})
})
: Promise.resolve(false);
: Promise.resolve(false)
}
// create directories recursively
async function createDir(path) {
export async function createDir(path) {
if (!path) {
throw new Error('value of path param invalid');
throw new Error('value of path param invalid')
}
else {
path = normalize(path) // ! required for '.../.myca' under win32
/* istanbul ignore else */
if (!await isDirExists(path)) {
await path.split(path_1.sep).reduce(async (parentDir, childDir) => {
const curDir = path_1.resolve(await parentDir, childDir);
await isPathAcessible(curDir) || await exports.mkdirAsync(curDir, 0o755);
return curDir;
}, Promise.resolve(path_1.sep));
await path.split(sep).reduce(async (parentDir, childDir) => {
const curDir = pathResolve(await parentDir, childDir)
await isPathAcessible(curDir) || await mkdirAsync(curDir, 0o755)
return curDir
}, Promise.resolve(sep))
}
}
}
exports.createDir = createDir;
async function createFile(file, data, options) {
const path = path_1.dirname(file);
export async function createFile(file, data, options) {
const path = dirname(file)
/* istanbul ignore next */
if (!path) {
throw new Error('path empty');
throw new Error('path empty')
}
if (!await isDirExists(path)) {
await createDir(path);
await createDir(path)
}
file = normalize(file)
/* istanbul ignore else */
if (!await isFileExists(file)) {
const opts = options ? options : { mode: 0o640 };
const opts = options ? options : { mode: 0o640 }
if (typeof data === 'object') {
await exports.writeFileAsync(file, JSON.stringify(data));
await writeFileAsync(file, JSON.stringify(data))
}
else {
await exports.writeFileAsync(file, data, opts);
await writeFileAsync(file, data, opts)
}
}
}
exports.createFile = createFile;
/* istanbul ignore next */
function logger(...args) {
export function logger(...args) {
// tslint:disable-next-line
console.log(args);
console.log(args)
}
exports.logger = logger;
export function assertNever(x) {
throw new Error('Assert Never Unexpected object: ' + x)
}
/**
* Remove directory recursively
* @see https://stackoverflow.com/a/42505874/3027390
*/
export async function rimraf(path) {
if (!path) {
return
}
await _rimraf(path)
if (await isDirExists(path)) {
await rmdirAsync(path)
}
}
async function _rimraf(path) {
if (!path) {
return
}
if (await isPathAcessible(path)) {
if (await isFileExists(path)) {
await unlinkAsync(path)
return
}
const entries = await readDirAsync(path)
if (entries.length) {
for (const entry of entries) {
await _rimraf(join(path, entry))
}
}
else {
await rmdirAsync(path)
}
}
}
{
"name": "win32-def",
"author": "waiting",
"version": "2.0.1",
"version": "2.0.2",
"description": "win32 definitions for node-ffi",

@@ -13,5 +13,7 @@ "keywords": [

"engines": {
"node": ">=8.9.0"
"node": ">=8.10.0"
},
"main": "./dist/index.js",
"browser": "",
"es2015": "./dist/index.esm.js",
"main": "./dist/index.cjs.js",
"module": "./dist/index.js",

@@ -49,7 +51,8 @@ "types": "./dist/index.d.ts",

"devDependencies": {
"@types/mocha": "^5.0.0",
"@types/node": "^9.4.7",
"@types/power-assert": "^1.4.29",
"@types/mocha": "^5.2.2",
"@types/node": "^10.3.2",
"@types/power-assert": "^1.5.0",
"@types/rewire": "^2.5.28",
"@types/rimraf": "^2.0.2",
"@types/yargs": "^11.0.0",
"coveralls": "^3.0.0",

@@ -59,14 +62,19 @@ "eslint": "^4.19.1",

"istanbul": "^0.4.5",
"mocha": "^5.0.3",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "^1.3.0",
"mz-modules": "^2.1.0",
"nyc": "^11.5.0",
"power-assert": "^1.4.4",
"rewire": "^3.0.2",
"nyc": "^12.0.2",
"power-assert": "^1.5.0",
"rewire": "^4.0.0",
"rimraf": "^2.6.2",
"source-map-support": "^0.5.4",
"ts-node": "^5.0.1",
"tslint": "^5.9.1",
"tslint-eslint-rules": "^5.1.0",
"typescript": "^2.7.2"
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-uglify": "^3.0.0",
"rxjs": "^6.2.0",
"source-map-support": "^0.5.6",
"ts-node": "^6.1.1",
"tslint": "^5.10.0",
"tslint-eslint-rules": "^5.3.1",
"typescript": "^2.9.1",
"yargs": "^11.1.0"
},

@@ -76,3 +84,3 @@ "scripts": {

"bp:sync": "git fetch bp && git pull --no-edit bp master",
"build": "npm run clean && npm run lint && npm run lint:t && npm run tsc && npm run jslint",
"build": "npm run clean && npm run lint && npm run lint:t && npm run tsc && npm run jslint && npm run rp",
"clean": "rm -rf dist/*",

@@ -85,3 +93,5 @@ "cov": "nyc mocha",

"prepublishOnly": "npm run build",
"repo:init": "git config --global core.hooksPath ./.githooks && echo It may going for long time. Plese wait... && npm i && ts-node .githooks/init.ts",
"repo:init": "git config --local push.followTags true && git config --local core.hooksPath ./.githooks && git config --local remote.origin.prune true && git config --local remote.origin.tagopt \"--tags\" && git config --local remote.pushdefault origin && echo It may going for a long time. Plese wait... && npm i && ts-node -P .githooks/tsconfig.json .githooks/init.ts",
"rp": "rollup -c rollup.config.js",
"rp:w": "npm run tsc:w | rollup -wc rollup.config.js",
"test": "mocha --opts test/mocha.opts",

@@ -88,0 +98,0 @@ "tsc": "tsc -p tsconfig.json",

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