file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
src/OpenArk/common/ui-wrapper/ui-wrapper.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <windows.h> #include <vector> #include <common/common.h> #include <openark/openark.h> class CommonMainTabObject : public QTabWidget { Q_OBJECT public: CommonMainTabObject(OpenArk *parent) { parent_ = parent; }; ~CommonMainTabObject() {}; public: OpenArk *GetParent() const { return parent_; }; Q_INVOKABLE void SetActiveTab(QVector<int> idx) { tabwidget_->setCurrentIndex(idx[0]); auto tabwidgets = tabwidget_->currentWidget()->findChildren<QTabWidget*>(); if (idx.size() >= 2 && tabwidgets.size() > 0) { auto obj = qobject_cast<QTabWidget*>(tabwidgets.at(0)); obj->setCurrentIndex(idx[1]); } }; Q_INVOKABLE int GetActiveTab() { return tabwidget_->currentIndex(); }; Q_INVOKABLE void SetActiveTab(int idx) { tabwidget_->setCurrentIndex(idx); }; Q_INVOKABLE void RefreshTab() { onTabChanged(GetActiveTab()); }; public slots: virtual void onTabChanged(int index) { auto tabwidgets = tabwidget_->currentWidget()->findChildren<QTabWidget*>(); if (tabwidgets.size() > 0) { auto obj = qobject_cast<QTabWidget*>(tabwidgets.at(0)); emit obj->currentChanged(obj->currentIndex()); } else { QVector<int> tabs; tabs.push_back(index); tabs.push_back(0); OpenArkConfig::Instance()->SetMainTabMap(maintab_id_, tabs); } }; protected: void Init(QTabWidget *tabwidget, int maintab_id) { tabwidget_ = tabwidget; maintab_id_ = maintab_id; tabwidget_->setTabPosition(QTabWidget::West); tabwidget_->tabBar()->setStyle(new OpenArkTabStyle); connect(tabwidget_, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int))); }; int maintab_id_; QTabWidget *tabwidget_; OpenArk *parent_; }; class CommonTabObject : public QWidget { Q_OBJECT public: CommonTabObject() {}; ~CommonTabObject() {}; public: Q_INVOKABLE int GetActiveTab() { return tabwidget_->currentIndex(); }; Q_INVOKABLE void SetActiveTab(QVector<int> idx) { tabwidget_->setCurrentIndex(idx[0]); qobject_cast<QTabWidget *>(tabwidget_->currentWidget())->setCurrentIndex(idx[1]); }; public slots: virtual void onTabChanged(int index) { QVector<int> tabs; tabs.push_back(l2tab_id_); tabs.push_back(index); OpenArkConfig::Instance()->SetMainTabMap(maintab_id_, tabs); }; protected: void Init(QTabWidget *tabwidget, int maintab_id, int l2tab_id) { tabwidget_ = tabwidget; maintab_id_ = maintab_id; l2tab_id_ = l2tab_id; connect(tabwidget_, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int))); }; int maintab_id_; int l2tab_id_; QTabWidget *tabwidget_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/compress/xzip/XUnzip.cpp
C++
// XZip.h Version 1.3 #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <time.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <tchar.h> #include "XUnzip.h" namespace Plugin { namespace XZip { #pragma warning(disable : 4996) // disable bogus deprecation warning // THIS FILE is almost entirely based upon code by Jean-loup Gailly // and Mark Adler. It has been modified by Lucian Wischik. // The original code may be found at http://www.gzip.org/zlib/ // The original copyright text follows. // // // // zlib.h -- interface of the 'zlib' general purpose compression library // version 1.1.3, July 9th, 1998 // // Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // 3. This notice may not be removed or altered from any source distribution. // // Jean-loup Gailly Mark Adler // jloup@gzip.org madler@alumni.caltech.edu // // // The data format used by the zlib library is described by RFCs (Request for // Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt // (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). // // // The 'zlib' compression library provides in-memory compression and // decompression functions, including integrity checks of the uncompressed // data. This version of the library supports only one compression method // (deflation) but other algorithms will be added later and will have the same // stream interface. // // Compression can be done in a single step if the buffers are large // enough (for example if an input file is mmap'ed), or can be done by // repeated calls of the compression function. In the latter case, the // application must provide more input and/or consume the output // (providing more output space) before each call. // // The library also supports reading and writing files in gzip (.gz) format // with an interface similar to that of stdio. // // The library does not install any signal handler. The decoder checks // the consistency of the compressed data, so the library should never // crash even in case of corrupted input. // // for more info about .ZIP format, see ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip // PkWare has also a specification at ftp://ftp.pkware.com/probdesc.zip #define zmalloc(len) malloc(len) #define zfree(p) free(p) /* void *zmalloc(unsigned int len) { char *buf = new char[len+32]; for (int i=0; i<16; i++) { buf[i]=i; buf[len+31-i]=i; } *((unsigned int*)buf) = len; char c[1000]; wsprintf(c,"malloc 0x%lx - %lu",buf+16,len); OutputDebugString(c); return buf+16; } void zfree(void *buf) { char c[1000]; wsprintf(c,"free 0x%lx",buf); OutputDebugString(c); char *p = ((char*)buf)-16; unsigned int len = *((unsigned int*)p); bool blown=false; for (int i=0; i<16; i++) { char lo = p[i]; char hi = p[len+31-i]; if (hi!=i || (lo!=i && i>4)) blown=true; } if (blown) { OutputDebugString("BLOWN!!!"); } delete[] p; } */ #pragma warning(disable : 4702) // unreachable code static ZRESULT zopenerror = ZR_OK; //+++1.2 typedef struct tm_unz_s { unsigned int tm_sec; // seconds after the minute - [0,59] unsigned int tm_min; // minutes after the hour - [0,59] unsigned int tm_hour; // hours since midnight - [0,23] unsigned int tm_mday; // day of the month - [1,31] unsigned int tm_mon; // months since January - [0,11] unsigned int tm_year; // years - [1980..2044] } tm_unz; // unz_global_info structure contain global data about the ZIPfile typedef struct unz_global_info_s { unsigned long number_entry; // total number of entries in the central dir on this disk unsigned long size_comment; // size of the global comment of the zipfile } unz_global_info; // unz_file_info contain information about a file in the zipfile typedef struct unz_file_info_s { unsigned long version; // version made by 2 bytes unsigned long version_needed; // version needed to extract 2 bytes unsigned long flag; // general purpose bit flag 2 bytes unsigned long compression_method; // compression method 2 bytes unsigned long dosDate; // last mod file date in Dos fmt 4 bytes unsigned long crc; // crc-32 4 bytes unsigned long compressed_size; // compressed size 4 bytes unsigned long uncompressed_size; // uncompressed size 4 bytes unsigned long size_filename; // filename length 2 bytes unsigned long size_file_extra; // extra field length 2 bytes unsigned long size_file_comment; // file comment length 2 bytes unsigned long disk_num_start; // disk number start 2 bytes unsigned long internal_fa; // internal file attributes 2 bytes unsigned long external_fa; // external file attributes 4 bytes tm_unz tmu_date; } unz_file_info; #define UNZ_OK (0) #define UNZ_END_OF_LIST_OF_FILE (-100) #define UNZ_ERRNO (Z_ERRNO) #define UNZ_EOF (0) #define UNZ_PARAMERROR (-102) #define UNZ_BADZIPFILE (-103) #define UNZ_INTERNALERROR (-104) #define UNZ_CRCERROR (-105) #define ZLIB_VERSION "1.1.3" // Allowed flush values; see deflate() for details #define Z_NO_FLUSH 0 #define Z_SYNC_FLUSH 2 #define Z_FULL_FLUSH 3 #define Z_FINISH 4 // compression levels #define Z_NO_COMPRESSION 0 #define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) // compression strategy; see deflateInit2() for details #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 #define Z_DEFAULT_STRATEGY 0 // Possible values of the data_type field #define Z_BINARY 0 #define Z_ASCII 1 #define Z_UNKNOWN 2 // The deflate compression method (the only one supported in this version) #define Z_DEFLATED 8 // for initializing zalloc, zfree, opaque #define Z_NULL 0 // case sensitivity when searching for filenames #define CASE_SENSITIVE 1 #define CASE_INSENSITIVE 2 // Return codes for the compression/decompression functions. Negative // values are errors, positive values are used for special but normal events. #define Z_OK 0 #define Z_STREAM_END 1 #define Z_NEED_DICT 2 #define Z_ERRNO (-1) #define Z_STREAM_ERROR (-2) #define Z_DATA_ERROR (-3) #define Z_MEM_ERROR (-4) #define Z_BUF_ERROR (-5) #define Z_VERSION_ERROR (-6) // Basic data types typedef unsigned char Byte; // 8 bits typedef unsigned int uInt; // 16 bits or more typedef unsigned long uLong; // 32 bits or more typedef void *voidpf; typedef void *voidp; typedef long z_off_t; typedef voidpf(*alloc_func) (voidpf opaque, uInt items, uInt size); typedef void(*free_func) (voidpf opaque, voidpf address); struct internal_state; typedef struct z_stream_s { Byte *next_in; // next input byte uInt avail_in; // number of bytes available at next_in uLong total_in; // total nb of input bytes read so far Byte *next_out; // next output byte should be put there uInt avail_out; // remaining free space at next_out uLong total_out; // total nb of bytes output so far char *msg; // last error message, NULL if no error struct internal_state *state; // not visible by applications alloc_func zalloc; // used to allocate the internal state free_func zfree; // used to free the internal state voidpf opaque; // private data object passed to zalloc and zfree int data_type; // best guess about the data type: ascii or binary uLong adler; // adler32 value of the uncompressed data uLong reserved; // reserved for future use } z_stream; typedef z_stream *z_streamp; // The application must update next_in and avail_in when avail_in has // dropped to zero. It must update next_out and avail_out when avail_out // has dropped to zero. The application must initialize zalloc, zfree and // opaque before calling the init function. All other fields are set by the // compression library and must not be updated by the application. // // The opaque value provided by the application will be passed as the first // parameter for calls of zalloc and zfree. This can be useful for custom // memory management. The compression library attaches no meaning to the // opaque value. // // zalloc must return Z_NULL if there is not enough memory for the object. // If zlib is used in a multi-threaded application, zalloc and zfree must be // thread safe. // // The fields total_in and total_out can be used for statistics or // progress reports. After compression, total_in holds the total size of // the uncompressed data and may be saved for use in the decompressor // (particularly if the decompressor wants to decompress everything in // a single step). // // basic functions const char *zlibVersion(); // The application can compare zlibVersion and ZLIB_VERSION for consistency. // If the first character differs, the library code actually used is // not compatible with the zlib.h header file used by the application. // This check is automatically made by inflateInit. int inflate(z_streamp strm, int flush); // // inflate decompresses as much data as possible, and stops when the input // buffer becomes empty or the output buffer becomes full. It may some // introduce some output latency (reading input without producing any output) // except when forced to flush. // // The detailed semantics are as follows. inflate performs one or both of the // following actions: // // - Decompress more input starting at next_in and update next_in and avail_in // accordingly. If not all input can be processed (because there is not // enough room in the output buffer), next_in is updated and processing // will resume at this point for the next call of inflate(). // // - Provide more output starting at next_out and update next_out and avail_out // accordingly. inflate() provides as much output as possible, until there // is no more input data or no more space in the output buffer (see below // about the flush parameter). // // Before the call of inflate(), the application should ensure that at least // one of the actions is possible, by providing more input and/or consuming // more output, and updating the next_* and avail_* values accordingly. // The application can consume the uncompressed output when it wants, for // example when the output buffer is full (avail_out == 0), or after each // call of inflate(). If inflate returns Z_OK and with zero avail_out, it // must be called again after making room in the output buffer because there // might be more output pending. // // If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much // output as possible to the output buffer. The flushing behavior of inflate is // not specified for values of the flush parameter other than Z_SYNC_FLUSH // and Z_FINISH, but the current implementation actually flushes as much output // as possible anyway. // // inflate() should normally be called until it returns Z_STREAM_END or an // error. However if all decompression is to be performed in a single step // (a single call of inflate), the parameter flush should be set to // Z_FINISH. In this case all pending input is processed and all pending // output is flushed; avail_out must be large enough to hold all the // uncompressed data. (The size of the uncompressed data may have been saved // by the compressor for this purpose.) The next operation on this stream must // be inflateEnd to deallocate the decompression state. The use of Z_FINISH // is never required, but can be used to inform inflate that a faster routine // may be used for the single inflate() call. // // If a preset dictionary is needed at this point (see inflateSetDictionary // below), inflate sets strm-adler to the adler32 checksum of the // dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise // it sets strm->adler to the adler32 checksum of all output produced // so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or // an error code as described below. At the end of the stream, inflate() // checks that its computed adler32 checksum is equal to that saved by the // compressor and returns Z_STREAM_END only if the checksum is correct. // // inflate() returns Z_OK if some progress has been made (more input processed // or more output produced), Z_STREAM_END if the end of the compressed data has // been reached and all uncompressed output has been produced, Z_NEED_DICT if a // preset dictionary is needed at this point, Z_DATA_ERROR if the input data was // corrupted (input stream not conforming to the zlib format or incorrect // adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent // (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not // enough memory, Z_BUF_ERROR if no progress is possible or if there was not // enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR // case, the application may then call inflateSync to look for a good // compression block. // int inflateEnd(z_streamp strm); // // All dynamically allocated data structures for this stream are freed. // This function discards any unprocessed input and does not flush any // pending output. // // inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state // was inconsistent. In the error case, msg may be set but then points to a // static string (which must not be deallocated). // Advanced functions // The following functions are needed only in some special applications. int inflateSetDictionary(z_streamp strm, const Byte *dictionary, uInt dictLength); // // Initializes the decompression dictionary from the given uncompressed byte // sequence. This function must be called immediately after a call of inflate // if this call returned Z_NEED_DICT. The dictionary chosen by the compressor // can be determined from the Adler32 value returned by this call of // inflate. The compressor and decompressor must use exactly the same // dictionary. // // inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a // parameter is invalid (such as NULL dictionary) or the stream state is // inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the // expected one (incorrect Adler32 value). inflateSetDictionary does not // perform any decompression: this will be done by subsequent calls of // inflate(). int inflateSync(z_streamp strm); // // Skips invalid compressed data until a full flush point can be found, or until all // available input is skipped. No output is provided. // // inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR // if no more input was provided, Z_DATA_ERROR if no flush point has been found, // or Z_STREAM_ERROR if the stream structure was inconsistent. In the success // case, the application may save the current current value of total_in which // indicates where valid compressed data was found. In the error case, the // application may repeatedly call inflateSync, providing more input each time, // until success or end of the input data. int inflateReset(z_streamp strm); // This function is equivalent to inflateEnd followed by inflateInit, // but does not free and reallocate all the internal decompression state. // The stream will keep attributes that may have been set by inflateInit2. // // inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source // stream state was inconsistent (such as zalloc or state being NULL). // // checksum functions // These functions are not related to compression but are exported // anyway because they might be useful in applications using the // compression library. uLong adler32(uLong adler, const Byte *buf, uInt len); // Update a running Adler-32 checksum with the bytes buf[0..len-1] and // return the updated checksum. If buf is NULL, this function returns // the required initial value for the checksum. // An Adler-32 checksum is almost as reliable as a CRC32 but can be computed // much faster. Usage example: // // uLong adler = adler32(0L, Z_NULL, 0); // // while (read_buffer(buffer, length) != EOF) { // adler = adler32(adler, buffer, length); // } // if (adler != original_adler) error(); uLong ucrc32(uLong crc, const Byte *buf, uInt len); // Update a running crc with the bytes buf[0..len-1] and return the updated // crc. If buf is NULL, this function returns the required initial value // for the crc. Pre- and post-conditioning (one's complement) is performed // within this function so it shouldn't be done by the application. // Usage example: // // uLong crc = crc32(0L, Z_NULL, 0); // // while (read_buffer(buffer, length) != EOF) { // crc = crc32(crc, buffer, length); // } // if (crc != original_crc) error(); const char *zError(int err); int inflateSyncPoint(z_streamp z); const uLong *get_crc_table(void); typedef unsigned char uch; typedef uch uchf; typedef unsigned short ush; typedef ush ushf; typedef unsigned long ulg; const char * const z_errmsg[10] = { // indexed by 2-zlib_error "need dictionary", // Z_NEED_DICT 2 "stream end", // Z_STREAM_END 1 "", // Z_OK 0 "file error", // Z_ERRNO (-1) "stream error", // Z_STREAM_ERROR (-2) "data error", // Z_DATA_ERROR (-3) "insufficient memory", // Z_MEM_ERROR (-4) "buffer error", // Z_BUF_ERROR (-5) "incompatible version",// Z_VERSION_ERROR (-6) "" }; #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] #define ERR_RETURN(strm,err) \ return (strm->msg = (char*)ERR_MSG(err), (err)) // To be used only when the state is known to be valid // common constants #define STORED_BLOCK 0 #define STATIC_TREES 1 #define DYN_TREES 2 // The three kinds of block type #define MIN_MATCH 3 #define MAX_MATCH 258 // The minimum and maximum match lengths #define PRESET_DICT 0x20 // preset dictionary flag in zlib header // target dependencies #define OS_CODE 0x0b // Window 95 & Windows NT // functions #define zmemzero(dest, len) memset(dest, 0, len) // Diagnostic functions #undef Assert #undef Trace #undef Tracev #undef Tracevv #undef Tracec #undef Tracecv #ifdef DEBUG int z_verbose = 0; void z_error(char *m) { fprintf(stderr, "%s\n", m); exit(1); } #define Assert(cond,msg) {if(!(cond)) z_error(msg);} #define Trace(x) {if (z_verbose>=0) fprintf x ;} #define Tracev(x) {if (z_verbose>0) fprintf x ;} #define Tracevv(x) {if (z_verbose>1) fprintf x ;} #define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} #define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} #else #ifndef __noop #if _MSC_VER < 1300 #define __noop ((void)0) #endif #endif #define Assert(cond,msg) __noop #define Trace(x) __noop #define Tracev(x) __noop #define Tracevv(x) __noop #define Tracec(c,x) __noop #define Tracecv(c,x) __noop #endif typedef uLong(*check_func) (uLong check, const Byte *buf, uInt len); voidpf zcalloc(voidpf opaque, unsigned items, unsigned size); void zcfree(voidpf opaque, voidpf ptr); #define ZALLOC(strm, items, size) \ (*((strm)->zalloc))((strm)->opaque, (items), (size)) #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) //void ZFREE(z_streamp strm,voidpf addr) //{ *((strm)->zfree))((strm)->opaque, addr); //} #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} // Huffman code lookup table entry--this entry is four bytes for machines // that have 16-bit pointers (e.g. PC's in the small or medium model). typedef struct inflate_huft_s inflate_huft; struct inflate_huft_s { union { struct { Byte Exop; // number of extra bits or operation Byte Bits; // number of bits in this code or subcode } what; uInt pad; // pad structure to a power of 2 (4 bytes for } word; // 16-bit, 8 bytes for 32-bit int's) uInt base; // literal, length base, distance base, or table offset }; // Maximum size of dynamic tree. The maximum found in a long but non- // exhaustive search was 1004 huft structures (850 for length/literals // and 154 for distances, the latter actually the result of an // exhaustive search). The actual maximum is not known, but the // value below is more than safe. #define MANY 1440 int inflate_trees_bits( uInt *, // 19 code lengths uInt *, // bits tree desired/actual depth inflate_huft * *, // bits tree result inflate_huft *, // space for trees z_streamp); // for messages int inflate_trees_dynamic( uInt, // number of literal/length codes uInt, // number of distance codes uInt *, // that many (total) code lengths uInt *, // literal desired/actual bit depth uInt *, // distance desired/actual bit depth inflate_huft * *, // literal/length tree result inflate_huft * *, // distance tree result inflate_huft *, // space for trees z_streamp); // for messages int inflate_trees_fixed( uInt *, // literal desired/actual bit depth uInt *, // distance desired/actual bit depth const inflate_huft * *, // literal/length tree result const inflate_huft * *, // distance tree result z_streamp); // for memory allocation struct inflate_blocks_state; typedef struct inflate_blocks_state inflate_blocks_statef; inflate_blocks_statef * inflate_blocks_new( z_streamp z, check_func c, // check function uInt w); // window size int inflate_blocks( inflate_blocks_statef *, z_streamp, int); // initial return code void inflate_blocks_reset( inflate_blocks_statef *, z_streamp, uLong *); // check value on output int inflate_blocks_free( inflate_blocks_statef *, z_streamp); void inflate_set_dictionary( inflate_blocks_statef *s, const Byte *d, // dictionary uInt n); // dictionary length int inflate_blocks_sync_point( inflate_blocks_statef *s); struct inflate_codes_state; typedef struct inflate_codes_state inflate_codes_statef; inflate_codes_statef *inflate_codes_new( uInt, uInt, const inflate_huft *, const inflate_huft *, z_streamp); int inflate_codes( inflate_blocks_statef *, z_streamp, int); void inflate_codes_free( inflate_codes_statef *, z_streamp); typedef enum { IBM_TYPE, // get type bits (3, including end bit) IBM_LENS, // get lengths for stored IBM_STORED, // processing stored block IBM_TABLE, // get table lengths IBM_BTREE, // get bit lengths tree for a dynamic block IBM_DTREE, // get length, distance trees for a dynamic block IBM_CODES, // processing fixed or dynamic block IBM_DRY, // output remaining window bytes IBM_DONE, // finished last block, done IBM_BAD } // got a data error--stuck here inflate_block_mode; // inflate blocks semi-private state struct inflate_blocks_state { // mode inflate_block_mode mode; // current inflate_block mode // mode dependent information union { uInt left; // if STORED, bytes left to copy struct { uInt table; // table lengths (14 bits) uInt index; // index into blens (or border) uInt *blens; // bit lengths of codes uInt bb; // bit length tree depth inflate_huft *tb; // bit length decoding tree } trees; // if DTREE, decoding info for trees struct { inflate_codes_statef *codes; } decode; // if CODES, current state } sub; // submode uInt last; // true if this block is the last block // mode independent information uInt bitk; // bits in bit buffer uLong bitb; // bit buffer inflate_huft *hufts; // single malloc for tree space Byte *window; // sliding window Byte *end; // one byte after sliding window Byte *read; // window read pointer Byte *write; // window write pointer check_func checkfn; // check function uLong check; // check on output }; // defines for inflate input/output // update pointers and return #define UPDBITS {s->bitb=b;s->bitk=k;} #define UPDIN {z->avail_in=n;z->total_in+=(uLong)(p-z->next_in);z->next_in=p;} #define UPDOUT {s->write=q;} #define UPDATE {UPDBITS UPDIN UPDOUT} #define LEAVE {UPDATE return inflate_flush(s,z,r);} // get bytes and bits #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} #define NEEDBYTE {if(n)r=Z_OK;else LEAVE} #define NEXTBYTE (n--,*p++) #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}} #define DUMPBITS(j) {b>>=(j);k-=(j);} // output bytes #define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q) #define LOADOUT {q=s->write;m=(uInt)WAVAIL;m;} #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} #define OUTBYTE(a) {*q++=(Byte)(a);m--;} // load local pointers #define LOAD {LOADIN LOADOUT} // masks for lower bits (size given to avoid silly warnings with Visual C++) // And'ing with mask[n] masks the lower n bits const uInt inflate_mask[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff }; // copy as much as possible from the sliding window to the output area int inflate_flush(inflate_blocks_statef *, z_streamp, int); int inflate_fast(uInt, uInt, const inflate_huft *, const inflate_huft *, inflate_blocks_statef *, z_streamp); const uInt fixed_bl = 9; const uInt fixed_bd = 5; const inflate_huft fixed_tl[] = { { { { 96, 7 } }, 256 }, { { { 0, 8 } }, 80 }, { { { 0, 8 } }, 16 }, { { { 84, 8 } }, 115 }, { { { 82, 7 } }, 31 }, { { { 0, 8 } }, 112 }, { { { 0, 8 } }, 48 }, { { { 0, 9 } }, 192 }, { { { 80, 7 } }, 10 }, { { { 0, 8 } }, 96 }, { { { 0, 8 } }, 32 }, { { { 0, 9 } }, 160 }, { { { 0, 8 } }, 0 }, { { { 0, 8 } }, 128 }, { { { 0, 8 } }, 64 }, { { { 0, 9 } }, 224 }, { { { 80, 7 } }, 6 }, { { { 0, 8 } }, 88 }, { { { 0, 8 } }, 24 }, { { { 0, 9 } }, 144 }, { { { 83, 7 } }, 59 }, { { { 0, 8 } }, 120 }, { { { 0, 8 } }, 56 }, { { { 0, 9 } }, 208 }, { { { 81, 7 } }, 17 }, { { { 0, 8 } }, 104 }, { { { 0, 8 } }, 40 }, { { { 0, 9 } }, 176 }, { { { 0, 8 } }, 8 }, { { { 0, 8 } }, 136 }, { { { 0, 8 } }, 72 }, { { { 0, 9 } }, 240 }, { { { 80, 7 } }, 4 }, { { { 0, 8 } }, 84 }, { { { 0, 8 } }, 20 }, { { { 85, 8 } }, 227 }, { { { 83, 7 } }, 43 }, { { { 0, 8 } }, 116 }, { { { 0, 8 } }, 52 }, { { { 0, 9 } }, 200 }, { { { 81, 7 } }, 13 }, { { { 0, 8 } }, 100 }, { { { 0, 8 } }, 36 }, { { { 0, 9 } }, 168 }, { { { 0, 8 } }, 4 }, { { { 0, 8 } }, 132 }, { { { 0, 8 } }, 68 }, { { { 0, 9 } }, 232 }, { { { 80, 7 } }, 8 }, { { { 0, 8 } }, 92 }, { { { 0, 8 } }, 28 }, { { { 0, 9 } }, 152 }, { { { 84, 7 } }, 83 }, { { { 0, 8 } }, 124 }, { { { 0, 8 } }, 60 }, { { { 0, 9 } }, 216 }, { { { 82, 7 } }, 23 }, { { { 0, 8 } }, 108 }, { { { 0, 8 } }, 44 }, { { { 0, 9 } }, 184 }, { { { 0, 8 } }, 12 }, { { { 0, 8 } }, 140 }, { { { 0, 8 } }, 76 }, { { { 0, 9 } }, 248 }, { { { 80, 7 } }, 3 }, { { { 0, 8 } }, 82 }, { { { 0, 8 } }, 18 }, { { { 85, 8 } }, 163 }, { { { 83, 7 } }, 35 }, { { { 0, 8 } }, 114 }, { { { 0, 8 } }, 50 }, { { { 0, 9 } }, 196 }, { { { 81, 7 } }, 11 }, { { { 0, 8 } }, 98 }, { { { 0, 8 } }, 34 }, { { { 0, 9 } }, 164 }, { { { 0, 8 } }, 2 }, { { { 0, 8 } }, 130 }, { { { 0, 8 } }, 66 }, { { { 0, 9 } }, 228 }, { { { 80, 7 } }, 7 }, { { { 0, 8 } }, 90 }, { { { 0, 8 } }, 26 }, { { { 0, 9 } }, 148 }, { { { 84, 7 } }, 67 }, { { { 0, 8 } }, 122 }, { { { 0, 8 } }, 58 }, { { { 0, 9 } }, 212 }, { { { 82, 7 } }, 19 }, { { { 0, 8 } }, 106 }, { { { 0, 8 } }, 42 }, { { { 0, 9 } }, 180 }, { { { 0, 8 } }, 10 }, { { { 0, 8 } }, 138 }, { { { 0, 8 } }, 74 }, { { { 0, 9 } }, 244 }, { { { 80, 7 } }, 5 }, { { { 0, 8 } }, 86 }, { { { 0, 8 } }, 22 }, { { { 192, 8 } }, 0 }, { { { 83, 7 } }, 51 }, { { { 0, 8 } }, 118 }, { { { 0, 8 } }, 54 }, { { { 0, 9 } }, 204 }, { { { 81, 7 } }, 15 }, { { { 0, 8 } }, 102 }, { { { 0, 8 } }, 38 }, { { { 0, 9 } }, 172 }, { { { 0, 8 } }, 6 }, { { { 0, 8 } }, 134 }, { { { 0, 8 } }, 70 }, { { { 0, 9 } }, 236 }, { { { 80, 7 } }, 9 }, { { { 0, 8 } }, 94 }, { { { 0, 8 } }, 30 }, { { { 0, 9 } }, 156 }, { { { 84, 7 } }, 99 }, { { { 0, 8 } }, 126 }, { { { 0, 8 } }, 62 }, { { { 0, 9 } }, 220 }, { { { 82, 7 } }, 27 }, { { { 0, 8 } }, 110 }, { { { 0, 8 } }, 46 }, { { { 0, 9 } }, 188 }, { { { 0, 8 } }, 14 }, { { { 0, 8 } }, 142 }, { { { 0, 8 } }, 78 }, { { { 0, 9 } }, 252 }, { { { 96, 7 } }, 256 }, { { { 0, 8 } }, 81 }, { { { 0, 8 } }, 17 }, { { { 85, 8 } }, 131 }, { { { 82, 7 } }, 31 }, { { { 0, 8 } }, 113 }, { { { 0, 8 } }, 49 }, { { { 0, 9 } }, 194 }, { { { 80, 7 } }, 10 }, { { { 0, 8 } }, 97 }, { { { 0, 8 } }, 33 }, { { { 0, 9 } }, 162 }, { { { 0, 8 } }, 1 }, { { { 0, 8 } }, 129 }, { { { 0, 8 } }, 65 }, { { { 0, 9 } }, 226 }, { { { 80, 7 } }, 6 }, { { { 0, 8 } }, 89 }, { { { 0, 8 } }, 25 }, { { { 0, 9 } }, 146 }, { { { 83, 7 } }, 59 }, { { { 0, 8 } }, 121 }, { { { 0, 8 } }, 57 }, { { { 0, 9 } }, 210 }, { { { 81, 7 } }, 17 }, { { { 0, 8 } }, 105 }, { { { 0, 8 } }, 41 }, { { { 0, 9 } }, 178 }, { { { 0, 8 } }, 9 }, { { { 0, 8 } }, 137 }, { { { 0, 8 } }, 73 }, { { { 0, 9 } }, 242 }, { { { 80, 7 } }, 4 }, { { { 0, 8 } }, 85 }, { { { 0, 8 } }, 21 }, { { { 80, 8 } }, 258 }, { { { 83, 7 } }, 43 }, { { { 0, 8 } }, 117 }, { { { 0, 8 } }, 53 }, { { { 0, 9 } }, 202 }, { { { 81, 7 } }, 13 }, { { { 0, 8 } }, 101 }, { { { 0, 8 } }, 37 }, { { { 0, 9 } }, 170 }, { { { 0, 8 } }, 5 }, { { { 0, 8 } }, 133 }, { { { 0, 8 } }, 69 }, { { { 0, 9 } }, 234 }, { { { 80, 7 } }, 8 }, { { { 0, 8 } }, 93 }, { { { 0, 8 } }, 29 }, { { { 0, 9 } }, 154 }, { { { 84, 7 } }, 83 }, { { { 0, 8 } }, 125 }, { { { 0, 8 } }, 61 }, { { { 0, 9 } }, 218 }, { { { 82, 7 } }, 23 }, { { { 0, 8 } }, 109 }, { { { 0, 8 } }, 45 }, { { { 0, 9 } }, 186 }, { { { 0, 8 } }, 13 }, { { { 0, 8 } }, 141 }, { { { 0, 8 } }, 77 }, { { { 0, 9 } }, 250 }, { { { 80, 7 } }, 3 }, { { { 0, 8 } }, 83 }, { { { 0, 8 } }, 19 }, { { { 85, 8 } }, 195 }, { { { 83, 7 } }, 35 }, { { { 0, 8 } }, 115 }, { { { 0, 8 } }, 51 }, { { { 0, 9 } }, 198 }, { { { 81, 7 } }, 11 }, { { { 0, 8 } }, 99 }, { { { 0, 8 } }, 35 }, { { { 0, 9 } }, 166 }, { { { 0, 8 } }, 3 }, { { { 0, 8 } }, 131 }, { { { 0, 8 } }, 67 }, { { { 0, 9 } }, 230 }, { { { 80, 7 } }, 7 }, { { { 0, 8 } }, 91 }, { { { 0, 8 } }, 27 }, { { { 0, 9 } }, 150 }, { { { 84, 7 } }, 67 }, { { { 0, 8 } }, 123 }, { { { 0, 8 } }, 59 }, { { { 0, 9 } }, 214 }, { { { 82, 7 } }, 19 }, { { { 0, 8 } }, 107 }, { { { 0, 8 } }, 43 }, { { { 0, 9 } }, 182 }, { { { 0, 8 } }, 11 }, { { { 0, 8 } }, 139 }, { { { 0, 8 } }, 75 }, { { { 0, 9 } }, 246 }, { { { 80, 7 } }, 5 }, { { { 0, 8 } }, 87 }, { { { 0, 8 } }, 23 }, { { { 192, 8 } }, 0 }, { { { 83, 7 } }, 51 }, { { { 0, 8 } }, 119 }, { { { 0, 8 } }, 55 }, { { { 0, 9 } }, 206 }, { { { 81, 7 } }, 15 }, { { { 0, 8 } }, 103 }, { { { 0, 8 } }, 39 }, { { { 0, 9 } }, 174 }, { { { 0, 8 } }, 7 }, { { { 0, 8 } }, 135 }, { { { 0, 8 } }, 71 }, { { { 0, 9 } }, 238 }, { { { 80, 7 } }, 9 }, { { { 0, 8 } }, 95 }, { { { 0, 8 } }, 31 }, { { { 0, 9 } }, 158 }, { { { 84, 7 } }, 99 }, { { { 0, 8 } }, 127 }, { { { 0, 8 } }, 63 }, { { { 0, 9 } }, 222 }, { { { 82, 7 } }, 27 }, { { { 0, 8 } }, 111 }, { { { 0, 8 } }, 47 }, { { { 0, 9 } }, 190 }, { { { 0, 8 } }, 15 }, { { { 0, 8 } }, 143 }, { { { 0, 8 } }, 79 }, { { { 0, 9 } }, 254 }, { { { 96, 7 } }, 256 }, { { { 0, 8 } }, 80 }, { { { 0, 8 } }, 16 }, { { { 84, 8 } }, 115 }, { { { 82, 7 } }, 31 }, { { { 0, 8 } }, 112 }, { { { 0, 8 } }, 48 }, { { { 0, 9 } }, 193 }, { { { 80, 7 } }, 10 }, { { { 0, 8 } }, 96 }, { { { 0, 8 } }, 32 }, { { { 0, 9 } }, 161 }, { { { 0, 8 } }, 0 }, { { { 0, 8 } }, 128 }, { { { 0, 8 } }, 64 }, { { { 0, 9 } }, 225 }, { { { 80, 7 } }, 6 }, { { { 0, 8 } }, 88 }, { { { 0, 8 } }, 24 }, { { { 0, 9 } }, 145 }, { { { 83, 7 } }, 59 }, { { { 0, 8 } }, 120 }, { { { 0, 8 } }, 56 }, { { { 0, 9 } }, 209 }, { { { 81, 7 } }, 17 }, { { { 0, 8 } }, 104 }, { { { 0, 8 } }, 40 }, { { { 0, 9 } }, 177 }, { { { 0, 8 } }, 8 }, { { { 0, 8 } }, 136 }, { { { 0, 8 } }, 72 }, { { { 0, 9 } }, 241 }, { { { 80, 7 } }, 4 }, { { { 0, 8 } }, 84 }, { { { 0, 8 } }, 20 }, { { { 85, 8 } }, 227 }, { { { 83, 7 } }, 43 }, { { { 0, 8 } }, 116 }, { { { 0, 8 } }, 52 }, { { { 0, 9 } }, 201 }, { { { 81, 7 } }, 13 }, { { { 0, 8 } }, 100 }, { { { 0, 8 } }, 36 }, { { { 0, 9 } }, 169 }, { { { 0, 8 } }, 4 }, { { { 0, 8 } }, 132 }, { { { 0, 8 } }, 68 }, { { { 0, 9 } }, 233 }, { { { 80, 7 } }, 8 }, { { { 0, 8 } }, 92 }, { { { 0, 8 } }, 28 }, { { { 0, 9 } }, 153 }, { { { 84, 7 } }, 83 }, { { { 0, 8 } }, 124 }, { { { 0, 8 } }, 60 }, { { { 0, 9 } }, 217 }, { { { 82, 7 } }, 23 }, { { { 0, 8 } }, 108 }, { { { 0, 8 } }, 44 }, { { { 0, 9 } }, 185 }, { { { 0, 8 } }, 12 }, { { { 0, 8 } }, 140 }, { { { 0, 8 } }, 76 }, { { { 0, 9 } }, 249 }, { { { 80, 7 } }, 3 }, { { { 0, 8 } }, 82 }, { { { 0, 8 } }, 18 }, { { { 85, 8 } }, 163 }, { { { 83, 7 } }, 35 }, { { { 0, 8 } }, 114 }, { { { 0, 8 } }, 50 }, { { { 0, 9 } }, 197 }, { { { 81, 7 } }, 11 }, { { { 0, 8 } }, 98 }, { { { 0, 8 } }, 34 }, { { { 0, 9 } }, 165 }, { { { 0, 8 } }, 2 }, { { { 0, 8 } }, 130 }, { { { 0, 8 } }, 66 }, { { { 0, 9 } }, 229 }, { { { 80, 7 } }, 7 }, { { { 0, 8 } }, 90 }, { { { 0, 8 } }, 26 }, { { { 0, 9 } }, 149 }, { { { 84, 7 } }, 67 }, { { { 0, 8 } }, 122 }, { { { 0, 8 } }, 58 }, { { { 0, 9 } }, 213 }, { { { 82, 7 } }, 19 }, { { { 0, 8 } }, 106 }, { { { 0, 8 } }, 42 }, { { { 0, 9 } }, 181 }, { { { 0, 8 } }, 10 }, { { { 0, 8 } }, 138 }, { { { 0, 8 } }, 74 }, { { { 0, 9 } }, 245 }, { { { 80, 7 } }, 5 }, { { { 0, 8 } }, 86 }, { { { 0, 8 } }, 22 }, { { { 192, 8 } }, 0 }, { { { 83, 7 } }, 51 }, { { { 0, 8 } }, 118 }, { { { 0, 8 } }, 54 }, { { { 0, 9 } }, 205 }, { { { 81, 7 } }, 15 }, { { { 0, 8 } }, 102 }, { { { 0, 8 } }, 38 }, { { { 0, 9 } }, 173 }, { { { 0, 8 } }, 6 }, { { { 0, 8 } }, 134 }, { { { 0, 8 } }, 70 }, { { { 0, 9 } }, 237 }, { { { 80, 7 } }, 9 }, { { { 0, 8 } }, 94 }, { { { 0, 8 } }, 30 }, { { { 0, 9 } }, 157 }, { { { 84, 7 } }, 99 }, { { { 0, 8 } }, 126 }, { { { 0, 8 } }, 62 }, { { { 0, 9 } }, 221 }, { { { 82, 7 } }, 27 }, { { { 0, 8 } }, 110 }, { { { 0, 8 } }, 46 }, { { { 0, 9 } }, 189 }, { { { 0, 8 } }, 14 }, { { { 0, 8 } }, 142 }, { { { 0, 8 } }, 78 }, { { { 0, 9 } }, 253 }, { { { 96, 7 } }, 256 }, { { { 0, 8 } }, 81 }, { { { 0, 8 } }, 17 }, { { { 85, 8 } }, 131 }, { { { 82, 7 } }, 31 }, { { { 0, 8 } }, 113 }, { { { 0, 8 } }, 49 }, { { { 0, 9 } }, 195 }, { { { 80, 7 } }, 10 }, { { { 0, 8 } }, 97 }, { { { 0, 8 } }, 33 }, { { { 0, 9 } }, 163 }, { { { 0, 8 } }, 1 }, { { { 0, 8 } }, 129 }, { { { 0, 8 } }, 65 }, { { { 0, 9 } }, 227 }, { { { 80, 7 } }, 6 }, { { { 0, 8 } }, 89 }, { { { 0, 8 } }, 25 }, { { { 0, 9 } }, 147 }, { { { 83, 7 } }, 59 }, { { { 0, 8 } }, 121 }, { { { 0, 8 } }, 57 }, { { { 0, 9 } }, 211 }, { { { 81, 7 } }, 17 }, { { { 0, 8 } }, 105 }, { { { 0, 8 } }, 41 }, { { { 0, 9 } }, 179 }, { { { 0, 8 } }, 9 }, { { { 0, 8 } }, 137 }, { { { 0, 8 } }, 73 }, { { { 0, 9 } }, 243 }, { { { 80, 7 } }, 4 }, { { { 0, 8 } }, 85 }, { { { 0, 8 } }, 21 }, { { { 80, 8 } }, 258 }, { { { 83, 7 } }, 43 }, { { { 0, 8 } }, 117 }, { { { 0, 8 } }, 53 }, { { { 0, 9 } }, 203 }, { { { 81, 7 } }, 13 }, { { { 0, 8 } }, 101 }, { { { 0, 8 } }, 37 }, { { { 0, 9 } }, 171 }, { { { 0, 8 } }, 5 }, { { { 0, 8 } }, 133 }, { { { 0, 8 } }, 69 }, { { { 0, 9 } }, 235 }, { { { 80, 7 } }, 8 }, { { { 0, 8 } }, 93 }, { { { 0, 8 } }, 29 }, { { { 0, 9 } }, 155 }, { { { 84, 7 } }, 83 }, { { { 0, 8 } }, 125 }, { { { 0, 8 } }, 61 }, { { { 0, 9 } }, 219 }, { { { 82, 7 } }, 23 }, { { { 0, 8 } }, 109 }, { { { 0, 8 } }, 45 }, { { { 0, 9 } }, 187 }, { { { 0, 8 } }, 13 }, { { { 0, 8 } }, 141 }, { { { 0, 8 } }, 77 }, { { { 0, 9 } }, 251 }, { { { 80, 7 } }, 3 }, { { { 0, 8 } }, 83 }, { { { 0, 8 } }, 19 }, { { { 85, 8 } }, 195 }, { { { 83, 7 } }, 35 }, { { { 0, 8 } }, 115 }, { { { 0, 8 } }, 51 }, { { { 0, 9 } }, 199 }, { { { 81, 7 } }, 11 }, { { { 0, 8 } }, 99 }, { { { 0, 8 } }, 35 }, { { { 0, 9 } }, 167 }, { { { 0, 8 } }, 3 }, { { { 0, 8 } }, 131 }, { { { 0, 8 } }, 67 }, { { { 0, 9 } }, 231 }, { { { 80, 7 } }, 7 }, { { { 0, 8 } }, 91 }, { { { 0, 8 } }, 27 }, { { { 0, 9 } }, 151 }, { { { 84, 7 } }, 67 }, { { { 0, 8 } }, 123 }, { { { 0, 8 } }, 59 }, { { { 0, 9 } }, 215 }, { { { 82, 7 } }, 19 }, { { { 0, 8 } }, 107 }, { { { 0, 8 } }, 43 }, { { { 0, 9 } }, 183 }, { { { 0, 8 } }, 11 }, { { { 0, 8 } }, 139 }, { { { 0, 8 } }, 75 }, { { { 0, 9 } }, 247 }, { { { 80, 7 } }, 5 }, { { { 0, 8 } }, 87 }, { { { 0, 8 } }, 23 }, { { { 192, 8 } }, 0 }, { { { 83, 7 } }, 51 }, { { { 0, 8 } }, 119 }, { { { 0, 8 } }, 55 }, { { { 0, 9 } }, 207 }, { { { 81, 7 } }, 15 }, { { { 0, 8 } }, 103 }, { { { 0, 8 } }, 39 }, { { { 0, 9 } }, 175 }, { { { 0, 8 } }, 7 }, { { { 0, 8 } }, 135 }, { { { 0, 8 } }, 71 }, { { { 0, 9 } }, 239 }, { { { 80, 7 } }, 9 }, { { { 0, 8 } }, 95 }, { { { 0, 8 } }, 31 }, { { { 0, 9 } }, 159 }, { { { 84, 7 } }, 99 }, { { { 0, 8 } }, 127 }, { { { 0, 8 } }, 63 }, { { { 0, 9 } }, 223 }, { { { 82, 7 } }, 27 }, { { { 0, 8 } }, 111 }, { { { 0, 8 } }, 47 }, { { { 0, 9 } }, 191 }, { { { 0, 8 } }, 15 }, { { { 0, 8 } }, 143 }, { { { 0, 8 } }, 79 }, { { { 0, 9 } }, 255 } }; const inflate_huft fixed_td[] = { { { { 80, 5 } }, 1 }, { { { 87, 5 } }, 257 }, { { { 83, 5 } }, 17 }, { { { 91, 5 } }, 4097 }, { { { 81, 5 } }, 5 }, { { { 89, 5 } }, 1025 }, { { { 85, 5 } }, 65 }, { { { 93, 5 } }, 16385 }, { { { 80, 5 } }, 3 }, { { { 88, 5 } }, 513 }, { { { 84, 5 } }, 33 }, { { { 92, 5 } }, 8193 }, { { { 82, 5 } }, 9 }, { { { 90, 5 } }, 2049 }, { { { 86, 5 } }, 129 }, { { { 192, 5 } }, 24577 }, { { { 80, 5 } }, 2 }, { { { 87, 5 } }, 385 }, { { { 83, 5 } }, 25 }, { { { 91, 5 } }, 6145 }, { { { 81, 5 } }, 7 }, { { { 89, 5 } }, 1537 }, { { { 85, 5 } }, 97 }, { { { 93, 5 } }, 24577 }, { { { 80, 5 } }, 4 }, { { { 88, 5 } }, 769 }, { { { 84, 5 } }, 49 }, { { { 92, 5 } }, 12289 }, { { { 82, 5 } }, 13 }, { { { 90, 5 } }, 3073 }, { { { 86, 5 } }, 193 }, { { { 192, 5 } }, 24577 } }; // copy as much as possible from the sliding window to the output area int inflate_flush(inflate_blocks_statef *s, z_streamp z, int r) { uInt n; Byte *p; Byte *q; // local copies of source and destination pointers p = z->next_out; q = s->read; // compute number of bytes to copy as far as end of window n = (uInt)((q <= s->write ? s->write : s->end) - q); if (n > z->avail_out) n = z->avail_out; if (n && r == Z_BUF_ERROR) r = Z_OK; // update counters z->avail_out -= n; z->total_out += n; // update check information if (s->checkfn != Z_NULL) z->adler = s->check = (*s->checkfn)(s->check, q, n); // copy as far as end of window if (n != 0) // check for n!=0 to avoid waking up CodeGuard { memcpy(p, q, n); p += n; q += n; } // see if more to copy at beginning of window if (q == s->end) { // wrap pointers q = s->window; if (s->write == s->end) s->write = s->window; // compute bytes to copy n = (uInt)(s->write - q); if (n > z->avail_out) n = z->avail_out; if (n && r == Z_BUF_ERROR) r = Z_OK; // update counters z->avail_out -= n; z->total_out += n; // update check information if (s->checkfn != Z_NULL) z->adler = s->check = (*s->checkfn)(s->check, q, n); // copy memcpy(p, q, n); p += n; q += n; } // update pointers z->next_out = p; s->read = q; // done return r; } // simplify the use of the inflate_huft type with some defines #define exop word.what.Exop #define bits word.what.Bits typedef enum { // waiting for "i:"=input, "o:"=output, "x:"=nothing START, // x: set up for LEN LEN, // i: get length/literal/eob next LENEXT, // i: getting length extra (have base) DIST, // i: get distance next DISTEXT, // i: getting distance extra COPY, // o: copying bytes in window, waiting for space LIT, // o: got literal, waiting for output space WASH, // o: got eob, possibly still output waiting END, // x: got eob and all data flushed BADCODE } // x: got error inflate_codes_mode; // inflate codes private state struct inflate_codes_state { // mode inflate_codes_mode mode; // current inflate_codes mode // mode dependent information uInt len; union { struct { const inflate_huft *tree; // pointer into tree uInt need; // bits needed } code; // if LEN or DIST, where in tree uInt lit; // if LIT, literal struct { uInt get; // bits to get for extra uInt dist; // distance back to copy from } copy; // if EXT or COPY, where and how much } sub; // submode // mode independent information Byte lbits; // ltree bits decoded per branch Byte dbits; // dtree bits decoder per branch const inflate_huft *ltree; // literal/length/eob tree const inflate_huft *dtree; // distance tree }; inflate_codes_statef *inflate_codes_new( uInt bl, uInt bd, const inflate_huft *tl, const inflate_huft *td, // need separate declaration for Borland C++ z_streamp z) { inflate_codes_statef *c; if ((c = (inflate_codes_statef *) ZALLOC(z, 1, sizeof(struct inflate_codes_state))) != Z_NULL) { c->mode = START; c->lbits = (Byte)bl; c->dbits = (Byte)bd; c->ltree = tl; c->dtree = td; Tracev((stderr, "inflate: codes new\n")); } return c; } int inflate_codes(inflate_blocks_statef *s, z_streamp z, int r) { uInt j; // temporary storage const inflate_huft *t; // temporary pointer uInt e; // extra bits or operation uLong b; // bit buffer uInt k; // bits in bit buffer Byte *p; // input data pointer uInt n; // bytes available there Byte *q; // output window write pointer uInt m; // bytes to end of window or read pointer Byte *f; // pointer to copy strings from inflate_codes_statef *c = s->sub.decode.codes; // codes state // copy input/output information to locals (UPDATE macro restores) LOAD // process input and output based on current state for (;;) switch (c->mode) { // waiting for "i:"=input, "o:"=output, "x:"=nothing case START: // x: set up for LEN #ifndef SLOW if (m >= 258 && n >= 10) { UPDATE r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); LOAD if (r != Z_OK) { c->mode = r == Z_STREAM_END ? WASH : BADCODE; break; } } #endif // !SLOW c->sub.code.need = c->lbits; c->sub.code.tree = c->ltree; c->mode = LEN; case LEN: // i: get length/literal/eob next j = c->sub.code.need; NEEDBITS(j) t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); DUMPBITS(t->bits) e = (uInt)(t->exop); if (e == 0) // literal { c->sub.lit = t->base; Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", t->base)); c->mode = LIT; break; } if (e & 16) // length { c->sub.copy.get = e & 15; c->len = t->base; c->mode = LENEXT; break; } if ((e & 64) == 0) // next table { c->sub.code.need = e; c->sub.code.tree = t + t->base; break; } if (e & 32) // end of block { Tracevv((stderr, "inflate: end of block\n")); c->mode = WASH; break; } c->mode = BADCODE; // invalid code z->msg = (char*)"invalid literal/length code"; r = Z_DATA_ERROR; LEAVE case LENEXT: // i: getting length extra (have base) j = c->sub.copy.get; NEEDBITS(j) c->len += (uInt)b & inflate_mask[j]; DUMPBITS(j) c->sub.code.need = c->dbits; c->sub.code.tree = c->dtree; Tracevv((stderr, "inflate: length %u\n", c->len)); c->mode = DIST; case DIST: // i: get distance next j = c->sub.code.need; NEEDBITS(j) t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); DUMPBITS(t->bits) e = (uInt)(t->exop); if (e & 16) // distance { c->sub.copy.get = e & 15; c->sub.copy.dist = t->base; c->mode = DISTEXT; break; } if ((e & 64) == 0) // next table { c->sub.code.need = e; c->sub.code.tree = t + t->base; break; } c->mode = BADCODE; // invalid code z->msg = (char*)"invalid distance code"; r = Z_DATA_ERROR; LEAVE case DISTEXT: // i: getting distance extra j = c->sub.copy.get; NEEDBITS(j) c->sub.copy.dist += (uInt)b & inflate_mask[j]; DUMPBITS(j) Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); c->mode = COPY; case COPY: // o: copying bytes in window, waiting for space f = (uInt)(q - s->window) < c->sub.copy.dist ? s->end - (c->sub.copy.dist - (q - s->window)) : q - c->sub.copy.dist; while (c->len) { NEEDOUT OUTBYTE(*f++) if (f == s->end) f = s->window; c->len--; } c->mode = START; break; case LIT: // o: got literal, waiting for output space NEEDOUT OUTBYTE(c->sub.lit) c->mode = START; break; case WASH: // o: got eob, possibly more output if (k > 7) // return unused byte, if any { Assert(k < 16, "inflate_codes grabbed too many bytes"); k -= 8; n++; p--; // can always return one } FLUSH if (s->read != s->write) LEAVE c->mode = END; case END: r = Z_STREAM_END; LEAVE case BADCODE: // x: got error r = Z_DATA_ERROR; LEAVE default: r = Z_STREAM_ERROR; LEAVE } } void inflate_codes_free(inflate_codes_statef *c, z_streamp z) { ZFREE(z, c); Tracev((stderr, "inflate: codes free\n")); } // infblock.c -- interpret and process block types to last block // Copyright (C) 1995-1998 Mark Adler // For conditions of distribution and use, see copyright notice in zlib.h //struct inflate_codes_state {int dummy;}; // for buggy compilers // Table for deflate from PKZIP's appnote.txt. const uInt border[] = { // Order of the bit length code lengths 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; // // Notes beyond the 1.93a appnote.txt: // // 1. Distance pointers never point before the beginning of the output stream. // 2. Distance pointers can point back across blocks, up to 32k away. // 3. There is an implied maximum of 7 bits for the bit length table and // 15 bits for the actual data. // 4. If only one code exists, then it is encoded using one bit. (Zero // would be more efficient, but perhaps a little confusing.) If two // codes exist, they are coded using one bit each (0 and 1). // 5. There is no way of sending zero distance codes--a dummy must be // sent if there are none. (History: a pre 2.0 version of PKZIP would // store blocks with no distance codes, but this was discovered to be // too harsh a criterion.) Valid only for 1.93a. 2.04c does allow // zero distance codes, which is sent as one code of zero bits in // length. // 6. There are up to 286 literal/length codes. Code 256 represents the // end-of-block. Note however that the static length tree defines // 288 codes just to fill out the Huffman codes. Codes 286 and 287 // cannot be used though, since there is no length base or extra bits // defined for them. Similarily, there are up to 30 distance codes. // However, static trees define 32 codes (all 5 bits) to fill out the // Huffman codes, but the last two had better not show up in the data. // 7. Unzip can check dynamic Huffman blocks for complete code sets. // The exception is that a single code would not be complete (see #4). // 8. The five bits following the block type is really the number of // literal codes sent minus 257. // 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits // (1+6+6). Therefore, to output three times the length, you output // three codes (1+1+1), whereas to output four times the same length, // you only need two codes (1+3). Hmm. //10. In the tree reconstruction algorithm, Code = Code + Increment // only if BitLength(i) is not zero. (Pretty obvious.) //11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) //12. Note: length code 284 can represent 227-258, but length code 285 // really is 258. The last length deserves its own, short code // since it gets used a lot in very redundant files. The length // 258 is special since 258 - 3 (the min match length) is 255. //13. The literal/length and distance code bit lengths are read as a // single stream of lengths. It is possible (and advantageous) for // a repeat code (16, 17, or 18) to go across the boundary between // the two sets of lengths. void inflate_blocks_reset(inflate_blocks_statef *s, z_streamp z, uLong *c) { if (c != Z_NULL) *c = s->check; if (s->mode == IBM_BTREE || s->mode == IBM_DTREE) ZFREE(z, s->sub.trees.blens); if (s->mode == IBM_CODES) inflate_codes_free(s->sub.decode.codes, z); s->mode = IBM_TYPE; s->bitk = 0; s->bitb = 0; s->read = s->write = s->window; if (s->checkfn != Z_NULL) z->adler = s->check = (*s->checkfn)(0L, (const Byte *)Z_NULL, 0); Tracev((stderr, "inflate: blocks reset\n")); } inflate_blocks_statef *inflate_blocks_new(z_streamp z, check_func c, uInt w) { inflate_blocks_statef *s; if ((s = (inflate_blocks_statef *)ZALLOC (z, 1, sizeof(struct inflate_blocks_state))) == Z_NULL) return s; if ((s->hufts = (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL) { ZFREE(z, s); return Z_NULL; } if ((s->window = (Byte *)ZALLOC(z, 1, w)) == Z_NULL) { ZFREE(z, s->hufts); ZFREE(z, s); return Z_NULL; } s->end = s->window + w; s->checkfn = c; s->mode = IBM_TYPE; Tracev((stderr, "inflate: blocks allocated\n")); inflate_blocks_reset(s, z, Z_NULL); return s; } int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r) { uInt t; // temporary storage uLong b; // bit buffer uInt k; // bits in bit buffer Byte *p; // input data pointer uInt n; // bytes available there Byte *q; // output window write pointer uInt m; // bytes to end of window or read pointer // copy input/output information to locals (UPDATE macro restores) LOAD // process input based on current state for (;;) switch (s->mode) { case IBM_TYPE: NEEDBITS(3) t = (uInt)b & 7; s->last = t & 1; switch (t >> 1) { case 0: // stored Tracev((stderr, "inflate: stored block%s\n", s->last ? " (last)" : "")); DUMPBITS(3) t = k & 7; // go to byte boundary DUMPBITS(t) s->mode = IBM_LENS; // get length of stored block break; case 1: // fixed Tracev((stderr, "inflate: fixed codes block%s\n", s->last ? " (last)" : "")); { uInt bl, bd; const inflate_huft *tl, *td; inflate_trees_fixed(&bl, &bd, &tl, &td, z); s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); if (s->sub.decode.codes == Z_NULL) { r = Z_MEM_ERROR; LEAVE } } DUMPBITS(3) s->mode = IBM_CODES; break; case 2: // dynamic Tracev((stderr, "inflate: dynamic codes block%s\n", s->last ? " (last)" : "")); DUMPBITS(3) s->mode = IBM_TABLE; break; case 3: // illegal DUMPBITS(3) s->mode = IBM_BAD; z->msg = (char*)"invalid block type"; r = Z_DATA_ERROR; LEAVE } break; case IBM_LENS: NEEDBITS(32) if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) { s->mode = IBM_BAD; z->msg = (char*)"invalid stored block lengths"; r = Z_DATA_ERROR; LEAVE } s->sub.left = (uInt)b & 0xffff; b = k = 0; // dump bits Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); s->mode = s->sub.left ? IBM_STORED : (s->last ? IBM_DRY : IBM_TYPE); break; case IBM_STORED: if (n == 0) LEAVE NEEDOUT t = s->sub.left; if (t > n) t = n; if (t > m) t = m; memcpy(q, p, t); p += t; n -= t; q += t; m -= t; if ((s->sub.left -= t) != 0) break; Tracev((stderr, "inflate: stored end, %lu total out\n", z->total_out + (q >= s->read ? q - s->read : (s->end - s->read) + (q - s->window)))); s->mode = s->last ? IBM_DRY : IBM_TYPE; break; case IBM_TABLE: NEEDBITS(14) s->sub.trees.table = t = (uInt)b & 0x3fff; // remove this section to workaround bug in pkzip if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) { s->mode = IBM_BAD; z->msg = (char*)"too many length or distance symbols"; r = Z_DATA_ERROR; LEAVE } // end remove t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); if ((s->sub.trees.blens = (uInt*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) { r = Z_MEM_ERROR; LEAVE } DUMPBITS(14) s->sub.trees.index = 0; Tracev((stderr, "inflate: table sizes ok\n")); s->mode = IBM_BTREE; case IBM_BTREE: while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) { NEEDBITS(3) s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; DUMPBITS(3) } while (s->sub.trees.index < 19) s->sub.trees.blens[border[s->sub.trees.index++]] = 0; s->sub.trees.bb = 7; t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, &s->sub.trees.tb, s->hufts, z); if (t != Z_OK) { ZFREE(z, s->sub.trees.blens); r = t; if (r == Z_DATA_ERROR) s->mode = IBM_BAD; LEAVE } s->sub.trees.index = 0; Tracev((stderr, "inflate: bits tree ok\n")); s->mode = IBM_DTREE; case IBM_DTREE: while (t = s->sub.trees.table, s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) { inflate_huft *h; uInt i, j, c; t = s->sub.trees.bb; NEEDBITS(t) h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); t = h->bits; c = h->base; if (c < 16) { DUMPBITS(t) s->sub.trees.blens[s->sub.trees.index++] = c; } else // c == 16..18 { i = c == 18 ? 7 : c - 14; j = c == 18 ? 11 : 3; NEEDBITS(t + i) DUMPBITS(t) j += (uInt)b & inflate_mask[i]; DUMPBITS(i) i = s->sub.trees.index; t = s->sub.trees.table; if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) { ZFREE(z, s->sub.trees.blens); s->mode = IBM_BAD; z->msg = (char*)"invalid bit length repeat"; r = Z_DATA_ERROR; LEAVE } c = c == 16 ? s->sub.trees.blens[i - 1] : 0; do { s->sub.trees.blens[i++] = c; } while (--j); s->sub.trees.index = i; } } s->sub.trees.tb = Z_NULL; { uInt bl, bd; inflate_huft *tl, *td; inflate_codes_statef *c; bl = 9; // must be <= 9 for lookahead assumptions bd = 6; // must be <= 9 for lookahead assumptions t = s->sub.trees.table; t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), s->sub.trees.blens, &bl, &bd, &tl, &td, s->hufts, z); ZFREE(z, s->sub.trees.blens); if (t != Z_OK) { if (t == (uInt)Z_DATA_ERROR) s->mode = IBM_BAD; r = t; LEAVE } Tracev((stderr, "inflate: trees ok\n")); if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) { r = Z_MEM_ERROR; LEAVE } s->sub.decode.codes = c; } s->mode = IBM_CODES; case IBM_CODES: UPDATE if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) return inflate_flush(s, z, r); r = Z_OK; inflate_codes_free(s->sub.decode.codes, z); LOAD Tracev((stderr, "inflate: codes end, %lu total out\n", z->total_out + (q >= s->read ? q - s->read : (s->end - s->read) + (q - s->window)))); if (!s->last) { s->mode = IBM_TYPE; break; } s->mode = IBM_DRY; case IBM_DRY: FLUSH if (s->read != s->write) LEAVE s->mode = IBM_DONE; case IBM_DONE: r = Z_STREAM_END; LEAVE case IBM_BAD: r = Z_DATA_ERROR; LEAVE default: r = Z_STREAM_ERROR; LEAVE } } int inflate_blocks_free(inflate_blocks_statef *s, z_streamp z) { inflate_blocks_reset(s, z, Z_NULL); ZFREE(z, s->window); ZFREE(z, s->hufts); ZFREE(z, s); Tracev((stderr, "inflate: blocks freed\n")); return Z_OK; } // inftrees.c -- generate Huffman trees for efficient decoding // Copyright (C) 1995-1998 Mark Adler // For conditions of distribution and use, see copyright notice in zlib.h // extern const char inflate_copyright[] = " ";//inflate 1.1.3 Copyright 1995-1998 Mark Adler "; // If you use the zlib library in a product, an acknowledgment is welcome // in the documentation of your product. If for some reason you cannot // include such an acknowledgment, I would appreciate that you keep this // copyright string in the executable of your product. int huft_build( uInt *, // code lengths in bits uInt, // number of codes uInt, // number of "simple" codes const uInt *, // list of base values for non-simple codes const uInt *, // list of extra bits for non-simple codes inflate_huft **,// result: starting table uInt *, // maximum lookup bits (returns actual) inflate_huft *, // space for trees uInt *, // hufts used in space uInt *); // space for values // Tables for deflate from PKZIP's appnote.txt. const uInt cplens[31] = { // Copy lengths for literal codes 257..285 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 }; // see note #13 above about 258 const uInt cplext[31] = { // Extra bits for literal codes 257..285 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112 }; // 112==invalid const uInt cpdist[30] = { // Copy offsets for distance codes 0..29 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 }; const uInt cpdext[30] = { // Extra bits for distance codes 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 }; // // Huffman code decoding is performed using a multi-level table lookup. // The fastest way to decode is to simply build a lookup table whose // size is determined by the longest code. However, the time it takes // to build this table can also be a factor if the data being decoded // is not very long. The most common codes are necessarily the // shortest codes, so those codes dominate the decoding time, and hence // the speed. The idea is you can have a shorter table that decodes the // shorter, more probable codes, and then point to subsidiary tables for // the longer codes. The time it costs to decode the longer codes is // then traded against the time it takes to make longer tables. // // This results of this trade are in the variables lbits and dbits // below. lbits is the number of bits the first level table for literal/ // length codes can decode in one step, and dbits is the same thing for // the distance codes. Subsequent tables are also less than or equal to // those sizes. These values may be adjusted either when all of the // codes are shorter than that, in which case the longest code length in // bits is used, or when the shortest code is *longer* than the requested // table size, in which case the length of the shortest code in bits is // used. // // There are two different values for the two tables, since they code a // different number of possibilities each. The literal/length table // codes 286 possible values, or in a flat code, a little over eight // bits. The distance table codes 30 possible values, or a little less // than five bits, flat. The optimum values for speed end up being // about one bit more than those, so lbits is 8+1 and dbits is 5+1. // The optimum values may differ though from machine to machine, and // possibly even between compilers. Your mileage may vary. // // If BMAX needs to be larger than 16, then h and x[] should be uLong. #define BMAX 15 // maximum bit length of any code int huft_build( uInt *b, // code lengths in bits (all assumed <= BMAX) uInt n, // number of codes (assumed <= 288) uInt s, // number of simple-valued codes (0..s-1) const uInt *d, // list of base values for non-simple codes const uInt *e, // list of extra bits for non-simple codes inflate_huft * *t, // result: starting table uInt *m, // maximum lookup bits, returns actual inflate_huft *hp, // space for trees uInt *hn, // hufts used in space uInt *v) // working area: values in order of bit length // Given a list of code lengths and a maximum table size, make a set of // tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR // if the given code set is incomplete (the tables are still built in this // case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of // lengths), or Z_MEM_ERROR if not enough memory. { uInt a; // counter for codes of length k uInt c[BMAX + 1]; // bit length count table uInt f; // i repeats in table every f entries int g; // maximum code length int h; // table level register uInt i; // counter, current code register uInt j; // counter register int k; // number of bits in current code int l; // bits per table (returned in m) uInt mask; // (1 << w) - 1, to avoid cc -O bug on HP register uInt *p; // pointer into c[], b[], or v[] inflate_huft *q; // points to current table struct inflate_huft_s r; // table entry for structure assignment inflate_huft *u[BMAX]; // table stack register int w; // bits before this table == (l * h) uInt x[BMAX + 1]; // bit offsets, then code stack uInt *xp; // pointer into x int y; // number of dummy codes added uInt z; // number of entries in current table // Generate counts for each bit length p = c; #define C0 *p++ = 0; #define C2 C0 C0 C0 C0 #define C4 C2 C2 C2 C2 C4; p; // clear c[]--assume BMAX+1 is 16 p = b; i = n; do { c[*p++]++; // assume all entries <= BMAX } while (--i); if (c[0] == n) // null input--all zero length codes { *t = (inflate_huft *)Z_NULL; *m = 0; return Z_OK; } // Find minimum and maximum length, bound *m by those l = *m; for (j = 1; j <= BMAX; j++) if (c[j]) break; k = j; // minimum code length if ((uInt)l < j) l = j; for (i = BMAX; i; i--) if (c[i]) break; g = i; // maximum code length if ((uInt)l > i) l = i; *m = l; // Adjust last length count to fill out codes, if needed for (y = 1 << j; j < i; j++, y <<= 1) if ((y -= c[j]) < 0) return Z_DATA_ERROR; if ((y -= c[i]) < 0) return Z_DATA_ERROR; c[i] += y; // Generate starting offsets into the value table for each length x[1] = j = 0; p = c + 1; xp = x + 2; while (--i) { // note that i == g from above *xp++ = (j += *p++); } // Make a table of values in order of bit lengths p = b; i = 0; do { if ((j = *p++) != 0) v[x[j]++] = i; } while (++i < n); n = x[g]; // set n to length of v // Generate the Huffman codes and for each, make the table entries x[0] = i = 0; // first Huffman code is zero p = v; // grab values in bit order h = -1; // no tables yet--level -1 w = -l; // bits decoded == (l * h) u[0] = (inflate_huft *)Z_NULL; // just to keep compilers happy q = (inflate_huft *)Z_NULL; // ditto z = 0; // ditto // go through the bit lengths (k already is bits in shortest code) for (; k <= g; k++) { a = c[k]; while (a--) { // here i is the Huffman code of length k bits for value *p // make tables up to required level while (k > w + l) { h++; w += l; // previous table always l bits // compute minimum size table less than or equal to l bits z = g - w; z = z > (uInt)l ? l : z; // table size upper limit if ((f = 1 << (j = k - w)) > a + 1) // try a k-w bit table { // too few codes for k-w bit table f -= a + 1; // deduct codes from patterns left xp = c + k; if (j < z) while (++j < z) // try smaller tables up to z bits { if ((f <<= 1) <= *++xp) break; // enough codes to use up j bits f -= *xp; // else deduct codes from patterns } } z = 1 << j; // table entries for j-bit table // allocate new table if (*hn + z > MANY) // (note: doesn't matter for fixed) return Z_MEM_ERROR; // not enough memory u[h] = q = hp + *hn; *hn += z; // connect to last table, if there is one if (h) { x[h] = i; // save pattern for backing up r.bits = (Byte)l; // bits to dump before this table r.exop = (Byte)j; // bits in this table j = i >> (w - l); r.base = (uInt)(q - u[h - 1] - j); // offset to this table u[h - 1][j] = r; // connect to last table } else *t = q; // first table is returned result } // set up table entry in r r.bits = (Byte)(k - w); if (p >= v + n) r.exop = 128 + 64; // out of values--invalid code else if (*p < s) { r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); // 256 is end-of-block r.base = *p++; // simple code is just the value } else { r.exop = (Byte)(e[*p - s] + 16 + 64);// non-simple--look up in lists r.base = d[*p++ - s]; } // fill code-like entries with r f = 1 << (k - w); for (j = i >> w; j < z; j += f) q[j] = r; // backwards increment the k-bit code i for (j = 1 << (k - 1); i & j; j >>= 1) i ^= j; i ^= j; // backup over finished tables mask = (1 << w) - 1; // needed on HP, cc -O bug while ((i & mask) != x[h]) { h--; // don't need to update q w -= l; mask = (1 << w) - 1; } } } // Return Z_BUF_ERROR if we were given an incomplete table return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; } int inflate_trees_bits( uInt *c, // 19 code lengths uInt *bb, // bits tree desired/actual depth inflate_huft * *tb, // bits tree result inflate_huft *hp, // space for trees z_streamp z) // for messages { int r; uInt hn = 0; // hufts used in space uInt *v; // work area for huft_build if ((v = (uInt*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL) return Z_MEM_ERROR; r = huft_build(c, 19, 19, (uInt*)Z_NULL, (uInt*)Z_NULL, tb, bb, hp, &hn, v); if (r == Z_DATA_ERROR) z->msg = (char*)"oversubscribed dynamic bit lengths tree"; else if (r == Z_BUF_ERROR || *bb == 0) { z->msg = (char*)"incomplete dynamic bit lengths tree"; r = Z_DATA_ERROR; } ZFREE(z, v); return r; } int inflate_trees_dynamic( uInt nl, // number of literal/length codes uInt nd, // number of distance codes uInt *c, // that many (total) code lengths uInt *bl, // literal desired/actual bit depth uInt *bd, // distance desired/actual bit depth inflate_huft * *tl, // literal/length tree result inflate_huft * *td, // distance tree result inflate_huft *hp, // space for trees z_streamp z) // for messages { int r; uInt hn = 0; // hufts used in space uInt *v; // work area for huft_build // allocate work area if ((v = (uInt*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) return Z_MEM_ERROR; // build literal/length tree r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v); if (r != Z_OK || *bl == 0) { if (r == Z_DATA_ERROR) z->msg = (char*)"oversubscribed literal/length tree"; else if (r != Z_MEM_ERROR) { z->msg = (char*)"incomplete literal/length tree"; r = Z_DATA_ERROR; } ZFREE(z, v); return r; } // build distance tree r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v); if (r != Z_OK || (*bd == 0 && nl > 257)) { if (r == Z_DATA_ERROR) z->msg = (char*)"oversubscribed distance tree"; else if (r == Z_BUF_ERROR) { z->msg = (char*)"incomplete distance tree"; r = Z_DATA_ERROR; } else if (r != Z_MEM_ERROR) { z->msg = (char*)"empty distance tree with lengths"; r = Z_DATA_ERROR; } ZFREE(z, v); return r; } // done ZFREE(z, v); return Z_OK; } int inflate_trees_fixed( uInt *bl, // literal desired/actual bit depth uInt *bd, // distance desired/actual bit depth const inflate_huft * * tl, // literal/length tree result const inflate_huft * *td, // distance tree result z_streamp) // for memory allocation { *bl = fixed_bl; *bd = fixed_bd; *tl = fixed_tl; *td = fixed_td; return Z_OK; } // inffast.c -- process literals and length/distance pairs fast // Copyright (C) 1995-1998 Mark Adler // For conditions of distribution and use, see copyright notice in zlib.h // //struct inflate_codes_state {int dummy;}; // for buggy compilers // macros for bit input with no checking and for returning unused bytes #define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}} #define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;} // Called with number of bytes left to write in window at least 258 // (the maximum string length) and number of input bytes available // at least ten. The ten bytes are six bytes for the longest length/ // distance pair plus four bytes for overloading the bit buffer. int inflate_fast( uInt bl, uInt bd, const inflate_huft *tl, const inflate_huft *td, // need separate declaration for Borland C++ inflate_blocks_statef *s, z_streamp z) { const inflate_huft *t; // temporary pointer uInt e; // extra bits or operation uLong b; // bit buffer uInt k; // bits in bit buffer Byte *p; // input data pointer uInt n; // bytes available there Byte *q; // output window write pointer uInt m; // bytes to end of window or read pointer uInt ml; // mask for literal/length tree uInt md; // mask for distance tree uInt c; // bytes to copy uInt d; // distance back to copy from Byte *r; // copy source pointer // load input, output, bit values LOAD // initialize masks ml = inflate_mask[bl]; md = inflate_mask[bd]; // do until not enough input or output space for fast loop do { // assume called with m >= 258 && n >= 10 // get literal/length code GRABBITS(20) // max bits for literal/length code if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) { DUMPBITS(t->bits) Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? "inflate: * literal '%c'\n" : "inflate: * literal 0x%02x\n", t->base)); *q++ = (Byte)t->base; m--; continue; } for (;;) { DUMPBITS(t->bits) if (e & 16) { // get extra bits for length e &= 15; c = t->base + ((uInt)b & inflate_mask[e]); DUMPBITS(e) Tracevv((stderr, "inflate: * length %u\n", c)); // decode distance base of block to copy GRABBITS(15); // max bits for distance code e = (t = td + ((uInt)b & md))->exop; for (;;) { DUMPBITS(t->bits) if (e & 16) { // get extra bits to add to distance base e &= 15; GRABBITS(e) // get extra bits (up to 13) d = t->base + ((uInt)b & inflate_mask[e]); DUMPBITS(e) Tracevv((stderr, "inflate: * distance %u\n", d)); // do the copy m -= c; if ((uInt)(q - s->window) >= d) // offset before dest { // just copy r = q - d; *q++ = *r++; c--; // minimum count is three, *q++ = *r++; c--; // so unroll loop a little } else // else offset after destination { e = d - (uInt)(q - s->window); // bytes from offset to end r = s->end - e; // pointer to offset if (c > e) // if source crosses, { c -= e; // copy to end of window do { *q++ = *r++; } while (--e); r = s->window; // copy rest from start of window } } do { // copy all or what's left *q++ = *r++; } while (--c); break; } else if ((e & 64) == 0) { t += t->base; e = (t += ((uInt)b & inflate_mask[e]))->exop; } else { z->msg = (char*)"invalid distance code"; UNGRAB UPDATE return Z_DATA_ERROR; } }; break; } if ((e & 64) == 0) { t += t->base; if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) { DUMPBITS(t->bits) Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? "inflate: * literal '%c'\n" : "inflate: * literal 0x%02x\n", t->base)); *q++ = (Byte)t->base; m--; break; } } else if (e & 32) { Tracevv((stderr, "inflate: * end of block\n")); UNGRAB UPDATE return Z_STREAM_END; } else { z->msg = (char*)"invalid literal/length code"; UNGRAB UPDATE return Z_DATA_ERROR; } }; } while (m >= 258 && n >= 10); // not enough input or output--restore pointers and return UNGRAB UPDATE return Z_OK; } // crc32.c -- compute the CRC-32 of a data stream // Copyright (C) 1995-1998 Mark Adler // For conditions of distribution and use, see copyright notice in zlib.h // @(#) $Id$ // Table of CRC-32's of all single-byte values (made by make_crc_table) const uLong crc_table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL }; const uLong * get_crc_table() { return (const uLong *)crc_table; } #define CRC_DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); #define CRC_DO2(buf) CRC_DO1(buf); CRC_DO1(buf); #define CRC_DO4(buf) CRC_DO2(buf); CRC_DO2(buf); #define CRC_DO8(buf) CRC_DO4(buf); CRC_DO4(buf); uLong ucrc32(uLong crc, const Byte *buf, uInt len) { if (buf == Z_NULL) return 0L; crc = crc ^ 0xffffffffL; while (len >= 8) { CRC_DO8(buf); len -= 8; } if (len) do { CRC_DO1(buf); } while (--len); return crc ^ 0xffffffffL; } // adler32.c -- compute the Adler-32 checksum of a data stream // Copyright (C) 1995-1998 Mark Adler // For conditions of distribution and use, see copyright notice in zlib.h // @(#) $Id$ #define BASE 65521L // largest prime smaller than 65536 #define NMAX 5552 // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 #define AD_DO1(buf,i) {s1 += buf[i]; s2 += s1;} #define AD_DO2(buf,i) AD_DO1(buf,i); AD_DO1(buf,i+1); #define AD_DO4(buf,i) AD_DO2(buf,i); AD_DO2(buf,i+2); #define AD_DO8(buf,i) AD_DO4(buf,i); AD_DO4(buf,i+4); #define AD_DO16(buf) AD_DO8(buf,0); AD_DO8(buf,8); // ========================================================================= uLong adler32(uLong adler, const Byte *buf, uInt len) { unsigned long s1 = adler & 0xffff; unsigned long s2 = (adler >> 16) & 0xffff; int k; if (buf == Z_NULL) return 1L; while (len > 0) { k = len < NMAX ? len : NMAX; len -= k; while (k >= 16) { AD_DO16(buf); buf += 16; k -= 16; } if (k != 0) do { s1 += *buf++; s2 += s1; } while (--k); s1 %= BASE; s2 %= BASE; } return (s2 << 16) | s1; } // zutil.c -- target dependent utility functions for the compression library // Copyright (C) 1995-1998 Jean-loup Gailly. // For conditions of distribution and use, see copyright notice in zlib.h // @(#) $Id$ const char * zlibVersion() { return ZLIB_VERSION; } // exported to allow conversion of error code to string for compress() and // uncompress() const char * zError(int err) { return ERR_MSG(err); } voidpf zcalloc(voidpf opaque, unsigned items, unsigned size) { if (opaque) items += size - size; // make compiler happy return (voidpf)calloc(items, size); } void zcfree(voidpf opaque, voidpf ptr) { zfree(ptr); if (opaque) return; // make compiler happy } // inflate.c -- zlib interface to inflate modules // Copyright (C) 1995-1998 Mark Adler // For conditions of distribution and use, see copyright notice in zlib.h //struct inflate_blocks_state {int dummy;}; // for buggy compilers typedef enum { IM_METHOD, // waiting for method byte IM_FLAG, // waiting for flag byte IM_DICT4, // four dictionary check bytes to go IM_DICT3, // three dictionary check bytes to go IM_DICT2, // two dictionary check bytes to go IM_DICT1, // one dictionary check byte to go IM_DICT0, // waiting for inflateSetDictionary IM_BLOCKS, // decompressing blocks IM_CHECK4, // four check bytes to go IM_CHECK3, // three check bytes to go IM_CHECK2, // two check bytes to go IM_CHECK1, // one check byte to go IM_DONE, // finished check, done IM_BAD } // got an error--stay here inflate_mode; // inflate private state struct internal_state { // mode inflate_mode mode; // current inflate mode // mode dependent information union { uInt method; // if IM_FLAGS, method byte struct { uLong was; // computed check value uLong need; // stream check value } check; // if CHECK, check values to compare uInt marker; // if IM_BAD, inflateSync's marker bytes count } sub; // submode // mode independent information int nowrap; // flag for no wrapper uInt wbits; // log2(window size) (8..15, defaults to 15) inflate_blocks_statef *blocks; // current inflate_blocks state }; int inflateReset(z_streamp z) { if (z == Z_NULL || z->state == Z_NULL) return Z_STREAM_ERROR; z->total_in = z->total_out = 0; z->msg = Z_NULL; z->state->mode = z->state->nowrap ? IM_BLOCKS : IM_METHOD; inflate_blocks_reset(z->state->blocks, z, Z_NULL); Tracev((stderr, "inflate: reset\n")); return Z_OK; } int inflateEnd(z_streamp z) { if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) return Z_STREAM_ERROR; if (z->state->blocks != Z_NULL) inflate_blocks_free(z->state->blocks, z); ZFREE(z, z->state); z->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; } int inflateInit2(z_streamp z) { const char *version = ZLIB_VERSION; int stream_size = sizeof(z_stream); if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != sizeof(z_stream)) return Z_VERSION_ERROR; int w = -15; // MAX_WBITS: 32K LZ77 window. // Warning: reducing MAX_WBITS makes minigzip unable to extract .gz files created by gzip. // The memory requirements for deflate are (in bytes): // (1 << (windowBits+2)) + (1 << (memLevel+9)) // that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) // plus a few kilobytes for small objects. For example, if you want to reduce // the default memory requirements from 256K to 128K, compile with // make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" // Of course this will generally degrade compression (there's no free lunch). // // The memory requirements for inflate are (in bytes) 1 << windowBits // that is, 32K for windowBits=15 (default value) plus a few kilobytes // for small objects. // initialize state if (z == Z_NULL) return Z_STREAM_ERROR; z->msg = Z_NULL; if (z->zalloc == Z_NULL) { z->zalloc = zcalloc; z->opaque = (voidpf)0; } if (z->zfree == Z_NULL) z->zfree = zcfree; if ((z->state = (struct internal_state *) ZALLOC(z, 1, sizeof(struct internal_state))) == Z_NULL) return Z_MEM_ERROR; z->state->blocks = Z_NULL; // handle undocumented nowrap option (no zlib header or check) z->state->nowrap = 0; if (w < 0) { w = -w; z->state->nowrap = 1; } // set window size if (w < 8 || w > 15) { inflateEnd(z); return Z_STREAM_ERROR; } z->state->wbits = (uInt)w; // create inflate_blocks state if ((z->state->blocks = inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) == Z_NULL) { inflateEnd(z); return Z_MEM_ERROR; } Tracev((stderr, "inflate: allocated\n")); // reset state inflateReset(z); return Z_OK; } #define IM_NEEDBYTE {if(z->avail_in==0)return r;r=f;} #define IM_NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) int inflate(z_streamp z, int f) { int r; uInt b; if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) return Z_STREAM_ERROR; f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; r = Z_BUF_ERROR; for (;;) switch (z->state->mode) { case IM_METHOD: IM_NEEDBYTE if (((z->state->sub.method = IM_NEXTBYTE) & 0xf) != Z_DEFLATED) { z->state->mode = IM_BAD; z->msg = (char*)"unknown compression method"; z->state->sub.marker = 5; // can't try inflateSync break; } if ((z->state->sub.method >> 4) + 8 > z->state->wbits) { z->state->mode = IM_BAD; z->msg = (char*)"invalid window size"; z->state->sub.marker = 5; // can't try inflateSync break; } z->state->mode = IM_FLAG; case IM_FLAG: IM_NEEDBYTE b = IM_NEXTBYTE; if (((z->state->sub.method << 8) + b) % 31) { z->state->mode = IM_BAD; z->msg = (char*)"incorrect header check"; z->state->sub.marker = 5; // can't try inflateSync break; } Tracev((stderr, "inflate: zlib header ok\n")); if (!(b & PRESET_DICT)) { z->state->mode = IM_BLOCKS; break; } z->state->mode = IM_DICT4; case IM_DICT4: IM_NEEDBYTE z->state->sub.check.need = (uLong)IM_NEXTBYTE << 24; z->state->mode = IM_DICT3; case IM_DICT3: IM_NEEDBYTE z->state->sub.check.need += (uLong)IM_NEXTBYTE << 16; z->state->mode = IM_DICT2; case IM_DICT2: IM_NEEDBYTE z->state->sub.check.need += (uLong)IM_NEXTBYTE << 8; z->state->mode = IM_DICT1; case IM_DICT1: IM_NEEDBYTE; r; z->state->sub.check.need += (uLong)IM_NEXTBYTE; z->adler = z->state->sub.check.need; z->state->mode = IM_DICT0; return Z_NEED_DICT; case IM_DICT0: z->state->mode = IM_BAD; z->msg = (char*)"need dictionary"; z->state->sub.marker = 0; // can try inflateSync return Z_STREAM_ERROR; case IM_BLOCKS: r = inflate_blocks(z->state->blocks, z, r); if (r == Z_DATA_ERROR) { z->state->mode = IM_BAD; z->state->sub.marker = 0; // can try inflateSync break; } if (r == Z_OK) r = f; if (r != Z_STREAM_END) return r; r = f; inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); if (z->state->nowrap) { z->state->mode = IM_DONE; break; } z->state->mode = IM_CHECK4; case IM_CHECK4: IM_NEEDBYTE z->state->sub.check.need = (uLong)IM_NEXTBYTE << 24; z->state->mode = IM_CHECK3; case IM_CHECK3: IM_NEEDBYTE z->state->sub.check.need += (uLong)IM_NEXTBYTE << 16; z->state->mode = IM_CHECK2; case IM_CHECK2: IM_NEEDBYTE z->state->sub.check.need += (uLong)IM_NEXTBYTE << 8; z->state->mode = IM_CHECK1; case IM_CHECK1: IM_NEEDBYTE z->state->sub.check.need += (uLong)IM_NEXTBYTE; if (z->state->sub.check.was != z->state->sub.check.need) { z->state->mode = IM_BAD; z->msg = (char*)"incorrect data check"; z->state->sub.marker = 5; // can't try inflateSync break; } Tracev((stderr, "inflate: zlib check ok\n")); z->state->mode = IM_DONE; case IM_DONE: return Z_STREAM_END; case IM_BAD: return Z_DATA_ERROR; default: return Z_STREAM_ERROR; } } #ifdef _UNICODE static int GetAnsiFileName(LPCWSTR name, char * buf, int nBufSize) { memset(buf, 0, nBufSize); int n = WideCharToMultiByte(CP_ACP, // code page 0, // performance and mapping flags name, // wide-character string -1, // number of chars in string buf, // buffer for new string nBufSize, // size of buffer NULL, // default for unmappable chars NULL); // set when default char used return n; } static int GetUnicodeFileName(const char * name, LPWSTR buf, int nBufSize) { memset(buf, 0, nBufSize*sizeof(TCHAR)); int n = MultiByteToWideChar(CP_ACP, // code page 0, // character-type options name, // string to map -1, // number of bytes in string buf, // wide-character buffer nBufSize); // size of buffer return n; } #endif // unzip.c -- IO on .zip files using zlib // Version 0.15 beta, Mar 19th, 1998, // Read unzip.h for more info #define UNZ_BUFSIZE (16384) #define UNZ_MAXFILENAMEINZIP (256) #define SIZECENTRALDIRITEM (0x2e) #define SIZEZIPLOCALHEADER (0x1e) const char unz_copyright[] = " ";//unzip 0.15 Copyright 1998 Gilles Vollant "; // unz_file_info_interntal contain internal info about a file in zipfile typedef struct unz_file_info_internal_s { uLong offset_curfile;// relative offset of local header 4 bytes } unz_file_info_internal; typedef struct { bool is_handle; // either a handle or memory bool canseek; // for handles: HANDLE h; bool herr; unsigned long initial_offset; // for memory: void *buf; unsigned int len, pos; // if it's a memory block } LUFILE; LUFILE *lufopen(void *z, unsigned int len, DWORD flags, ZRESULT *err) { if (flags != ZIP_HANDLE && flags != ZIP_FILENAME && flags != ZIP_MEMORY) { *err = ZR_ARGS; return NULL; } // HANDLE h = 0; bool canseek = false; *err = ZR_OK; if (flags == ZIP_HANDLE || flags == ZIP_FILENAME) { if (flags == ZIP_HANDLE) { HANDLE hf = z; BOOL res = DuplicateHandle(GetCurrentProcess(), hf, GetCurrentProcess(), &h, 0, FALSE, DUPLICATE_SAME_ACCESS); if (!res) { *err = ZR_NODUPH; return NULL; } } else { h = CreateFile((const TCHAR *)z, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h == INVALID_HANDLE_VALUE) { *err = ZR_NOFILE; return NULL; } } DWORD type = GetFileType(h); canseek = (type == FILE_TYPE_DISK); } LUFILE *lf = new LUFILE; if (flags == ZIP_HANDLE || flags == ZIP_FILENAME) { lf->is_handle = true; lf->canseek = canseek; lf->h = h; lf->herr = false; lf->initial_offset = 0; if (canseek) lf->initial_offset = SetFilePointer(h, 0, NULL, FILE_CURRENT); } else { lf->is_handle = false; lf->canseek = true; lf->buf = z; lf->len = len; lf->pos = 0; lf->initial_offset = 0; } *err = ZR_OK; return lf; } int lufclose(LUFILE *stream) { if (stream == NULL) return EOF; if (stream->is_handle) CloseHandle(stream->h); delete stream; return 0; } int luferror(LUFILE *stream) { if (stream->is_handle && stream->herr) return 1; else return 0; } long int luftell(LUFILE *stream) { if (stream->is_handle && stream->canseek) return SetFilePointer(stream->h, 0, NULL, FILE_CURRENT) - stream->initial_offset; else if (stream->is_handle) return 0; else return stream->pos; } int lufseek(LUFILE *stream, long offset, int whence) { if (stream->is_handle && stream->canseek) { if (whence == SEEK_SET) SetFilePointer(stream->h, stream->initial_offset + offset, 0, FILE_BEGIN); else if (whence == SEEK_CUR) SetFilePointer(stream->h, offset, NULL, FILE_CURRENT); else if (whence == SEEK_END) SetFilePointer(stream->h, offset, NULL, FILE_END); else return 19; // EINVAL return 0; } else if (stream->is_handle) return 29; // ESPIPE else { if (whence == SEEK_SET) stream->pos = offset; else if (whence == SEEK_CUR) stream->pos += offset; else if (whence == SEEK_END) stream->pos = stream->len + offset; return 0; } } size_t lufread(void *ptr, size_t size, size_t n, LUFILE *stream) { unsigned int toread = (unsigned int)(size*n); if (stream->is_handle) { DWORD red; BOOL res = ReadFile(stream->h, ptr, toread, &red, NULL); if (!res) stream->herr = true; return red / size; } if (stream->pos + toread > stream->len) toread = stream->len - stream->pos; memcpy(ptr, (char*)stream->buf + stream->pos, toread); DWORD red = toread; stream->pos += red; return red / size; } // file_in_zip_read_info_s contain internal information about a file in zipfile, // when reading and decompress it typedef struct { char *read_buffer; // internal buffer for compressed data z_stream stream; // zLib stream structure for inflate uLong pos_in_zipfile; // position in byte on the zipfile, for fseek uLong stream_initialised; // flag set if stream structure is initialised uLong offset_local_extrafield;// offset of the local extra field uInt size_local_extrafield;// size of the local extra field uLong pos_local_extrafield; // position in the local extra field in read uLong crc32; // crc32 of all data uncompressed uLong crc32_wait; // crc32 we must obtain after decompress all uLong rest_read_compressed; // number of byte to be decompressed uLong rest_read_uncompressed;//number of byte to be obtained after decomp LUFILE* file; // io structore of the zipfile uLong compression_method; // compression method (0==store) uLong byte_before_the_zipfile;// byte before the zipfile, (>0 for sfx) } file_in_zip_read_info_s; // unz_s contain internal information about the zipfile typedef struct { LUFILE* file; // io structore of the zipfile unz_global_info gi; // public global information uLong byte_before_the_zipfile;// byte before the zipfile, (>0 for sfx) uLong num_file; // number of the current file in the zipfile uLong pos_in_central_dir; // pos of the current file in the central dir uLong current_file_ok; // flag about the usability of the current file uLong central_pos; // position of the beginning of the central dir uLong size_central_dir; // size of the central directory uLong offset_central_dir; // offset of start of central directory with respect to the starting disk number unz_file_info cur_file_info; // public info about the current file in zip unz_file_info_internal cur_file_info_internal; // private info about it file_in_zip_read_info_s* pfile_in_zip_read; // structure about the current file if we are decompressing it } unz_s, *unzFile; int unzStringFileNameCompare(const char* fileName1, const char* fileName2, int iCaseSensitivity); // Compare two filename (fileName1,fileName2). z_off_t unztell(unzFile file); // Give the current position in uncompressed data int unzeof(unzFile file); // return 1 if the end of file was reached, 0 elsewhere int unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len); // Read extra field from the current file (opened by unzOpenCurrentFile) // This is the local-header version of the extra field (sometimes, there is // more info in the local-header version than in the central-header) // // if buf==NULL, it return the size of the local extra field // // if buf!=NULL, len is the size of the buffer, the extra header is copied in // buf. // the return value is the number of bytes copied in buf, or (if <0) // the error code // =========================================================================== // Read a byte from a gz_stream; update next_in and avail_in. Return EOF // for end of file. // IN assertion: the stream s has been sucessfully opened for reading. int unzlocal_getByte(LUFILE *fin, int *pi) { unsigned char c; int err = (int)lufread(&c, 1, 1, fin); if (err == 1) { *pi = (int)c; return UNZ_OK; } else { if (luferror(fin)) return UNZ_ERRNO; else return UNZ_EOF; } } // =========================================================================== // Reads a long in LSB order from the given gz_stream. Sets int unzlocal_getShort(LUFILE *fin, uLong *pX) { uLong x; int i; int err; err = unzlocal_getByte(fin, &i); x = (uLong)i; if (err == UNZ_OK) err = unzlocal_getByte(fin, &i); x += ((uLong)i) << 8; if (err == UNZ_OK) *pX = x; else *pX = 0; return err; } int unzlocal_getLong(LUFILE *fin, uLong *pX) { uLong x; int i; int err; err = unzlocal_getByte(fin, &i); x = (uLong)i; if (err == UNZ_OK) err = unzlocal_getByte(fin, &i); x += ((uLong)i) << 8; if (err == UNZ_OK) err = unzlocal_getByte(fin, &i); x += ((uLong)i) << 16; if (err == UNZ_OK) err = unzlocal_getByte(fin, &i); x += ((uLong)i) << 24; if (err == UNZ_OK) *pX = x; else *pX = 0; return err; } // My own strcmpi / strcasecmp int strcmpcasenosensitive_internal(const char* fileName1, const char *fileName2) { for (;;) { char c1 = *(fileName1++); char c2 = *(fileName2++); if ((c1 >= 'a') && (c1 <= 'z')) c1 -= (char)0x20; if ((c2 >= 'a') && (c2 <= 'z')) c2 -= (char)0x20; if (c1 == '\0') return ((c2 == '\0') ? 0 : -1); if (c2 == '\0') return 1; if (c1<c2) return -1; if (c1>c2) return 1; } } // // Compare two filename (fileName1,fileName2). // If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) // If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi or strcasecmp) // int unzStringFileNameCompare(const char*fileName1, const char*fileName2, int iCaseSensitivity) { if (iCaseSensitivity == 1) return strcmp(fileName1, fileName2); else return strcmpcasenosensitive_internal(fileName1, fileName2); } #define BUFREADCOMMENT (0x400) // Locate the Central directory of a zipfile (at the end, just before // the global comment) uLong unzlocal_SearchCentralDir(LUFILE *fin) { if (lufseek(fin, 0, SEEK_END) != 0) return 0; uLong uSizeFile = luftell(fin); uLong uMaxBack = 0xffff; // maximum size of global comment if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; unsigned char *buf = (unsigned char*)zmalloc(BUFREADCOMMENT + 4); if (buf == NULL) return 0; uLong uPosFound = 0; uLong uBackRead = 4; while (uBackRead<uMaxBack) { uLong uReadSize, uReadPos; int i; if (uBackRead + BUFREADCOMMENT>uMaxBack) uBackRead = uMaxBack; else uBackRead += BUFREADCOMMENT; uReadPos = uSizeFile - uBackRead; uReadSize = ((BUFREADCOMMENT + 4) < (uSizeFile - uReadPos)) ? (BUFREADCOMMENT + 4) : (uSizeFile - uReadPos); if (lufseek(fin, uReadPos, SEEK_SET) != 0) break; if (lufread(buf, (uInt)uReadSize, 1, fin) != 1) break; for (i = (int)uReadSize - 3; (i--)>0;) { if (((*(buf + i)) == 0x50) && ((*(buf + i + 1)) == 0x4b) && ((*(buf + i + 2)) == 0x05) && ((*(buf + i + 3)) == 0x06)) { uPosFound = uReadPos + i; break; } } if (uPosFound != 0) break; } if (buf) zfree(buf); return uPosFound; } int unzGoToFirstFile(unzFile file); int unzCloseCurrentFile(unzFile file); // Open a Zip file. // If the zipfile cannot be opened (file don't exist or in not valid), return NULL. // Otherwise, the return value is a unzFile Handle, usable with other unzip functions unzFile unzOpenInternal(LUFILE *fin) { zopenerror = ZR_OK; //+++1.2 if (fin == NULL) { zopenerror = ZR_ARGS; return NULL; } //+++1.2 if (unz_copyright[0] != ' ') { lufclose(fin); zopenerror = ZR_CORRUPT; return NULL; } //+++1.2 int err = UNZ_OK; unz_s us; uLong central_pos, uL; central_pos = unzlocal_SearchCentralDir(fin); if (central_pos == 0) err = UNZ_ERRNO; if (lufseek(fin, central_pos, SEEK_SET) != 0) err = UNZ_ERRNO; // the signature, already checked if (unzlocal_getLong(fin, &uL) != UNZ_OK) err = UNZ_ERRNO; // number of this disk uLong number_disk; // number of the current dist, used for spanning ZIP, unsupported, always 0 if (unzlocal_getShort(fin, &number_disk) != UNZ_OK) err = UNZ_ERRNO; // number of the disk with the start of the central directory uLong number_disk_with_CD; // number the the disk with central dir, used for spaning ZIP, unsupported, always 0 if (unzlocal_getShort(fin, &number_disk_with_CD) != UNZ_OK) err = UNZ_ERRNO; // total number of entries in the central dir on this disk if (unzlocal_getShort(fin, &us.gi.number_entry) != UNZ_OK) err = UNZ_ERRNO; // total number of entries in the central dir uLong number_entry_CD; // total number of entries in the central dir (same than number_entry on nospan) if (unzlocal_getShort(fin, &number_entry_CD) != UNZ_OK) err = UNZ_ERRNO; if ((number_entry_CD != us.gi.number_entry) || (number_disk_with_CD != 0) || (number_disk != 0)) err = UNZ_BADZIPFILE; // size of the central directory if (unzlocal_getLong(fin, &us.size_central_dir) != UNZ_OK) err = UNZ_ERRNO; // offset of start of central directory with respect to the starting disk number if (unzlocal_getLong(fin, &us.offset_central_dir) != UNZ_OK) err = UNZ_ERRNO; // zipfile comment length if (unzlocal_getShort(fin, &us.gi.size_comment) != UNZ_OK) err = UNZ_ERRNO; if ((central_pos + fin->initial_offset<us.offset_central_dir + us.size_central_dir) && (err == UNZ_OK)) err = UNZ_BADZIPFILE; //if (err!=UNZ_OK) {lufclose(fin);return NULL;} if (err != UNZ_OK) { lufclose(fin); zopenerror = err; return NULL; } //+++1.2 us.file = fin; us.byte_before_the_zipfile = central_pos + fin->initial_offset - (us.offset_central_dir + us.size_central_dir); us.central_pos = central_pos; us.pfile_in_zip_read = NULL; fin->initial_offset = 0; // since the zipfile itself is expected to handle this unz_s *s = (unz_s*)zmalloc(sizeof(unz_s)); *s = us; unzGoToFirstFile((unzFile)s); return (unzFile)s; } // Close a ZipFile opened with unzipOpen. // If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), // these files MUST be closed with unzipCloseCurrentFile before call unzipClose. // return UNZ_OK if there is no problem. int unzClose(unzFile file) { unz_s* s; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; if (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); lufclose(s->file); if (s) zfree(s); // unused s=0; return UNZ_OK; } // Write info about the ZipFile in the *pglobal_info structure. // No preparation of the structure is needed // return UNZ_OK if there is no problem. int unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info) { unz_s* s; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; *pglobal_info = s->gi; return UNZ_OK; } // Translate date/time from Dos format to tm_unz (readable more easilty) void unzlocal_DosDateToTmuDate(uLong ulDosDate, tm_unz* ptm) { uLong uDate; uDate = (uLong)(ulDosDate >> 16); ptm->tm_mday = (uInt)(uDate & 0x1f); ptm->tm_mon = (uInt)((((uDate)& 0x1E0) / 0x20) - 1); ptm->tm_year = (uInt)(((uDate & 0x0FE00) / 0x0200) + 1980); ptm->tm_hour = (uInt)((ulDosDate & 0xF800) / 0x800); ptm->tm_min = (uInt)((ulDosDate & 0x7E0) / 0x20); ptm->tm_sec = (uInt)(2 * (ulDosDate & 0x1f)); } // Get Info about the current file in the zipfile, with internal only info int unzlocal_GetCurrentFileInfoInternal(unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize); int unzlocal_GetCurrentFileInfoInternal(unzFile file, unz_file_info *pfile_info, unz_file_info_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize) { unz_s* s; unz_file_info file_info; unz_file_info_internal file_info_internal; int err = UNZ_OK; uLong uMagic; long lSeek = 0; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; if (lufseek(s->file, s->pos_in_central_dir + s->byte_before_the_zipfile, SEEK_SET) != 0) err = UNZ_ERRNO; // we check the magic if (err == UNZ_OK) if (unzlocal_getLong(s->file, &uMagic) != UNZ_OK) err = UNZ_ERRNO; else if (uMagic != 0x02014b50) err = UNZ_BADZIPFILE; if (unzlocal_getShort(s->file, &file_info.version) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getShort(s->file, &file_info.version_needed) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getShort(s->file, &file_info.flag) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getShort(s->file, &file_info.compression_method) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getLong(s->file, &file_info.dosDate) != UNZ_OK) err = UNZ_ERRNO; unzlocal_DosDateToTmuDate(file_info.dosDate, &file_info.tmu_date); if (unzlocal_getLong(s->file, &file_info.crc) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getLong(s->file, &file_info.compressed_size) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getLong(s->file, &file_info.uncompressed_size) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getShort(s->file, &file_info.size_filename) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getShort(s->file, &file_info.size_file_extra) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getShort(s->file, &file_info.size_file_comment) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getShort(s->file, &file_info.disk_num_start) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getShort(s->file, &file_info.internal_fa) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getLong(s->file, &file_info.external_fa) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getLong(s->file, &file_info_internal.offset_curfile) != UNZ_OK) err = UNZ_ERRNO; lSeek += file_info.size_filename; if ((err == UNZ_OK) && (szFileName != NULL)) { uLong uSizeRead; if (file_info.size_filename<fileNameBufferSize) { *(szFileName + file_info.size_filename) = '\0'; uSizeRead = file_info.size_filename; } else uSizeRead = fileNameBufferSize; if ((file_info.size_filename>0) && (fileNameBufferSize>0)) if (lufread(szFileName, (uInt)uSizeRead, 1, s->file) != 1) err = UNZ_ERRNO; lSeek -= uSizeRead; } if ((err == UNZ_OK) && (extraField != NULL)) { uLong uSizeRead; if (file_info.size_file_extra<extraFieldBufferSize) uSizeRead = file_info.size_file_extra; else uSizeRead = extraFieldBufferSize; if (lSeek != 0) if (lufseek(s->file, lSeek, SEEK_CUR) == 0) lSeek = 0; else err = UNZ_ERRNO; if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) if (lufread(extraField, (uInt)uSizeRead, 1, s->file) != 1) err = UNZ_ERRNO; lSeek += file_info.size_file_extra - uSizeRead; } else lSeek += file_info.size_file_extra; if ((err == UNZ_OK) && (szComment != NULL)) { uLong uSizeRead; if (file_info.size_file_comment<commentBufferSize) { *(szComment + file_info.size_file_comment) = '\0'; uSizeRead = file_info.size_file_comment; } else uSizeRead = commentBufferSize; if (lSeek != 0) if (lufseek(s->file, lSeek, SEEK_CUR) == 0) { } // unused lSeek=0; else err = UNZ_ERRNO; if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if (lufread(szComment, (uInt)uSizeRead, 1, s->file) != 1) err = UNZ_ERRNO; //unused lSeek+=file_info.size_file_comment - uSizeRead; } else {} //unused lSeek+=file_info.size_file_comment; if ((err == UNZ_OK) && (pfile_info != NULL)) *pfile_info = file_info; if ((err == UNZ_OK) && (pfile_info_internal != NULL)) *pfile_info_internal = file_info_internal; return err; } // Write info about the ZipFile in the *pglobal_info structure. // No preparation of the structure is needed // return UNZ_OK if there is no problem. int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *szFileName, uLong fileNameBufferSize, void *extraField, uLong extraFieldBufferSize, char *szComment, uLong commentBufferSize) { return unzlocal_GetCurrentFileInfoInternal(file, pfile_info, NULL, szFileName, fileNameBufferSize, extraField, extraFieldBufferSize, szComment, commentBufferSize); } // Set the current file of the zipfile to the first file. // return UNZ_OK if there is no problem int unzGoToFirstFile(unzFile file) { int err; unz_s* s; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; s->pos_in_central_dir = s->offset_central_dir; s->num_file = 0; err = unzlocal_GetCurrentFileInfoInternal(file, &s->cur_file_info, &s->cur_file_info_internal, NULL, 0, NULL, 0, NULL, 0); s->current_file_ok = (err == UNZ_OK); return err; } // Set the current file of the zipfile to the next file. // return UNZ_OK if there is no problem // return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. int unzGoToNextFile(unzFile file) { unz_s* s; int err; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; if (s->num_file + 1 == s->gi.number_entry) return UNZ_END_OF_LIST_OF_FILE; s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment; s->num_file++; err = unzlocal_GetCurrentFileInfoInternal(file, &s->cur_file_info, &s->cur_file_info_internal, NULL, 0, NULL, 0, NULL, 0); s->current_file_ok = (err == UNZ_OK); return err; } // Try locate the file szFileName in the zipfile. // For the iCaseSensitivity signification, see unzStringFileNameCompare // return value : // UNZ_OK if the file is found. It becomes the current file. // UNZ_END_OF_LIST_OF_FILE if the file is not found int unzLocateFile(unzFile file, const TCHAR *szFileName, int iCaseSensitivity) { unz_s* s; int err; uLong num_fileSaved; uLong pos_in_central_dirSaved; if (file == NULL) return UNZ_PARAMERROR; if (_tcslen(szFileName) >= UNZ_MAXFILENAMEINZIP) return UNZ_PARAMERROR; char szFileNameA[MAX_PATH]; #ifdef _UNICODE GetAnsiFileName(szFileName, szFileNameA, MAX_PATH - 1); #else strcpy(szFileNameA, szFileName); #endif s = (unz_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; num_fileSaved = s->num_file; pos_in_central_dirSaved = s->pos_in_central_dir; err = unzGoToFirstFile(file); while (err == UNZ_OK) { char szCurrentFileName[UNZ_MAXFILENAMEINZIP + 1]; unzGetCurrentFileInfo(file, NULL, szCurrentFileName, sizeof(szCurrentFileName) - 1, NULL, 0, NULL, 0); if (unzStringFileNameCompare(szCurrentFileName, szFileNameA, iCaseSensitivity) == 0) return UNZ_OK; err = unzGoToNextFile(file); } s->num_file = num_fileSaved; s->pos_in_central_dir = pos_in_central_dirSaved; return err; } // Read the local header of the current zipfile // Check the coherency of the local header and info in the end of central // directory about this file // store in *piSizeVar the size of extra info in local header // (filename and size of extra field data) int unzlocal_CheckCurrentFileCoherencyHeader(unz_s *s, uInt *piSizeVar, uLong *poffset_local_extrafield, uInt *psize_local_extrafield) { uLong uMagic, uData, uFlags; uLong size_filename; uLong size_extra_field; int err = UNZ_OK; *piSizeVar = 0; *poffset_local_extrafield = 0; *psize_local_extrafield = 0; if (lufseek(s->file, s->cur_file_info_internal.offset_curfile + s->byte_before_the_zipfile, SEEK_SET) != 0) return UNZ_ERRNO; if (err == UNZ_OK) if (unzlocal_getLong(s->file, &uMagic) != UNZ_OK) err = UNZ_ERRNO; else if (uMagic != 0x04034b50) err = UNZ_BADZIPFILE; if (unzlocal_getShort(s->file, &uData) != UNZ_OK) err = UNZ_ERRNO; // else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) // err=UNZ_BADZIPFILE; if (unzlocal_getShort(s->file, &uFlags) != UNZ_OK) err = UNZ_ERRNO; if (unzlocal_getShort(s->file, &uData) != UNZ_OK) err = UNZ_ERRNO; else if ((err == UNZ_OK) && (uData != s->cur_file_info.compression_method)) err = UNZ_BADZIPFILE; if ((err == UNZ_OK) && (s->cur_file_info.compression_method != 0) && (s->cur_file_info.compression_method != Z_DEFLATED)) err = UNZ_BADZIPFILE; if (unzlocal_getLong(s->file, &uData) != UNZ_OK) // date/time err = UNZ_ERRNO; if (unzlocal_getLong(s->file, &uData) != UNZ_OK) // crc err = UNZ_ERRNO; else if ((err == UNZ_OK) && (uData != s->cur_file_info.crc) && ((uFlags & 8) == 0)) err = UNZ_BADZIPFILE; if (unzlocal_getLong(s->file, &uData) != UNZ_OK) // size compr err = UNZ_ERRNO; else if ((err == UNZ_OK) && (uData != s->cur_file_info.compressed_size) && ((uFlags & 8) == 0)) err = UNZ_BADZIPFILE; if (unzlocal_getLong(s->file, &uData) != UNZ_OK) // size uncompr err = UNZ_ERRNO; else if ((err == UNZ_OK) && (uData != s->cur_file_info.uncompressed_size) && ((uFlags & 8) == 0)) err = UNZ_BADZIPFILE; if (unzlocal_getShort(s->file, &size_filename) != UNZ_OK) err = UNZ_ERRNO; else if ((err == UNZ_OK) && (size_filename != s->cur_file_info.size_filename)) err = UNZ_BADZIPFILE; *piSizeVar += (uInt)size_filename; if (unzlocal_getShort(s->file, &size_extra_field) != UNZ_OK) err = UNZ_ERRNO; *poffset_local_extrafield = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + size_filename; *psize_local_extrafield = (uInt)size_extra_field; *piSizeVar += (uInt)size_extra_field; return err; } // Open for reading data the current file in the zipfile. // If there is no error and the file is opened, the return value is UNZ_OK. int unzOpenCurrentFile(unzFile file) { int err; int Store; uInt iSizeVar; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; uLong offset_local_extrafield; // offset of the local extra field uInt size_local_extrafield; // size of the local extra field if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; if (!s->current_file_ok) return UNZ_PARAMERROR; if (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); if (unzlocal_CheckCurrentFileCoherencyHeader(s, &iSizeVar, &offset_local_extrafield, &size_local_extrafield) != UNZ_OK) return UNZ_BADZIPFILE; pfile_in_zip_read_info = (file_in_zip_read_info_s*)zmalloc(sizeof(file_in_zip_read_info_s)); if (pfile_in_zip_read_info == NULL) return UNZ_INTERNALERROR; pfile_in_zip_read_info->read_buffer = (char*)zmalloc(UNZ_BUFSIZE); pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; pfile_in_zip_read_info->pos_local_extrafield = 0; if (pfile_in_zip_read_info->read_buffer == NULL) { if (pfile_in_zip_read_info != 0) zfree(pfile_in_zip_read_info); //unused pfile_in_zip_read_info=0; return UNZ_INTERNALERROR; } pfile_in_zip_read_info->stream_initialised = 0; if ((s->cur_file_info.compression_method != 0) && (s->cur_file_info.compression_method != Z_DEFLATED)) { // unused err=UNZ_BADZIPFILE; } Store = s->cur_file_info.compression_method == 0; pfile_in_zip_read_info->crc32_wait = s->cur_file_info.crc; pfile_in_zip_read_info->crc32 = 0; pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; pfile_in_zip_read_info->file = s->file; pfile_in_zip_read_info->byte_before_the_zipfile = s->byte_before_the_zipfile; pfile_in_zip_read_info->stream.total_out = 0; if (!Store) { pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; pfile_in_zip_read_info->stream.zfree = (free_func)0; pfile_in_zip_read_info->stream.opaque = (voidpf)0; err = inflateInit2(&pfile_in_zip_read_info->stream); if (err == Z_OK) pfile_in_zip_read_info->stream_initialised = 1; // windowBits is passed < 0 to tell that there is no zlib header. // Note that in this case inflate *requires* an extra "dummy" byte // after the compressed stream in order to complete decompression and // return Z_STREAM_END. // In unzip, i don't wait absolutely Z_STREAM_END because I known the // size of both compressed and uncompressed data } pfile_in_zip_read_info->rest_read_compressed = s->cur_file_info.compressed_size; pfile_in_zip_read_info->rest_read_uncompressed = s->cur_file_info.uncompressed_size; pfile_in_zip_read_info->pos_in_zipfile = s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + iSizeVar; pfile_in_zip_read_info->stream.avail_in = (uInt)0; s->pfile_in_zip_read = pfile_in_zip_read_info; return UNZ_OK; } // Read bytes from the current file. // buf contain buffer where data must be copied // len the size of buf. // return the number of byte copied if somes bytes are copied // return 0 if the end of file was reached // return <0 with error code if there is an error // (UNZ_ERRNO for IO error, or zLib error for uncompress error) int unzReadCurrentFile(unzFile file, voidp buf, unsigned len) { int err = UNZ_OK; uInt iRead = 0; unz_s *s = (unz_s*)file; if (s == NULL) return UNZ_PARAMERROR; file_in_zip_read_info_s* pfile_in_zip_read_info = s->pfile_in_zip_read; if (pfile_in_zip_read_info == NULL) return UNZ_PARAMERROR; if ((pfile_in_zip_read_info->read_buffer == NULL)) return UNZ_END_OF_LIST_OF_FILE; if (len == 0) return 0; pfile_in_zip_read_info->stream.next_out = (Byte*)buf; pfile_in_zip_read_info->stream.avail_out = (uInt)len; if (len>pfile_in_zip_read_info->rest_read_uncompressed) { pfile_in_zip_read_info->stream.avail_out = (uInt)pfile_in_zip_read_info->rest_read_uncompressed; } while (pfile_in_zip_read_info->stream.avail_out>0) { if ((pfile_in_zip_read_info->stream.avail_in == 0) && (pfile_in_zip_read_info->rest_read_compressed>0)) { uInt uReadThis = UNZ_BUFSIZE; if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; if (uReadThis == 0) return UNZ_EOF; if (lufseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile, SEEK_SET) != 0) return UNZ_ERRNO; if (lufread(pfile_in_zip_read_info->read_buffer, uReadThis, 1, pfile_in_zip_read_info->file) != 1) return UNZ_ERRNO; pfile_in_zip_read_info->pos_in_zipfile += uReadThis; pfile_in_zip_read_info->rest_read_compressed -= uReadThis; pfile_in_zip_read_info->stream.next_in = (Byte*)pfile_in_zip_read_info->read_buffer; pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; } if (pfile_in_zip_read_info->compression_method == 0) { uInt uDoCopy, i; if (pfile_in_zip_read_info->stream.avail_out < pfile_in_zip_read_info->stream.avail_in) { uDoCopy = pfile_in_zip_read_info->stream.avail_out; } else { uDoCopy = pfile_in_zip_read_info->stream.avail_in; } for (i = 0; i<uDoCopy; i++) { *(pfile_in_zip_read_info->stream.next_out + i) = *(pfile_in_zip_read_info->stream.next_in + i); } pfile_in_zip_read_info->crc32 = ucrc32(pfile_in_zip_read_info->crc32, pfile_in_zip_read_info->stream.next_out, uDoCopy); pfile_in_zip_read_info->rest_read_uncompressed -= uDoCopy; pfile_in_zip_read_info->stream.avail_in -= uDoCopy; pfile_in_zip_read_info->stream.avail_out -= uDoCopy; pfile_in_zip_read_info->stream.next_out += uDoCopy; pfile_in_zip_read_info->stream.next_in += uDoCopy; pfile_in_zip_read_info->stream.total_out += uDoCopy; iRead += uDoCopy; } else { uLong uTotalOutBefore, uTotalOutAfter; const Byte *bufBefore; uLong uOutThis; int flush = Z_SYNC_FLUSH; uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; bufBefore = pfile_in_zip_read_info->stream.next_out; err = inflate(&pfile_in_zip_read_info->stream, flush); uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; uOutThis = uTotalOutAfter - uTotalOutBefore; pfile_in_zip_read_info->crc32 = ucrc32(pfile_in_zip_read_info->crc32, bufBefore, (uInt)(uOutThis)); pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); if (err == Z_STREAM_END) return (iRead == 0) ? UNZ_EOF : iRead; //+++1.3 //if (err==Z_STREAM_END) return (iRead==len) ? UNZ_EOF : iRead; //+++1.2 if (err != Z_OK) break; } } if (err == Z_OK) return iRead; return iRead; } // Give the current position in uncompressed data z_off_t unztell(unzFile file) { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; pfile_in_zip_read_info = s->pfile_in_zip_read; if (pfile_in_zip_read_info == NULL) return UNZ_PARAMERROR; return (z_off_t)pfile_in_zip_read_info->stream.total_out; } // return 1 if the end of file was reached, 0 elsewhere int unzeof(unzFile file) { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; pfile_in_zip_read_info = s->pfile_in_zip_read; if (pfile_in_zip_read_info == NULL) return UNZ_PARAMERROR; if (pfile_in_zip_read_info->rest_read_uncompressed == 0) return 1; else return 0; } // Read extra field from the current file (opened by unzOpenCurrentFile) // This is the local-header version of the extra field (sometimes, there is // more info in the local-header version than in the central-header) // if buf==NULL, it return the size of the local extra field that can be read // if buf!=NULL, len is the size of the buffer, the extra header is copied in buf. // the return value is the number of bytes copied in buf, or (if <0) the error code int unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len) { unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; uInt read_now; uLong size_to_read; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; pfile_in_zip_read_info = s->pfile_in_zip_read; if (pfile_in_zip_read_info == NULL) return UNZ_PARAMERROR; size_to_read = (pfile_in_zip_read_info->size_local_extrafield - pfile_in_zip_read_info->pos_local_extrafield); if (buf == NULL) return (int)size_to_read; if (len>size_to_read) read_now = (uInt)size_to_read; else read_now = (uInt)len; if (read_now == 0) return 0; if (lufseek(pfile_in_zip_read_info->file, pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield, SEEK_SET) != 0) return UNZ_ERRNO; if (lufread(buf, (uInt)size_to_read, 1, pfile_in_zip_read_info->file) != 1) return UNZ_ERRNO; return (int)read_now; } // Close the file in zip opened with unzipOpenCurrentFile // Return UNZ_CRCERROR if all the file was read but the CRC is not good int unzCloseCurrentFile(unzFile file) { int err = UNZ_OK; unz_s* s; file_in_zip_read_info_s* pfile_in_zip_read_info; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; pfile_in_zip_read_info = s->pfile_in_zip_read; if (pfile_in_zip_read_info == NULL) return UNZ_PARAMERROR; if (pfile_in_zip_read_info->rest_read_uncompressed == 0) { if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) err = UNZ_CRCERROR; } if (pfile_in_zip_read_info->read_buffer != 0) { void *buf = pfile_in_zip_read_info->read_buffer; zfree(buf); pfile_in_zip_read_info->read_buffer = 0; } pfile_in_zip_read_info->read_buffer = NULL; if (pfile_in_zip_read_info->stream_initialised) inflateEnd(&pfile_in_zip_read_info->stream); pfile_in_zip_read_info->stream_initialised = 0; if (pfile_in_zip_read_info != 0) zfree(pfile_in_zip_read_info); // unused pfile_in_zip_read_info=0; s->pfile_in_zip_read = NULL; return err; } // Get the global comment string of the ZipFile, in the szComment buffer. // uSizeBuf is the size of the szComment buffer. // return the number of byte copied or an error code <0 int unzGetGlobalComment(unzFile file, char *szComment, uLong uSizeBuf) { //int err=UNZ_OK; unz_s* s; uLong uReadThis; if (file == NULL) return UNZ_PARAMERROR; s = (unz_s*)file; uReadThis = uSizeBuf; if (uReadThis>s->gi.size_comment) uReadThis = s->gi.size_comment; if (lufseek(s->file, s->central_pos + 22, SEEK_SET) != 0) return UNZ_ERRNO; if (uReadThis>0) { *szComment = '\0'; if (lufread(szComment, (uInt)uReadThis, 1, s->file) != 1) return UNZ_ERRNO; } if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) *(szComment + s->gi.size_comment) = '\0'; return (int)uReadThis; } int unzOpenCurrentFile(unzFile file); int unzReadCurrentFile(unzFile file, void *buf, unsigned len); int unzCloseCurrentFile(unzFile file); FILETIME timet2filetime(time_t timer) { struct tm *tm = _gmtime32((__time32_t*)&timer); SYSTEMTIME st; st.wYear = (WORD)(tm->tm_year + 1900); st.wMonth = (WORD)(tm->tm_mon + 1); st.wDay = (WORD)(tm->tm_mday); st.wHour = (WORD)(tm->tm_hour); st.wMinute = (WORD)(tm->tm_min); st.wSecond = (WORD)(tm->tm_sec); st.wMilliseconds = 0; FILETIME ft; SystemTimeToFileTime(&st, &ft); return ft; } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// class TUnzip { public: TUnzip() : uf(0), currentfile(-1), czei(-1) {} unzFile uf; int currentfile; ZIPENTRY cze; int czei; TCHAR rootdir[MAX_PATH]; ZRESULT Open(void *z, unsigned int len, DWORD flags); ZRESULT Get(int index, ZIPENTRY *ze); ZRESULT Find(const TCHAR *name, bool ic, int *index, ZIPENTRY *ze); ZRESULT Unzip(int index, void *dst, unsigned int len, DWORD flags); ZRESULT Close(); }; ZRESULT TUnzip::Open(void *z, unsigned int len, DWORD flags) { if (uf != 0 || currentfile != -1) return ZR_NOTINITED; GetCurrentDirectory(MAX_PATH, rootdir); _tcscat(rootdir, _T("\\")); if (flags == ZIP_HANDLE) { DWORD type = GetFileType(z); if (type != FILE_TYPE_DISK) return ZR_SEEK; } ZRESULT e; LUFILE *f = lufopen(z, len, flags, &e); if (f == NULL) return e; uf = unzOpenInternal(f); //return ZR_OK; return zopenerror; //+++1.2 } ZRESULT TUnzip::Get(int index, ZIPENTRY *ze) { if (index<-1 || index >= (int)uf->gi.number_entry) return ZR_ARGS; if (currentfile != -1) unzCloseCurrentFile(uf); currentfile = -1; if (index == czei && index != -1) { memcpy(ze, &cze, sizeof(ZIPENTRY)); return ZR_OK; } if (index == -1) { ze->index = uf->gi.number_entry; ze->name[0] = 0; ze->attr = 0; ze->atime.dwLowDateTime = 0; ze->atime.dwHighDateTime = 0; ze->ctime.dwLowDateTime = 0; ze->ctime.dwHighDateTime = 0; ze->mtime.dwLowDateTime = 0; ze->mtime.dwHighDateTime = 0; ze->comp_size = 0; ze->unc_size = 0; return ZR_OK; } if (index<(int)uf->num_file) unzGoToFirstFile(uf); while ((int)uf->num_file<index) unzGoToNextFile(uf); unz_file_info ufi; char fn[MAX_PATH]; unzGetCurrentFileInfo(uf, &ufi, fn, MAX_PATH, NULL, 0, NULL, 0); // now get the extra header. We do this ourselves, instead of // calling unzOpenCurrentFile &c., to avoid allocating more than necessary. unsigned int extralen, iSizeVar; unsigned long offset; int res = unzlocal_CheckCurrentFileCoherencyHeader(uf, &iSizeVar, &offset, &extralen); if (res != UNZ_OK) return ZR_CORRUPT; if (lufseek(uf->file, offset, SEEK_SET) != 0) return ZR_READ; char *extra = new char[extralen]; if (lufread(extra, 1, (uInt)extralen, uf->file) != extralen) { delete[] extra; return ZR_READ; } // ze->index = uf->num_file; strcpy(ze->name, fn); // zip has an 'attribute' 32bit value. Its lower half is windows stuff // its upper half is standard unix attr. unsigned long a = ufi.external_fa; bool uisdir = (a & 0x40000000) != 0; //bool uwriteable= (a&0x08000000)!=0; bool uwriteable = (a & 0x00800000) != 0; // ***hd*** //bool ureadable= (a&0x01000000)!=0; //bool uexecutable=(a&0x00400000)!=0; bool wreadonly = (a & 0x00000001) != 0; bool whidden = (a & 0x00000002) != 0; bool wsystem = (a & 0x00000004) != 0; bool wisdir = (a & 0x00000010) != 0; bool warchive = (a & 0x00000020) != 0; ze->attr = FILE_ATTRIBUTE_NORMAL; if (uisdir || wisdir) ze->attr |= FILE_ATTRIBUTE_DIRECTORY; if (warchive) ze->attr |= FILE_ATTRIBUTE_ARCHIVE; if (whidden) ze->attr |= FILE_ATTRIBUTE_HIDDEN; if (wreadonly) ze->attr |= FILE_ATTRIBUTE_READONLY; if (wsystem) ze->attr |= FILE_ATTRIBUTE_SYSTEM; ze->comp_size = ufi.compressed_size; ze->unc_size = ufi.uncompressed_size; // WORD dostime = (WORD)(ufi.dosDate & 0xFFFF); WORD dosdate = (WORD)((ufi.dosDate >> 16) & 0xFFFF); FILETIME ft; DosDateTimeToFileTime(dosdate, dostime, &ft); ze->atime = ft; ze->ctime = ft; ze->mtime = ft; // the zip will always have at least that dostime. But if it also has // an extra header, then we'll instead get the info from that. unsigned int epos = 0; while (epos + 4<extralen) { char etype[3]; etype[0] = extra[epos + 0]; etype[1] = extra[epos + 1]; etype[2] = 0; int size = extra[epos + 2]; if (strcmp(etype, "UT") != 0) { epos += 4 + size; continue; } int flags = extra[epos + 4]; bool hasmtime = (flags & 1) != 0; bool hasatime = (flags & 2) != 0; bool hasctime = (flags & 4) != 0; epos += 5; if (hasmtime) { time_t mtime = *(time_t*)(extra + epos); epos += 4; ze->mtime = timet2filetime(mtime); } if (hasatime) { time_t atime = *(time_t*)(extra + epos); epos += 4; ze->atime = timet2filetime(atime); } if (hasctime) { time_t ctime = *(time_t*)(extra + epos); ze->ctime = timet2filetime(ctime); } break; } // if (extra != 0) delete[] extra; memcpy(&cze, ze, sizeof(ZIPENTRY)); czei = index; return ZR_OK; } ZRESULT TUnzip::Find(const TCHAR *name, bool ic, int *index, ZIPENTRY *ze) { int res = unzLocateFile(uf, name, ic ? CASE_INSENSITIVE : CASE_SENSITIVE); if (res != UNZ_OK) { if (index != 0) *index = -1; if (ze != NULL) { ZeroMemory(ze, sizeof(ZIPENTRY)); ze->index = -1; } return ZR_NOTFOUND; } if (currentfile != -1) unzCloseCurrentFile(uf); currentfile = -1; int i = (int)uf->num_file; if (index != NULL) *index = i; if (ze != NULL) { ZRESULT zres = Get(i, ze); if (zres != ZR_OK) return zres; } return ZR_OK; } void EnsureDirectory(const TCHAR *rootdir, const TCHAR *dir) { if (dir == NULL || dir[0] == _T('\0')) return; const TCHAR *lastslash = dir, *c = lastslash; while (*c != _T('\0')) { if (*c == _T('/') || *c == _T('\\')) lastslash = c; c++; } const TCHAR *name = lastslash; if (lastslash != dir) { TCHAR tmp[MAX_PATH]; _tcsncpy(tmp, dir, lastslash - dir); tmp[lastslash - dir] = _T('\0'); EnsureDirectory(rootdir, tmp); name++; } TCHAR cd[MAX_PATH]; _tcscpy(cd, rootdir); //_tcscat(cd,name); _tcscat(cd, dir); //+++1.2 CreateDirectory(cd, NULL); } ZRESULT TUnzip::Unzip(int index, void *dst, unsigned int len, DWORD flags) { if (flags != ZIP_MEMORY && flags != ZIP_FILENAME && flags != ZIP_HANDLE) return ZR_ARGS; if (flags == ZIP_MEMORY) { if (index != currentfile) { if (currentfile != -1) unzCloseCurrentFile(uf); currentfile = -1; if (index >= (int)uf->gi.number_entry) return ZR_ARGS; if (index<(int)uf->num_file) unzGoToFirstFile(uf); while ((int)uf->num_file<index) unzGoToNextFile(uf); unzOpenCurrentFile(uf); currentfile = index; } int res = unzReadCurrentFile(uf, dst, len); if (res>0) return ZR_MORE; unzCloseCurrentFile(uf); currentfile = -1; if (res == 0) return ZR_OK; else return ZR_FLATE; } // otherwise we're writing to a handle or a file if (currentfile != -1) unzCloseCurrentFile(uf); currentfile = -1; if (index >= (int)uf->gi.number_entry) return ZR_ARGS; if (index < (int)uf->num_file) unzGoToFirstFile(uf); while ((int)uf->num_file<index) unzGoToNextFile(uf); ZIPENTRY ze; Get(index, &ze); // zipentry=directory is handled specially if ((ze.attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { if (flags == ZIP_HANDLE) return ZR_OK; // don't do anything #ifdef _UNICODE TCHAR uname[MAX_PATH]; GetUnicodeFileName(ze.name, uname, MAX_PATH - 1); EnsureDirectory(rootdir, uname); #else EnsureDirectory(rootdir, ze.name); #endif return ZR_OK; } // otherwise, we write the zipentry to a file/handle HANDLE h; if (flags == ZIP_HANDLE) h = dst; else { const TCHAR *name = (const TCHAR *)dst; const TCHAR *c = name; while (*c) { if (*c == _T('/') || *c == _T('\\')) name = c + 1; c++; } // if it's a relative filename, ensure directories. We do this as a service // to the caller so they can just unzip straight unto ze.name. if (name != (const TCHAR *)dst) { TCHAR dir[MAX_PATH]; _tcscpy(dir, (const TCHAR*)dst); dir[name - (const TCHAR*)dst - 1] = _T('\0'); bool isabsolute = (dir[0] == _T('/') || dir[0] == _T('\\') || dir[1] == _T(':')); isabsolute |= (_tcsstr(dir, _T("../")) != 0) | (_tcsstr(dir, _T("..\\")) != 0); if (!isabsolute) EnsureDirectory(rootdir, dir); } h = ::CreateFile((const TCHAR*)dst, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, ze.attr, NULL); } if (h == INVALID_HANDLE_VALUE) return ZR_NOFILE; unzOpenCurrentFile(uf); BYTE buf[16384]; bool haderr = false; for (;;) { int res = unzReadCurrentFile(uf, buf, 16384); if (res<0) { haderr = true; break; } if (res == 0) break; DWORD writ; BOOL bres = WriteFile(h, buf, res, &writ, NULL); if (!bres) { haderr = true; break; } } bool settime = false; DWORD type = GetFileType(h); if (type == FILE_TYPE_DISK && !haderr) settime = true; if (settime) SetFileTime(h, &ze.ctime, &ze.atime, &ze.mtime); if (flags != ZIP_HANDLE) CloseHandle(h); unzCloseCurrentFile(uf); if (haderr) return ZR_WRITE; return ZR_OK; } ZRESULT TUnzip::Close() { if (currentfile != -1) unzCloseCurrentFile(uf); currentfile = -1; if (uf != 0) unzClose(uf); uf = 0; return ZR_OK; } ZRESULT lasterrorU = ZR_OK; unsigned int FormatZipMessageU(ZRESULT code, char *buf, unsigned int len) { if (code == ZR_RECENT) code = lasterrorU; const char *msg = "unknown zip result code"; switch (code) { case ZR_OK: msg = "Success"; break; case ZR_NODUPH: msg = "Culdn't duplicate handle"; break; case ZR_NOFILE: msg = "Couldn't create/open file"; break; case ZR_NOALLOC: msg = "Failed to allocate memory"; break; case ZR_WRITE: msg = "Error writing to file"; break; case ZR_NOTFOUND: msg = "File not found in the zipfile"; break; case ZR_MORE: msg = "Still more data to unzip"; break; case ZR_CORRUPT: msg = "Zipfile is corrupt or not a zipfile"; break; case ZR_READ: msg = "Error reading file"; break; case ZR_ARGS: msg = "Caller: faulty arguments"; break; case ZR_PARTIALUNZ: msg = "Caller: the file had already been partially unzipped"; break; case ZR_NOTMMAP: msg = "Caller: can only get memory of a memory zipfile"; break; case ZR_MEMSIZE: msg = "Caller: not enough space allocated for memory zipfile"; break; case ZR_FAILED: msg = "Caller: there was a previous error"; break; case ZR_ENDED: msg = "Caller: additions to the zip have already been ended"; break; case ZR_ZMODE: msg = "Caller: mixing creation and opening of zip"; break; case ZR_NOTINITED: msg = "Zip-bug: internal initialisation not completed"; break; case ZR_SEEK: msg = "Zip-bug: trying to seek the unseekable"; break; case ZR_MISSIZE: msg = "Zip-bug: the anticipated size turned out wrong"; break; case ZR_NOCHANGE: msg = "Zip-bug: tried to change mind, but not allowed"; break; case ZR_FLATE: msg = "Zip-bug: an internal error during flation"; break; } unsigned int mlen = (unsigned int)strlen(msg); if (buf == 0 || len == 0) return mlen; unsigned int n = mlen; if (n + 1>len) n = len - 1; strncpy(buf, msg, n); buf[n] = 0; return mlen; } typedef struct { DWORD flag; TUnzip *unz; } TUnzipHandleData; HZIP OpenZipU(void *z, unsigned int len, DWORD flags) { TUnzip *unz = new TUnzip(); lasterrorU = unz->Open(z, len, flags); if (lasterrorU != ZR_OK) { delete unz; return 0; } TUnzipHandleData *han = new TUnzipHandleData; han->flag = 1; han->unz = unz; return (HZIP)han; } ZRESULT GetZipItemA(HZIP hz, int index, ZIPENTRY *ze) { if (hz == 0) { lasterrorU = ZR_ARGS; return ZR_ARGS; } TUnzipHandleData *han = (TUnzipHandleData*)hz; if (han->flag != 1) { lasterrorU = ZR_ZMODE; return ZR_ZMODE; } TUnzip *unz = han->unz; lasterrorU = unz->Get(index, ze); return lasterrorU; } ZRESULT GetZipItemW(HZIP hz, int index, ZIPENTRYW *zew) { if (hz == 0) { lasterrorU = ZR_ARGS; return ZR_ARGS; } TUnzipHandleData *han = (TUnzipHandleData*)hz; if (han->flag != 1) { lasterrorU = ZR_ZMODE; return ZR_ZMODE; } TUnzip *unz = han->unz; ZIPENTRY ze; lasterrorU = unz->Get(index, &ze); if (lasterrorU == ZR_OK) { zew->index = ze.index; zew->attr = ze.attr; zew->atime = ze.atime; zew->ctime = ze.ctime; zew->mtime = ze.mtime; zew->comp_size = ze.comp_size; zew->unc_size = ze.unc_size; #ifdef _UNICODE GetUnicodeFileName(ze.name, zew->name, MAX_PATH - 1); #else strcpy(zew->name, ze.name); #endif } return lasterrorU; } ZRESULT FindZipItemA(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRY *ze) { if (hz == 0) { lasterrorU = ZR_ARGS; return ZR_ARGS; } TUnzipHandleData *han = (TUnzipHandleData*)hz; if (han->flag != 1) { lasterrorU = ZR_ZMODE; return ZR_ZMODE; } TUnzip *unz = han->unz; lasterrorU = unz->Find(name, ic, index, ze); return lasterrorU; } ZRESULT FindZipItemW(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRYW *zew) { if (hz == 0) { lasterrorU = ZR_ARGS; return ZR_ARGS; } TUnzipHandleData *han = (TUnzipHandleData*)hz; if (han->flag != 1) { lasterrorU = ZR_ZMODE; return ZR_ZMODE; } TUnzip *unz = han->unz; ZIPENTRY ze; lasterrorU = unz->Find(name, ic, index, &ze); if (lasterrorU == ZR_OK) { zew->index = ze.index; zew->attr = ze.attr; zew->atime = ze.atime; zew->ctime = ze.ctime; zew->mtime = ze.mtime; zew->comp_size = ze.comp_size; zew->unc_size = ze.unc_size; #ifdef _UNICODE GetUnicodeFileName(ze.name, zew->name, MAX_PATH - 1); #else strcpy(zew->name, ze.name); #endif } return lasterrorU; } ZRESULT UnzipItem(HZIP hz, int index, void *dst, unsigned int len, DWORD flags) { if (hz == 0) { lasterrorU = ZR_ARGS; return ZR_ARGS; } TUnzipHandleData *han = (TUnzipHandleData*)hz; if (han->flag != 1) { lasterrorU = ZR_ZMODE; return ZR_ZMODE; } TUnzip *unz = han->unz; lasterrorU = unz->Unzip(index, dst, len, flags); return lasterrorU; } ZRESULT CloseZipU(HZIP hz) { if (hz == 0) { lasterrorU = ZR_ARGS; return ZR_ARGS; } TUnzipHandleData *han = (TUnzipHandleData*)hz; if (han->flag != 1) { lasterrorU = ZR_ZMODE; return ZR_ZMODE; } TUnzip *unz = han->unz; lasterrorU = unz->Close(); delete unz; delete han; return lasterrorU; } bool IsZipHandleU(HZIP hz) { if (hz == 0) return true; TUnzipHandleData *han = (TUnzipHandleData*)hz; return (han->flag == 1); } } }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/compress/xzip/XUnzip.h
C/C++ Header
// XZip.h Version 1.3 #pragma once namespace Plugin { namespace XZip { #ifndef XUNZIP_H #define XUNZIP_H #ifndef XZIP_H DECLARE_HANDLE(HZIP); // An HZIP identifies a zip file that has been opened #endif typedef DWORD ZRESULT; // return codes from any of the zip functions. Listed later. #define ZIP_HANDLE 1 #define ZIP_FILENAME 2 #define ZIP_MEMORY 3 typedef struct { int index; // index of this file within the zip char name[MAX_PATH]; // filename within the zip DWORD attr; // attributes, as in GetFileAttributes. FILETIME atime, ctime, mtime;// access, create, modify filetimes long comp_size; // sizes of item, compressed and uncompressed. These long unc_size; // may be -1 if not yet known (e.g. being streamed in) } ZIPENTRY; typedef struct { int index; // index of this file within the zip TCHAR name[MAX_PATH]; // filename within the zip DWORD attr; // attributes, as in GetFileAttributes. FILETIME atime, ctime, mtime;// access, create, modify filetimes long comp_size; // sizes of item, compressed and uncompressed. These long unc_size; // may be -1 if not yet known (e.g. being streamed in) } ZIPENTRYW; /////////////////////////////////////////////////////////////////////////////// // // OpenZip() // // Purpose: Open an existing zip archive file // // Parameters: z - archive file name if flags is ZIP_FILENAME; for other // uses see below // len - for memory (ZIP_MEMORY) should be the buffer size; // for other uses, should be 0 // flags - indicates usage, see below; for files, this will be // ZIP_FILENAME // // Returns: HZIP - non-zero if zip archive opened ok, otherwise 0 // HZIP OpenZip(void *z, unsigned int len, DWORD flags); // OpenZip - opens a zip file and returns a handle with which you can // subsequently examine its contents. You can open a zip file from: // from a pipe: OpenZip(hpipe_read,0, ZIP_HANDLE); // from a file (by handle): OpenZip(hfile,0, ZIP_HANDLE); // from a file (by name): OpenZip("c:\\test.zip",0, ZIP_FILENAME); // from a memory block: OpenZip(bufstart, buflen, ZIP_MEMORY); // If the file is opened through a pipe, then items may only be // accessed in increasing order, and an item may only be unzipped once, // although GetZipItem can be called immediately before and after unzipping // it. If it's opened i n any other way, then full random access is possible. // Note: pipe input is not yet implemented. /////////////////////////////////////////////////////////////////////////////// // // GetZipItem() // // Purpose: Get information about an item in an open zip archive // // Parameters: hz - handle of open zip archive // index - index number (0 based) of item in zip // ze - pointer to a ZIPENTRY (if ANSI) or ZIPENTRYW struct // (if Unicode) // // Returns: ZRESULT - ZR_OK if success, otherwise some other value // #ifdef _UNICODE #define GetZipItem GetZipItemW #else #define GetZipItem GetZipItemA #endif ZRESULT GetZipItemA(HZIP hz, int index, ZIPENTRY *ze); ZRESULT GetZipItemW(HZIP hz, int index, ZIPENTRYW *ze); // GetZipItem - call this to get information about an item in the zip. // If index is -1 and the file wasn't opened through a pipe, // then it returns information about the whole zipfile // (and in particular ze.index returns the number of index items). // Note: the item might be a directory (ze.attr & FILE_ATTRIBUTE_DIRECTORY) // See below for notes on what happens when you unzip such an item. // Note: if you are opening the zip through a pipe, then random access // is not possible and GetZipItem(-1) fails and you can't discover the number // of items except by calling GetZipItem on each one of them in turn, // starting at 0, until eventually the call fails. Also, in the event that // you are opening through a pipe and the zip was itself created into a pipe, // then then comp_size and sometimes unc_size as well may not be known until // after the item has been unzipped. /////////////////////////////////////////////////////////////////////////////// // // FindZipItem() // // Purpose: Find item by name and return information about it // // Parameters: hz - handle of open zip archive // name - name of file to look for inside zip archive // ic - TRUE = case insensitive // index - pointer to index number returned, or -1 // ze - pointer to a ZIPENTRY (if ANSI) or ZIPENTRYW struct // (if Unicode) // // Returns: ZRESULT - ZR_OK if success, otherwise some other value // #ifdef _UNICODE #define FindZipItem FindZipItemW #else #define FindZipItem FindZipItemA #endif ZRESULT FindZipItemA(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRY *ze); ZRESULT FindZipItemW(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRYW *ze); // FindZipItem - finds an item by name. ic means 'insensitive to case'. // It returns the index of the item, and returns information about it. // If nothing was found, then index is set to -1 and the function returns // an error code. /////////////////////////////////////////////////////////////////////////////// // // UnzipItem() // // Purpose: Find item by index and unzip it // // Parameters: hz - handle of open zip archive // index - index number of file to unzip // dst - target file name of unzipped file // len - for memory (ZIP_MEMORY. length of buffer; // otherwise 0 // flags - indicates usage, see below; for files, this will be // ZIP_FILENAME // // Returns: ZRESULT - ZR_OK if success, otherwise some other value // ZRESULT UnzipItem(HZIP hz, int index, void *dst, unsigned int len, DWORD flags); // UnzipItem - given an index to an item, unzips it. You can unzip to: // to a pipe: UnzipItem(hz,i, hpipe_write,0,ZIP_HANDLE); // to a file (by handle): UnzipItem(hz,i, hfile,0,ZIP_HANDLE); // to a file (by name): UnzipItem(hz,i, ze.name,0,ZIP_FILENAME); // to a memory block: UnzipItem(hz,i, buf,buflen,ZIP_MEMORY); // In the final case, if the buffer isn't large enough to hold it all, // then the return code indicates that more is yet to come. If it was // large enough, and you want to know precisely how big, GetZipItem. // Note: zip files are normally stored with relative pathnames. If you // unzip with ZIP_FILENAME a relative pathname then the item gets created // relative to the current directory - it first ensures that all necessary // subdirectories have been created. Also, the item may itself be a directory. // If you unzip a directory with ZIP_FILENAME, then the directory gets created. // If you unzip it to a handle or a memory block, then nothing gets created // and it emits 0 bytes. /////////////////////////////////////////////////////////////////////////////// // // CloseZip() // // Purpose: Close an open zip archive // // Parameters: hz - handle to an open zip archive // // Returns: ZRESULT - ZR_OK if success, otherwise some other value // ZRESULT CloseZip(HZIP hz); // CloseZip - the zip handle must be closed with this function. unsigned int FormatZipMessage(ZRESULT code, char *buf, unsigned int len); // FormatZipMessage - given an error code, formats it as a string. // It returns the length of the error message. If buf/len points // to a real buffer, then it also writes as much as possible into there. // These are the result codes: #define ZR_OK 0x00000000 // nb. the pseudo-code zr-recent is never returned, #define ZR_RECENT 0x00000001 // but can be passed to FormatZipMessage. // The following come from general system stuff (e.g. files not openable) #define ZR_GENMASK 0x0000FF00 #define ZR_NODUPH 0x00000100 // couldn't duplicate the handle #define ZR_NOFILE 0x00000200 // couldn't create/open the file #define ZR_NOALLOC 0x00000300 // failed to allocate some resource #define ZR_WRITE 0x00000400 // a general error writing to the file #define ZR_NOTFOUND 0x00000500 // couldn't find that file in the zip #define ZR_MORE 0x00000600 // there's still more data to be unzipped #define ZR_CORRUPT 0x00000700 // the zipfile is corrupt or not a zipfile #define ZR_READ 0x00000800 // a general error reading the file // The following come from mistakes on the part of the caller #define ZR_CALLERMASK 0x00FF0000 #define ZR_ARGS 0x00010000 // general mistake with the arguments #define ZR_NOTMMAP 0x00020000 // tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't #define ZR_MEMSIZE 0x00030000 // the memory size is too small #define ZR_FAILED 0x00040000 // the thing was already failed when you called this function #define ZR_ENDED 0x00050000 // the zip creation has already been closed #define ZR_MISSIZE 0x00060000 // the indicated input file size turned out mistaken #define ZR_PARTIALUNZ 0x00070000 // the file had already been partially unzipped #define ZR_ZMODE 0x00080000 // tried to mix creating/opening a zip // The following come from bugs within the zip library itself #define ZR_BUGMASK 0xFF000000 #define ZR_NOTINITED 0x01000000 // initialisation didn't work #define ZR_SEEK 0x02000000 // trying to seek in an unseekable file #define ZR_NOCHANGE 0x04000000 // changed its mind on storage, but not allowed #define ZR_FLATE 0x05000000 // an internal error in the de/inflation code // e.g. // // SetCurrentDirectory("c:\\docs\\stuff"); // HZIP hz = OpenZip("c:\\stuff.zip",0,ZIP_FILENAME); // ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index; // for (int i=0; i<numitems; i++) // { GetZipItem(hz,i,&ze); // UnzipItem(hz,i,ze.name,0,ZIP_FILENAME); // } // CloseZip(hz); // // // HRSRC hrsrc = FindResource(hInstance,MAKEINTRESOURCE(1),RT_RCDATA); // HANDLE hglob = LoadResource(hInstance,hrsrc); // void *zipbuf=LockResource(hglob); // unsigned int ziplen=SizeofResource(hInstance,hrsrc); // HZIP hz = OpenZip(zipbuf, ziplen, ZIP_MEMORY); // - unzip to a membuffer - // ZIPENTRY ze; int i; FindZipItem(hz,"file.dat",&i,&ze); // char *ibuf = new char[ze.unc_size]; // UnzipItem(hz,i, ibuf, ze.unc_size,ZIP_MEMORY); // delete[] buf; // - unzip to a fixed membuff - // ZIPENTRY ze; int i; FindZipItem(hz,"file.dat",&i,&ze); // char ibuf[1024]; ZIPRESULT zr=ZR_MORE; unsigned long totsize=0; // while (zr==ZR_MORE) // { zr = UnzipItem(hz,i, ibuf,1024,ZIP_MEMORY); // unsigned long bufsize=1024; if (zr==ZR_OK) bufsize=ze.unc_size-totsize; // totsize+=bufsize; // } // - unzip to a pipe - // HANDLE hthread=CreateWavReaderThread(&hread,&hwrite); // FindZipItem(hz,"sound.wav",&i,&ze); // UnzipItem(hz,i, hwrite,0,ZIP_HANDLE); // CloseHandle(hwrite); // WaitForSingleObject(hthread,INFINITE); // CloseHandle(hread); CloseHandle(hthread); // - finished - // CloseZip(hz); // // note: no need to free resources obtained through Find/Load/LockResource // // // SetCurrentDirectory("c:\\docs\\pipedzipstuff"); // HANDLE hread,hwrite; CreatePipe(&hread,&hwrite); // CreateZipWriterThread(hwrite); // HZIP hz = OpenZip(hread,0,ZIP_HANDLE); // for (int i=0; ; i++) // { ZIPENTRY ze; ZRESULT res = GetZipItem(hz,i,&ze); // if (res!=ZE_OK) break; // no more // UnzipItem(hz,i, ze.name,0,ZIP_FILENAME); // } // CloseZip(hz); // // Now we indulge in a little skullduggery so that the code works whether // the user has included just zip or both zip and unzip. // Idea: if header files for both zip and unzip are present, then presumably // the cpp files for zip and unzip are both present, so we will call // one or the other of them based on a dynamic choice. If the header file // for only one is present, then we will bind to that particular one. HZIP OpenZipU(void *z, unsigned int len, DWORD flags); ZRESULT CloseZipU(HZIP hz); unsigned int FormatZipMessageU(ZRESULT code, char *buf, unsigned int len); bool IsZipHandleU(HZIP hz); #define OpenZip OpenZipU #ifdef XZIP_H #undef CloseZip #define CloseZip(hz) (IsZipHandleU(hz)?CloseZipU(hz):CloseZipZ(hz)) #else #define CloseZip CloseZipU #define FormatZipMessage FormatZipMessageU #endif extern ZRESULT lasterrorU; #endif //XUNZIP_H } } using namespace Plugin::XZip;
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/compress/xzip/XZip.cpp
C++
// XZip.h Version 1.3 #define STRICT #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <tchar.h> #include <time.h> #include "xzip.h" namespace Plugin { namespace XZip { #pragma warning(disable : 4996) // disable bogus deprecation warning typedef unsigned char uch; // unsigned 8-bit value typedef unsigned short ush; // unsigned 16-bit value typedef unsigned long ulg; // unsigned 32-bit value typedef size_t extent; // file size typedef unsigned Pos; // must be at least 32 bits typedef unsigned IPos; // A Pos is an index in the character window. Pos is used only for parameter passing #ifndef EOF #define EOF (-1) #endif // Error return values. The values 0..4 and 12..18 follow the conventions // of PKZIP. The values 4..10 are all assigned to "insufficient memory" // by PKZIP, so the codes 5..10 are used here for other purposes. #define ZE_MISS -1 // used by procname(), zipbare() #define ZE_OK 0 // success #define ZE_EOF 2 // unexpected end of zip file #define ZE_FORM 3 // zip file structure error #define ZE_MEM 4 // out of memory #define ZE_LOGIC 5 // internal logic error #define ZE_BIG 6 // entry too large to split #define ZE_NOTE 7 // invalid comment format #define ZE_TEST 8 // zip test (-T) failed or out of memory #define ZE_ABORT 9 // user interrupt or termination #define ZE_TEMP 10 // error using a temp file #define ZE_READ 11 // read or seek error #define ZE_NONE 12 // nothing to do #define ZE_NAME 13 // missing or empty zip file #define ZE_WRITE 14 // error writing to a file #define ZE_CREAT 15 // couldn't open to write #define ZE_PARMS 16 // bad command line #define ZE_OPEN 18 // could not open a specified file to read #define ZE_MAXERR 18 // the highest error number // internal file attribute #define UNKNOWN (-1) #define BINARY 0 #define ASCII 1 #define BEST -1 // Use best method (deflation or store) #define STORE 0 // Store method #define DEFLATE 8 // Deflation method #define CRCVAL_INITIAL 0L // MSDOS file or directory attributes #define MSDOS_HIDDEN_ATTR 0x02 #define MSDOS_DIR_ATTR 0x10 // Lengths of headers after signatures in bytes #define LOCHEAD 26 #define CENHEAD 42 #define ENDHEAD 18 // Definitions for extra field handling: #define EB_HEADSIZE 4 /* length of a extra field block header */ #define EB_LEN 2 /* offset of data length field in header */ #define EB_UT_MINLEN 1 /* minimal UT field contains Flags byte */ #define EB_UT_FLAGS 0 /* byte offset of Flags field */ #define EB_UT_TIME1 1 /* byte offset of 1st time value */ #define EB_UT_FL_MTIME (1 << 0) /* mtime present */ #define EB_UT_FL_ATIME (1 << 1) /* atime present */ #define EB_UT_FL_CTIME (1 << 2) /* ctime present */ #define EB_UT_LEN(n) (EB_UT_MINLEN + 4 * (n)) #define EB_L_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(3)) #define EB_C_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(1)) // Macros for writing machine integers to little-endian format #define PUTSH(a,f) {char _putsh_c=(char)((a)&0xff); wfunc(param,&_putsh_c,1); _putsh_c=(char)((a)>>8); wfunc(param,&_putsh_c,1);} #define PUTLG(a,f) {PUTSH((a) & 0xffff,(f)) PUTSH((a) >> 16,(f))} // -- Structure of a ZIP file -- // Signatures for zip file information headers #define LOCSIG 0x04034b50L #define CENSIG 0x02014b50L #define ENDSIG 0x06054b50L #define EXTLOCSIG 0x08074b50L #define MIN_MATCH 3 #define MAX_MATCH 258 // The minimum and maximum match lengths #define WSIZE (0x8000) // Maximum window size = 32K. If you are really short of memory, compile // with a smaller WSIZE but this reduces the compression ratio for files // of size > WSIZE. WSIZE must be a power of two in the current implementation. // #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) // Minimum amount of lookahead, except at the end of the input file. // See deflate.c for comments about the MIN_MATCH+1. // #define MAX_DIST (WSIZE-MIN_LOOKAHEAD) // In order to simplify the code, particularly on 16 bit machines, match // distances are limited to MAX_DIST instead of WSIZE. // // =========================================================================== // Constants // #define MAX_BITS 15 // All codes must not exceed MAX_BITS bits #define MAX_BL_BITS 7 // Bit length codes must not exceed MAX_BL_BITS bits #define LENGTH_CODES 29 // number of length codes, not counting the special END_BLOCK code #define LITERALS 256 // number of literal bytes 0..255 #define END_BLOCK 256 // end of block literal code #define L_CODES (LITERALS+1+LENGTH_CODES) // number of Literal or Length codes, including the END_BLOCK code #define D_CODES 30 // number of distance codes #define BL_CODES 19 // number of codes used to transfer the bit lengths #define STORED_BLOCK 0 #define STATIC_TREES 1 #define DYN_TREES 2 // The three kinds of block type #define LIT_BUFSIZE 0x8000 #define DIST_BUFSIZE LIT_BUFSIZE // Sizes of match buffers for literals/lengths and distances. There are // 4 reasons for limiting LIT_BUFSIZE to 64K: // - frequencies can be kept in 16 bit counters // - if compression is not successful for the first block, all input data is // still in the window so we can still emit a stored block even when input // comes from standard input. (This can also be done for all blocks if // LIT_BUFSIZE is not greater than 32K.) // - if compression is not successful for a file smaller than 64K, we can // even emit a stored file instead of a stored block (saving 5 bytes). // - creating new Huffman trees less frequently may not provide fast // adaptation to changes in the input data statistics. (Take for // example a binary file with poorly compressible code followed by // a highly compressible string table.) Smaller buffer sizes give // fast adaptation but have of course the overhead of transmitting trees // more frequently. // - I can't count above 4 // The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save // memory at the expense of compression). Some optimizations would be possible // if we rely on DIST_BUFSIZE == LIT_BUFSIZE. // #define REP_3_6 16 // repeat previous bit length 3-6 times (2 bits of repeat count) #define REPZ_3_10 17 // repeat a zero length 3-10 times (3 bits of repeat count) #define REPZ_11_138 18 // repeat a zero length 11-138 times (7 bits of repeat count) #define HEAP_SIZE (2*L_CODES+1) // maximum heap size // =========================================================================== // Local data used by the "bit string" routines. // #define Buf_size (8 * 2*sizeof(char)) // Number of bits used within bi_buf. (bi_buf may be implemented on // more than 16 bits on some systems.) // Output a 16 bit value to the bit stream, lower (oldest) byte first #if 0 // ----------------------------------------------------------- #define PUTSHORT(state,w) \ { \ if (state.bs.out_offset >= state.bs.out_size-1) \ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \ state.bs.out_buf[state.bs.out_offset++] = (char) ((w) & 0xff); \ state.bs.out_buf[state.bs.out_offset++] = (char) ((ush)(w) >> 8); \ } #endif // ----------------------------------------------------------- //+++1.2 #define PUTSHORT(state,w) \ { \ if (state.bs.out_offset >= state.bs.out_size-1) \ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \ if (state.bs.out_offset < state.bs.out_size-1) \ { \ state.bs.out_buf[state.bs.out_offset++] = (char) ((w) & 0xff); \ state.bs.out_buf[state.bs.out_offset++] = (char) ((ush)(w) >> 8); \ }\ } #if 0 // ----------------------------------------------------------- #define PUTBYTE(state,b) \ { \ if (state.bs.out_offset >= state.bs.out_size) \ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \ state.bs.out_buf[state.bs.out_offset++] = (char) (b); \ } #endif // ----------------------------------------------------------- //+++1.2 #define PUTBYTE(state,b) \ { \ if (state.bs.out_offset >= state.bs.out_size) \ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \ if (state.bs.out_offset < state.bs.out_size) \ state.bs.out_buf[state.bs.out_offset++] = (char) (b); \ } // DEFLATE.CPP HEADER #define HASH_BITS 15 // For portability to 16 bit machines, do not use values above 15. #define HASH_SIZE (unsigned)(1<<HASH_BITS) #define HASH_MASK (HASH_SIZE-1) #define WMASK (WSIZE-1) // HASH_SIZE and WSIZE must be powers of two #define NIL 0 // Tail of hash chains #define FAST 4 #define SLOW 2 // speed options for the general purpose bit flag #define TOO_FAR 4096 // Matches of length 3 are discarded if their distance exceeds TOO_FAR #define EQUAL 0 // result of memcmp for equal strings // =========================================================================== // Local data used by the "longest match" routines. #define H_SHIFT ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH) // Number of bits by which ins_h and del_h must be shifted at each // input step. It must be such that after MIN_MATCH steps, the oldest // byte no longer takes part in the hash key, that is: // H_SHIFT * MIN_MATCH >= HASH_BITS #define max_insert_length max_lazy_match // Insert new strings in the hash table only if the match length // is not greater than this length. This saves time but degrades compression. // max_insert_length is used only for compression levels <= 3. const int extra_lbits[LENGTH_CODES] // extra bits for each length code = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; const int extra_dbits[D_CODES] // extra bits for each distance code = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 }; const int extra_blbits[BL_CODES]// extra bits for each bit length code = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7 }; const uch bl_order[BL_CODES] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; // The lengths of the bit length codes are sent in order of decreasing // probability, to avoid transmitting the lengths for unused bit length codes. typedef struct config { ush good_length; // reduce lazy search above this match length ush max_lazy; // do not perform lazy search above this match length ush nice_length; // quit search above this match length ush max_chain; } config; // Values for max_lazy_match, good_match, nice_match and max_chain_length, // depending on the desired pack level (0..9). The values given below have // been tuned to exclude worst case performance for pathological files. // Better values may be found for specific files. // const config configuration_table[10] = { // good lazy nice chain { 0, 0, 0, 0 }, // 0 store only { 4, 4, 8, 4 }, // 1 maximum speed, no lazy matches { 4, 5, 16, 8 }, // 2 { 4, 6, 32, 32 }, // 3 { 4, 4, 16, 16 }, // 4 lazy matches */ { 8, 16, 32, 32 }, // 5 { 8, 16, 128, 128 }, // 6 { 8, 32, 128, 256 }, // 7 { 32, 128, 258, 1024 }, // 8 { 32, 258, 258, 4096 } };// 9 maximum compression */ // Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 // For deflate_fast() (levels <= 3) good is ignored and lazy has a different meaning. // Data structure describing a single value and its code string. typedef struct ct_data { union { ush freq; // frequency count ush code; // bit string } fc; union { ush dad; // father node in Huffman tree ush len; // length of bit string } dl; } ct_data; typedef struct tree_desc { ct_data *dyn_tree; // the dynamic tree ct_data *static_tree; // corresponding static tree or NULL const int *extra_bits; // extra bits for each code or NULL int extra_base; // base index for extra_bits int elems; // max number of elements in the tree int max_length; // max bit length for the codes int max_code; // largest code with non zero frequency } tree_desc; class TTreeState { public: TTreeState(); ct_data dyn_ltree[HEAP_SIZE]; // literal and length tree ct_data dyn_dtree[2 * D_CODES + 1]; // distance tree ct_data static_ltree[L_CODES + 2]; // the static literal tree... // ... Since the bit lengths are imposed, there is no need for the L_CODES // extra codes used during heap construction. However the codes 286 and 287 // are needed to build a canonical tree (see ct_init below). ct_data static_dtree[D_CODES]; // the static distance tree... // ... (Actually a trivial tree since all codes use 5 bits.) ct_data bl_tree[2 * BL_CODES + 1]; // Huffman tree for the bit lengths tree_desc l_desc; tree_desc d_desc; tree_desc bl_desc; ush bl_count[MAX_BITS + 1]; // number of codes at each bit length for an optimal tree int heap[2 * L_CODES + 1]; // heap used to build the Huffman trees int heap_len; // number of elements in the heap int heap_max; // element of largest frequency // The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. // The same heap array is used to build all trees. uch depth[2 * L_CODES + 1]; // Depth of each subtree used as tie breaker for trees of equal frequency uch length_code[MAX_MATCH - MIN_MATCH + 1]; // length code for each normalized match length (0 == MIN_MATCH) uch dist_code[512]; // distance codes. The first 256 values correspond to the distances // 3 .. 258, the last 256 values correspond to the top 8 bits of // the 15 bit distances. int base_length[LENGTH_CODES]; // First normalized length for each code (0 = MIN_MATCH) int base_dist[D_CODES]; // First normalized distance for each code (0 = distance of 1) uch far l_buf[LIT_BUFSIZE]; // buffer for literals/lengths ush far d_buf[DIST_BUFSIZE]; // buffer for distances uch flag_buf[(LIT_BUFSIZE / 8)]; // flag_buf is a bit array distinguishing literals from lengths in // l_buf, and thus indicating the presence or absence of a distance. unsigned last_lit; // running index in l_buf unsigned last_dist; // running index in d_buf unsigned last_flags; // running index in flag_buf uch flags; // current flags not yet saved in flag_buf uch flag_bit; // current bit used in flags // bits are filled in flags starting at bit 0 (least significant). // Note: these flags are overkill in the current code since we don't // take advantage of DIST_BUFSIZE == LIT_BUFSIZE. ulg opt_len; // bit length of current block with optimal trees ulg static_len; // bit length of current block with static trees ulg cmpr_bytelen; // total byte length of compressed file ulg cmpr_len_bits; // number of bits past 'cmpr_bytelen' ulg input_len; // total byte length of input file // input_len is for debugging only since we can get it by other means. ush *file_type; // pointer to UNKNOWN, BINARY or ASCII // int *file_method; // pointer to DEFLATE or STORE }; TTreeState::TTreeState() { tree_desc a = { dyn_ltree, static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS, 0 }; l_desc = a; tree_desc b = { dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0 }; d_desc = b; tree_desc c = { bl_tree, NULL, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0 }; bl_desc = c; last_lit = 0; last_dist = 0; last_flags = 0; memset(dyn_ltree, 0, sizeof(dyn_ltree)); memset(dyn_dtree, 0, sizeof(dyn_dtree)); memset(static_ltree, 0, sizeof(static_ltree)); memset(static_dtree, 0, sizeof(static_dtree)); memset(bl_tree, 0, sizeof(bl_tree)); memset(bl_count, 0, sizeof(bl_count)); memset(heap, 0, sizeof(heap)); heap_len = 0; heap_max = 0; memset(depth, 0, sizeof(depth)); memset(length_code, 0, sizeof(length_code)); memset(dist_code, 0, sizeof(dist_code)); memset(base_length, 0, sizeof(base_length)); memset(base_dist, 0, sizeof(base_dist)); memset(l_buf, 0, sizeof(l_buf)); memset(d_buf, 0, sizeof(d_buf)); memset(flag_buf, 0, sizeof(flag_buf)); last_lit = 0; last_dist = 0; last_flags = 0; flags = 0; flag_bit = 0; opt_len = 0; static_len = 0; cmpr_bytelen = 0; cmpr_len_bits = 0; input_len = 0; file_type = 0; } class TBitState { public: TBitState() { flush_flg = 0; bi_buf = 0; bi_valid = 0; out_buf = 0; out_offset = 0; out_size = 0; bits_sent = 0; } int flush_flg; // unsigned bi_buf; // Output buffer. bits are inserted starting at the bottom (least significant // bits). The width of bi_buf must be at least 16 bits. int bi_valid; // Number of valid bits in bi_buf. All bits above the last valid bit // are always zero. char *out_buf; // Current output buffer. unsigned out_offset; // Current offset in output buffer. // On 16 bit machines, the buffer is limited to 64K. unsigned out_size; // Size of current output buffer ulg bits_sent; // bit length of the compressed data only needed for debugging??? }; class TDeflateState { public: TDeflateState() { memset(window, 0, sizeof(window)); memset(prev, 0, sizeof(prev)); memset(head, 0, sizeof(head)); window_size = 0; block_start = 0; sliding = 0; ins_h = 0; prev_length = 0; strstart = 0; match_start = 0; eofile = 0; lookahead = 0; max_chain_length = 0; max_lazy_match = 0; good_match = 0; nice_match = 0; } uch window[2L * WSIZE]; // Sliding window. Input bytes are read into the second half of the window, // and move to the first half later to keep a dictionary of at least WSIZE // bytes. With this organization, matches are limited to a distance of // WSIZE-MAX_MATCH bytes, but this ensures that IO is always // performed with a length multiple of the block size. Also, it limits // the window size to 64K, which is quite useful on MSDOS. // To do: limit the window size to WSIZE+CBSZ if SMALL_MEM (the code would // be less efficient since the data would have to be copied WSIZE/CBSZ times) Pos prev[WSIZE]; // Link to older string with same hash index. To limit the size of this // array to 64K, this link is maintained only for the last 32K strings. // An index in this array is thus a window index modulo 32K. Pos head[HASH_SIZE]; // Heads of the hash chains or NIL. If your compiler thinks that // HASH_SIZE is a dynamic value, recompile with -DDYN_ALLOC. ulg window_size; // window size, 2*WSIZE except for MMAP or BIG_MEM, where it is the // input file length plus MIN_LOOKAHEAD. long block_start; // window position at the beginning of the current output block. Gets // negative when the window is moved backwards. int sliding; // Set to false when the input file is already in memory unsigned ins_h; // hash index of string to be inserted unsigned int prev_length; // Length of the best match at previous step. Matches not greater than this // are discarded. This is used in the lazy match evaluation. unsigned strstart; // start of string to insert unsigned match_start; // start of matching string int eofile; // flag set at end of input file unsigned lookahead; // number of valid bytes ahead in window unsigned max_chain_length; // To speed up deflation, hash chains are never searched beyond this length. // A higher limit improves compression ratio but degrades the speed. unsigned int max_lazy_match; // Attempt to find a better match only when the current match is strictly // smaller than this value. This mechanism is used only for compression // levels >= 4. unsigned good_match; // Use a faster search when the previous match is longer than this int nice_match; // Stop searching when current match exceeds this }; typedef struct iztimes { time_t atime, mtime, ctime; } iztimes; // access, modify, create times typedef struct zlist { ush vem, ver, flg, how; // See central header in zipfile.c for what vem..off are ulg tim, crc, siz, len; extent nam, ext, cext, com; // offset of ext must be >= LOCHEAD ush dsk, att, lflg; // offset of lflg must be >= LOCHEAD ulg atx, off; char name[MAX_PATH]; // File name in zip file char *extra; // Extra field (set only if ext != 0) char *cextra; // Extra in central (set only if cext != 0) char *comment; // Comment (set only if com != 0) char iname[MAX_PATH]; // Internal file name after cleanup char zname[MAX_PATH]; // External version of internal name int mark; // Marker for files to operate on int trash; // Marker for files to delete int dosflag; // Set to force MSDOS file attributes struct zlist far *nxt; // Pointer to next header in list } TZipFileInfo; class TState; typedef unsigned(*READFUNC)(TState &state, char *buf, unsigned size); typedef unsigned(*FLUSHFUNC)(void *param, const char *buf, unsigned *size); typedef unsigned(*WRITEFUNC)(void *param, const char *buf, unsigned size); class TState { public: TState() //+++1.2 { param = 0; level = 0; seekable = FALSE; readfunc = 0; flush_outbuf = 0; err = 0; } void *param; int level; bool seekable; READFUNC readfunc; FLUSHFUNC flush_outbuf; TTreeState ts; TBitState bs; TDeflateState ds; const char *err; }; void Assert(TState &state, bool cond, const char *msg) { if (cond) return; state.err = msg; } void __cdecl Trace(const char *x, ...) { va_list paramList; va_start(paramList, x); paramList; va_end(paramList); } void __cdecl Tracec(bool, const char *x, ...) { va_list paramList; va_start(paramList, x); paramList; va_end(paramList); } // =========================================================================== // Local (static) routines in this file. // void init_block(TState &); void pqdownheap(TState &, ct_data *tree, int k); void gen_bitlen(TState &, tree_desc *desc); void gen_codes(TState &state, ct_data *tree, int max_code); void build_tree(TState &, tree_desc *desc); void scan_tree(TState &, ct_data *tree, int max_code); void send_tree(TState &state, ct_data *tree, int max_code); int build_bl_tree(TState &); void send_all_trees(TState &state, int lcodes, int dcodes, int blcodes); void compress_block(TState &state, ct_data *ltree, ct_data *dtree); void set_file_type(TState &); void send_bits(TState &state, int value, int length); unsigned bi_reverse(unsigned code, int len); void bi_windup(TState &state); void copy_block(TState &state, char *buf, unsigned len, int header); #define send_code(state, c, tree) send_bits(state, tree[c].fc.code, tree[c].dl.len) // Send a code of the given tree. c and tree must not have side effects // alternatively... //#define send_code(state, c, tree) // { if (state.verbose>1) fprintf(stderr,"\ncd %3d ",(c)); // send_bits(state, tree[c].fc.code, tree[c].dl.len); } #define d_code(dist) ((dist) < 256 ? state.ts.dist_code[dist] : state.ts.dist_code[256+((dist)>>7)]) // Mapping from a distance to a distance code. dist is the distance - 1 and // must not have side effects. dist_code[256] and dist_code[257] are never used. #define Max(a,b) (a >= b ? a : b) /* the arguments must not have side effects */ /* =========================================================================== * Allocate the match buffer, initialize the various tables and save the * location of the internal file attribute (ascii/binary) and method * (DEFLATE/STORE). */ void ct_init(TState &state, ush *attr) { int n; /* iterates over tree elements */ int bits; /* bit counter */ int length; /* length value */ int code; /* code value */ int dist; /* distance index */ state.ts.file_type = attr; //state.ts.file_method = method; state.ts.cmpr_bytelen = state.ts.cmpr_len_bits = 0L; state.ts.input_len = 0L; if (state.ts.static_dtree[0].dl.len != 0) return; /* ct_init already called */ /* Initialize the mapping length (0..255) -> length code (0..28) */ length = 0; for (code = 0; code < LENGTH_CODES - 1; code++) { state.ts.base_length[code] = length; for (n = 0; n < (1 << extra_lbits[code]); n++) { state.ts.length_code[length++] = (uch)code; } } Assert(state, length == 256, "ct_init: length != 256"); /* Note that the length 255 (match length 258) can be represented * in two different ways: code 284 + 5 bits or code 285, so we * overwrite length_code[255] to use the best encoding: */ state.ts.length_code[length - 1] = (uch)code; /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ dist = 0; for (code = 0; code < 16; code++) { state.ts.base_dist[code] = dist; for (n = 0; n < (1 << extra_dbits[code]); n++) { state.ts.dist_code[dist++] = (uch)code; } } Assert(state, dist == 256, "ct_init: dist != 256"); dist >>= 7; /* from now on, all distances are divided by 128 */ for (; code < D_CODES; code++) { state.ts.base_dist[code] = dist << 7; for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { state.ts.dist_code[256 + dist++] = (uch)code; } } Assert(state, dist == 256, "ct_init: 256+dist != 512"); /* Construct the codes of the static literal tree */ for (bits = 0; bits <= MAX_BITS; bits++) state.ts.bl_count[bits] = 0; n = 0; while (n <= 143) state.ts.static_ltree[n++].dl.len = 8, state.ts.bl_count[8]++; while (n <= 255) state.ts.static_ltree[n++].dl.len = 9, state.ts.bl_count[9]++; while (n <= 279) state.ts.static_ltree[n++].dl.len = 7, state.ts.bl_count[7]++; while (n <= 287) state.ts.static_ltree[n++].dl.len = 8, state.ts.bl_count[8]++; /* fc.codes 286 and 287 do not exist, but we must include them in the * tree construction to get a canonical Huffman tree (longest code * all ones) */ gen_codes(state, (ct_data *)state.ts.static_ltree, L_CODES + 1); /* The static distance tree is trivial: */ for (n = 0; n < D_CODES; n++) { state.ts.static_dtree[n].dl.len = 5; state.ts.static_dtree[n].fc.code = (ush)bi_reverse(n, 5); } /* Initialize the first block of the first file: */ init_block(state); } /* =========================================================================== * Initialize a new block. */ void init_block(TState &state) { int n; /* iterates over tree elements */ /* Initialize the trees. */ for (n = 0; n < L_CODES; n++) state.ts.dyn_ltree[n].fc.freq = 0; for (n = 0; n < D_CODES; n++) state.ts.dyn_dtree[n].fc.freq = 0; for (n = 0; n < BL_CODES; n++) state.ts.bl_tree[n].fc.freq = 0; state.ts.dyn_ltree[END_BLOCK].fc.freq = 1; state.ts.opt_len = state.ts.static_len = 0L; state.ts.last_lit = state.ts.last_dist = state.ts.last_flags = 0; state.ts.flags = 0; state.ts.flag_bit = 1; } #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ /* =========================================================================== * Remove the smallest element from the heap and recreate the heap with * one less element. Updates heap and heap_len. */ #define pqremove(tree, top) \ {\ top = state.ts.heap[SMALLEST]; \ state.ts.heap[SMALLEST] = state.ts.heap[state.ts.heap_len--]; \ pqdownheap(state,tree, SMALLEST); \ } /* =========================================================================== * Compares to subtrees, using the tree depth as tie breaker when * the subtrees have equal frequency. This minimizes the worst case length. */ #define smaller(tree, n, m) \ (tree[n].fc.freq < tree[m].fc.freq || \ (tree[n].fc.freq == tree[m].fc.freq && state.ts.depth[n] <= state.ts.depth[m])) /* =========================================================================== * Restore the heap property by moving down the tree starting at node k, * exchanging a node with the smallest of its two sons if necessary, stopping * when the heap property is re-established (each father smaller than its * two sons). */ void pqdownheap(TState &state, ct_data *tree, int k) { int v = state.ts.heap[k]; int j = k << 1; /* left son of k */ int htemp; /* required because of bug in SASC compiler */ while (j <= state.ts.heap_len) { /* Set j to the smallest of the two sons: */ if (j < state.ts.heap_len && smaller(tree, state.ts.heap[j + 1], state.ts.heap[j])) j++; /* Exit if v is smaller than both sons */ htemp = state.ts.heap[j]; if (smaller(tree, v, htemp)) break; /* Exchange v with the smallest son */ state.ts.heap[k] = htemp; k = j; /* And continue down the tree, setting j to the left son of k */ j <<= 1; } state.ts.heap[k] = v; } /* =========================================================================== * Compute the optimal bit lengths for a tree and update the total bit length * for the current block. * IN assertion: the fields freq and dad are set, heap[heap_max] and * above are the tree nodes sorted by increasing frequency. * OUT assertions: the field len is set to the optimal bit length, the * array bl_count contains the frequencies for each bit length. * The length opt_len is updated; static_len is also updated if stree is * not null. */ void gen_bitlen(TState &state, tree_desc *desc) { ct_data *tree = desc->dyn_tree; const int *extra = desc->extra_bits; int base = desc->extra_base; int max_code = desc->max_code; int max_length = desc->max_length; ct_data *stree = desc->static_tree; int h; /* heap index */ int n, m; /* iterate over the tree elements */ int bits; /* bit length */ int xbits; /* extra bits */ ush f; /* frequency */ int overflow = 0; /* number of elements with bit length too large */ for (bits = 0; bits <= MAX_BITS; bits++) state.ts.bl_count[bits] = 0; /* In a first pass, compute the optimal bit lengths (which may * overflow in the case of the bit length tree). */ tree[state.ts.heap[state.ts.heap_max]].dl.len = 0; /* root of the heap */ for (h = state.ts.heap_max + 1; h < HEAP_SIZE; h++) { n = state.ts.heap[h]; bits = tree[tree[n].dl.dad].dl.len + 1; if (bits > max_length) bits = max_length, overflow++; tree[n].dl.len = (ush)bits; /* We overwrite tree[n].dl.dad which is no longer needed */ if (n > max_code) continue; /* not a leaf node */ state.ts.bl_count[bits]++; xbits = 0; if (n >= base) xbits = extra[n - base]; f = tree[n].fc.freq; state.ts.opt_len += (ulg)f * (bits + xbits); if (stree) state.ts.static_len += (ulg)f * (stree[n].dl.len + xbits); } if (overflow == 0) return; Trace("\nbit length overflow\n"); /* This happens for example on obj2 and pic of the Calgary corpus */ /* Find the first bit length which could increase: */ do { bits = max_length - 1; while (state.ts.bl_count[bits] == 0) bits--; state.ts.bl_count[bits]--; /* move one leaf down the tree */ state.ts.bl_count[bits + 1] += (ush)2; /* move one overflow item as its brother */ state.ts.bl_count[max_length]--; /* The brother of the overflow item also moves one step up, * but this does not affect bl_count[max_length] */ overflow -= 2; } while (overflow > 0); /* Now recompute all bit lengths, scanning in increasing frequency. * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all * lengths instead of fixing only the wrong ones. This idea is taken * from 'ar' written by Haruhiko Okumura.) */ for (bits = max_length; bits != 0; bits--) { n = state.ts.bl_count[bits]; while (n != 0) { m = state.ts.heap[--h]; if (m > max_code) continue; if (tree[m].dl.len != (ush)bits) { Trace("code %d bits %d->%d\n", m, tree[m].dl.len, bits); state.ts.opt_len += ((long)bits - (long)tree[m].dl.len)*(long)tree[m].fc.freq; tree[m].dl.len = (ush)bits; } n--; } } } /* =========================================================================== * Generate the codes for a given tree and bit counts (which need not be * optimal). * IN assertion: the array bl_count contains the bit length statistics for * the given tree and the field len is set for all tree elements. * OUT assertion: the field code is set for all tree elements of non * zero code length. */ void gen_codes(TState &state, ct_data *tree, int max_code) { ush next_code[MAX_BITS + 1]; /* next code value for each bit length */ ush code = 0; /* running code value */ int bits; /* bit index */ int n; /* code index */ /* The distribution counts are first used to generate the code values * without bit reversal. */ for (bits = 1; bits <= MAX_BITS; bits++) { next_code[bits] = code = (ush)((code + state.ts.bl_count[bits - 1]) << 1); } /* Check that the bit counts in bl_count are consistent. The last code * must be all ones. */ Assert(state, code + state.ts.bl_count[MAX_BITS] - 1 == (1 << ((ush)MAX_BITS)) - 1, "inconsistent bit counts"); Trace("\ngen_codes: max_code %d ", max_code); for (n = 0; n <= max_code; n++) { int len = tree[n].dl.len; if (len == 0) continue; /* Now reverse the bits */ tree[n].fc.code = (ush)bi_reverse(next_code[len]++, len); //Tracec(tree != state.ts.static_ltree, "\nn %3d %c l %2d c %4x (%x) ", n, (isgraph(n) ? n : ' '), len, tree[n].fc.code, next_code[len]-1); } } /* =========================================================================== * Construct one Huffman tree and assigns the code bit strings and lengths. * Update the total bit length for the current block. * IN assertion: the field freq is set for all tree elements. * OUT assertions: the fields len and code are set to the optimal bit length * and corresponding code. The length opt_len is updated; static_len is * also updated if stree is not null. The field max_code is set. */ void build_tree(TState &state, tree_desc *desc) { ct_data *tree = desc->dyn_tree; ct_data *stree = desc->static_tree; int elems = desc->elems; int n, m; /* iterate over heap elements */ int max_code = -1; /* largest code with non zero frequency */ int node = elems; /* next internal node of the tree */ /* Construct the initial heap, with least frequent element in * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. * heap[0] is not used. */ state.ts.heap_len = 0, state.ts.heap_max = HEAP_SIZE; for (n = 0; n < elems; n++) { if (tree[n].fc.freq != 0) { state.ts.heap[++state.ts.heap_len] = max_code = n; state.ts.depth[n] = 0; } else { tree[n].dl.len = 0; } } /* The pkzip format requires that at least one distance code exists, * and that at least one bit should be sent even if there is only one * possible code. So to avoid special checks later on we force at least * two codes of non zero frequency. */ while (state.ts.heap_len < 2) { int newcp = state.ts.heap[++state.ts.heap_len] = (max_code < 2 ? ++max_code : 0); tree[newcp].fc.freq = 1; state.ts.depth[newcp] = 0; state.ts.opt_len--; if (stree) state.ts.static_len -= stree[newcp].dl.len; /* new is 0 or 1 so it does not have extra bits */ } desc->max_code = max_code; /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, * establish sub-heaps of increasing lengths: */ for (n = state.ts.heap_len / 2; n >= 1; n--) pqdownheap(state, tree, n); /* Construct the Huffman tree by repeatedly combining the least two * frequent nodes. */ do { pqremove(tree, n); /* n = node of least frequency */ m = state.ts.heap[SMALLEST]; /* m = node of next least frequency */ state.ts.heap[--state.ts.heap_max] = n; /* keep the nodes sorted by frequency */ state.ts.heap[--state.ts.heap_max] = m; /* Create a new node father of n and m */ tree[node].fc.freq = (ush)(tree[n].fc.freq + tree[m].fc.freq); state.ts.depth[node] = (uch)(Max(state.ts.depth[n], state.ts.depth[m]) + 1); tree[n].dl.dad = tree[m].dl.dad = (ush)node; /* and insert the new node in the heap */ state.ts.heap[SMALLEST] = node++; pqdownheap(state, tree, SMALLEST); } while (state.ts.heap_len >= 2); state.ts.heap[--state.ts.heap_max] = state.ts.heap[SMALLEST]; /* At this point, the fields freq and dad are set. We can now * generate the bit lengths. */ gen_bitlen(state, (tree_desc *)desc); /* The field len is now set, we can generate the bit codes */ gen_codes(state, (ct_data *)tree, max_code); } /* =========================================================================== * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. Updates opt_len to take into account the repeat * counts. (The contribution of the bit length codes will be added later * during the construction of bl_tree.) */ void scan_tree(TState &state, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].dl.len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ if (nextlen == 0) max_count = 138, min_count = 3; tree[max_code + 1].dl.len = (ush)-1; /* guard */ for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n + 1].dl.len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { state.ts.bl_tree[curlen].fc.freq = (ush)(state.ts.bl_tree[curlen].fc.freq + count); } else if (curlen != 0) { if (curlen != prevlen) state.ts.bl_tree[curlen].fc.freq++; state.ts.bl_tree[REP_3_6].fc.freq++; } else if (count <= 10) { state.ts.bl_tree[REPZ_3_10].fc.freq++; } else { state.ts.bl_tree[REPZ_11_138].fc.freq++; } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ void send_tree(TState &state, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].dl.len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ /* tree[max_code+1].dl.len = -1; */ /* guard already set */ if (nextlen == 0) max_count = 138, min_count = 3; for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n + 1].dl.len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { do { send_code(state, curlen, state.ts.bl_tree); } while (--count != 0); } else if (curlen != 0) { if (curlen != prevlen) { send_code(state, curlen, state.ts.bl_tree); count--; } Assert(state, count >= 3 && count <= 6, " 3_6?"); send_code(state, REP_3_6, state.ts.bl_tree); send_bits(state, count - 3, 2); } else if (count <= 10) { send_code(state, REPZ_3_10, state.ts.bl_tree); send_bits(state, count - 3, 3); } else { send_code(state, REPZ_11_138, state.ts.bl_tree); send_bits(state, count - 11, 7); } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ int build_bl_tree(TState &state) { int max_blindex; /* index of last bit length code of non zero freq */ /* Determine the bit length frequencies for literal and distance trees */ scan_tree(state, (ct_data *)state.ts.dyn_ltree, state.ts.l_desc.max_code); scan_tree(state, (ct_data *)state.ts.dyn_dtree, state.ts.d_desc.max_code); /* Build the bit length tree: */ build_tree(state, (tree_desc *)(&state.ts.bl_desc)); /* opt_len now includes the length of the tree representations, except * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. */ /* Determine the number of bit length codes to send. The pkzip format * requires that at least 4 bit length codes be sent. (appnote.txt says * 3 but the actual value used is 4.) */ for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { if (state.ts.bl_tree[bl_order[max_blindex]].dl.len != 0) break; } /* Update opt_len to include the bit length tree and counts */ state.ts.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; Trace("\ndyn trees: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len); return max_blindex; } /* =========================================================================== * Send the header for a block using dynamic Huffman trees: the counts, the * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ void send_all_trees(TState &state, int lcodes, int dcodes, int blcodes) { int rank; /* index in bl_order */ Assert(state, lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); Assert(state, lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes"); Trace("\nbl counts: "); send_bits(state, lcodes - 257, 5); /* not +255 as stated in appnote.txt 1.93a or -256 in 2.04c */ send_bits(state, dcodes - 1, 5); send_bits(state, blcodes - 4, 4); /* not -3 as stated in appnote.txt */ for (rank = 0; rank < blcodes; rank++) { Trace("\nbl code %2d ", bl_order[rank]); send_bits(state, state.ts.bl_tree[bl_order[rank]].dl.len, 3); } Trace("\nbl tree: sent %ld", state.bs.bits_sent); send_tree(state, (ct_data *)state.ts.dyn_ltree, lcodes - 1); /* send the literal tree */ Trace("\nlit tree: sent %ld", state.bs.bits_sent); send_tree(state, (ct_data *)state.ts.dyn_dtree, dcodes - 1); /* send the distance tree */ Trace("\ndist tree: sent %ld", state.bs.bits_sent); } /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static * trees or store, and output the encoded block to the zip file. This function * returns the total compressed length (in bytes) for the file so far. */ ulg flush_block(TState &state, char *buf, ulg stored_len, int eof) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex; /* index of last bit length code of non zero freq */ state.ts.flag_buf[state.ts.last_flags] = state.ts.flags; /* Save the flags for the last 8 items */ /* Check if the file is ascii or binary */ if (*state.ts.file_type == (ush)UNKNOWN) set_file_type(state); /* Construct the literal and distance trees */ build_tree(state, (tree_desc *)(&state.ts.l_desc)); Trace("\nlit data: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len); build_tree(state, (tree_desc *)(&state.ts.d_desc)); Trace("\ndist data: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len); /* At this point, opt_len and static_len are the total bit lengths of * the compressed block data, excluding the tree representations. */ /* Build the bit length tree for the above two trees, and get the index * in bl_order of the last bit length code to send. */ max_blindex = build_bl_tree(state); /* Determine the best encoding. Compute first the block length in bytes */ opt_lenb = (state.ts.opt_len + 3 + 7) >> 3; static_lenb = (state.ts.static_len + 3 + 7) >> 3; state.ts.input_len += stored_len; /* for debugging only */ Trace("\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", opt_lenb, state.ts.opt_len, static_lenb, state.ts.static_len, stored_len, state.ts.last_lit, state.ts.last_dist); if (static_lenb <= opt_lenb) opt_lenb = static_lenb; // Originally, zip allowed the file to be transformed from a compressed // into a stored file in the case where compression failed, there // was only one block, and it was allowed to change. I've removed this // possibility since the code's cleaner if no changes are allowed. //if (stored_len <= opt_lenb && eof && state.ts.cmpr_bytelen == 0L // && state.ts.cmpr_len_bits == 0L && state.seekable) //{ // && state.ts.file_method != NULL // // Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: // Assert(state,buf!=NULL,"block vanished"); // copy_block(state,buf, (unsigned)stored_len, 0); // without header // state.ts.cmpr_bytelen = stored_len; // Assert(state,false,"unimplemented *state.ts.file_method = STORE;"); // //*state.ts.file_method = STORE; //} //else if (stored_len + 4 <= opt_lenb && buf != (char*)NULL) { /* 4: two words for the lengths */ /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. * Otherwise we can't have processed more than WSIZE input bytes since * the last block flush, because compression would have been * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to * transform a block into a stored block. */ send_bits(state, (STORED_BLOCK << 1) + eof, 3); /* send block type */ state.ts.cmpr_bytelen += ((state.ts.cmpr_len_bits + 3 + 7) >> 3) + stored_len + 4; state.ts.cmpr_len_bits = 0L; copy_block(state, buf, (unsigned)stored_len, 1); /* with header */ } else if (static_lenb == opt_lenb) { send_bits(state, (STATIC_TREES << 1) + eof, 3); compress_block(state, (ct_data *)state.ts.static_ltree, (ct_data *)state.ts.static_dtree); state.ts.cmpr_len_bits += 3 + state.ts.static_len; state.ts.cmpr_bytelen += state.ts.cmpr_len_bits >> 3; state.ts.cmpr_len_bits &= 7L; } else { send_bits(state, (DYN_TREES << 1) + eof, 3); send_all_trees(state, state.ts.l_desc.max_code + 1, state.ts.d_desc.max_code + 1, max_blindex + 1); compress_block(state, (ct_data *)state.ts.dyn_ltree, (ct_data *)state.ts.dyn_dtree); state.ts.cmpr_len_bits += 3 + state.ts.opt_len; state.ts.cmpr_bytelen += state.ts.cmpr_len_bits >> 3; state.ts.cmpr_len_bits &= 7L; } Assert(state, ((state.ts.cmpr_bytelen << 3) + state.ts.cmpr_len_bits) == state.bs.bits_sent, "bad compressed size"); init_block(state); if (eof) { // Assert(state,input_len == isize, "bad input size"); bi_windup(state); state.ts.cmpr_len_bits += 7; /* align on byte boundary */ } Trace("\n"); return state.ts.cmpr_bytelen + (state.ts.cmpr_len_bits >> 3); } /* =========================================================================== * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ int ct_tally(TState &state, int dist, int lc) { state.ts.l_buf[state.ts.last_lit++] = (uch)lc; if (dist == 0) { /* lc is the unmatched char */ state.ts.dyn_ltree[lc].fc.freq++; } else { /* Here, lc is the match length - MIN_MATCH */ dist--; /* dist = match distance - 1 */ Assert(state, (ush)dist < (ush)MAX_DIST && (ush)lc <= (ush)(MAX_MATCH - MIN_MATCH) && (ush)d_code(dist) < (ush)D_CODES, "ct_tally: bad match"); state.ts.dyn_ltree[state.ts.length_code[lc] + LITERALS + 1].fc.freq++; state.ts.dyn_dtree[d_code(dist)].fc.freq++; state.ts.d_buf[state.ts.last_dist++] = (ush)dist; state.ts.flags |= state.ts.flag_bit; } state.ts.flag_bit <<= 1; /* Output the flags if they fill a byte: */ if ((state.ts.last_lit & 7) == 0) { state.ts.flag_buf[state.ts.last_flags++] = state.ts.flags; state.ts.flags = 0, state.ts.flag_bit = 1; } /* Try to guess if it is profitable to stop the current block here */ if (state.level > 2 && (state.ts.last_lit & 0xfff) == 0) { /* Compute an upper bound for the compressed length */ ulg out_length = (ulg)state.ts.last_lit * 8L; ulg in_length = (ulg)state.ds.strstart - state.ds.block_start; int dcode; for (dcode = 0; dcode < D_CODES; dcode++) { out_length += (ulg)state.ts.dyn_dtree[dcode].fc.freq*(5L + extra_dbits[dcode]); } out_length >>= 3; Trace("\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", state.ts.last_lit, state.ts.last_dist, in_length, out_length, 100L - out_length * 100L / in_length); if (state.ts.last_dist < state.ts.last_lit / 2 && out_length < in_length / 2) return 1; } return (state.ts.last_lit == LIT_BUFSIZE - 1 || state.ts.last_dist == DIST_BUFSIZE); /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. */ } /* =========================================================================== * Send the block data compressed using the given Huffman trees */ void compress_block(TState &state, ct_data *ltree, ct_data *dtree) { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ unsigned lx = 0; /* running index in l_buf */ unsigned dx = 0; /* running index in d_buf */ unsigned fx = 0; /* running index in flag_buf */ uch flag = 0; /* current flags */ unsigned code; /* the code to send */ int extra; /* number of extra bits to send */ if (state.ts.last_lit != 0) do { if ((lx & 7) == 0) flag = state.ts.flag_buf[fx++]; lc = state.ts.l_buf[lx++]; if ((flag & 1) == 0) { send_code(state, lc, ltree); /* send a literal byte */ } else { /* Here, lc is the match length - MIN_MATCH */ code = state.ts.length_code[lc]; send_code(state, code + LITERALS + 1, ltree); /* send the length code */ extra = extra_lbits[code]; if (extra != 0) { lc -= state.ts.base_length[code]; send_bits(state, lc, extra); /* send the extra length bits */ } dist = state.ts.d_buf[dx++]; /* Here, dist is the match distance - 1 */ code = d_code(dist); Assert(state, code < D_CODES, "bad d_code"); send_code(state, code, dtree); /* send the distance code */ extra = extra_dbits[code]; if (extra != 0) { dist -= state.ts.base_dist[code]; send_bits(state, dist, extra); /* send the extra distance bits */ } } /* literal or match pair ? */ flag >>= 1; } while (lx < state.ts.last_lit); send_code(state, END_BLOCK, ltree); } /* =========================================================================== * Set the file type to ASCII or BINARY, using a crude approximation: * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. * IN assertion: the fields freq of dyn_ltree are set and the total of all * frequencies does not exceed 64K (to fit in an int on 16 bit machines). */ void set_file_type(TState &state) { int n = 0; unsigned ascii_freq = 0; unsigned bin_freq = 0; while (n < 7) bin_freq += state.ts.dyn_ltree[n++].fc.freq; while (n < 128) ascii_freq += state.ts.dyn_ltree[n++].fc.freq; while (n < LITERALS) bin_freq += state.ts.dyn_ltree[n++].fc.freq; *state.ts.file_type = (ush)(bin_freq >(ascii_freq >> 2) ? BINARY : ASCII); } /* =========================================================================== * Initialize the bit string routines. */ void bi_init(TState &state, char *tgt_buf, unsigned tgt_size, int flsh_allowed) { state.bs.out_buf = tgt_buf; state.bs.out_size = tgt_size; state.bs.out_offset = 0; state.bs.flush_flg = flsh_allowed; state.bs.bi_buf = 0; state.bs.bi_valid = 0; state.bs.bits_sent = 0L; } /* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ void send_bits(TState &state, int value, int length) { Assert(state, length > 0 && length <= 15, "invalid length"); state.bs.bits_sent += (ulg)length; /* If not enough room in bi_buf, use (bi_valid) bits from bi_buf and * (Buf_size - bi_valid) bits from value to flush the filled bi_buf, * then fill in the rest of (value), leaving (length - (Buf_size-bi_valid)) * unused bits in bi_buf. */ state.bs.bi_buf |= (value << state.bs.bi_valid); state.bs.bi_valid += length; if (state.bs.bi_valid > (int)Buf_size) { PUTSHORT(state, state.bs.bi_buf); state.bs.bi_valid -= Buf_size; state.bs.bi_buf = (unsigned)value >> (length - state.bs.bi_valid); } } /* =========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) * IN assertion: 1 <= len <= 15 */ unsigned bi_reverse(unsigned code, int len) { register unsigned res = 0; do { res |= code & 1; code >>= 1, res <<= 1; } while (--len > 0); return res >> 1; } /* =========================================================================== * Write out any remaining bits in an incomplete byte. */ void bi_windup(TState &state) { if (state.bs.bi_valid > 8) { PUTSHORT(state, state.bs.bi_buf); } else if (state.bs.bi_valid > 0) { PUTBYTE(state, state.bs.bi_buf); } if (state.bs.flush_flg) { state.flush_outbuf(state.param, state.bs.out_buf, &state.bs.out_offset); } state.bs.bi_buf = 0; state.bs.bi_valid = 0; state.bs.bits_sent = (state.bs.bits_sent + 7) & ~7; } /* =========================================================================== * Copy a stored block to the zip file, storing first the length and its * one's complement if requested. */ void copy_block(TState &state, char *block, unsigned len, int header) { bi_windup(state); /* align on byte boundary */ if (header) { PUTSHORT(state, (ush)len); PUTSHORT(state, (ush)~len); state.bs.bits_sent += 2 * 16; } if (state.bs.flush_flg) { state.flush_outbuf(state.param, state.bs.out_buf, &state.bs.out_offset); state.bs.out_offset = len; state.flush_outbuf(state.param, block, &state.bs.out_offset); } else if (state.bs.out_offset + len > state.bs.out_size) { Assert(state, false, "output buffer too small for in-memory compression"); } else { memcpy(state.bs.out_buf + state.bs.out_offset, block, len); state.bs.out_offset += len; } state.bs.bits_sent += (ulg)len << 3; } /* =========================================================================== * Prototypes for functions. */ void fill_window(TState &state); ulg deflate_fast(TState &state); int longest_match(TState &state, IPos cur_match); /* =========================================================================== * Update a hash value with the given input byte * IN assertion: all calls to to UPDATE_HASH are made with consecutive * input characters, so that a running hash key can be computed from the * previous key instead of complete recalculation each time. */ #define UPDATE_HASH(h,c) (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK) /* =========================================================================== * Insert string s in the dictionary and set match_head to the previous head * of the hash chain (the most recent string with same hash key). Return * the previous length of the hash chain. * IN assertion: all calls to to INSERT_STRING are made with consecutive * input characters and the first MIN_MATCH bytes of s are valid * (except for the last MIN_MATCH-1 bytes of the input file). */ #define INSERT_STRING(s, match_head) \ (UPDATE_HASH(state.ds.ins_h, state.ds.window[(s) + (MIN_MATCH-1)]), \ state.ds.prev[(s) & WMASK] = match_head = state.ds.head[state.ds.ins_h], \ state.ds.head[state.ds.ins_h] = (s)) /* =========================================================================== * Initialize the "longest match" routines for a new file * * IN assertion: window_size is > 0 if the input file is already read or * mmap'ed in the window[] array, 0 otherwise. In the first case, * window_size is sufficient to contain the whole input file plus * MIN_LOOKAHEAD bytes (to avoid referencing memory beyond the end * of window[] when looking for matches towards the end). */ void lm_init(TState &state, int pack_level, ush *flags) { register unsigned j; Assert(state, pack_level >= 1 && pack_level <= 8, "bad pack level"); /* Do not slide the window if the whole input is already in memory * (window_size > 0) */ state.ds.sliding = 0; if (state.ds.window_size == 0L) { state.ds.sliding = 1; state.ds.window_size = (ulg)2L * WSIZE; } /* Initialize the hash table (avoiding 64K overflow for 16 bit systems). * prev[] will be initialized on the fly. */ state.ds.head[HASH_SIZE - 1] = NIL; memset((char*)state.ds.head, NIL, (unsigned)(HASH_SIZE - 1)*sizeof(*state.ds.head)); /* Set the default configuration parameters: */ state.ds.max_lazy_match = configuration_table[pack_level].max_lazy; state.ds.good_match = configuration_table[pack_level].good_length; state.ds.nice_match = configuration_table[pack_level].nice_length; state.ds.max_chain_length = configuration_table[pack_level].max_chain; if (pack_level <= 2) { *flags |= FAST; } else if (pack_level >= 8) { *flags |= SLOW; } /* ??? reduce max_chain_length for binary files */ state.ds.strstart = 0; state.ds.block_start = 0L; j = WSIZE; j <<= 1; // Can read 64K in one step state.ds.lookahead = state.readfunc(state, (char*)state.ds.window, j); if (state.ds.lookahead == 0 || state.ds.lookahead == (unsigned)EOF) { state.ds.eofile = 1, state.ds.lookahead = 0; return; } state.ds.eofile = 0; /* Make sure that we always have enough lookahead. This is important * if input comes from a device such as a tty. */ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state); state.ds.ins_h = 0; for (j = 0; j<MIN_MATCH - 1; j++) UPDATE_HASH(state.ds.ins_h, state.ds.window[j]); /* If lookahead < MIN_MATCH, ins_h is garbage, but this is * not important since only literal bytes will be emitted. */ } /* =========================================================================== * Set match_start to the longest match starting at the given string and * return its length. Matches shorter or equal to prev_length are discarded, * in which case the result is equal to prev_length and match_start is * garbage. * IN assertions: cur_match is the head of the hash chain for the current * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 */ // For 80x86 and 680x0 and ARM, an optimized version is in match.asm or // match.S. The code is functionally equivalent, so you can use the C version // if desired. Which I do so desire! int longest_match(TState &state, IPos cur_match) { unsigned chain_length = state.ds.max_chain_length; /* max hash chain length */ register uch far *scan = state.ds.window + state.ds.strstart; /* current string */ register uch far *match; /* matched string */ register int len; /* length of current match */ int best_len = state.ds.prev_length; /* best match length so far */ IPos limit = state.ds.strstart > (IPos)MAX_DIST ? state.ds.strstart - (IPos)MAX_DIST : NIL; /* Stop when cur_match becomes <= limit. To simplify the code, * we prevent matches with the string of window index 0. */ // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. // It is easy to get rid of this optimization if necessary. Assert(state, HASH_BITS >= 8 && MAX_MATCH == 258, "Code too clever"); register uch far *strend = state.ds.window + state.ds.strstart + MAX_MATCH; register uch scan_end1 = scan[best_len - 1]; register uch scan_end = scan[best_len]; /* Do not waste too much time if we already have a good match: */ if (state.ds.prev_length >= state.ds.good_match) { chain_length >>= 2; } Assert(state, state.ds.strstart <= state.ds.window_size - MIN_LOOKAHEAD, "insufficient lookahead"); do { Assert(state, cur_match < state.ds.strstart, "no future"); match = state.ds.window + cur_match; /* Skip to next match if the match length cannot increase * or if the match length is less than 2: */ if (match[best_len] != scan_end || match[best_len - 1] != scan_end1 || *match != *scan || *++match != scan[1]) continue; /* The check at best_len-1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that * the hash keys are equal and that HASH_BITS >= 8. */ scan += 2, match++; /* We check for insufficient lookahead only every 8th comparison; * the 256th check will be made at strstart+258. */ do { } while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); Assert(state, scan <= state.ds.window + (unsigned)(state.ds.window_size - 1), "wild scan"); len = MAX_MATCH - (int)(strend - scan); scan = strend - MAX_MATCH; if (len > best_len) { state.ds.match_start = cur_match; best_len = len; if (len >= state.ds.nice_match) break; scan_end1 = scan[best_len - 1]; scan_end = scan[best_len]; } } while ((cur_match = state.ds.prev[cur_match & WMASK]) > limit && --chain_length != 0); return best_len; } #define check_match(state,start, match, length) // or alternatively... //void check_match(TState &state,IPos start, IPos match, int length) //{ // check that the match is indeed a match // if (memcmp((char*)state.ds.window + match, // (char*)state.ds.window + start, length) != EQUAL) { // fprintf(stderr, // " start %d, match %d, length %d\n", // start, match, length); // error("invalid match"); // } // if (state.verbose > 1) { // fprintf(stderr,"\\[%d,%d]", start-match, length); // do { fprintf(stdout,"%c",state.ds.window[start++]); } while (--length != 0); // } //} /* =========================================================================== * Fill the window when the lookahead becomes insufficient. * Updates strstart and lookahead, and sets eofile if end of input file. * * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0 * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD * At least one byte has been read, or eofile is set; file reads are * performed for at least two bytes (required for the translate_eol option). */ void fill_window(TState &state) { register unsigned n, m; unsigned more; /* Amount of free space at the end of the window. */ do { more = (unsigned)(state.ds.window_size - (ulg)state.ds.lookahead - (ulg)state.ds.strstart); /* If the window is almost full and there is insufficient lookahead, * move the upper half to the lower one to make room in the upper half. */ if (more == (unsigned)EOF) { /* Very unlikely, but possible on 16 bit machine if strstart == 0 * and lookahead == 1 (input done one byte at time) */ more--; /* For MMAP or BIG_MEM, the whole input file is already in memory so * we must not perform sliding. We must however call (*read_buf)() in * order to compute the crc, update lookahead and possibly set eofile. */ } else if (state.ds.strstart >= WSIZE + MAX_DIST && state.ds.sliding) { /* By the IN assertion, the window is not empty so we can't confuse * more == 0 with more == 64K on a 16 bit machine. */ memcpy((char*)state.ds.window, (char*)state.ds.window + WSIZE, (unsigned)WSIZE); state.ds.match_start -= WSIZE; state.ds.strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */ state.ds.block_start -= (long)WSIZE; for (n = 0; n < HASH_SIZE; n++) { m = state.ds.head[n]; state.ds.head[n] = (Pos)(m >= WSIZE ? m - WSIZE : NIL); } for (n = 0; n < WSIZE; n++) { m = state.ds.prev[n]; state.ds.prev[n] = (Pos)(m >= WSIZE ? m - WSIZE : NIL); /* If n is not on any hash chain, prev[n] is garbage but * its value will never be used. */ } more += WSIZE; } if (state.ds.eofile) return; /* If there was no sliding: * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && * more == window_size - lookahead - strstart * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) * => more >= window_size - 2*WSIZE + 2 * In the MMAP or BIG_MEM case (not yet supported in gzip), * window_size == input_size + MIN_LOOKAHEAD && * strstart + lookahead <= input_size => more >= MIN_LOOKAHEAD. * Otherwise, window_size == 2*WSIZE so more >= 2. * If there was sliding, more >= WSIZE. So in all cases, more >= 2. */ Assert(state, more >= 2, "more < 2"); n = state.readfunc(state, (char*)state.ds.window + state.ds.strstart + state.ds.lookahead, more); if (n == 0 || n == (unsigned)EOF) { state.ds.eofile = 1; } else { state.ds.lookahead += n; } } while (state.ds.lookahead < MIN_LOOKAHEAD && !state.ds.eofile); } /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. */ #define FLUSH_BLOCK(state,eof) \ flush_block(state,state.ds.block_start >= 0L ? (char*)&state.ds.window[(unsigned)state.ds.block_start] : \ (char*)NULL, (long)state.ds.strstart - state.ds.block_start, (eof)) /* =========================================================================== * Processes a new input file and return its compressed length. This * function does not perform lazy evaluation of matches and inserts * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ ulg deflate_fast(TState &state) { IPos hash_head = NIL; /* head of the hash chain */ int flush; /* set if current block must be flushed */ unsigned match_length = 0; /* length of best match */ state.ds.prev_length = MIN_MATCH - 1; while (state.ds.lookahead != 0) { /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (state.ds.lookahead >= MIN_MATCH) INSERT_STRING(state.ds.strstart, hash_head); /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ if (hash_head != NIL && state.ds.strstart - hash_head <= MAX_DIST) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ /* Do not look for matches beyond the end of the input. * This is necessary to make deflate deterministic. */ if ((unsigned)state.ds.nice_match > state.ds.lookahead) state.ds.nice_match = (int)state.ds.lookahead; match_length = longest_match(state, hash_head); /* longest_match() sets match_start */ if (match_length > state.ds.lookahead) match_length = state.ds.lookahead; } if (match_length >= MIN_MATCH) { check_match(state, state.ds.strstart, state.ds.match_start, match_length); flush = ct_tally(state, state.ds.strstart - state.ds.match_start, match_length - MIN_MATCH); state.ds.lookahead -= match_length; /* Insert new strings in the hash table only if the match length * is not too large. This saves time but degrades compression. */ if (match_length <= state.ds.max_insert_length && state.ds.lookahead >= MIN_MATCH) { match_length--; /* string at strstart already in hash table */ do { state.ds.strstart++; INSERT_STRING(state.ds.strstart, hash_head); /* strstart never exceeds WSIZE-MAX_MATCH, so there are * always MIN_MATCH bytes ahead. */ } while (--match_length != 0); state.ds.strstart++; } else { state.ds.strstart += match_length; match_length = 0; state.ds.ins_h = state.ds.window[state.ds.strstart]; UPDATE_HASH(state.ds.ins_h, state.ds.window[state.ds.strstart + 1]); Assert(state, MIN_MATCH == 3, "Call UPDATE_HASH() MIN_MATCH-3 more times"); } } else { /* No match, output a literal byte */ flush = ct_tally(state, 0, state.ds.window[state.ds.strstart]); state.ds.lookahead--; state.ds.strstart++; } if (flush) FLUSH_BLOCK(state, 0), state.ds.block_start = state.ds.strstart; /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state); } return FLUSH_BLOCK(state, 1); /* eof */ } /* =========================================================================== * Same as above, but achieves better compression. We use a lazy * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ ulg deflate(TState &state) { IPos hash_head = NIL; /* head of hash chain */ IPos prev_match; /* previous match */ int flush; /* set if current block must be flushed */ int match_available = 0; /* set if previous match exists */ register unsigned match_length = MIN_MATCH - 1; /* length of best match */ if (state.level <= 3) return deflate_fast(state); /* optimized for speed */ /* Process the input block. */ while (state.ds.lookahead != 0) { /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (state.ds.lookahead >= MIN_MATCH) INSERT_STRING(state.ds.strstart, hash_head); /* Find the longest match, discarding those <= prev_length. */ state.ds.prev_length = match_length, prev_match = state.ds.match_start; match_length = MIN_MATCH - 1; if (hash_head != NIL && state.ds.prev_length < state.ds.max_lazy_match && state.ds.strstart - hash_head <= MAX_DIST) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ /* Do not look for matches beyond the end of the input. * This is necessary to make deflate deterministic. */ if ((unsigned)state.ds.nice_match > state.ds.lookahead) state.ds.nice_match = (int)state.ds.lookahead; match_length = longest_match(state, hash_head); /* longest_match() sets match_start */ if (match_length > state.ds.lookahead) match_length = state.ds.lookahead; /* Ignore a length 3 match if it is too distant: */ if (match_length == MIN_MATCH && state.ds.strstart - state.ds.match_start > TOO_FAR){ /* If prev_match is also MIN_MATCH, match_start is garbage * but we will ignore the current match anyway. */ match_length = MIN_MATCH - 1; } } /* If there was a match at the previous step and the current * match is not better, output the previous match: */ if (state.ds.prev_length >= MIN_MATCH && match_length <= state.ds.prev_length) { unsigned max_insert = state.ds.strstart + state.ds.lookahead - MIN_MATCH; check_match(state, state.ds.strstart - 1, prev_match, state.ds.prev_length); flush = ct_tally(state, state.ds.strstart - 1 - prev_match, state.ds.prev_length - MIN_MATCH); /* Insert in hash table all strings up to the end of the match. * strstart-1 and strstart are already inserted. */ state.ds.lookahead -= state.ds.prev_length - 1; state.ds.prev_length -= 2; do { if (++state.ds.strstart <= max_insert) { INSERT_STRING(state.ds.strstart, hash_head); /* strstart never exceeds WSIZE-MAX_MATCH, so there are * always MIN_MATCH bytes ahead. */ } } while (--state.ds.prev_length != 0); state.ds.strstart++; match_available = 0; match_length = MIN_MATCH - 1; if (flush) FLUSH_BLOCK(state, 0), state.ds.block_start = state.ds.strstart; } else if (match_available) { /* If there was no match at the previous position, output a * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ if (ct_tally(state, 0, state.ds.window[state.ds.strstart - 1])) { FLUSH_BLOCK(state, 0), state.ds.block_start = state.ds.strstart; } state.ds.strstart++; state.ds.lookahead--; } else { /* There is no previous match to compare with, wait for * the next step to decide. */ match_available = 1; state.ds.strstart++; state.ds.lookahead--; } // Assert(state,strstart <= isize && lookahead <= isize, "a bit too far"); /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state); } if (match_available) ct_tally(state, 0, state.ds.window[state.ds.strstart - 1]); return FLUSH_BLOCK(state, 1); /* eof */ } int putlocal(struct zlist far *z, WRITEFUNC wfunc, void *param) { // Write a local header described by *z to file *f. Return a ZE_ error code. PUTLG(LOCSIG, f); PUTSH(z->ver, f); PUTSH(z->lflg, f); PUTSH(z->how, f); PUTLG(z->tim, f); PUTLG(z->crc, f); PUTLG(z->siz, f); PUTLG(z->len, f); PUTSH(z->nam, f); PUTSH(z->ext, f); size_t res = (size_t)wfunc(param, z->iname, (unsigned int)z->nam); if (res != z->nam) return ZE_TEMP; if (z->ext) { res = (size_t)wfunc(param, z->extra, (unsigned int)z->ext); if (res != z->ext) return ZE_TEMP; } return ZE_OK; } int putextended(struct zlist far *z, WRITEFUNC wfunc, void *param) { // Write an extended local header described by *z to file *f. Returns a ZE_ code PUTLG(EXTLOCSIG, f); PUTLG(z->crc, f); PUTLG(z->siz, f); PUTLG(z->len, f); return ZE_OK; } int putcentral(struct zlist far *z, WRITEFUNC wfunc, void *param) { // Write a central header entry of *z to file *f. Returns a ZE_ code. PUTLG(CENSIG, f); PUTSH(z->vem, f); PUTSH(z->ver, f); PUTSH(z->flg, f); PUTSH(z->how, f); PUTLG(z->tim, f); PUTLG(z->crc, f); PUTLG(z->siz, f); PUTLG(z->len, f); PUTSH(z->nam, f); PUTSH(z->cext, f); PUTSH(z->com, f); PUTSH(z->dsk, f); PUTSH(z->att, f); PUTLG(z->atx, f); PUTLG(z->off, f); if ((size_t)wfunc(param, z->iname, (unsigned int)z->nam) != z->nam || (z->cext && (size_t)wfunc(param, z->cextra, (unsigned int)z->cext) != z->cext) || (z->com && (size_t)wfunc(param, z->comment, (unsigned int)z->com) != z->com)) return ZE_TEMP; return ZE_OK; } int putend(int n, ulg s, ulg c, extent m, char *z, WRITEFUNC wfunc, void *param) { // write the end of the central-directory-data to file *f. PUTLG(ENDSIG, f); PUTSH(0, f); PUTSH(0, f); PUTSH(n, f); PUTSH(n, f); PUTLG(s, f); PUTLG(c, f); PUTSH(m, f); // Write the comment, if any if (m && wfunc(param, z, (unsigned int)m) != m) return ZE_TEMP; return ZE_OK; } const ulg crc_table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL }; #define CRC32(c, b) (crc_table[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8)) #define DO1(buf) crc = CRC32(crc, *buf++) #define DO2(buf) DO1(buf); DO1(buf) #define DO4(buf) DO2(buf); DO2(buf) #define DO8(buf) DO4(buf); DO4(buf) ulg crc32(ulg crc, const uch *buf, extent len) { if (buf == NULL) return 0L; crc = crc ^ 0xffffffffL; while (len >= 8) { DO8(buf); len -= 8; } if (len) do { DO1(buf); } while (--len); return crc ^ 0xffffffffL; // (instead of ~c for 64-bit machines) } bool HasZipSuffix(const char *fn) { const char *ext = fn + strlen(fn); while (ext>fn && *ext != '.') ext--; if (ext == fn && *ext != '.') return false; if (stricmp(ext, ".Z") == 0) return true; if (stricmp(ext, ".zip") == 0) return true; if (stricmp(ext, ".zoo") == 0) return true; if (stricmp(ext, ".arc") == 0) return true; if (stricmp(ext, ".lzh") == 0) return true; if (stricmp(ext, ".arj") == 0) return true; if (stricmp(ext, ".gz") == 0) return true; if (stricmp(ext, ".tgz") == 0) return true; return false; } time_t filetime2timet(const FILETIME ft) { SYSTEMTIME st; FileTimeToSystemTime(&ft, &st); if (st.wYear<1970) { st.wYear = 1970; st.wMonth = 1; st.wDay = 1; } if (st.wYear >= 2038) { st.wYear = 2037; st.wMonth = 12; st.wDay = 31; } struct tm tm; tm.tm_sec = st.wSecond; tm.tm_min = st.wMinute; tm.tm_hour = st.wHour; tm.tm_mday = st.wDay; tm.tm_mon = st.wMonth - 1; tm.tm_year = st.wYear - 1900; tm.tm_isdst = 0; time_t t = mktime(&tm); return t; } ZRESULT GetFileInfo(HANDLE hf, ulg *attr, long *size, iztimes *times, ulg *timestamp) { DWORD type = GetFileType(hf); if (type != FILE_TYPE_DISK) return ZR_NOTINITED; // The handle must be a handle to a file // The date and time is returned in a long with the date most significant to allow // unsigned integer comparison of absolute times. The attributes have two // high bytes unix attr, and two low bytes a mapping of that to DOS attr. //struct stat s; int res=stat(fn,&s); if (res!=0) return false; // translate windows file attributes into zip ones. BY_HANDLE_FILE_INFORMATION bhi; BOOL res = GetFileInformationByHandle(hf, &bhi); if (!res) return ZR_NOFILE; // +++1.3 /// Convert times from UTC to local time. MSDN says that FILETIME is local /// for FAT file system and UTC for NTFS system, but tests show that both FAT and NTFS /// return UTC time. { // Get time zone difference SYSTEMTIME stUTC, stLocal; GetSystemTime(&stUTC); GetLocalTime(&stLocal); // could be a few milliseconds difference, but should we care? FILETIME ftUTC, ftLocal; SystemTimeToFileTime(&stUTC, &ftUTC); SystemTimeToFileTime(&stLocal, &ftLocal); LONG64 uiUTC, uiLocal; memcpy(&uiUTC, &ftUTC, min(sizeof(LONG64), sizeof(FILETIME))); // use 'min' as safeguard, however both sizes should be the same: 64-bit memcpy(&uiLocal, &ftLocal, min(sizeof(LONG64), sizeof(FILETIME))); LONG64 uiTimeDiff = uiUTC - uiLocal; // apply difference FILETIME* pFileTimes[3] = { &bhi.ftLastWriteTime, &bhi.ftLastAccessTime, &bhi.ftCreationTime }; for (int i = 0; i<3; i++){ LONG64 uiUTC_file; memcpy(&uiUTC_file, pFileTimes[i], min(sizeof(LONG64), sizeof(FILETIME))); LONG64 uiLocal_file = uiUTC_file - uiTimeDiff; memcpy(pFileTimes[i], &uiLocal_file, min(sizeof(LONG64), sizeof(FILETIME))); } } DWORD fa = bhi.dwFileAttributes; ulg a = 0; // Zip uses the lower word for its interpretation of windows stuff if (fa&FILE_ATTRIBUTE_READONLY) a |= 0x01; if (fa&FILE_ATTRIBUTE_HIDDEN) a |= 0x02; if (fa&FILE_ATTRIBUTE_SYSTEM) a |= 0x04; if (fa&FILE_ATTRIBUTE_DIRECTORY)a |= 0x10; if (fa&FILE_ATTRIBUTE_ARCHIVE) a |= 0x20; // It uses the upper word for standard unix attr, which we must manually construct if (fa&FILE_ATTRIBUTE_DIRECTORY)a |= 0x40000000; // directory else a |= 0x80000000; // normal file a |= 0x01000000; // readable if (fa&FILE_ATTRIBUTE_READONLY) {} else a |= 0x00800000; // writeable // now just a small heuristic to check if it's an executable: DWORD red, hsize = GetFileSize(hf, NULL); if (hsize>40) { SetFilePointer(hf, 0, NULL, FILE_BEGIN); unsigned short magic; ReadFile(hf, &magic, sizeof(magic), &red, NULL); SetFilePointer(hf, 36, NULL, FILE_BEGIN); unsigned long hpos; ReadFile(hf, &hpos, sizeof(hpos), &red, NULL); if (magic == 0x54AD && hsize>hpos + 4 + 20 + 28) { SetFilePointer(hf, hpos, NULL, FILE_BEGIN); unsigned long signature; ReadFile(hf, &signature, sizeof(signature), &red, NULL); if (signature == IMAGE_DOS_SIGNATURE || signature == IMAGE_OS2_SIGNATURE || signature == IMAGE_OS2_SIGNATURE_LE || signature == IMAGE_NT_SIGNATURE) { a |= 0x00400000; // executable } } } // if (attr != NULL) *attr = a; if (size != NULL) *size = hsize; if (times != NULL) { // time_t is 32bit number of seconds elapsed since 0:0:0GMT, Jan1, 1970. // but FILETIME is 64bit number of 100-nanosecs since Jan1, 1601 times->atime = filetime2timet(bhi.ftLastAccessTime); times->mtime = filetime2timet(bhi.ftLastWriteTime); times->ctime = filetime2timet(bhi.ftCreationTime); } if (timestamp != NULL) { WORD dosdate, dostime; FileTimeToDosDateTime(&bhi.ftLastWriteTime, &dosdate, &dostime); *timestamp = (WORD)dostime | (((DWORD)dosdate) << 16); } return ZR_OK; } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// class TZip { public: TZip() : hfout(0), hmapout(0), zfis(0), obuf(0), hfin(0), writ(0), oerr(false), hasputcen(false), ooffset(0) {} ~TZip() {} // These variables say about the file we're writing into // We can write to pipe, file-by-handle, file-by-name, memory-to-memmapfile HANDLE hfout; // if valid, we'll write here (for files or pipes) HANDLE hmapout; // otherwise, we'll write here (for memmap) unsigned ooffset; // for hfout, this is where the pointer was initially ZRESULT oerr; // did a write operation give rise to an error? unsigned writ; // how far have we written. This is maintained by Add, not write(), to avoid confusion over seeks bool ocanseek; // can we seek? char *obuf; // this is where we've locked mmap to view. unsigned int opos; // current pos in the mmap unsigned int mapsize; // the size of the map we created bool hasputcen; // have we yet placed the central directory? // TZipFileInfo *zfis; // each file gets added onto this list, for writing the table at the end ZRESULT Create(void *z, unsigned int len, DWORD flags); static unsigned sflush(void *param, const char *buf, unsigned *size); static unsigned swrite(void *param, const char *buf, unsigned size); unsigned int write(const char *buf, unsigned int size); bool oseek(unsigned int pos); ZRESULT GetMemory(void **pbuf, unsigned long *plen); ZRESULT Close(); // some variables to do with the file currently being read: // I haven't done it object-orientedly here, just put them all // together, since OO didn't seem to make the design any clearer. ulg attr; iztimes times; ulg timestamp; // all open_* methods set these bool iseekable; long isize, ired; // size is not set until close() on pips ulg crc; // crc is not set until close(). iwrit is cumulative HANDLE hfin; bool selfclosehf; // for input files and pipes const char *bufin; unsigned int lenin, posin; // for memory // and a variable for what we've done with the input: (i.e. compressed it!) ulg csize; // compressed size, set by the compression routines // and this is used by some of the compression routines char buf[16384]; ZRESULT open_file(const TCHAR *fn); ZRESULT open_handle(HANDLE hf, unsigned int len); ZRESULT open_mem(void *src, unsigned int len); ZRESULT open_dir(); static unsigned sread(TState &s, char *buf, unsigned size); unsigned read(char *buf, unsigned size); ZRESULT iclose(); ZRESULT ideflate(TZipFileInfo *zfi); ZRESULT istore(); ZRESULT Add(const char *odstzn, void *src, unsigned int len, DWORD flags); ZRESULT AddCentral(); }; ZRESULT TZip::Create(void *z, unsigned int len, DWORD flags) { if (hfout != 0 || hmapout != 0 || obuf != 0 || writ != 0 || oerr != ZR_OK || hasputcen) return ZR_NOTINITED; // if (flags == ZIP_HANDLE) { HANDLE hf = (HANDLE)z; BOOL res = DuplicateHandle(GetCurrentProcess(), hf, GetCurrentProcess(), &hfout, 0, FALSE, DUPLICATE_SAME_ACCESS); if (!res) return ZR_NODUPH; // now we have our own hfout, which we must close. And the caller will close hf DWORD type = GetFileType(hfout); ocanseek = (type == FILE_TYPE_DISK); if (type == FILE_TYPE_DISK) ooffset = SetFilePointer(hfout, 0, NULL, FILE_CURRENT); else ooffset = 0; return ZR_OK; } else if (flags == ZIP_FILENAME) { #ifdef _UNICODE const TCHAR *fn = (const TCHAR*)z; hfout = CreateFileW(fn, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); #else const char *fn = (const char*)z; hfout = CreateFileA(fn, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); #endif if (hfout == INVALID_HANDLE_VALUE) { hfout = 0; return ZR_NOFILE; } ocanseek = true; ooffset = 0; return ZR_OK; } else if (flags == ZIP_MEMORY) { unsigned int size = len; if (size == 0) return ZR_MEMSIZE; if (z != 0) obuf = (char*)z; else { hmapout = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, NULL); if (hmapout == NULL) return ZR_NOALLOC; obuf = (char*)MapViewOfFile(hmapout, FILE_MAP_ALL_ACCESS, 0, 0, size); if (obuf == 0) { CloseHandle(hmapout); hmapout = 0; return ZR_NOALLOC; } } ocanseek = true; opos = 0; mapsize = size; return ZR_OK; } else return ZR_ARGS; } unsigned TZip::sflush(void *param, const char *buf, unsigned *size) { // static if (*size == 0) return 0; TZip *zip = (TZip*)param; unsigned int writ = zip->write(buf, *size); if (writ != 0) *size = 0; return writ; } unsigned TZip::swrite(void *param, const char *buf, unsigned size) { // static if (size == 0) return 0; TZip *zip = (TZip*)param; return zip->write(buf, size); } #if 0 // ----------------------------------------------------------- unsigned int TZip::write(const char *buf, unsigned int size) { if (obuf != 0) { if (opos + size >= mapsize) { oerr = ZR_MEMSIZE; return 0; } memcpy(obuf + opos, buf, size); opos += size; return size; } else if (hfout != 0) { DWORD writ; WriteFile(hfout, buf, size, &writ, NULL); return writ; } oerr = ZR_NOTINITED; return 0; } #endif // ----------------------------------------------------------- //+++1.2 unsigned int TZip::write(const char *buf, unsigned int size) { if (obuf != 0) { if (opos + size >= mapsize) { int newmapsize = 2 * mapsize>opos + size ? 2 * mapsize : opos + size; HANDLE hmapout2 = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, newmapsize, NULL); if (hmapout2 == NULL) return ZR_NOALLOC; char *obuf2 = NULL; // this is where we've locked mmap to view. obuf2 = (char*)MapViewOfFile(hmapout2, FILE_MAP_ALL_ACCESS, 0, 0, newmapsize); if (obuf2 == 0) { CloseHandle(hmapout2); hmapout2 = 0; return ZR_NOALLOC; } memcpy(obuf2, obuf, mapsize); UnmapViewOfFile(obuf); CloseHandle(hmapout); mapsize = newmapsize; obuf = obuf2; hmapout = hmapout2; } memcpy(obuf + opos, buf, size); opos += size; return size; } else if (hfout != 0) { DWORD writ = 0; WriteFile(hfout, buf, size, &writ, NULL); return writ; } oerr = ZR_NOTINITED; return 0; } bool TZip::oseek(unsigned int pos) { if (!ocanseek) { oerr = ZR_SEEK; return false; } if (obuf != 0) { if (pos >= mapsize) { oerr = ZR_MEMSIZE; return false; } opos = pos; return true; } else if (hfout != 0) { SetFilePointer(hfout, pos + ooffset, NULL, FILE_BEGIN); return true; } oerr = ZR_NOTINITED; return 0; } ZRESULT TZip::GetMemory(void **pbuf, unsigned long *plen) { // When the user calls GetMemory, they're presumably at the end // of all their adding. In any case, we have to add the central // directory now, otherwise the memory we tell them won't be complete. if (!hasputcen) AddCentral(); hasputcen = true; if (pbuf != NULL) *pbuf = (void*)obuf; if (plen != NULL) *plen = writ; if (obuf == NULL) return ZR_NOTMMAP; return ZR_OK; } ZRESULT TZip::Close() { // if the directory hadn't already been added through a call to GetMemory, // then we do it now ZRESULT res = ZR_OK; if (!hasputcen) res = AddCentral(); hasputcen = true; if (obuf != 0 && hmapout != 0) UnmapViewOfFile(obuf); obuf = 0; if (hmapout != 0) CloseHandle(hmapout); hmapout = 0; if (hfout != 0) CloseHandle(hfout); hfout = 0; return res; } ZRESULT TZip::open_file(const TCHAR *fn) { hfin = 0; bufin = 0; selfclosehf = false; crc = CRCVAL_INITIAL; isize = 0; csize = 0; ired = 0; if (fn == 0) return ZR_ARGS; HANDLE hf = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hf == INVALID_HANDLE_VALUE) return ZR_NOFILE; ZRESULT res = open_handle(hf, 0); if (res != ZR_OK) { CloseHandle(hf); return res; } selfclosehf = true; return ZR_OK; } ZRESULT TZip::open_handle(HANDLE hf, unsigned int len) { hfin = 0; bufin = 0; selfclosehf = false; crc = CRCVAL_INITIAL; isize = 0; csize = 0; ired = 0; if (hf == 0 || hf == INVALID_HANDLE_VALUE) return ZR_ARGS; DWORD type = GetFileType(hf); if (type == FILE_TYPE_DISK) { ZRESULT res = GetFileInfo(hf, &attr, &isize, &times, &timestamp); if (res != ZR_OK) return res; SetFilePointer(hf, 0, NULL, FILE_BEGIN); // because GetFileInfo will have screwed it up iseekable = true; hfin = hf; return ZR_OK; } else { attr = 0x80000000; // just a normal file isize = -1; // can't know size until at the end if (len != 0) isize = len; // unless we were told explicitly! iseekable = false; SYSTEMTIME st; GetLocalTime(&st); FILETIME ft; SystemTimeToFileTime(&st, &ft); WORD dosdate, dostime; FileTimeToDosDateTime(&ft, &dosdate, &dostime); times.atime = filetime2timet(ft); times.mtime = times.atime; times.ctime = times.atime; timestamp = (WORD)dostime | (((DWORD)dosdate) << 16); hfin = hf; return ZR_OK; } } ZRESULT TZip::open_mem(void *src, unsigned int len) { hfin = 0; bufin = (const char*)src; selfclosehf = false; crc = CRCVAL_INITIAL; ired = 0; csize = 0; ired = 0; lenin = len; posin = 0; if (src == 0 || len == 0) return ZR_ARGS; attr = 0x80000000; // just a normal file isize = len; iseekable = true; SYSTEMTIME st; GetLocalTime(&st); FILETIME ft; SystemTimeToFileTime(&st, &ft); WORD dosdate, dostime; FileTimeToDosDateTime(&ft, &dosdate, &dostime); times.atime = filetime2timet(ft); times.mtime = times.atime; times.ctime = times.atime; timestamp = (WORD)dostime | (((DWORD)dosdate) << 16); return ZR_OK; } ZRESULT TZip::open_dir() { hfin = 0; bufin = 0; selfclosehf = false; crc = CRCVAL_INITIAL; isize = 0; csize = 0; ired = 0; attr = 0x41C00010; // a readable writable directory, and again directory isize = 0; iseekable = false; SYSTEMTIME st; GetLocalTime(&st); FILETIME ft; SystemTimeToFileTime(&st, &ft); WORD dosdate, dostime; FileTimeToDosDateTime(&ft, &dosdate, &dostime); times.atime = filetime2timet(ft); times.mtime = times.atime; times.ctime = times.atime; timestamp = (WORD)dostime | (((DWORD)dosdate) << 16); return ZR_OK; } unsigned TZip::sread(TState &s, char *buf, unsigned size) { // static TZip *zip = (TZip*)s.param; return zip->read(buf, size); } unsigned TZip::read(char *buf, unsigned size) { if (bufin != 0) { if (posin >= lenin) return 0; // end of input ulg red = lenin - posin; if (red>size) red = size; memcpy(buf, bufin + posin, red); posin += red; ired += red; crc = crc32(crc, (uch*)buf, red); return red; } else if (hfin != 0) { DWORD red; BOOL ok = ReadFile(hfin, buf, size, &red, NULL); if (!ok) return 0; ired += red; crc = crc32(crc, (uch*)buf, red); return red; } else { oerr = ZR_NOTINITED; return 0; } } ZRESULT TZip::iclose() { if (selfclosehf && hfin != 0) CloseHandle(hfin); hfin = 0; bool mismatch = (isize != -1 && isize != ired); isize = ired; // and crc has been being updated anyway if (mismatch) return ZR_MISSIZE; else return ZR_OK; } #if 0 // ----------------------------------------------------------- ZRESULT TZip::ideflate(TZipFileInfo *zfi) { TState state; state.readfunc = sread; state.flush_outbuf = sflush; state.param = this; state.level = 8; state.seekable = iseekable; state.err = NULL; // the following line will make ct_init realise it has to perform the init state.ts.static_dtree[0].dl.len = 0; // It would be nicer if I could figure out precisely which data had to // be initted each time, and which didn't, but that's kind of difficult. // Maybe for the next version... // bi_init(state, buf, sizeof(buf), TRUE); // it used to be just 1024-size, not 16384 as here ct_init(state, &zfi->att); lm_init(state, state.level, &zfi->flg); ulg sz = deflate(state); csize = sz; if (state.err != NULL) return ZR_FLATE; else return ZR_OK; } #endif // ----------------------------------------------------------- //+++1.2 // create state object on heap ZRESULT TZip::ideflate(TZipFileInfo *zfi) { ZRESULT zr = ZR_OK; TState* state = new TState(); (*state).readfunc = sread; (*state).flush_outbuf = sflush; (*state).param = this; (*state).level = 8; (*state).seekable = iseekable; (*state).err = NULL; // the following line will make ct_init realise it has to perform the init (*state).ts.static_dtree[0].dl.len = 0; // It would be nicer if I could figure out precisely which data had to // be initted each time, and which didn't, but that's kind of difficult. // Maybe for the next version... // bi_init(*state, buf, sizeof(buf), TRUE); // it used to be just 1024-size, not 16384 as here ct_init(*state, &zfi->att); lm_init(*state, (*state).level, &zfi->flg); ulg sz = deflate(*state); csize = sz; if ((*state).err != NULL) { zr = ZR_FLATE; } delete state; return zr; } ZRESULT TZip::istore() { ulg size = 0; for (;;) { unsigned int cin = read(buf, 16384); if (cin <= 0 || cin == (unsigned int)EOF) break; unsigned int cout = write(buf, cin); if (cout != cin) return ZR_MISSIZE; size += cin; } csize = size; return ZR_OK; } ZRESULT TZip::Add(const char *odstzn, void *src, unsigned int len, DWORD flags) { if (oerr) return ZR_FAILED; if (hasputcen) return ZR_ENDED; // zip has its own notion of what its names should look like: i.e. dir/file.stuff char dstzn[MAX_PATH]; strcpy(dstzn, odstzn); if (*dstzn == 0) return ZR_ARGS; char *d = dstzn; while (*d != 0) { if (*d == '\\') *d = '/'; d++; } bool isdir = (flags == ZIP_FOLDER); bool needs_trailing_slash = (isdir && dstzn[strlen(dstzn) - 1] != '/'); int method = DEFLATE; if (isdir || HasZipSuffix(dstzn)) method = STORE; // now open whatever was our input source: ZRESULT openres; if (flags == ZIP_FILENAME) openres = open_file((const TCHAR*)src); else if (flags == ZIP_HANDLE) openres = open_handle((HANDLE)src, len); else if (flags == ZIP_MEMORY) openres = open_mem(src, len); else if (flags == ZIP_FOLDER) openres = open_dir(); else return ZR_ARGS; if (openres != ZR_OK) return openres; // A zip "entry" consists of a local header (which includes the file name), // then the compressed data, and possibly an extended local header. // Initialize the local header TZipFileInfo zfi; zfi.nxt = NULL; strcpy(zfi.name, ""); strcpy(zfi.iname, dstzn); zfi.nam = strlen(zfi.iname); if (needs_trailing_slash) { strcat(zfi.iname, "/"); zfi.nam++; } strcpy(zfi.zname, ""); zfi.extra = NULL; zfi.ext = 0; // extra header to go after this compressed data, and its length zfi.cextra = NULL; zfi.cext = 0; // extra header to go in the central end-of-zip directory, and its length zfi.comment = NULL; zfi.com = 0; // comment, and its length zfi.mark = 1; zfi.dosflag = 0; zfi.att = (ush)BINARY; zfi.vem = (ush)0xB17; // 0xB00 is win32 os-code. 0x17 is 23 in decimal: zip 2.3 zfi.ver = (ush)20; // Needs PKUNZIP 2.0 to unzip it zfi.tim = timestamp; // Even though we write the header now, it will have to be rewritten, since we don't know compressed size or crc. zfi.crc = 0; // to be updated later zfi.flg = 8; // 8 means 'there is an extra header'. Assume for the moment that we need it. zfi.lflg = zfi.flg; // to be updated later zfi.how = (ush)method; // to be updated later zfi.siz = (ulg)(method == STORE && isize >= 0 ? isize : 0); // to be updated later zfi.len = (ulg)(isize); // to be updated later zfi.dsk = 0; zfi.atx = attr; zfi.off = writ + ooffset; // offset within file of the start of this local record // stuff the 'times' structure into zfi.extra char xloc[EB_L_UT_SIZE]; zfi.extra = xloc; zfi.ext = EB_L_UT_SIZE; char xcen[EB_C_UT_SIZE]; zfi.cextra = xcen; zfi.cext = EB_C_UT_SIZE; xloc[0] = 'U'; xloc[1] = 'T'; xloc[2] = EB_UT_LEN(3); // length of data part of e.f. xloc[3] = 0; xloc[4] = EB_UT_FL_MTIME | EB_UT_FL_ATIME | EB_UT_FL_CTIME; xloc[5] = (char)(times.mtime); xloc[6] = (char)(times.mtime >> 8); xloc[7] = (char)(times.mtime >> 16); xloc[8] = (char)(times.mtime >> 24); xloc[9] = (char)(times.atime); xloc[10] = (char)(times.atime >> 8); xloc[11] = (char)(times.atime >> 16); xloc[12] = (char)(times.atime >> 24); xloc[13] = (char)(times.ctime); xloc[14] = (char)(times.ctime >> 8); xloc[15] = (char)(times.ctime >> 16); xloc[16] = (char)(times.ctime >> 24); memcpy(zfi.cextra, zfi.extra, EB_C_UT_SIZE); zfi.cextra[EB_LEN] = EB_UT_LEN(1); // (1) Start by writing the local header: int r = putlocal(&zfi, swrite, this); if (r != ZE_OK) { iclose(); return ZR_WRITE; } writ += 4 + LOCHEAD + (unsigned int)zfi.nam + (unsigned int)zfi.ext; if (oerr != ZR_OK) { iclose(); return oerr; } //(2) Write deflated/stored file to zip file ZRESULT writeres = ZR_OK; if (!isdir && method == DEFLATE) writeres = ideflate(&zfi); else if (!isdir && method == STORE) writeres = istore(); else if (isdir) csize = 0; iclose(); writ += csize; if (oerr != ZR_OK) return oerr; if (writeres != ZR_OK) return ZR_WRITE; // (3) Either rewrite the local header with correct information... bool first_header_has_size_right = (zfi.siz == csize); zfi.crc = crc; zfi.siz = csize; zfi.len = isize; if (ocanseek) { zfi.how = (ush)method; if ((zfi.flg & 1) == 0) zfi.flg &= ~8; // clear the extended local header flag zfi.lflg = zfi.flg; // rewrite the local header: if (!oseek(zfi.off - ooffset)) return ZR_SEEK; if ((r = putlocal(&zfi, swrite, this)) != ZE_OK) return ZR_WRITE; if (!oseek(writ)) return ZR_SEEK; } else { // (4) ... or put an updated header at the end if (zfi.how != (ush)method) return ZR_NOCHANGE; if (method == STORE && !first_header_has_size_right) return ZR_NOCHANGE; if ((r = putextended(&zfi, swrite, this)) != ZE_OK) return ZR_WRITE; writ += 16L; zfi.flg = zfi.lflg; // if flg modified by inflate, for the central index } if (oerr != ZR_OK) return oerr; // Keep a copy of the zipfileinfo, for our end-of-zip directory char *cextra = new char[zfi.cext]; memcpy(cextra, zfi.cextra, zfi.cext); zfi.cextra = cextra; TZipFileInfo *pzfi = new TZipFileInfo; memcpy(pzfi, &zfi, sizeof(zfi)); if (zfis == NULL) zfis = pzfi; else { TZipFileInfo *z = zfis; while (z->nxt != NULL) z = z->nxt; z->nxt = pzfi; } return ZR_OK; } ZRESULT TZip::AddCentral() { // write central directory int numentries = 0; ulg pos_at_start_of_central = writ; //ulg tot_unc_size=0, tot_compressed_size=0; bool okay = true; for (TZipFileInfo *zfi = zfis; zfi != NULL;) { if (okay) { int res = putcentral(zfi, swrite, this); if (res != ZE_OK) okay = false; } writ += 4 + CENHEAD + (unsigned int)zfi->nam + (unsigned int)zfi->cext + (unsigned int)zfi->com; //tot_unc_size += zfi->len; //tot_compressed_size += zfi->siz; numentries++; // TZipFileInfo *zfinext = zfi->nxt; if (zfi->cextra != 0) delete[] zfi->cextra; delete zfi; zfi = zfinext; } ulg center_size = writ - pos_at_start_of_central; if (okay) { int res = putend(numentries, center_size, pos_at_start_of_central + ooffset, 0, NULL, swrite, this); if (res != ZE_OK) okay = false; writ += 4 + ENDHEAD + 0; } if (!okay) return ZR_WRITE; return ZR_OK; } ZRESULT lasterrorZ = ZR_OK; unsigned int FormatZipMessageZ(ZRESULT code, char *buf, unsigned int len) { if (code == ZR_RECENT) code = lasterrorZ; const char *msg = "unknown zip result code"; switch (code) { case ZR_OK: msg = "Success"; break; case ZR_NODUPH: msg = "Culdn't duplicate handle"; break; case ZR_NOFILE: msg = "Couldn't create/open file"; break; case ZR_NOALLOC: msg = "Failed to allocate memory"; break; case ZR_WRITE: msg = "Error writing to file"; break; case ZR_NOTFOUND: msg = "File not found in the zipfile"; break; case ZR_MORE: msg = "Still more data to unzip"; break; case ZR_CORRUPT: msg = "Zipfile is corrupt or not a zipfile"; break; case ZR_READ: msg = "Error reading file"; break; case ZR_ARGS: msg = "Caller: faulty arguments"; break; case ZR_PARTIALUNZ: msg = "Caller: the file had already been partially unzipped"; break; case ZR_NOTMMAP: msg = "Caller: can only get memory of a memory zipfile"; break; case ZR_MEMSIZE: msg = "Caller: not enough space allocated for memory zipfile"; break; case ZR_FAILED: msg = "Caller: there was a previous error"; break; case ZR_ENDED: msg = "Caller: additions to the zip have already been ended"; break; case ZR_ZMODE: msg = "Caller: mixing creation and opening of zip"; break; case ZR_NOTINITED: msg = "Zip-bug: internal initialisation not completed"; break; case ZR_SEEK: msg = "Zip-bug: trying to seek the unseekable"; break; case ZR_MISSIZE: msg = "Zip-bug: the anticipated size turned out wrong"; break; case ZR_NOCHANGE: msg = "Zip-bug: tried to change mind, but not allowed"; break; case ZR_FLATE: msg = "Zip-bug: an internal error during flation"; break; } unsigned int mlen = (unsigned int)strlen(msg); if (buf == 0 || len == 0) return mlen; unsigned int n = mlen; if (n + 1>len) n = len - 1; strncpy(buf, msg, n); buf[n] = 0; return mlen; } typedef struct { DWORD flag; TZip *zip; } TZipHandleData; HZIP CreateZipZ(void *z, unsigned int len, DWORD flags) { tzset(); TZip *zip = new TZip(); lasterrorZ = zip->Create(z, len, flags); if (lasterrorZ != ZR_OK) { delete zip; return 0; } TZipHandleData *han = new TZipHandleData; han->flag = 2; han->zip = zip; return (HZIP)han; } ZRESULT ZipAdd(HZIP hz, const CHAR *dstzn, void *src, unsigned int len, DWORD flags) { if (hz == 0) { lasterrorZ = ZR_ARGS; return ZR_ARGS; } TZipHandleData *han = (TZipHandleData*)hz; if (han->flag != 2) { lasterrorZ = ZR_ZMODE; return ZR_ZMODE; } TZip *zip = han->zip; char szDest[MAX_PATH * 2]; memset(szDest, 0, sizeof(szDest)); strcpy(szDest, dstzn); if (flags == ZIP_FILENAME) { lasterrorZ = zip->Add(szDest, src, len, flags); } else { lasterrorZ = zip->Add(szDest, src, len, flags); } return lasterrorZ; } ZRESULT ZipGetMemory(HZIP hz, void **buf, unsigned long *len) { if (hz == 0) { if (buf != 0) *buf = 0; if (len != 0) *len = 0; lasterrorZ = ZR_ARGS; return ZR_ARGS; } TZipHandleData *han = (TZipHandleData*)hz; if (han->flag != 2) { lasterrorZ = ZR_ZMODE; return ZR_ZMODE; } TZip *zip = han->zip; lasterrorZ = zip->GetMemory(buf, len); return lasterrorZ; } ZRESULT CloseZipZ(HZIP hz) { if (hz == 0) { lasterrorZ = ZR_ARGS; return ZR_ARGS; } TZipHandleData *han = (TZipHandleData*)hz; if (han->flag != 2) { lasterrorZ = ZR_ZMODE; return ZR_ZMODE; } TZip *zip = han->zip; lasterrorZ = zip->Close(); delete zip; delete han; return lasterrorZ; } bool IsZipHandleZ(HZIP hz) { if (hz == 0) return true; TZipHandleData *han = (TZipHandleData*)hz; return (han->flag == 2); } //+++1.2 /** * Added by Renaud Deysine. This fonctionnality was missing in API * @brief Add a folder to the zip file. Empty folders will also be added. * This method add recursively the content of a directory * @param AbsolutePath like "C:\\Windows" or "C:\\Windows\" * @param DirToAdd like "System32" * */ BOOL AddFolderContent(HZIP hZip, CHAR* AbsolutePath, CHAR* DirToAdd) { HANDLE hFind; // file handle WIN32_FIND_DATAA FindFileData; CHAR PathToSearchInto[MAX_PATH] = { 0 }; if (NULL != DirToAdd) { ZipAdd(hZip, DirToAdd, 0, 0, ZIP_FOLDER); } // Construct the path to search into "C:\\Windows\\System32\\*" strcpy(PathToSearchInto, AbsolutePath); strcat(PathToSearchInto, "\\"); strcat(PathToSearchInto, DirToAdd); strcat(PathToSearchInto, "\\*"); hFind = FindFirstFileA(PathToSearchInto, &FindFileData); // find the first file if (hFind == INVALID_HANDLE_VALUE) { return FALSE; } bool bSearch = true; while (bSearch) // until we finds an entry { if (FindNextFileA(hFind, &FindFileData)) { // Don't care about . and .. //if(IsDots(FindFileData.cFileName)) if ((strcmp(FindFileData.cFileName, ".") == 0) || (strcmp(FindFileData.cFileName, "..") == 0)) continue; // We have found a directory if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { CHAR RelativePathNewDirFound[MAX_PATH] = { 0 }; strcat(RelativePathNewDirFound, DirToAdd); strcat(RelativePathNewDirFound, "\\"); strcat(RelativePathNewDirFound, FindFileData.cFileName); // Recursive call with the new directory found if (AddFolderContent(hZip, AbsolutePath, RelativePathNewDirFound) == FALSE) { return FALSE; } } // We have found a file else { // Add the found file to the zip file CHAR RelativePathNewFileFound[MAX_PATH] = { 0 }; strcpy(RelativePathNewFileFound, AbsolutePath); strcat(RelativePathNewFileFound, DirToAdd); strcat(RelativePathNewFileFound, "\\"); strcat(RelativePathNewFileFound, FindFileData.cFileName); if (ZipAdd(hZip, RelativePathNewFileFound + strlen(AbsolutePath), RelativePathNewFileFound, 0, ZIP_FILENAME) != ZR_OK) { return FALSE; } } }//FindNextFile else { if (GetLastError() == ERROR_NO_MORE_FILES) // no more files there bSearch = false; else { // some error occured, close the handle and return FALSE FindClose(hFind); return FALSE; } } }//while FindClose(hFind); // closing file handle return true; } } }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/compress/xzip/XZip.h
C/C++ Header
// XZip.h Version 1.3 #pragma once namespace Plugin { namespace XZip { #ifndef XZIP_H #define XZIP_H // ZIP functions -- for creating zip files // This file is a repackaged form of the Info-Zip source code available // at www.info-zip.org. The original copyright notice may be found in // zip.cpp. The repackaging was done by Lucian Wischik to simplify its // use in Windows/C++. #ifndef XUNZIP_H DECLARE_HANDLE(HZIP); // An HZIP identifies a zip file that is being created #endif typedef DWORD ZRESULT; // result codes from any of the zip functions. Listed later. // flag values passed to some functions #define ZIP_HANDLE 1 #define ZIP_FILENAME 2 #define ZIP_MEMORY 3 #define ZIP_FOLDER 4 /////////////////////////////////////////////////////////////////////////////// // // CreateZip() // // Purpose: Create a zip archive file // // Parameters: z - archive file name if flags is ZIP_FILENAME; for other // uses see below // len - for memory (ZIP_MEMORY) should be the buffer size; // for other uses, should be 0 // flags - indicates usage, see below; for files, this will be // ZIP_FILENAME // // Returns: HZIP - non-zero if zip archive created ok, otherwise 0 // HZIP CreateZip(void *z, unsigned int len, DWORD flags); // CreateZip - call this to start the creation of a zip file. // As the zip is being created, it will be stored somewhere: // to a pipe: CreateZip(hpipe_write, 0,ZIP_HANDLE); // in a file (by handle): CreateZip(hfile, 0,ZIP_HANDLE); // in a file (by name): CreateZip("c:\\test.zip", 0,ZIP_FILENAME); // in memory: CreateZip(buf, len,ZIP_MEMORY); // or in pagefile memory: CreateZip(0, len,ZIP_MEMORY); /////////////////////////////////////////////////////////////////////////////// // // ZipAdd() // // Purpose: Add a file to a zip archive // // Parameters: hz - handle to an open zip archive // dstzn - name used inside the zip archive to identify the file // src - for a file (ZIP_FILENAME) this specifies the filename // to be added to the archive; for other uses, see below // len - for memory (ZIP_MEMORY) this specifies the buffer // length; for other uses, this should be 0 // flags - indicates usage, see below; for files, this will be // ZIP_FILENAME // // Returns: ZRESULT - ZR_OK if success, otherwise some other value // ZRESULT ZipAdd(HZIP hz, const CHAR *dstzn, void *src, unsigned int len, DWORD flags); /////////////////////////////////////////////////////////////////////////////// // // CloseZip() // // Purpose: Close an open zip archive // // Parameters: hz - handle to an open zip archive // // Returns: ZRESULT - ZR_OK if success, otherwise some other value // ZRESULT CloseZip(HZIP hz); // CloseZip - the zip handle must be closed with this function. ZRESULT ZipGetMemory(HZIP hz, void **buf, unsigned long *len); // ZipGetMemory - If the zip was created in memory, via ZipCreate(0,ZIP_MEMORY), // then this function will return information about that memory block. // buf will receive a pointer to its start, and len its length. // Note: you can't add any more after calling this. unsigned int FormatZipMessage(ZRESULT code, char *buf, unsigned int len); // FormatZipMessage - given an error code, formats it as a string. // It returns the length of the error message. If buf/len points // to a real buffer, then it also writes as much as possible into there. // These are the result codes: #define ZR_OK 0x00000000 // nb. the pseudo-code zr-recent is never returned, #define ZR_RECENT 0x00000001 // but can be passed to FormatZipMessage. // The following come from general system stuff (e.g. files not openable) #define ZR_GENMASK 0x0000FF00 #define ZR_NODUPH 0x00000100 // couldn't duplicate the handle #define ZR_NOFILE 0x00000200 // couldn't create/open the file #define ZR_NOALLOC 0x00000300 // failed to allocate some resource #define ZR_WRITE 0x00000400 // a general error writing to the file #define ZR_NOTFOUND 0x00000500 // couldn't find that file in the zip #define ZR_MORE 0x00000600 // there's still more data to be unzipped #define ZR_CORRUPT 0x00000700 // the zipfile is corrupt or not a zipfile #define ZR_READ 0x00000800 // a general error reading the file // The following come from mistakes on the part of the caller #define ZR_CALLERMASK 0x00FF0000 #define ZR_ARGS 0x00010000 // general mistake with the arguments #define ZR_NOTMMAP 0x00020000 // tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't #define ZR_MEMSIZE 0x00030000 // the memory size is too small #define ZR_FAILED 0x00040000 // the thing was already failed when you called this function #define ZR_ENDED 0x00050000 // the zip creation has already been closed #define ZR_MISSIZE 0x00060000 // the indicated input file size turned out mistaken #define ZR_PARTIALUNZ 0x00070000 // the file had already been partially unzipped #define ZR_ZMODE 0x00080000 // tried to mix creating/opening a zip // The following come from bugs within the zip library itself #define ZR_BUGMASK 0xFF000000 #define ZR_NOTINITED 0x01000000 // initialisation didn't work #define ZR_SEEK 0x02000000 // trying to seek in an unseekable file #define ZR_NOCHANGE 0x04000000 // changed its mind on storage, but not allowed #define ZR_FLATE 0x05000000 // an internal error in the de/inflation code // Now we indulge in a little skullduggery so that the code works whether // the user has included just zip or both zip and unzip. // Idea: if header files for both zip and unzip are present, then presumably // the cpp files for zip and unzip are both present, so we will call // one or the other of them based on a dynamic choice. If the header file // for only one is present, then we will bind to that particular one. HZIP CreateZipZ(void *z, unsigned int len, DWORD flags); ZRESULT CloseZipZ(HZIP hz); unsigned int FormatZipMessageZ(ZRESULT code, char *buf, unsigned int len); bool IsZipHandleZ(HZIP hz); BOOL AddFolderContent(HZIP hZip, CHAR* AbsolutePath, CHAR* DirToAdd); #define CreateZip CreateZipZ #ifdef XUNZIP_H #undef CloseZip #define CloseZip(hz) (IsZipHandleZ(hz)?CloseZipZ(hz):CloseZipU(hz)) #else #define CloseZip CloseZipZ #define FormatZipMessage FormatZipMessageZ #endif #endif //XZIP_H } } using namespace Plugin::XZip;
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/compress/zip_utils.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "zip_utils.h" #include "xzip/XUnzip.h" #include "xzip/XZip.h" namespace Plugin { namespace Compressor { bool ZipUtils::UnpackToDir(const std::string& zip_path, WRAPPER_TYPE wrapper_type, const std::string& out_dir) { bool result = true; #ifdef _UNICODE auto wzip_path = UNONE::StrToW(zip_path); HZIP h_zip = OpenZip((void*)wzip_path.c_str(), 0, ZIP_FILENAME); #else HZIP h_zip = OpenZip((void*)zip_path.c_str(), 0, ZIP_FILENAME); #endif if (h_zip == NULL) { int x = lasterrorU; printf("Open zip:%s err:%d", zip_path.c_str(), lasterrorU); return false; } ZIPENTRY ze; unsigned long ret = 0; for (int index=0; ret==0; index++) { ret = GetZipItemA(h_zip, index, &ze); if (ret == 0) { std::string name = ze.name; if (wrapper_type == UNPACK_SUBDIR) { auto pos = name.find("/"); if (pos != std::string::npos) { name = name.substr(pos+1); } } if (name.empty()) { continue; } std::string&& path = UNONE::FsPathComposeA(out_dir, name); if (ze.attr & FILE_ATTRIBUTE_DIRECTORY) { UNONE::FsCreateDirA(path); continue; } UNONE::FsCreateDirA(UNONE::FsPathToDirA(path)); #ifdef _UNICODE auto wpath = UNONE::StrToW(path); if (UnzipItem(h_zip, index, (void*)wpath.c_str(), 0, ZIP_FILENAME) != 0) { #else if (UnzipItem(h_zip, index, (void*)path.c_str(), 0, ZIP_FILENAME) != 0) { #endif printf("UnzipItem %s to dir:%s err:%d", ze.name, out_dir.c_str(), lasterrorU); result = false; break; } result = true; } } CloseZip(h_zip); return result; } bool ZipUtils::PackDir(const std::string& dir, WRAPPER_TYPE wrapper_type, const std::string& zip_path) { if (!UNONE::FsIsExistedA(dir)) { printf("Dir:%s not existed", dir.c_str()); return false; } #ifdef _UNICODE auto wzip_path = UNONE::StrToW(zip_path); HZIP h_zip = CreateZip((void *)wzip_path.c_str(), 0, ZIP_FILENAME); #else HZIP h_zip = CreateZip((void *)zip_path.c_str(), 0, ZIP_FILENAME); #endif if(h_zip == NULL) { printf("Create zip_path:%s failed, error %d", zip_path.c_str(), lasterrorU); return false; } bool result = true; std::vector<std::string> path_vec; std::string std_dir = UNONE::FsPathStandardA(dir); UNONE::DirEnumCallbackA fcb = [&](__in char* path, __in char* name, __in void* param)->bool { if (UNONE::FsIsDirA(path)) { UNONE::FsEnumDirectoryA(path, fcb, param);; } auto& path_vec = *reinterpret_cast<std::vector<std::string>*>(param); path_vec.push_back(path); return true; }; UNONE::FsEnumDirectoryA(std_dir, fcb, &path_vec); if (wrapper_type == PACK_CURRENT) { std_dir = UNONE::FsPathToDirA(std_dir); } std_dir.append("\\"); for (size_t i = 0; i < path_vec.size(); i++) { ZRESULT zip_ret = 0; const std::string& path = path_vec[i]; std::string rel_name = path; UNONE::StrReplaceA(rel_name, std_dir, ""); auto flag = ZIP_FILENAME; if (UNONE::FsIsDirA(path)) { flag = ZIP_FOLDER; } #ifdef _UNICODE auto wpath = UNONE::StrToW(path); zip_ret = ZipAdd(h_zip, rel_name.c_str(), (void*)wpath.c_str(), 0, flag); #else zip_ret = ZipAdd(h_zip, rel_name.c_str(), (void*)path.c_str(), 0, flag); #endif if (zip_ret != ZR_OK) { printf("ZipAdd file:%s err:%d", path.c_str(), lasterrorU); result = false; break; } } CloseZip(h_zip); if (!result) { DeleteFileA(zip_path.c_str()); } return result; } bool ZipUtils::PackFile(const std::string& file, const std::string& zip_path) { bool result = true; if (!UNONE::FsIsExistedA(file)) { printf("File:%s not exsited", file.c_str()); return false; } #ifdef _UNICODE auto wzip_path = UNONE::StrToW(zip_path); HZIP h_zip = CreateZip((void *)wzip_path.c_str(), 0, ZIP_FILENAME); #else HZIP h_zip = CreateZip((void *)zip_path.c_str(), 0, ZIP_FILENAME); #endif if(h_zip == NULL) { printf("Create zip_path:%s err:%d", zip_path.c_str(), lasterrorU); return false; } ZRESULT zip_ret = 0; std::string&& rel_name = UNONE::FsPathToNameA(file); #ifdef _UNICODE auto wpath = UNONE::StrToW(file); zip_ret = ZipAdd(h_zip, rel_name.c_str(), (void*)wpath.c_str(), 0, ZIP_FILENAME); #else zip_ret = ZipAdd(h_zip, rel_name.c_str(), (void*)file.c_str(), 0, ZIP_FILENAME); #endif if (zip_ret != ZR_OK) { result = false; } CloseZip(h_zip); if (!result) { DeleteFileA(zip_path.c_str()); } return result; } } //namespace Compressor } //namespace Plugin
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/compress/zip_utils.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <string> #include <unone.h> namespace Plugin { namespace Compressor { class ZipUtils { public: enum WRAPPER_TYPE { UNPACK_CURRENT, //uncompress to / UNPACK_SUBDIR, //uncompress to /sub-dir PACK_CURRENT, //compress / PACK_SUBDIR, //compress /sub-dir }; static bool UnpackToDir(const std::string& zip_path, WRAPPER_TYPE wrapper_type, const std::string& out_dir); static bool PackDir(const std::string& dir, WRAPPER_TYPE wrapper_type, const std::string& zip_path); static bool PackFile(const std::string& file, const std::string& zip_path); public: ZipUtils(){}; ~ZipUtils(){}; }; } //namespace Compressor } //namespace Plugin
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/disassembly.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include <unone.h> #include "disassembly.h" #include "udis86/udis86.h" std::string DisasmMemory(ULONG64 pc, char *mem, ULONG memsize, int bits /*= 64*/) { if (mem == nullptr) return "??"; std::string disasm; ud_t ud_obj; /* initialize */ ud_init(&ud_obj); ud_set_mode(&ud_obj, bits); ud_set_syntax(&ud_obj, UD_SYN_INTEL); unsigned char o_do_off = 1; unsigned char o_do_hex = 1; ud_set_pc(&ud_obj, pc); ud_set_input_buffer(&ud_obj, (const uint8_t *)mem, memsize); /* disassembly loop */ while (ud_disassemble(&ud_obj)) { if (o_do_off) disasm += UNONE::StrFormatA("%016llX ", ud_insn_off(&ud_obj)); if (o_do_hex) { const char* hex1, *hex2; hex1 = ud_insn_hex(&ud_obj); hex2 = hex1 + 16; disasm += UNONE::StrFormatA("%-16.16s %-24s\n", hex1, ud_insn_asm(&ud_obj)); /* if (strlen(hex1) > 16) { disasm += UNONE::StrFormatA("\n"); if (o_do_off) disasm += UNONE::StrFormatA("%15s -", ""); disasm += UNONE::StrFormatA("%-16s", hex2); }*/ } else disasm += UNONE::StrFormatA(" %-24s", ud_insn_asm(&ud_obj)); } return disasm; } std::string HexDumpMemory(ULONG64 pc, char *mem, ULONG memsize) { auto hexchars = [&](std::string data)->std::string{ std::string prints; std::string stream; if (mem != nullptr) { stream = UNONE::StrHexStrToStreamA(data);; } else { stream.resize(data.size()/2); } for (unsigned char ch : stream) { if (mem == nullptr) { prints.push_back('?'); continue; } if (!isprint(ch)) prints.push_back('.'); else prints.push_back(ch); } return prints; }; std::string str; if (mem == nullptr) { str.assign(memsize*2, '?'); } else { str = UNONE::StrStreamToHexStrA(std::string(mem, memsize)); } std::string formated; auto &&newbuf = UNONE::StrInsertA(str, 32, "\n"); std::vector<std::string> lines; UNONE::StrSplitLinesA(newbuf, lines); for (auto line : lines) { std::string data; data = UNONE::StrInsertA(line, 2, " "); if (line.size() < 32) { auto padsize = (32 - (line.size() % 32)); data += " " + UNONE::StrInsertA(std::string(padsize, ' '), 2, " "); } formated += UNONE::StrFormatA("%016llX %s %s\n", pc, data.c_str(), hexchars(line).c_str()); pc += line.size() / 2; } return formated; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/disassembly.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <string> #include <Windows.h> std::string DisasmMemory(ULONG64 pc, char *mem, ULONG memsize, int bits = 64); std::string HexDumpMemory(ULONG64 pc, char *mem, ULONG memsize);
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/decode.c
C
/* udis86 - libudis86/decode.c * * Copyright (c) 2002-2009 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "udint.h" #include "types.h" #include "extern.h" #include "decode.h" #ifndef __UD_STANDALONE__ # include <string.h> #endif /* __UD_STANDALONE__ */ /* The max number of prefixes to an instruction */ #define MAX_PREFIXES 15 /* rex prefix bits */ #define REX_W(r) ( ( 0xF & ( r ) ) >> 3 ) #define REX_R(r) ( ( 0x7 & ( r ) ) >> 2 ) #define REX_X(r) ( ( 0x3 & ( r ) ) >> 1 ) #define REX_B(r) ( ( 0x1 & ( r ) ) >> 0 ) #define REX_PFX_MASK(n) ( ( P_REXW(n) << 3 ) | \ ( P_REXR(n) << 2 ) | \ ( P_REXX(n) << 1 ) | \ ( P_REXB(n) << 0 ) ) /* scable-index-base bits */ #define SIB_S(b) ( ( b ) >> 6 ) #define SIB_I(b) ( ( ( b ) >> 3 ) & 7 ) #define SIB_B(b) ( ( b ) & 7 ) /* modrm bits */ #define MODRM_REG(b) ( ( ( b ) >> 3 ) & 7 ) #define MODRM_NNN(b) ( ( ( b ) >> 3 ) & 7 ) #define MODRM_MOD(b) ( ( ( b ) >> 6 ) & 3 ) #define MODRM_RM(b) ( ( b ) & 7 ) static int decode_ext(struct ud *u, uint16_t ptr); static int decode_opcode(struct ud *u); enum reg_class { /* register classes */ REGCLASS_GPR, REGCLASS_MMX, REGCLASS_CR, REGCLASS_DB, REGCLASS_SEG, REGCLASS_XMM }; /* * inp_start * Should be called before each de-code operation. */ static void inp_start(struct ud *u) { u->inp_ctr = 0; } static uint8_t inp_peek(struct ud *u) { if (u->inp_end == 0) { if (u->inp_buf != NULL) { if (u->inp_buf_index < u->inp_buf_size) { return u->inp_buf[u->inp_buf_index]; } } else if (u->inp_peek != UD_EOI) { return u->inp_peek; } else { int c; if ((c = u->inp_hook(u)) != UD_EOI) { u->inp_peek = c; return u->inp_peek; } } } u->inp_end = 1; UDERR(u, "byte expected, eoi received\n"); return 0; } static uint8_t inp_next(struct ud *u) { if (u->inp_end == 0) { if (u->inp_buf != NULL) { if (u->inp_buf_index < u->inp_buf_size) { u->inp_ctr++; return (u->inp_curr = u->inp_buf[u->inp_buf_index++]); } } else { int c = u->inp_peek; if (c != UD_EOI || (c = u->inp_hook(u)) != UD_EOI) { u->inp_peek = UD_EOI; u->inp_curr = c; u->inp_sess[u->inp_ctr++] = u->inp_curr; return u->inp_curr; } } } u->inp_end = 1; UDERR(u, "byte expected, eoi received\n"); return 0; } static uint8_t inp_curr(struct ud *u) { return u->inp_curr; } /* * inp_uint8 * int_uint16 * int_uint32 * int_uint64 * Load little-endian values from input */ static uint8_t inp_uint8(struct ud* u) { return inp_next(u); } static uint16_t inp_uint16(struct ud* u) { uint16_t r, ret; ret = inp_next(u); r = inp_next(u); return ret | (r << 8); } static uint32_t inp_uint32(struct ud* u) { uint32_t r, ret; ret = inp_next(u); r = inp_next(u); ret = ret | (r << 8); r = inp_next(u); ret = ret | (r << 16); r = inp_next(u); return ret | (r << 24); } static uint64_t inp_uint64(struct ud* u) { uint64_t r, ret; ret = inp_next(u); r = inp_next(u); ret = ret | (r << 8); r = inp_next(u); ret = ret | (r << 16); r = inp_next(u); ret = ret | (r << 24); r = inp_next(u); ret = ret | (r << 32); r = inp_next(u); ret = ret | (r << 40); r = inp_next(u); ret = ret | (r << 48); r = inp_next(u); return ret | (r << 56); } static UD_INLINE int eff_opr_mode(int dis_mode, int rex_w, int pfx_opr) { if (dis_mode == 64) { return rex_w ? 64 : (pfx_opr ? 16 : 32); } else if (dis_mode == 32) { return pfx_opr ? 16 : 32; } else { UD_ASSERT(dis_mode == 16); return pfx_opr ? 32 : 16; } } static UD_INLINE int eff_adr_mode(int dis_mode, int pfx_adr) { if (dis_mode == 64) { return pfx_adr ? 32 : 64; } else if (dis_mode == 32) { return pfx_adr ? 16 : 32; } else { UD_ASSERT(dis_mode == 16); return pfx_adr ? 32 : 16; } } /* * decode_prefixes * * Extracts instruction prefixes. */ static int decode_prefixes(struct ud *u) { int done = 0; uint8_t curr = 0, last = 0; UD_RETURN_ON_ERROR(u); do { last = curr; curr = inp_next(u); UD_RETURN_ON_ERROR(u); if (u->inp_ctr == MAX_INSN_LENGTH) { UD_RETURN_WITH_ERROR(u, "max instruction length"); } switch (curr) { case 0x2E: u->pfx_seg = UD_R_CS; break; case 0x36: u->pfx_seg = UD_R_SS; break; case 0x3E: u->pfx_seg = UD_R_DS; break; case 0x26: u->pfx_seg = UD_R_ES; break; case 0x64: u->pfx_seg = UD_R_FS; break; case 0x65: u->pfx_seg = UD_R_GS; break; case 0x67: /* adress-size override prefix */ u->pfx_adr = 0x67; break; case 0xF0: u->pfx_lock = 0xF0; break; case 0x66: u->pfx_opr = 0x66; break; case 0xF2: u->pfx_str = 0xf2; break; case 0xF3: u->pfx_str = 0xf3; break; default: /* consume if rex */ done = (u->dis_mode == 64 && (curr & 0xF0) == 0x40) ? 0 : 1; break; } } while (!done); /* rex prefixes in 64bit mode, must be the last prefix */ if (u->dis_mode == 64 && (last & 0xF0) == 0x40) { u->pfx_rex = last; } return 0; } /* * vex_l, vex_w * Return the vex.L and vex.W bits */ static UD_INLINE uint8_t vex_l(const struct ud *u) { UD_ASSERT(u->vex_op != 0); return ((u->vex_op == 0xc4 ? u->vex_b2 : u->vex_b1) >> 2) & 1; } static UD_INLINE uint8_t vex_w(const struct ud *u) { UD_ASSERT(u->vex_op != 0); return u->vex_op == 0xc4 ? ((u->vex_b2 >> 7) & 1) : 0; } static UD_INLINE uint8_t modrm(struct ud * u) { if ( !u->have_modrm ) { u->modrm = inp_next( u ); u->modrm_offset = (uint8_t) (u->inp_ctr - 1); u->have_modrm = 1; } return u->modrm; } static unsigned int resolve_operand_size(const struct ud* u, ud_operand_size_t osize) { switch (osize) { case SZ_V: return u->opr_mode; case SZ_Z: return u->opr_mode == 16 ? 16 : 32; case SZ_Y: return u->opr_mode == 16 ? 32 : u->opr_mode; case SZ_RDQ: return u->dis_mode == 64 ? 64 : 32; case SZ_X: UD_ASSERT(u->vex_op != 0); return (P_VEXL(u->itab_entry->prefix) && vex_l(u)) ? SZ_QQ : SZ_DQ; default: return osize; } } static int resolve_mnemonic( struct ud* u ) { /* resolve 3dnow weirdness. */ if ( u->mnemonic == UD_I3dnow ) { u->mnemonic = ud_itab[ u->le->table[ inp_curr( u ) ] ].mnemonic; } /* SWAPGS is only valid in 64bits mode */ if ( u->mnemonic == UD_Iswapgs && u->dis_mode != 64 ) { UDERR(u, "swapgs invalid in 64bits mode\n"); return -1; } if (u->mnemonic == UD_Ixchg) { if ((u->operand[0].type == UD_OP_REG && u->operand[0].base == UD_R_AX && u->operand[1].type == UD_OP_REG && u->operand[1].base == UD_R_AX) || (u->operand[0].type == UD_OP_REG && u->operand[0].base == UD_R_EAX && u->operand[1].type == UD_OP_REG && u->operand[1].base == UD_R_EAX)) { u->operand[0].type = UD_NONE; u->operand[1].type = UD_NONE; u->mnemonic = UD_Inop; } } if (u->mnemonic == UD_Inop && u->pfx_repe) { u->pfx_repe = 0; u->mnemonic = UD_Ipause; } return 0; } /* ----------------------------------------------------------------------------- * decode_a()- Decodes operands of the type seg:offset * ----------------------------------------------------------------------------- */ static void decode_a(struct ud* u, struct ud_operand *op) { if (u->opr_mode == 16) { /* seg16:off16 */ op->type = UD_OP_PTR; op->size = 32; op->lval.ptr.off = inp_uint16(u); op->lval.ptr.seg = inp_uint16(u); } else { /* seg16:off32 */ op->type = UD_OP_PTR; op->size = 48; op->lval.ptr.off = inp_uint32(u); op->lval.ptr.seg = inp_uint16(u); } } /* ----------------------------------------------------------------------------- * decode_gpr() - Returns decoded General Purpose Register * ----------------------------------------------------------------------------- */ static enum ud_type decode_gpr(register struct ud* u, unsigned int s, unsigned char rm) { switch (s) { case 64: return UD_R_RAX + rm; case 32: return UD_R_EAX + rm; case 16: return UD_R_AX + rm; case 8: if (u->dis_mode == 64 && u->pfx_rex) { if (rm >= 4) return UD_R_SPL + (rm-4); return UD_R_AL + rm; } else return UD_R_AL + rm; case 0: /* invalid size in case of a decode error */ UD_ASSERT(u->error); return UD_NONE; default: UD_ASSERT(!"invalid operand size"); return UD_NONE; } } static void decode_reg(struct ud *u, struct ud_operand *opr, int type, int num, int size) { int reg; size = resolve_operand_size(u, size); switch (type) { case REGCLASS_GPR : reg = decode_gpr(u, size, num); break; case REGCLASS_MMX : reg = UD_R_MM0 + (num & 7); break; case REGCLASS_XMM : reg = num + (size == SZ_QQ ? UD_R_YMM0 : UD_R_XMM0); break; case REGCLASS_CR : reg = UD_R_CR0 + num; break; case REGCLASS_DB : reg = UD_R_DR0 + num; break; case REGCLASS_SEG : { /* * Only 6 segment registers, anything else is an error. */ if ((num & 7) > 5) { UDERR(u, "invalid segment register value\n"); return; } else { reg = UD_R_ES + (num & 7); } break; } default: UD_ASSERT(!"invalid register type"); return; } opr->type = UD_OP_REG; opr->base = reg; opr->size = size; } /* * decode_imm * * Decode Immediate values. */ static void decode_imm(struct ud* u, unsigned int size, struct ud_operand *op) { op->size = resolve_operand_size(u, size); op->type = UD_OP_IMM; switch (op->size) { case 8: op->lval.sbyte = inp_uint8(u); break; case 16: op->lval.uword = inp_uint16(u); break; case 32: op->lval.udword = inp_uint32(u); break; case 64: op->lval.uqword = inp_uint64(u); break; default: return; } } /* * decode_mem_disp * * Decode mem address displacement. */ static void decode_mem_disp(struct ud* u, unsigned int size, struct ud_operand *op) { switch (size) { case 8: op->offset = 8; op->lval.ubyte = inp_uint8(u); break; case 16: op->offset = 16; op->lval.uword = inp_uint16(u); break; case 32: op->offset = 32; op->lval.udword = inp_uint32(u); break; case 64: op->offset = 64; op->lval.uqword = inp_uint64(u); break; default: return; } } /* * decode_modrm_reg * * Decodes reg field of mod/rm byte * */ static UD_INLINE void decode_modrm_reg(struct ud *u, struct ud_operand *operand, unsigned int type, unsigned int size) { uint8_t reg = (REX_R(u->_rex) << 3) | MODRM_REG(modrm(u)); decode_reg(u, operand, type, reg, size); } /* * decode_modrm_rm * * Decodes rm field of mod/rm byte * */ static void decode_modrm_rm(struct ud *u, struct ud_operand *op, unsigned char type, /* register type */ unsigned int size) /* operand size */ { size_t offset = 0; unsigned char mod, rm; /* get mod, r/m and reg fields */ mod = MODRM_MOD(modrm(u)); rm = (REX_B(u->_rex) << 3) | MODRM_RM(modrm(u)); /* * If mod is 11b, then the modrm.rm specifies a register. * */ if (mod == 3) { decode_reg(u, op, type, rm, size); return; } /* * !11b => Memory Address */ op->type = UD_OP_MEM; op->size = resolve_operand_size(u, size); if (u->adr_mode == 64) { op->base = UD_R_RAX + rm; if (mod == 1) { offset = 8; } else if (mod == 2) { offset = 32; } else if (mod == 0 && (rm & 7) == 5) { op->base = UD_R_RIP; offset = 32; } else { offset = 0; } /* * Scale-Index-Base (SIB) */ if ((rm & 7) == 4) { inp_next(u); op->base = UD_R_RAX + (SIB_B(inp_curr(u)) | (REX_B(u->_rex) << 3)); op->index = UD_R_RAX + (SIB_I(inp_curr(u)) | (REX_X(u->_rex) << 3)); /* special conditions for base reference */ if (op->index == UD_R_RSP) { op->index = UD_NONE; op->scale = UD_NONE; } else { op->scale = (1 << SIB_S(inp_curr(u))) & ~1; } if (op->base == UD_R_RBP || op->base == UD_R_R13) { if (mod == 0) { op->base = UD_NONE; } if (mod == 1) { offset = 8; } else { offset = 32; } } } else { op->scale = UD_NONE; op->index = UD_NONE; } } else if (u->adr_mode == 32) { op->base = UD_R_EAX + rm; if (mod == 1) { offset = 8; } else if (mod == 2) { offset = 32; } else if (mod == 0 && rm == 5) { op->base = UD_NONE; offset = 32; } else { offset = 0; } /* Scale-Index-Base (SIB) */ if ((rm & 7) == 4) { inp_next(u); op->scale = (1 << SIB_S(inp_curr(u))) & ~1; op->index = UD_R_EAX + (SIB_I(inp_curr(u)) | (REX_X(u->pfx_rex) << 3)); op->base = UD_R_EAX + (SIB_B(inp_curr(u)) | (REX_B(u->pfx_rex) << 3)); if (op->index == UD_R_ESP) { op->index = UD_NONE; op->scale = UD_NONE; } /* special condition for base reference */ if (op->base == UD_R_EBP) { if (mod == 0) { op->base = UD_NONE; } if (mod == 1) { offset = 8; } else { offset = 32; } } } else { op->scale = UD_NONE; op->index = UD_NONE; } } else { const unsigned int bases[] = { UD_R_BX, UD_R_BX, UD_R_BP, UD_R_BP, UD_R_SI, UD_R_DI, UD_R_BP, UD_R_BX }; const unsigned int indices[] = { UD_R_SI, UD_R_DI, UD_R_SI, UD_R_DI, UD_NONE, UD_NONE, UD_NONE, UD_NONE }; op->base = bases[rm & 7]; op->index = indices[rm & 7]; op->scale = UD_NONE; if (mod == 0 && rm == 6) { offset = 16; op->base = UD_NONE; } else if (mod == 1) { offset = 8; } else if (mod == 2) { offset = 16; } } if (offset) { decode_mem_disp(u, offset, op); } else { op->offset = 0; } } /* * decode_moffset * Decode offset-only memory operand */ static void decode_moffset(struct ud *u, unsigned int size, struct ud_operand *opr) { opr->type = UD_OP_MEM; opr->base = UD_NONE; opr->index = UD_NONE; opr->scale = UD_NONE; opr->size = resolve_operand_size(u, size); decode_mem_disp(u, u->adr_mode, opr); } static void decode_vex_vvvv(struct ud *u, struct ud_operand *opr, unsigned size) { uint8_t vvvv; UD_ASSERT(u->vex_op != 0); vvvv = ((u->vex_op == 0xc4 ? u->vex_b2 : u->vex_b1) >> 3) & 0xf; decode_reg(u, opr, REGCLASS_XMM, (0xf & ~vvvv), size); } /* * decode_vex_immreg * Decode source operand encoded in immediate byte [7:4] */ static int decode_vex_immreg(struct ud *u, struct ud_operand *opr, unsigned size) { uint8_t imm = inp_next(u); uint8_t mask = u->dis_mode == 64 ? 0xf : 0x7; UD_RETURN_ON_ERROR(u); UD_ASSERT(u->vex_op != 0); decode_reg(u, opr, REGCLASS_XMM, mask & (imm >> 4), size); return 0; } /* * decode_operand * * Decodes a single operand. * Returns the type of the operand (UD_NONE if none) */ static int decode_operand(struct ud *u, struct ud_operand *operand, enum ud_operand_code type, unsigned int size) { operand->type = UD_NONE; operand->_oprcode = type; switch (type) { case OP_A : decode_a(u, operand); break; case OP_MR: decode_modrm_rm(u, operand, REGCLASS_GPR, MODRM_MOD(modrm(u)) == 3 ? Mx_reg_size(size) : Mx_mem_size(size)); break; case OP_F: u->br_far = 1; /* intended fall through */ case OP_M: if (MODRM_MOD(modrm(u)) == 3) { UDERR(u, "expected modrm.mod != 3\n"); } /* intended fall through */ case OP_E: decode_modrm_rm(u, operand, REGCLASS_GPR, size); break; case OP_G: decode_modrm_reg(u, operand, REGCLASS_GPR, size); break; case OP_sI: case OP_I: decode_imm(u, size, operand); break; case OP_I1: operand->type = UD_OP_CONST; operand->lval.udword = 1; break; case OP_N: if (MODRM_MOD(modrm(u)) != 3) { UDERR(u, "expected modrm.mod == 3\n"); } /* intended fall through */ case OP_Q: decode_modrm_rm(u, operand, REGCLASS_MMX, size); break; case OP_P: decode_modrm_reg(u, operand, REGCLASS_MMX, size); break; case OP_U: if (MODRM_MOD(modrm(u)) != 3) { UDERR(u, "expected modrm.mod == 3\n"); } /* intended fall through */ case OP_W: decode_modrm_rm(u, operand, REGCLASS_XMM, size); break; case OP_V: decode_modrm_reg(u, operand, REGCLASS_XMM, size); break; case OP_H: decode_vex_vvvv(u, operand, size); break; case OP_MU: decode_modrm_rm(u, operand, REGCLASS_XMM, MODRM_MOD(modrm(u)) == 3 ? Mx_reg_size(size) : Mx_mem_size(size)); break; case OP_S: decode_modrm_reg(u, operand, REGCLASS_SEG, size); break; case OP_O: decode_moffset(u, size, operand); break; case OP_R0: case OP_R1: case OP_R2: case OP_R3: case OP_R4: case OP_R5: case OP_R6: case OP_R7: decode_reg(u, operand, REGCLASS_GPR, (REX_B(u->_rex) << 3) | (type - OP_R0), size); break; case OP_AL: case OP_AX: case OP_eAX: case OP_rAX: decode_reg(u, operand, REGCLASS_GPR, 0, size); break; case OP_CL: case OP_CX: case OP_eCX: decode_reg(u, operand, REGCLASS_GPR, 1, size); break; case OP_DL: case OP_DX: case OP_eDX: decode_reg(u, operand, REGCLASS_GPR, 2, size); break; case OP_ES: case OP_CS: case OP_DS: case OP_SS: case OP_FS: case OP_GS: /* in 64bits mode, only fs and gs are allowed */ if (u->dis_mode == 64) { if (type != OP_FS && type != OP_GS) { UDERR(u, "invalid segment register in 64bits\n"); } } operand->type = UD_OP_REG; operand->base = (type - OP_ES) + UD_R_ES; operand->size = 16; break; case OP_J : decode_imm(u, size, operand); operand->type = UD_OP_JIMM; break ; case OP_R : if (MODRM_MOD(modrm(u)) != 3) { UDERR(u, "expected modrm.mod == 3\n"); } decode_modrm_rm(u, operand, REGCLASS_GPR, size); break; case OP_C: decode_modrm_reg(u, operand, REGCLASS_CR, size); break; case OP_D: decode_modrm_reg(u, operand, REGCLASS_DB, size); break; case OP_I3 : operand->type = UD_OP_CONST; operand->lval.sbyte = 3; break; case OP_ST0: case OP_ST1: case OP_ST2: case OP_ST3: case OP_ST4: case OP_ST5: case OP_ST6: case OP_ST7: operand->type = UD_OP_REG; operand->base = (type - OP_ST0) + UD_R_ST0; operand->size = 80; break; case OP_L: decode_vex_immreg(u, operand, size); break; default : operand->type = UD_NONE; break; } return operand->type; } /* * decode_operands * * Disassemble upto 3 operands of the current instruction being * disassembled. By the end of the function, the operand fields * of the ud structure will have been filled. */ static int decode_operands(struct ud* u) { decode_operand(u, &u->operand[0], u->itab_entry->operand1.type, u->itab_entry->operand1.size); if (u->operand[0].type != UD_NONE) { decode_operand(u, &u->operand[1], u->itab_entry->operand2.type, u->itab_entry->operand2.size); } if (u->operand[1].type != UD_NONE) { decode_operand(u, &u->operand[2], u->itab_entry->operand3.type, u->itab_entry->operand3.size); } if (u->operand[2].type != UD_NONE) { decode_operand(u, &u->operand[3], u->itab_entry->operand4.type, u->itab_entry->operand4.size); } return 0; } /* ----------------------------------------------------------------------------- * clear_insn() - clear instruction structure * ----------------------------------------------------------------------------- */ static void clear_insn(register struct ud* u) { u->error = 0; u->pfx_seg = 0; u->pfx_opr = 0; u->pfx_adr = 0; u->pfx_lock = 0; u->pfx_repne = 0; u->pfx_rep = 0; u->pfx_repe = 0; u->pfx_rex = 0; u->pfx_str = 0; u->mnemonic = UD_Inone; u->itab_entry = NULL; u->have_modrm = 0; u->br_far = 0; u->vex_op = 0; u->_rex = 0; u->operand[0].type = UD_NONE; u->operand[1].type = UD_NONE; u->operand[2].type = UD_NONE; u->operand[3].type = UD_NONE; } static UD_INLINE int resolve_pfx_str(struct ud* u) { if (u->pfx_str == 0xf3) { if (P_STR(u->itab_entry->prefix)) { u->pfx_rep = 0xf3; } else { u->pfx_repe = 0xf3; } } else if (u->pfx_str == 0xf2) { u->pfx_repne = 0xf3; } return 0; } static int resolve_mode( struct ud* u ) { int default64; /* if in error state, bail out */ if ( u->error ) return -1; /* propagate prefix effects */ if ( u->dis_mode == 64 ) { /* set 64bit-mode flags */ /* Check validity of instruction m64 */ if ( P_INV64( u->itab_entry->prefix ) ) { UDERR(u, "instruction invalid in 64bits\n"); return -1; } /* compute effective rex based on, * - vex prefix (if any) * - rex prefix (if any, and not vex) * - allowed prefixes specified by the opcode map */ if (u->vex_op == 0xc4) { /* vex has rex.rxb in 1's complement */ u->_rex = ((~(u->vex_b1 >> 5) & 0x7) /* rex.0rxb */ | ((u->vex_b2 >> 4) & 0x8) /* rex.w000 */); } else if (u->vex_op == 0xc5) { /* vex has rex.r in 1's complement */ u->_rex = (~(u->vex_b1 >> 5)) & 4; } else { UD_ASSERT(u->vex_op == 0); u->_rex = u->pfx_rex; } u->_rex &= REX_PFX_MASK(u->itab_entry->prefix); /* whether this instruction has a default operand size of * 64bit, also hardcoded into the opcode map. */ default64 = P_DEF64( u->itab_entry->prefix ); /* calculate effective operand size */ if (REX_W(u->_rex)) { u->opr_mode = 64; } else if ( u->pfx_opr ) { u->opr_mode = 16; } else { /* unless the default opr size of instruction is 64, * the effective operand size in the absence of rex.w * prefix is 32. */ u->opr_mode = default64 ? 64 : 32; } /* calculate effective address size */ u->adr_mode = (u->pfx_adr) ? 32 : 64; } else if ( u->dis_mode == 32 ) { /* set 32bit-mode flags */ u->opr_mode = ( u->pfx_opr ) ? 16 : 32; u->adr_mode = ( u->pfx_adr ) ? 16 : 32; } else if ( u->dis_mode == 16 ) { /* set 16bit-mode flags */ u->opr_mode = ( u->pfx_opr ) ? 32 : 16; u->adr_mode = ( u->pfx_adr ) ? 32 : 16; } return 0; } static UD_INLINE int decode_insn(struct ud *u, uint16_t ptr) { UD_ASSERT((ptr & 0x8000) == 0); u->itab_entry = &ud_itab[ ptr ]; u->mnemonic = u->itab_entry->mnemonic; return (resolve_pfx_str(u) == 0 && resolve_mode(u) == 0 && decode_operands(u) == 0 && resolve_mnemonic(u) == 0) ? 0 : -1; } /* * decode_3dnow() * * Decoding 3dnow is a little tricky because of its strange opcode * structure. The final opcode disambiguation depends on the last * byte that comes after the operands have been decoded. Fortunately, * all 3dnow instructions have the same set of operand types. So we * go ahead and decode the instruction by picking an arbitrarily chosen * valid entry in the table, decode the operands, and read the final * byte to resolve the menmonic. */ static UD_INLINE int decode_3dnow(struct ud* u) { uint16_t ptr; UD_ASSERT(u->le->type == UD_TAB__OPC_3DNOW); UD_ASSERT(u->le->table[0xc] != 0); decode_insn(u, u->le->table[0xc]); inp_next(u); if (u->error) { return -1; } ptr = u->le->table[inp_curr(u)]; UD_ASSERT((ptr & 0x8000) == 0); u->mnemonic = ud_itab[ptr].mnemonic; return 0; } static int decode_ssepfx(struct ud *u) { uint8_t idx; uint8_t pfx; /* * String prefixes (f2, f3) take precedence over operand * size prefix (66). */ pfx = u->pfx_str; if (pfx == 0) { pfx = u->pfx_opr; } idx = ((pfx & 0xf) + 1) / 2; if (u->le->table[idx] == 0) { idx = 0; } if (idx && u->le->table[idx] != 0) { /* * "Consume" the prefix as a part of the opcode, so it is no * longer exported as an instruction prefix. */ u->pfx_str = 0; if (pfx == 0x66) { /* * consume "66" only if it was used for decoding, leaving * it to be used as an operands size override for some * simd instructions. */ u->pfx_opr = 0; } } return decode_ext(u, u->le->table[idx]); } static int decode_vex(struct ud *u) { uint8_t index; if (u->dis_mode != 64 && MODRM_MOD(inp_peek(u)) != 0x3) { index = 0; } else { u->vex_op = inp_curr(u); u->vex_b1 = inp_next(u); if (u->vex_op == 0xc4) { uint8_t pp, m; /* 3-byte vex */ u->vex_b2 = inp_next(u); UD_RETURN_ON_ERROR(u); m = u->vex_b1 & 0x1f; if (m == 0 || m > 3) { UD_RETURN_WITH_ERROR(u, "reserved vex.m-mmmm value"); } pp = u->vex_b2 & 0x3; index = (pp << 2) | m; } else { /* 2-byte vex */ UD_ASSERT(u->vex_op == 0xc5); index = 0x1 | ((u->vex_b1 & 0x3) << 2); } } return decode_ext(u, u->le->table[index]); } /* * decode_ext() * * Decode opcode extensions (if any) */ static int decode_ext(struct ud *u, uint16_t ptr) { uint8_t idx = 0; if ((ptr & 0x8000) == 0) { return decode_insn(u, ptr); } u->le = &ud_lookup_table_list[(~0x8000 & ptr)]; if (u->le->type == UD_TAB__OPC_3DNOW) { return decode_3dnow(u); } switch (u->le->type) { case UD_TAB__OPC_MOD: /* !11 = 0, 11 = 1 */ idx = (MODRM_MOD(modrm(u)) + 1) / 4; break; /* disassembly mode/operand size/address size based tables. * 16 = 0,, 32 = 1, 64 = 2 */ case UD_TAB__OPC_MODE: idx = u->dis_mode != 64 ? 0 : 1; break; case UD_TAB__OPC_OSIZE: idx = eff_opr_mode(u->dis_mode, REX_W(u->pfx_rex), u->pfx_opr) / 32; break; case UD_TAB__OPC_ASIZE: idx = eff_adr_mode(u->dis_mode, u->pfx_adr) / 32; break; case UD_TAB__OPC_X87: idx = modrm(u) - 0xC0; break; case UD_TAB__OPC_VENDOR: if (u->vendor == UD_VENDOR_ANY) { /* choose a valid entry */ idx = (u->le->table[idx] != 0) ? 0 : 1; } else if (u->vendor == UD_VENDOR_AMD) { idx = 0; } else { idx = 1; } break; case UD_TAB__OPC_RM: idx = MODRM_RM(modrm(u)); break; case UD_TAB__OPC_REG: idx = MODRM_REG(modrm(u)); break; case UD_TAB__OPC_SSE: return decode_ssepfx(u); case UD_TAB__OPC_VEX: return decode_vex(u); case UD_TAB__OPC_VEX_W: idx = vex_w(u); break; case UD_TAB__OPC_VEX_L: idx = vex_l(u); break; case UD_TAB__OPC_TABLE: inp_next(u); return decode_opcode(u); default: UD_ASSERT(!"not reached"); break; } return decode_ext(u, u->le->table[idx]); } static int decode_opcode(struct ud *u) { uint16_t ptr; UD_ASSERT(u->le->type == UD_TAB__OPC_TABLE); UD_RETURN_ON_ERROR(u); ptr = u->le->table[inp_curr(u)]; return decode_ext(u, ptr); } /* ============================================================================= * ud_decode() - Instruction decoder. Returns the number of bytes decoded. * ============================================================================= */ unsigned int ud_decode(struct ud *u) { inp_start(u); clear_insn(u); u->le = &ud_lookup_table_list[0]; u->error = decode_prefixes(u) == -1 || decode_opcode(u) == -1 || u->error; /* Handle decode error. */ if (u->error) { /* clear out the decode data. */ clear_insn(u); /* mark the sequence of bytes as invalid. */ u->itab_entry = &ud_itab[0]; /* entry 0 is invalid */ u->mnemonic = u->itab_entry->mnemonic; } /* maybe this stray segment override byte * should be spewed out? */ if ( !P_SEG( u->itab_entry->prefix ) && u->operand[0].type != UD_OP_MEM && u->operand[1].type != UD_OP_MEM ) u->pfx_seg = 0; u->insn_offset = u->pc; /* set offset of instruction */ u->asm_buf_fill = 0; /* set translation buffer index to 0 */ u->pc += u->inp_ctr; /* move program counter by bytes decoded */ /* return number of bytes disassembled. */ return u->inp_ctr; } /* vim: set ts=2 sw=2 expandtab */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/decode.h
C/C++ Header
/* udis86 - libudis86/decode.h * * Copyright (c) 2002-2009 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef UD_DECODE_H #define UD_DECODE_H #include "types.h" #include "udint.h" #include "itab.h" #define MAX_INSN_LENGTH 15 /* itab prefix bits */ #define P_none ( 0 ) #define P_inv64 ( 1 << 0 ) #define P_INV64(n) ( ( n >> 0 ) & 1 ) #define P_def64 ( 1 << 1 ) #define P_DEF64(n) ( ( n >> 1 ) & 1 ) #define P_oso ( 1 << 2 ) #define P_OSO(n) ( ( n >> 2 ) & 1 ) #define P_aso ( 1 << 3 ) #define P_ASO(n) ( ( n >> 3 ) & 1 ) #define P_rexb ( 1 << 4 ) #define P_REXB(n) ( ( n >> 4 ) & 1 ) #define P_rexw ( 1 << 5 ) #define P_REXW(n) ( ( n >> 5 ) & 1 ) #define P_rexr ( 1 << 6 ) #define P_REXR(n) ( ( n >> 6 ) & 1 ) #define P_rexx ( 1 << 7 ) #define P_REXX(n) ( ( n >> 7 ) & 1 ) #define P_seg ( 1 << 8 ) #define P_SEG(n) ( ( n >> 8 ) & 1 ) #define P_vexl ( 1 << 9 ) #define P_VEXL(n) ( ( n >> 9 ) & 1 ) #define P_vexw ( 1 << 10 ) #define P_VEXW(n) ( ( n >> 10 ) & 1 ) #define P_str ( 1 << 11 ) #define P_STR(n) ( ( n >> 11 ) & 1 ) #define P_strz ( 1 << 12 ) #define P_STR_ZF(n) ( ( n >> 12 ) & 1 ) /* operand type constants -- order is important! */ enum ud_operand_code { OP_NONE, OP_A, OP_E, OP_M, OP_G, OP_I, OP_F, OP_R0, OP_R1, OP_R2, OP_R3, OP_R4, OP_R5, OP_R6, OP_R7, OP_AL, OP_CL, OP_DL, OP_AX, OP_CX, OP_DX, OP_eAX, OP_eCX, OP_eDX, OP_rAX, OP_rCX, OP_rDX, OP_ES, OP_CS, OP_SS, OP_DS, OP_FS, OP_GS, OP_ST0, OP_ST1, OP_ST2, OP_ST3, OP_ST4, OP_ST5, OP_ST6, OP_ST7, OP_J, OP_S, OP_O, OP_I1, OP_I3, OP_sI, OP_V, OP_W, OP_Q, OP_P, OP_U, OP_N, OP_MU, OP_H, OP_L, OP_R, OP_C, OP_D, OP_MR } UD_ATTR_PACKED; /* * Operand size constants * * Symbolic constants for various operand sizes. Some of these constants * are given a value equal to the width of the data (SZ_B == 8), such * that they maybe used interchangeably in the internals. Modifying them * will most certainly break things! */ typedef uint16_t ud_operand_size_t; #define SZ_NA 0 #define SZ_Z 1 #define SZ_V 2 #define SZ_Y 3 #define SZ_X 4 #define SZ_RDQ 7 #define SZ_B 8 #define SZ_W 16 #define SZ_D 32 #define SZ_Q 64 #define SZ_T 80 #define SZ_O 12 #define SZ_DQ 128 /* double quad */ #define SZ_QQ 256 /* quad quad */ /* * Complex size types; that encode sizes for operands of type MR (memory or * register); for internal use only. Id space above 256. */ #define SZ_BD ((SZ_B << 8) | SZ_D) #define SZ_BV ((SZ_B << 8) | SZ_V) #define SZ_WD ((SZ_W << 8) | SZ_D) #define SZ_WV ((SZ_W << 8) | SZ_V) #define SZ_WY ((SZ_W << 8) | SZ_Y) #define SZ_DY ((SZ_D << 8) | SZ_Y) #define SZ_WO ((SZ_W << 8) | SZ_O) #define SZ_DO ((SZ_D << 8) | SZ_O) #define SZ_QO ((SZ_Q << 8) | SZ_O) /* resolve complex size type. */ static UD_INLINE ud_operand_size_t Mx_mem_size(ud_operand_size_t size) { return (size >> 8) & 0xff; } static UD_INLINE ud_operand_size_t Mx_reg_size(ud_operand_size_t size) { return size & 0xff; } /* A single operand of an entry in the instruction table. * (internal use only) */ struct ud_itab_entry_operand { enum ud_operand_code type; ud_operand_size_t size; }; /* A single entry in an instruction table. *(internal use only) */ struct ud_itab_entry { enum ud_mnemonic_code mnemonic; struct ud_itab_entry_operand operand1; struct ud_itab_entry_operand operand2; struct ud_itab_entry_operand operand3; struct ud_itab_entry_operand operand4; uint32_t prefix; }; struct ud_lookup_table_list_entry { const uint16_t *table; enum ud_table_type type; const char *meta; }; extern struct ud_itab_entry ud_itab[]; extern struct ud_lookup_table_list_entry ud_lookup_table_list[]; #endif /* UD_DECODE_H */ /* vim:cindent * vim:expandtab * vim:ts=4 * vim:sw=4 */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/extern.h
C/C++ Header
/* udis86 - libudis86/extern.h * * Copyright (c) 2002-2009, 2013 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef UD_EXTERN_H #define UD_EXTERN_H #ifdef __cplusplus extern "C" { #endif #include "types.h" #if defined(_MSC_VER) && defined(_USRDLL) # ifdef LIBUDIS86_EXPORTS # define LIBUDIS86_DLLEXTERN __declspec(dllexport) # else # define LIBUDIS86_DLLEXTERN __declspec(dllimport) # endif #else # define LIBUDIS86_DLLEXTERN #endif /* ============================= PUBLIC API ================================= */ extern LIBUDIS86_DLLEXTERN void ud_init(struct ud*); extern LIBUDIS86_DLLEXTERN void ud_set_mode(struct ud*, uint8_t); extern LIBUDIS86_DLLEXTERN void ud_set_pc(struct ud*, uint64_t); extern LIBUDIS86_DLLEXTERN void ud_set_input_hook(struct ud*, int (*)(struct ud*)); extern LIBUDIS86_DLLEXTERN void ud_set_input_buffer(struct ud*, const uint8_t*, size_t); #ifndef __UD_STANDALONE__ extern LIBUDIS86_DLLEXTERN void ud_set_input_file(struct ud*, FILE*); #endif /* __UD_STANDALONE__ */ extern LIBUDIS86_DLLEXTERN void ud_set_vendor(struct ud*, unsigned); extern LIBUDIS86_DLLEXTERN void ud_set_syntax(struct ud*, void (*)(struct ud*)); extern LIBUDIS86_DLLEXTERN void ud_input_skip(struct ud*, size_t); extern LIBUDIS86_DLLEXTERN int ud_input_end(const struct ud*); extern LIBUDIS86_DLLEXTERN unsigned int ud_decode(struct ud*); extern LIBUDIS86_DLLEXTERN unsigned int ud_disassemble(struct ud*); extern LIBUDIS86_DLLEXTERN void ud_translate_intel(struct ud*); extern LIBUDIS86_DLLEXTERN void ud_translate_att(struct ud*); extern LIBUDIS86_DLLEXTERN const char* ud_insn_asm(const struct ud* u); extern LIBUDIS86_DLLEXTERN const uint8_t* ud_insn_ptr(const struct ud* u); extern LIBUDIS86_DLLEXTERN uint64_t ud_insn_off(const struct ud*); extern LIBUDIS86_DLLEXTERN const char* ud_insn_hex(struct ud*); extern LIBUDIS86_DLLEXTERN unsigned int ud_insn_len(const struct ud* u); extern LIBUDIS86_DLLEXTERN const struct ud_operand* ud_insn_opr(const struct ud *u, unsigned int n); extern LIBUDIS86_DLLEXTERN int ud_opr_is_sreg(const struct ud_operand *opr); extern LIBUDIS86_DLLEXTERN int ud_opr_is_gpr(const struct ud_operand *opr); extern LIBUDIS86_DLLEXTERN enum ud_mnemonic_code ud_insn_mnemonic(const struct ud *u); extern LIBUDIS86_DLLEXTERN const char* ud_lookup_mnemonic(enum ud_mnemonic_code c); extern LIBUDIS86_DLLEXTERN void ud_set_user_opaque_data(struct ud*, void*); extern LIBUDIS86_DLLEXTERN void* ud_get_user_opaque_data(const struct ud*); extern LIBUDIS86_DLLEXTERN void ud_set_asm_buffer(struct ud *u, char *buf, size_t size); extern LIBUDIS86_DLLEXTERN void ud_set_sym_resolver(struct ud *u, const char* (*resolver)(struct ud*, uint64_t addr, int64_t *offset)); /* ========================================================================== */ #ifdef __cplusplus } #endif #endif /* UD_EXTERN_H */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/itab.c
C
/* itab.c -- generated by udis86:scripts/ud_itab.py, do no edit */ #include "decode.h" #define GROUP(n) (0x8000 | (n)) #define INVALID 0 const uint16_t ud_itab__0[] = { /* 0 */ 15, 16, 17, 18, /* 4 */ 19, 20, GROUP(1), GROUP(2), /* 8 */ 964, 965, 966, 967, /* c */ 968, 969, GROUP(3), GROUP(4), /* 10 */ 5, 6, 7, 8, /* 14 */ 9, 10, GROUP(284), GROUP(285), /* 18 */ 1337, 1338, 1339, 1340, /* 1c */ 1341, 1342, GROUP(286), GROUP(287), /* 20 */ 49, 50, 51, 52, /* 24 */ 53, 54, INVALID, GROUP(288), /* 28 */ 1408, 1409, 1410, 1411, /* 2c */ 1412, 1413, INVALID, GROUP(289), /* 30 */ 1488, 1489, 1490, 1491, /* 34 */ 1492, 1493, INVALID, GROUP(290), /* 38 */ 100, 101, 102, 103, /* 3c */ 104, 105, INVALID, GROUP(291), /* 40 */ 699, 700, 701, 702, /* 44 */ 703, 704, 705, 706, /* 48 */ 175, 176, 177, 178, /* 4c */ 179, 180, 181, 182, /* 50 */ 1247, 1248, 1249, 1250, /* 54 */ 1251, 1252, 1253, 1254, /* 58 */ 1101, 1102, 1103, 1104, /* 5c */ 1105, 1106, 1107, 1108, /* 60 */ GROUP(292), GROUP(295), GROUP(298), GROUP(299), /* 64 */ INVALID, INVALID, INVALID, INVALID, /* 68 */ 1255, 697, 1257, 698, /* 6c */ 709, GROUP(300), 982, GROUP(301), /* 70 */ 726, 728, 730, 732, /* 74 */ 734, 736, 738, 740, /* 78 */ 742, 744, 746, 748, /* 7c */ 750, 752, 754, 756, /* 80 */ GROUP(302), GROUP(303), GROUP(304), GROUP(313), /* 84 */ 1434, 1435, 1476, 1477, /* 88 */ 828, 829, 830, 831, /* 8c */ 832, 770, 833, GROUP(314), /* 90 */ 1478, 1479, 1480, 1481, /* 94 */ 1482, 1483, 1484, 1485, /* 98 */ GROUP(315), GROUP(316), GROUP(317), 1471, /* 9c */ GROUP(318), GROUP(322), 1311, 766, /* a0 */ 834, 835, 836, 837, /* a4 */ 922, GROUP(326), 114, GROUP(327), /* a8 */ 1436, 1437, 1403, GROUP(328), /* ac */ 790, GROUP(329), 1347, GROUP(330), /* b0 */ 838, 839, 840, 841, /* b4 */ 842, 843, 844, 845, /* b8 */ 846, 847, 848, 849, /* bc */ 850, 851, 852, 853, /* c0 */ GROUP(331), GROUP(332), 1302, 1303, /* c4 */ GROUP(333), GROUP(403), GROUP(405), GROUP(406), /* c8 */ 200, 776, 1304, 1305, /* cc */ 713, 714, GROUP(407), GROUP(408), /* d0 */ GROUP(409), GROUP(410), GROUP(411), GROUP(412), /* d4 */ GROUP(413), GROUP(414), GROUP(415), 1487, /* d8 */ GROUP(416), GROUP(419), GROUP(422), GROUP(425), /* dc */ GROUP(428), GROUP(431), GROUP(434), GROUP(437), /* e0 */ 794, 795, 796, GROUP(440), /* e4 */ 690, 691, 978, 979, /* e8 */ 72, 763, GROUP(441), 765, /* ec */ 692, 693, 980, 981, /* f0 */ 789, 712, 1300, 1301, /* f4 */ 687, 83, GROUP(442), GROUP(443), /* f8 */ 77, 1396, 81, 1399, /* fc */ 78, 1397, GROUP(444), GROUP(445), }; static const uint16_t ud_itab__1[] = { /* 0 */ 1241, INVALID, }; static const uint16_t ud_itab__2[] = { /* 0 */ 1096, INVALID, }; static const uint16_t ud_itab__3[] = { /* 0 */ 1242, INVALID, }; static const uint16_t ud_itab__4[] = { /* 0 */ GROUP(5), GROUP(6), 767, 797, /* 4 */ INVALID, 1427, 82, 1432, /* 8 */ 716, 1472, INVALID, 1445, /* c */ INVALID, GROUP(27), 430, GROUP(28), /* 10 */ GROUP(29), GROUP(30), GROUP(31), GROUP(34), /* 14 */ GROUP(35), GROUP(36), GROUP(37), GROUP(40), /* 18 */ GROUP(41), 955, 956, 957, /* 1c */ 958, 959, 960, 961, /* 20 */ 854, 855, 856, 857, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ GROUP(42), GROUP(43), GROUP(44), GROUP(45), /* 2c */ GROUP(46), GROUP(47), GROUP(48), GROUP(49), /* 30 */ 1473, 1298, 1296, 1297, /* 34 */ GROUP(50), GROUP(52), INVALID, 1515, /* 38 */ GROUP(54), INVALID, GROUP(116), INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, /* 40 */ 84, 85, 86, 87, /* 44 */ 88, 89, 90, 91, /* 48 */ 92, 93, 94, 95, /* 4c */ 96, 97, 98, 99, /* 50 */ GROUP(143), GROUP(144), GROUP(145), GROUP(146), /* 54 */ GROUP(147), GROUP(148), GROUP(149), GROUP(150), /* 58 */ GROUP(151), GROUP(152), GROUP(153), GROUP(154), /* 5c */ GROUP(155), GROUP(156), GROUP(157), GROUP(158), /* 60 */ GROUP(159), GROUP(160), GROUP(161), GROUP(162), /* 64 */ GROUP(163), GROUP(164), GROUP(165), GROUP(166), /* 68 */ GROUP(167), GROUP(168), GROUP(169), GROUP(170), /* 6c */ GROUP(171), GROUP(172), GROUP(173), GROUP(176), /* 70 */ GROUP(177), GROUP(178), GROUP(182), GROUP(186), /* 74 */ GROUP(191), GROUP(192), GROUP(193), 199, /* 78 */ GROUP(194), GROUP(195), INVALID, INVALID, /* 7c */ GROUP(196), GROUP(197), GROUP(198), GROUP(201), /* 80 */ 727, 729, 731, 733, /* 84 */ 735, 737, 739, 741, /* 88 */ 743, 745, 747, 749, /* 8c */ 751, 753, 755, 757, /* 90 */ 1351, 1352, 1353, 1354, /* 94 */ 1355, 1356, 1357, 1358, /* 98 */ 1359, 1360, 1361, 1362, /* 9c */ 1363, 1364, 1365, 1366, /* a0 */ 1246, 1100, 131, 1671, /* a4 */ 1376, 1377, GROUP(202), GROUP(207), /* a8 */ 1245, 1099, 1306, 1676, /* ac */ 1378, 1379, GROUP(215), 694, /* b0 */ 122, 123, 775, 1674, /* b4 */ 772, 773, 940, 941, /* b8 */ GROUP(221), INVALID, GROUP(222), 1672, /* bc */ 1660, 1661, 930, 931, /* c0 */ 1474, 1475, GROUP(223), 904, /* c4 */ GROUP(224), GROUP(225), GROUP(226), GROUP(227), /* c8 */ 1662, 1663, 1664, 1665, /* cc */ 1666, 1667, 1668, 1669, /* d0 */ GROUP(236), GROUP(237), GROUP(238), GROUP(239), /* d4 */ GROUP(240), GROUP(241), GROUP(242), GROUP(243), /* d8 */ GROUP(244), GROUP(245), GROUP(246), GROUP(247), /* dc */ GROUP(248), GROUP(249), GROUP(250), GROUP(251), /* e0 */ GROUP(252), GROUP(253), GROUP(254), GROUP(255), /* e4 */ GROUP(256), GROUP(257), GROUP(258), GROUP(259), /* e8 */ GROUP(260), GROUP(261), GROUP(262), GROUP(263), /* ec */ GROUP(264), GROUP(265), GROUP(266), GROUP(267), /* f0 */ GROUP(268), GROUP(269), GROUP(270), GROUP(271), /* f4 */ GROUP(272), GROUP(273), GROUP(274), GROUP(275), /* f8 */ GROUP(277), GROUP(278), GROUP(279), GROUP(280), /* fc */ GROUP(281), GROUP(282), GROUP(283), INVALID, }; static const uint16_t ud_itab__5[] = { /* 0 */ 1385, 1407, 786, 798, /* 4 */ 1454, 1455, INVALID, INVALID, }; static const uint16_t ud_itab__6[] = { /* 0 */ GROUP(7), GROUP(8), }; static const uint16_t ud_itab__7[] = { /* 0 */ 1375, 1384, 785, 774, /* 4 */ 1386, INVALID, 787, 719, }; static const uint16_t ud_itab__8[] = { /* 0 */ GROUP(9), GROUP(14), GROUP(15), GROUP(16), /* 4 */ 1387, INVALID, 788, GROUP(25), }; static const uint16_t ud_itab__9[] = { /* 0 */ INVALID, GROUP(10), GROUP(11), GROUP(12), /* 4 */ GROUP(13), INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__10[] = { /* 0 */ INVALID, 1456, INVALID, }; static const uint16_t ud_itab__11[] = { /* 0 */ INVALID, 1462, INVALID, }; static const uint16_t ud_itab__12[] = { /* 0 */ INVALID, 1463, INVALID, }; static const uint16_t ud_itab__13[] = { /* 0 */ INVALID, 1464, INVALID, }; static const uint16_t ud_itab__14[] = { /* 0 */ 824, 952, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__15[] = { /* 0 */ 1486, 1509, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__16[] = { /* 0 */ GROUP(17), GROUP(18), GROUP(19), GROUP(20), /* 4 */ GROUP(21), GROUP(22), GROUP(23), GROUP(24), }; static const uint16_t ud_itab__17[] = { /* 0 */ 1467, INVALID, INVALID, }; static const uint16_t ud_itab__18[] = { /* 0 */ 1468, INVALID, INVALID, }; static const uint16_t ud_itab__19[] = { /* 0 */ 1469, INVALID, INVALID, }; static const uint16_t ud_itab__20[] = { /* 0 */ 1470, INVALID, INVALID, }; static const uint16_t ud_itab__21[] = { /* 0 */ 1398, INVALID, INVALID, }; static const uint16_t ud_itab__22[] = { /* 0 */ 80, INVALID, INVALID, }; static const uint16_t ud_itab__23[] = { /* 0 */ 1400, INVALID, INVALID, }; static const uint16_t ud_itab__24[] = { /* 0 */ 720, INVALID, INVALID, }; static const uint16_t ud_itab__25[] = { /* 0 */ 1426, GROUP(26), INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__26[] = { /* 0 */ 1299, INVALID, INVALID, }; static const uint16_t ud_itab__27[] = { /* 0 */ 1120, 1121, 1122, 1123, /* 4 */ 1124, 1125, 1126, 1127, }; static const uint16_t ud_itab__28[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, /* 8 */ INVALID, INVALID, INVALID, INVALID, /* c */ 1217, 1218, INVALID, INVALID, /* 10 */ INVALID, INVALID, INVALID, INVALID, /* 14 */ INVALID, INVALID, INVALID, INVALID, /* 18 */ INVALID, INVALID, INVALID, INVALID, /* 1c */ 1219, 1220, INVALID, INVALID, /* 20 */ INVALID, INVALID, INVALID, INVALID, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ INVALID, INVALID, INVALID, INVALID, /* 2c */ INVALID, INVALID, INVALID, INVALID, /* 30 */ INVALID, INVALID, INVALID, INVALID, /* 34 */ INVALID, INVALID, INVALID, INVALID, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, /* 40 */ INVALID, INVALID, INVALID, INVALID, /* 44 */ INVALID, INVALID, INVALID, INVALID, /* 48 */ INVALID, INVALID, INVALID, INVALID, /* 4c */ INVALID, INVALID, INVALID, INVALID, /* 50 */ INVALID, INVALID, INVALID, INVALID, /* 54 */ INVALID, INVALID, INVALID, INVALID, /* 58 */ INVALID, INVALID, INVALID, INVALID, /* 5c */ INVALID, INVALID, INVALID, INVALID, /* 60 */ INVALID, INVALID, INVALID, INVALID, /* 64 */ INVALID, INVALID, INVALID, INVALID, /* 68 */ INVALID, INVALID, INVALID, INVALID, /* 6c */ INVALID, INVALID, INVALID, INVALID, /* 70 */ INVALID, INVALID, INVALID, INVALID, /* 74 */ INVALID, INVALID, INVALID, INVALID, /* 78 */ INVALID, INVALID, INVALID, INVALID, /* 7c */ INVALID, INVALID, INVALID, INVALID, /* 80 */ INVALID, INVALID, INVALID, INVALID, /* 84 */ INVALID, INVALID, INVALID, INVALID, /* 88 */ INVALID, INVALID, 1221, INVALID, /* 8c */ INVALID, INVALID, 1222, INVALID, /* 90 */ 1223, INVALID, INVALID, INVALID, /* 94 */ 1224, INVALID, 1225, 1226, /* 98 */ INVALID, INVALID, 1227, INVALID, /* 9c */ INVALID, INVALID, 1228, INVALID, /* a0 */ 1229, INVALID, INVALID, INVALID, /* a4 */ 1230, INVALID, 1231, 1232, /* a8 */ INVALID, INVALID, 1233, INVALID, /* ac */ INVALID, INVALID, 1234, INVALID, /* b0 */ 1235, INVALID, INVALID, INVALID, /* b4 */ 1236, INVALID, 1237, 1238, /* b8 */ INVALID, INVALID, INVALID, 1239, /* bc */ INVALID, INVALID, INVALID, 1240, /* c0 */ INVALID, INVALID, INVALID, INVALID, /* c4 */ INVALID, INVALID, INVALID, INVALID, /* c8 */ INVALID, INVALID, INVALID, INVALID, /* cc */ INVALID, INVALID, INVALID, INVALID, /* d0 */ INVALID, INVALID, INVALID, INVALID, /* d4 */ INVALID, INVALID, INVALID, INVALID, /* d8 */ INVALID, INVALID, INVALID, INVALID, /* dc */ INVALID, INVALID, INVALID, INVALID, /* e0 */ INVALID, INVALID, INVALID, INVALID, /* e4 */ INVALID, INVALID, INVALID, INVALID, /* e8 */ INVALID, INVALID, INVALID, INVALID, /* ec */ INVALID, INVALID, INVALID, INVALID, /* f0 */ INVALID, INVALID, INVALID, INVALID, /* f4 */ INVALID, INVALID, INVALID, INVALID, /* f8 */ INVALID, INVALID, INVALID, INVALID, /* fc */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__29[] = { /* 0 */ 936, 925, 928, 932, }; static const uint16_t ud_itab__30[] = { /* 0 */ 938, 926, 929, 934, }; static const uint16_t ud_itab__31[] = { /* 0 */ GROUP(32), GROUP(33), }; static const uint16_t ud_itab__32[] = { /* 0 */ 892, 1564, 1572, 888, }; static const uint16_t ud_itab__33[] = { /* 0 */ 896, 1562, 1570, INVALID, }; static const uint16_t ud_itab__34[] = { /* 0 */ 894, INVALID, INVALID, 890, }; static const uint16_t ud_itab__35[] = { /* 0 */ 1450, INVALID, INVALID, 1452, }; static const uint16_t ud_itab__36[] = { /* 0 */ 1448, INVALID, INVALID, 1446, }; static const uint16_t ud_itab__37[] = { /* 0 */ GROUP(38), GROUP(39), }; static const uint16_t ud_itab__38[] = { /* 0 */ 882, INVALID, 1568, 878, }; static const uint16_t ud_itab__39[] = { /* 0 */ 886, INVALID, 1566, INVALID, }; static const uint16_t ud_itab__40[] = { /* 0 */ 884, INVALID, INVALID, 880, }; static const uint16_t ud_itab__41[] = { /* 0 */ 1128, 1129, 1130, 1131, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__42[] = { /* 0 */ 862, INVALID, INVALID, 858, }; static const uint16_t ud_itab__43[] = { /* 0 */ 864, INVALID, INVALID, 860, }; static const uint16_t ud_itab__44[] = { /* 0 */ 141, 152, 154, 142, }; static const uint16_t ud_itab__45[] = { /* 0 */ 907, INVALID, INVALID, 905, }; static const uint16_t ud_itab__46[] = { /* 0 */ 165, 166, 168, 162, }; static const uint16_t ud_itab__47[] = { /* 0 */ 147, 148, 158, 138, }; static const uint16_t ud_itab__48[] = { /* 0 */ 1443, INVALID, INVALID, 1441, }; static const uint16_t ud_itab__49[] = { /* 0 */ 129, INVALID, INVALID, 127, }; static const uint16_t ud_itab__50[] = { /* 0 */ 1428, GROUP(51), }; static const uint16_t ud_itab__51[] = { /* 0 */ INVALID, 1429, INVALID, }; static const uint16_t ud_itab__52[] = { /* 0 */ 1430, GROUP(53), }; static const uint16_t ud_itab__53[] = { /* 0 */ INVALID, 1431, INVALID, }; static const uint16_t ud_itab__54[] = { /* 0 */ GROUP(67), GROUP(68), GROUP(63), GROUP(64), /* 4 */ GROUP(65), GROUP(66), GROUP(86), GROUP(90), /* 8 */ GROUP(69), GROUP(70), GROUP(71), GROUP(72), /* c */ INVALID, INVALID, INVALID, INVALID, /* 10 */ GROUP(73), INVALID, INVALID, INVALID, /* 14 */ GROUP(75), GROUP(76), INVALID, GROUP(77), /* 18 */ INVALID, INVALID, INVALID, INVALID, /* 1c */ GROUP(78), GROUP(79), GROUP(80), INVALID, /* 20 */ GROUP(81), GROUP(82), GROUP(83), GROUP(84), /* 24 */ GROUP(85), GROUP(108), INVALID, INVALID, /* 28 */ GROUP(87), GROUP(88), GROUP(89), GROUP(74), /* 2c */ INVALID, INVALID, INVALID, INVALID, /* 30 */ GROUP(91), GROUP(92), GROUP(93), GROUP(94), /* 34 */ GROUP(95), GROUP(96), INVALID, GROUP(97), /* 38 */ GROUP(98), GROUP(99), GROUP(100), GROUP(101), /* 3c */ GROUP(102), GROUP(103), GROUP(104), GROUP(105), /* 40 */ GROUP(106), GROUP(107), INVALID, INVALID, /* 44 */ INVALID, INVALID, INVALID, INVALID, /* 48 */ INVALID, INVALID, INVALID, INVALID, /* 4c */ INVALID, INVALID, INVALID, INVALID, /* 50 */ INVALID, INVALID, INVALID, INVALID, /* 54 */ INVALID, INVALID, INVALID, INVALID, /* 58 */ INVALID, INVALID, INVALID, INVALID, /* 5c */ INVALID, INVALID, INVALID, INVALID, /* 60 */ INVALID, INVALID, INVALID, INVALID, /* 64 */ INVALID, INVALID, INVALID, INVALID, /* 68 */ INVALID, INVALID, INVALID, INVALID, /* 6c */ INVALID, INVALID, INVALID, INVALID, /* 70 */ INVALID, INVALID, INVALID, INVALID, /* 74 */ INVALID, INVALID, INVALID, INVALID, /* 78 */ INVALID, INVALID, INVALID, INVALID, /* 7c */ INVALID, INVALID, INVALID, INVALID, /* 80 */ GROUP(55), GROUP(59), INVALID, INVALID, /* 84 */ INVALID, INVALID, INVALID, INVALID, /* 88 */ INVALID, INVALID, INVALID, INVALID, /* 8c */ INVALID, INVALID, INVALID, INVALID, /* 90 */ INVALID, INVALID, INVALID, INVALID, /* 94 */ INVALID, INVALID, INVALID, INVALID, /* 98 */ INVALID, INVALID, INVALID, INVALID, /* 9c */ INVALID, INVALID, INVALID, INVALID, /* a0 */ INVALID, INVALID, INVALID, INVALID, /* a4 */ INVALID, INVALID, INVALID, INVALID, /* a8 */ INVALID, INVALID, INVALID, INVALID, /* ac */ INVALID, INVALID, INVALID, INVALID, /* b0 */ INVALID, INVALID, INVALID, INVALID, /* b4 */ INVALID, INVALID, INVALID, INVALID, /* b8 */ INVALID, INVALID, INVALID, INVALID, /* bc */ INVALID, INVALID, INVALID, INVALID, /* c0 */ INVALID, INVALID, INVALID, INVALID, /* c4 */ INVALID, INVALID, INVALID, INVALID, /* c8 */ INVALID, INVALID, INVALID, INVALID, /* cc */ INVALID, INVALID, INVALID, INVALID, /* d0 */ INVALID, INVALID, INVALID, INVALID, /* d4 */ INVALID, INVALID, INVALID, INVALID, /* d8 */ INVALID, INVALID, INVALID, GROUP(109), /* dc */ GROUP(110), GROUP(111), GROUP(112), GROUP(113), /* e0 */ INVALID, INVALID, INVALID, INVALID, /* e4 */ INVALID, INVALID, INVALID, INVALID, /* e8 */ INVALID, INVALID, INVALID, INVALID, /* ec */ INVALID, INVALID, INVALID, INVALID, /* f0 */ GROUP(114), GROUP(115), INVALID, INVALID, /* f4 */ INVALID, INVALID, INVALID, INVALID, /* f8 */ INVALID, INVALID, INVALID, INVALID, /* fc */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__55[] = { /* 0 */ INVALID, INVALID, INVALID, GROUP(56), }; static const uint16_t ud_itab__56[] = { /* 0 */ GROUP(57), GROUP(58), }; static const uint16_t ud_itab__57[] = { /* 0 */ INVALID, 717, INVALID, }; static const uint16_t ud_itab__58[] = { /* 0 */ INVALID, 718, INVALID, }; static const uint16_t ud_itab__59[] = { /* 0 */ INVALID, INVALID, INVALID, GROUP(60), }; static const uint16_t ud_itab__60[] = { /* 0 */ GROUP(61), GROUP(62), }; static const uint16_t ud_itab__61[] = { /* 0 */ INVALID, 721, INVALID, }; static const uint16_t ud_itab__62[] = { /* 0 */ INVALID, 722, INVALID, }; static const uint16_t ud_itab__63[] = { /* 0 */ 1589, INVALID, INVALID, 1590, }; static const uint16_t ud_itab__64[] = { /* 0 */ 1592, INVALID, INVALID, 1593, }; static const uint16_t ud_itab__65[] = { /* 0 */ 1595, INVALID, INVALID, 1596, }; static const uint16_t ud_itab__66[] = { /* 0 */ 1598, INVALID, INVALID, 1599, }; static const uint16_t ud_itab__67[] = { /* 0 */ 1583, INVALID, INVALID, 1584, }; static const uint16_t ud_itab__68[] = { /* 0 */ 1586, INVALID, INVALID, 1587, }; static const uint16_t ud_itab__69[] = { /* 0 */ 1607, INVALID, INVALID, 1608, }; static const uint16_t ud_itab__70[] = { /* 0 */ 1613, INVALID, INVALID, 1614, }; static const uint16_t ud_itab__71[] = { /* 0 */ 1610, INVALID, INVALID, 1611, }; static const uint16_t ud_itab__72[] = { /* 0 */ 1616, INVALID, INVALID, 1617, }; static const uint16_t ud_itab__73[] = { /* 0 */ INVALID, INVALID, INVALID, 1622, }; static const uint16_t ud_itab__74[] = { /* 0 */ INVALID, INVALID, INVALID, 1684, }; static const uint16_t ud_itab__75[] = { /* 0 */ INVALID, INVALID, INVALID, 1658, }; static const uint16_t ud_itab__76[] = { /* 0 */ INVALID, INVALID, INVALID, 1657, }; static const uint16_t ud_itab__77[] = { /* 0 */ INVALID, INVALID, INVALID, 1712, }; static const uint16_t ud_itab__78[] = { /* 0 */ 1574, INVALID, INVALID, 1575, }; static const uint16_t ud_itab__79[] = { /* 0 */ 1577, INVALID, INVALID, 1578, }; static const uint16_t ud_itab__80[] = { /* 0 */ 1580, INVALID, INVALID, 1581, }; static const uint16_t ud_itab__81[] = { /* 0 */ INVALID, INVALID, INVALID, 1686, }; static const uint16_t ud_itab__82[] = { /* 0 */ INVALID, INVALID, INVALID, 1688, }; static const uint16_t ud_itab__83[] = { /* 0 */ INVALID, INVALID, INVALID, 1690, }; static const uint16_t ud_itab__84[] = { /* 0 */ INVALID, INVALID, INVALID, 1692, }; static const uint16_t ud_itab__85[] = { /* 0 */ INVALID, INVALID, INVALID, 1694, }; static const uint16_t ud_itab__86[] = { /* 0 */ 1601, INVALID, INVALID, 1602, }; static const uint16_t ud_itab__87[] = { /* 0 */ INVALID, INVALID, INVALID, 1623, }; static const uint16_t ud_itab__88[] = { /* 0 */ INVALID, INVALID, INVALID, 1709, }; static const uint16_t ud_itab__89[] = { /* 0 */ INVALID, INVALID, INVALID, 1682, }; static const uint16_t ud_itab__90[] = { /* 0 */ 1604, INVALID, INVALID, 1605, }; static const uint16_t ud_itab__91[] = { /* 0 */ INVALID, INVALID, INVALID, 1697, }; static const uint16_t ud_itab__92[] = { /* 0 */ INVALID, INVALID, INVALID, 1699, }; static const uint16_t ud_itab__93[] = { /* 0 */ INVALID, INVALID, INVALID, 1701, }; static const uint16_t ud_itab__94[] = { /* 0 */ INVALID, INVALID, INVALID, 1703, }; static const uint16_t ud_itab__95[] = { /* 0 */ INVALID, INVALID, INVALID, 1705, }; static const uint16_t ud_itab__96[] = { /* 0 */ INVALID, INVALID, INVALID, 1707, }; static const uint16_t ud_itab__97[] = { /* 0 */ INVALID, INVALID, INVALID, 1718, }; static const uint16_t ud_itab__98[] = { /* 0 */ INVALID, INVALID, INVALID, 1625, }; static const uint16_t ud_itab__99[] = { /* 0 */ INVALID, INVALID, INVALID, 1627, }; static const uint16_t ud_itab__100[] = { /* 0 */ INVALID, INVALID, INVALID, 1629, }; static const uint16_t ud_itab__101[] = { /* 0 */ INVALID, INVALID, INVALID, 1631, }; static const uint16_t ud_itab__102[] = { /* 0 */ INVALID, INVALID, INVALID, 1633, }; static const uint16_t ud_itab__103[] = { /* 0 */ INVALID, INVALID, INVALID, 1635, }; static const uint16_t ud_itab__104[] = { /* 0 */ INVALID, INVALID, INVALID, 1639, }; static const uint16_t ud_itab__105[] = { /* 0 */ INVALID, INVALID, INVALID, 1637, }; static const uint16_t ud_itab__106[] = { /* 0 */ INVALID, INVALID, INVALID, 1641, }; static const uint16_t ud_itab__107[] = { /* 0 */ INVALID, INVALID, INVALID, 1643, }; static const uint16_t ud_itab__108[] = { /* 0 */ INVALID, INVALID, INVALID, 1696, }; static const uint16_t ud_itab__109[] = { /* 0 */ INVALID, INVALID, INVALID, 45, }; static const uint16_t ud_itab__110[] = { /* 0 */ INVALID, INVALID, INVALID, 41, }; static const uint16_t ud_itab__111[] = { /* 0 */ INVALID, INVALID, INVALID, 43, }; static const uint16_t ud_itab__112[] = { /* 0 */ INVALID, INVALID, INVALID, 37, }; static const uint16_t ud_itab__113[] = { /* 0 */ INVALID, INVALID, INVALID, 39, }; static const uint16_t ud_itab__114[] = { /* 0 */ 1724, 1726, INVALID, INVALID, }; static const uint16_t ud_itab__115[] = { /* 0 */ 1725, 1727, INVALID, INVALID, }; static const uint16_t ud_itab__116[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, /* 8 */ GROUP(117), GROUP(118), GROUP(119), GROUP(120), /* c */ GROUP(121), GROUP(122), GROUP(123), GROUP(124), /* 10 */ INVALID, INVALID, INVALID, INVALID, /* 14 */ GROUP(125), GROUP(126), GROUP(127), GROUP(129), /* 18 */ INVALID, INVALID, INVALID, INVALID, /* 1c */ INVALID, INVALID, INVALID, INVALID, /* 20 */ GROUP(130), GROUP(131), GROUP(132), INVALID, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ INVALID, INVALID, INVALID, INVALID, /* 2c */ INVALID, INVALID, INVALID, INVALID, /* 30 */ INVALID, INVALID, INVALID, INVALID, /* 34 */ INVALID, INVALID, INVALID, INVALID, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, /* 40 */ GROUP(134), GROUP(135), GROUP(136), INVALID, /* 44 */ GROUP(137), INVALID, INVALID, INVALID, /* 48 */ INVALID, INVALID, INVALID, INVALID, /* 4c */ INVALID, INVALID, INVALID, INVALID, /* 50 */ INVALID, INVALID, INVALID, INVALID, /* 54 */ INVALID, INVALID, INVALID, INVALID, /* 58 */ INVALID, INVALID, INVALID, INVALID, /* 5c */ INVALID, INVALID, INVALID, INVALID, /* 60 */ GROUP(139), GROUP(140), GROUP(141), GROUP(142), /* 64 */ INVALID, INVALID, INVALID, INVALID, /* 68 */ INVALID, INVALID, INVALID, INVALID, /* 6c */ INVALID, INVALID, INVALID, INVALID, /* 70 */ INVALID, INVALID, INVALID, INVALID, /* 74 */ INVALID, INVALID, INVALID, INVALID, /* 78 */ INVALID, INVALID, INVALID, INVALID, /* 7c */ INVALID, INVALID, INVALID, INVALID, /* 80 */ INVALID, INVALID, INVALID, INVALID, /* 84 */ INVALID, INVALID, INVALID, INVALID, /* 88 */ INVALID, INVALID, INVALID, INVALID, /* 8c */ INVALID, INVALID, INVALID, INVALID, /* 90 */ INVALID, INVALID, INVALID, INVALID, /* 94 */ INVALID, INVALID, INVALID, INVALID, /* 98 */ INVALID, INVALID, INVALID, INVALID, /* 9c */ INVALID, INVALID, INVALID, INVALID, /* a0 */ INVALID, INVALID, INVALID, INVALID, /* a4 */ INVALID, INVALID, INVALID, INVALID, /* a8 */ INVALID, INVALID, INVALID, INVALID, /* ac */ INVALID, INVALID, INVALID, INVALID, /* b0 */ INVALID, INVALID, INVALID, INVALID, /* b4 */ INVALID, INVALID, INVALID, INVALID, /* b8 */ INVALID, INVALID, INVALID, INVALID, /* bc */ INVALID, INVALID, INVALID, INVALID, /* c0 */ INVALID, INVALID, INVALID, INVALID, /* c4 */ INVALID, INVALID, INVALID, INVALID, /* c8 */ INVALID, INVALID, INVALID, INVALID, /* cc */ INVALID, INVALID, INVALID, INVALID, /* d0 */ INVALID, INVALID, INVALID, INVALID, /* d4 */ INVALID, INVALID, INVALID, INVALID, /* d8 */ INVALID, INVALID, INVALID, INVALID, /* dc */ INVALID, INVALID, INVALID, GROUP(138), /* e0 */ INVALID, INVALID, INVALID, INVALID, /* e4 */ INVALID, INVALID, INVALID, INVALID, /* e8 */ INVALID, INVALID, INVALID, INVALID, /* ec */ INVALID, INVALID, INVALID, INVALID, /* f0 */ INVALID, INVALID, INVALID, INVALID, /* f4 */ INVALID, INVALID, INVALID, INVALID, /* f8 */ INVALID, INVALID, INVALID, INVALID, /* fc */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__117[] = { /* 0 */ INVALID, INVALID, INVALID, 1645, }; static const uint16_t ud_itab__118[] = { /* 0 */ INVALID, INVALID, INVALID, 1647, }; static const uint16_t ud_itab__119[] = { /* 0 */ INVALID, INVALID, INVALID, 1649, }; static const uint16_t ud_itab__120[] = { /* 0 */ INVALID, INVALID, INVALID, 1651, }; static const uint16_t ud_itab__121[] = { /* 0 */ INVALID, INVALID, INVALID, 1655, }; static const uint16_t ud_itab__122[] = { /* 0 */ INVALID, INVALID, INVALID, 1653, }; static const uint16_t ud_itab__123[] = { /* 0 */ INVALID, INVALID, INVALID, 1678, }; static const uint16_t ud_itab__124[] = { /* 0 */ 1619, INVALID, INVALID, 1620, }; static const uint16_t ud_itab__125[] = { /* 0 */ INVALID, INVALID, INVALID, 1045, }; static const uint16_t ud_itab__126[] = { /* 0 */ INVALID, INVALID, INVALID, 1056, }; static const uint16_t ud_itab__127[] = { /* 0 */ INVALID, INVALID, INVALID, GROUP(128), }; static const uint16_t ud_itab__128[] = { /* 0 */ 1047, 1049, 1051, }; static const uint16_t ud_itab__129[] = { /* 0 */ INVALID, INVALID, INVALID, 201, }; static const uint16_t ud_itab__130[] = { /* 0 */ INVALID, INVALID, INVALID, 1058, }; static const uint16_t ud_itab__131[] = { /* 0 */ INVALID, INVALID, INVALID, 1558, }; static const uint16_t ud_itab__132[] = { /* 0 */ INVALID, INVALID, INVALID, GROUP(133), }; static const uint16_t ud_itab__133[] = { /* 0 */ 1062, 1063, 1064, }; static const uint16_t ud_itab__134[] = { /* 0 */ INVALID, INVALID, INVALID, 197, }; static const uint16_t ud_itab__135[] = { /* 0 */ INVALID, INVALID, INVALID, 195, }; static const uint16_t ud_itab__136[] = { /* 0 */ INVALID, INVALID, INVALID, 1680, }; static const uint16_t ud_itab__137[] = { /* 0 */ INVALID, INVALID, INVALID, 1513, }; static const uint16_t ud_itab__138[] = { /* 0 */ INVALID, INVALID, INVALID, 47, }; static const uint16_t ud_itab__139[] = { /* 0 */ INVALID, INVALID, INVALID, 1716, }; static const uint16_t ud_itab__140[] = { /* 0 */ INVALID, INVALID, INVALID, 1714, }; static const uint16_t ud_itab__141[] = { /* 0 */ INVALID, INVALID, INVALID, 1722, }; static const uint16_t ud_itab__142[] = { /* 0 */ INVALID, INVALID, INVALID, 1720, }; static const uint16_t ud_itab__143[] = { /* 0 */ 900, INVALID, INVALID, 898, }; static const uint16_t ud_itab__144[] = { /* 0 */ 1388, 1392, 1394, 1390, }; static const uint16_t ud_itab__145[] = { /* 0 */ 1307, INVALID, 1309, INVALID, }; static const uint16_t ud_itab__146[] = { /* 0 */ 1292, INVALID, 1294, INVALID, }; static const uint16_t ud_itab__147[] = { /* 0 */ 61, INVALID, INVALID, 59, }; static const uint16_t ud_itab__148[] = { /* 0 */ 65, INVALID, INVALID, 63, }; static const uint16_t ud_itab__149[] = { /* 0 */ 976, INVALID, INVALID, 974, }; static const uint16_t ud_itab__150[] = { /* 0 */ 1500, INVALID, INVALID, 1498, }; static const uint16_t ud_itab__151[] = { /* 0 */ 27, 29, 31, 25, }; static const uint16_t ud_itab__152[] = { /* 0 */ 946, 948, 950, 944, }; static const uint16_t ud_itab__153[] = { /* 0 */ 145, 150, 156, 139, }; static const uint16_t ud_itab__154[] = { /* 0 */ 134, INVALID, 163, 143, }; static const uint16_t ud_itab__155[] = { /* 0 */ 1420, 1422, 1424, 1418, }; static const uint16_t ud_itab__156[] = { /* 0 */ 818, 820, 822, 816, }; static const uint16_t ud_itab__157[] = { /* 0 */ 189, 191, 193, 187, }; static const uint16_t ud_itab__158[] = { /* 0 */ 802, 804, 806, 800, }; static const uint16_t ud_itab__159[] = { /* 0 */ 1210, INVALID, INVALID, 1208, }; static const uint16_t ud_itab__160[] = { /* 0 */ 1213, INVALID, INVALID, 1211, }; static const uint16_t ud_itab__161[] = { /* 0 */ 1216, INVALID, INVALID, 1214, }; static const uint16_t ud_itab__162[] = { /* 0 */ 987, INVALID, INVALID, 985, }; static const uint16_t ud_itab__163[] = { /* 0 */ 1038, INVALID, INVALID, 1036, }; static const uint16_t ud_itab__164[] = { /* 0 */ 1041, INVALID, INVALID, 1039, }; static const uint16_t ud_itab__165[] = { /* 0 */ 1044, INVALID, INVALID, 1042, }; static const uint16_t ud_itab__166[] = { /* 0 */ 993, INVALID, INVALID, 991, }; static const uint16_t ud_itab__167[] = { /* 0 */ 1201, INVALID, INVALID, 1199, }; static const uint16_t ud_itab__168[] = { /* 0 */ 1204, INVALID, INVALID, 1202, }; static const uint16_t ud_itab__169[] = { /* 0 */ 1207, INVALID, INVALID, 1205, }; static const uint16_t ud_itab__170[] = { /* 0 */ 990, INVALID, INVALID, 988, }; static const uint16_t ud_itab__171[] = { /* 0 */ INVALID, INVALID, INVALID, 1548, }; static const uint16_t ud_itab__172[] = { /* 0 */ INVALID, INVALID, INVALID, 1546, }; static const uint16_t ud_itab__173[] = { /* 0 */ GROUP(174), INVALID, INVALID, GROUP(175), }; static const uint16_t ud_itab__174[] = { /* 0 */ 866, 867, 910, }; static const uint16_t ud_itab__175[] = { /* 0 */ 868, 870, 911, }; static const uint16_t ud_itab__176[] = { /* 0 */ 920, INVALID, 1523, 1518, }; static const uint16_t ud_itab__177[] = { /* 0 */ 1135, 1538, 1536, 1540, }; static const uint16_t ud_itab__178[] = { /* 0 */ INVALID, INVALID, GROUP(179), INVALID, /* 4 */ GROUP(180), INVALID, GROUP(181), INVALID, }; static const uint16_t ud_itab__179[] = { /* 0 */ 1160, INVALID, INVALID, 1164, }; static const uint16_t ud_itab__180[] = { /* 0 */ 1153, INVALID, INVALID, 1151, }; static const uint16_t ud_itab__181[] = { /* 0 */ 1139, INVALID, INVALID, 1138, }; static const uint16_t ud_itab__182[] = { /* 0 */ INVALID, INVALID, GROUP(183), INVALID, /* 4 */ GROUP(184), INVALID, GROUP(185), INVALID, }; static const uint16_t ud_itab__183[] = { /* 0 */ 1166, INVALID, INVALID, 1170, }; static const uint16_t ud_itab__184[] = { /* 0 */ 1154, INVALID, INVALID, 1158, }; static const uint16_t ud_itab__185[] = { /* 0 */ 1143, INVALID, INVALID, 1142, }; static const uint16_t ud_itab__186[] = { /* 0 */ INVALID, INVALID, GROUP(187), GROUP(188), /* 4 */ INVALID, INVALID, GROUP(189), GROUP(190), }; static const uint16_t ud_itab__187[] = { /* 0 */ 1172, INVALID, INVALID, 1176, }; static const uint16_t ud_itab__188[] = { /* 0 */ INVALID, INVALID, INVALID, 1544, }; static const uint16_t ud_itab__189[] = { /* 0 */ 1147, INVALID, INVALID, 1146, }; static const uint16_t ud_itab__190[] = { /* 0 */ INVALID, INVALID, INVALID, 1542, }; static const uint16_t ud_itab__191[] = { /* 0 */ 1027, INVALID, INVALID, 1028, }; static const uint16_t ud_itab__192[] = { /* 0 */ 1030, INVALID, INVALID, 1031, }; static const uint16_t ud_itab__193[] = { /* 0 */ 1033, INVALID, INVALID, 1034, }; static const uint16_t ud_itab__194[] = { /* 0 */ INVALID, 1465, INVALID, }; static const uint16_t ud_itab__195[] = { /* 0 */ INVALID, 1466, INVALID, }; static const uint16_t ud_itab__196[] = { /* 0 */ INVALID, 1552, INVALID, 1550, }; static const uint16_t ud_itab__197[] = { /* 0 */ INVALID, 1556, INVALID, 1554, }; static const uint16_t ud_itab__198[] = { /* 0 */ GROUP(199), INVALID, 916, GROUP(200), }; static const uint16_t ud_itab__199[] = { /* 0 */ 872, 873, 913, }; static const uint16_t ud_itab__200[] = { /* 0 */ 874, 876, 914, }; static const uint16_t ud_itab__201[] = { /* 0 */ 921, INVALID, 1525, 1516, }; static const uint16_t ud_itab__202[] = { /* 0 */ INVALID, GROUP(203), }; static const uint16_t ud_itab__203[] = { /* 0 */ GROUP(204), GROUP(205), GROUP(206), INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__204[] = { /* 0 */ 825, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__205[] = { /* 0 */ 1510, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__206[] = { /* 0 */ 1511, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__207[] = { /* 0 */ INVALID, GROUP(208), }; static const uint16_t ud_itab__208[] = { /* 0 */ GROUP(209), GROUP(210), GROUP(211), GROUP(212), /* 4 */ GROUP(213), GROUP(214), INVALID, INVALID, }; static const uint16_t ud_itab__209[] = { /* 0 */ 1512, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__210[] = { /* 0 */ 1502, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__211[] = { /* 0 */ 1503, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__212[] = { /* 0 */ 1504, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__213[] = { /* 0 */ 1505, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__214[] = { /* 0 */ 1506, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__215[] = { /* 0 */ GROUP(216), GROUP(217), }; static const uint16_t ud_itab__216[] = { /* 0 */ 683, 682, 768, 1401, /* 4 */ 1508, 1507, INVALID, 79, }; static const uint16_t ud_itab__217[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ INVALID, GROUP(218), GROUP(219), GROUP(220), }; static const uint16_t ud_itab__218[] = { /* 0 */ 777, 778, 779, 780, /* 4 */ 781, 782, 783, 784, }; static const uint16_t ud_itab__219[] = { /* 0 */ 808, 809, 810, 811, /* 4 */ 812, 813, 814, 815, }; static const uint16_t ud_itab__220[] = { /* 0 */ 1367, 1368, 1369, 1370, /* 4 */ 1371, 1372, 1373, 1374, }; static const uint16_t ud_itab__221[] = { /* 0 */ INVALID, INVALID, 1711, INVALID, }; static const uint16_t ud_itab__222[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ 1670, 1677, 1675, 1673, }; static const uint16_t ud_itab__223[] = { /* 0 */ 112, 117, 120, 110, }; static const uint16_t ud_itab__224[] = { /* 0 */ 1059, INVALID, INVALID, 1060, }; static const uint16_t ud_itab__225[] = { /* 0 */ 1055, INVALID, INVALID, 1053, }; static const uint16_t ud_itab__226[] = { /* 0 */ 1382, INVALID, INVALID, 1380, }; static const uint16_t ud_itab__227[] = { /* 0 */ GROUP(228), GROUP(235), }; static const uint16_t ud_itab__228[] = { /* 0 */ INVALID, GROUP(229), INVALID, INVALID, /* 4 */ INVALID, INVALID, GROUP(230), GROUP(234), }; static const uint16_t ud_itab__229[] = { /* 0 */ 124, 125, 126, }; static const uint16_t ud_itab__230[] = { /* 0 */ GROUP(231), INVALID, GROUP(232), GROUP(233), }; static const uint16_t ud_itab__231[] = { /* 0 */ INVALID, 1460, INVALID, }; static const uint16_t ud_itab__232[] = { /* 0 */ INVALID, 1459, INVALID, }; static const uint16_t ud_itab__233[] = { /* 0 */ INVALID, 1458, INVALID, }; static const uint16_t ud_itab__234[] = { /* 0 */ INVALID, 1461, INVALID, }; static const uint16_t ud_itab__235[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, 1457, INVALID, }; static const uint16_t ud_itab__236[] = { /* 0 */ INVALID, 35, INVALID, 33, }; static const uint16_t ud_itab__237[] = { /* 0 */ 1161, INVALID, INVALID, 1162, }; static const uint16_t ud_itab__238[] = { /* 0 */ 1167, INVALID, INVALID, 1168, }; static const uint16_t ud_itab__239[] = { /* 0 */ 1173, INVALID, INVALID, 1174, }; static const uint16_t ud_itab__240[] = { /* 0 */ 1528, INVALID, INVALID, 1529, }; static const uint16_t ud_itab__241[] = { /* 0 */ 1093, INVALID, INVALID, 1094, }; static const uint16_t ud_itab__242[] = { /* 0 */ INVALID, 1522, 1527, 918, }; static const uint16_t ud_itab__243[] = { /* 0 */ 1086, INVALID, INVALID, 1084, }; static const uint16_t ud_itab__244[] = { /* 0 */ 1193, INVALID, INVALID, 1194, }; static const uint16_t ud_itab__245[] = { /* 0 */ 1196, INVALID, INVALID, 1197, }; static const uint16_t ud_itab__246[] = { /* 0 */ 1083, INVALID, INVALID, 1081, }; static const uint16_t ud_itab__247[] = { /* 0 */ 1017, INVALID, INVALID, 1015, }; static const uint16_t ud_itab__248[] = { /* 0 */ 1009, INVALID, INVALID, 1010, }; static const uint16_t ud_itab__249[] = { /* 0 */ 1012, INVALID, INVALID, 1013, }; static const uint16_t ud_itab__250[] = { /* 0 */ 1075, INVALID, INVALID, 1076, }; static const uint16_t ud_itab__251[] = { /* 0 */ 1020, INVALID, INVALID, 1018, }; static const uint16_t ud_itab__252[] = { /* 0 */ 1023, INVALID, INVALID, 1021, }; static const uint16_t ud_itab__253[] = { /* 0 */ 1148, INVALID, INVALID, 1149, }; static const uint16_t ud_itab__254[] = { /* 0 */ 1157, INVALID, INVALID, 1155, }; static const uint16_t ud_itab__255[] = { /* 0 */ 1026, INVALID, INVALID, 1024, }; static const uint16_t ud_itab__256[] = { /* 0 */ 1087, INVALID, INVALID, 1088, }; static const uint16_t ud_itab__257[] = { /* 0 */ 1092, INVALID, INVALID, 1090, }; static const uint16_t ud_itab__258[] = { /* 0 */ INVALID, 136, 132, 160, }; static const uint16_t ud_itab__259[] = { /* 0 */ 909, INVALID, INVALID, 902, }; static const uint16_t ud_itab__260[] = { /* 0 */ 1187, INVALID, INVALID, 1188, }; static const uint16_t ud_itab__261[] = { /* 0 */ 1190, INVALID, INVALID, 1191, }; static const uint16_t ud_itab__262[] = { /* 0 */ 1080, INVALID, INVALID, 1078, }; static const uint16_t ud_itab__263[] = { /* 0 */ 1119, INVALID, INVALID, 1117, }; static const uint16_t ud_itab__264[] = { /* 0 */ 1003, INVALID, INVALID, 1004, }; static const uint16_t ud_itab__265[] = { /* 0 */ 1006, INVALID, INVALID, 1007, }; static const uint16_t ud_itab__266[] = { /* 0 */ 1074, INVALID, INVALID, 1072, }; static const uint16_t ud_itab__267[] = { /* 0 */ 1267, INVALID, INVALID, 1265, }; static const uint16_t ud_itab__268[] = { /* 0 */ INVALID, 1560, INVALID, INVALID, }; static const uint16_t ud_itab__269[] = { /* 0 */ 1137, INVALID, INVALID, 1136, }; static const uint16_t ud_itab__270[] = { /* 0 */ 1141, INVALID, INVALID, 1140, }; static const uint16_t ud_itab__271[] = { /* 0 */ 1145, INVALID, INVALID, 1144, }; static const uint16_t ud_itab__272[] = { /* 0 */ 1534, INVALID, INVALID, 1535, }; static const uint16_t ud_itab__273[] = { /* 0 */ 1069, INVALID, INVALID, 1070, }; static const uint16_t ud_itab__274[] = { /* 0 */ 1134, INVALID, INVALID, 1132, }; static const uint16_t ud_itab__275[] = { /* 0 */ INVALID, GROUP(276), }; static const uint16_t ud_itab__276[] = { /* 0 */ 799, INVALID, INVALID, 1520, }; static const uint16_t ud_itab__277[] = { /* 0 */ 1180, INVALID, INVALID, 1178, }; static const uint16_t ud_itab__278[] = { /* 0 */ 1183, INVALID, INVALID, 1181, }; static const uint16_t ud_itab__279[] = { /* 0 */ 1184, INVALID, INVALID, 1185, }; static const uint16_t ud_itab__280[] = { /* 0 */ 1533, INVALID, INVALID, 1531, }; static const uint16_t ud_itab__281[] = { /* 0 */ 996, INVALID, INVALID, 994, }; static const uint16_t ud_itab__282[] = { /* 0 */ 997, INVALID, INVALID, 998, }; static const uint16_t ud_itab__283[] = { /* 0 */ 1000, INVALID, INVALID, 1001, }; static const uint16_t ud_itab__284[] = { /* 0 */ 1243, INVALID, }; static const uint16_t ud_itab__285[] = { /* 0 */ 1097, INVALID, }; static const uint16_t ud_itab__286[] = { /* 0 */ 1244, INVALID, }; static const uint16_t ud_itab__287[] = { /* 0 */ 1098, INVALID, }; static const uint16_t ud_itab__288[] = { /* 0 */ 173, INVALID, }; static const uint16_t ud_itab__289[] = { /* 0 */ 174, INVALID, }; static const uint16_t ud_itab__290[] = { /* 0 */ 1, INVALID, }; static const uint16_t ud_itab__291[] = { /* 0 */ 4, INVALID, }; static const uint16_t ud_itab__292[] = { /* 0 */ GROUP(293), GROUP(294), INVALID, }; static const uint16_t ud_itab__293[] = { /* 0 */ 1258, INVALID, }; static const uint16_t ud_itab__294[] = { /* 0 */ 1259, INVALID, }; static const uint16_t ud_itab__295[] = { /* 0 */ GROUP(296), GROUP(297), INVALID, }; static const uint16_t ud_itab__296[] = { /* 0 */ 1110, INVALID, }; static const uint16_t ud_itab__297[] = { /* 0 */ 1111, INVALID, }; static const uint16_t ud_itab__298[] = { /* 0 */ 1659, INVALID, }; static const uint16_t ud_itab__299[] = { /* 0 */ 67, 68, }; static const uint16_t ud_itab__300[] = { /* 0 */ 710, 711, INVALID, }; static const uint16_t ud_itab__301[] = { /* 0 */ 983, 984, INVALID, }; static const uint16_t ud_itab__302[] = { /* 0 */ 21, 970, 11, 1343, /* 4 */ 55, 1414, 1494, 106, }; static const uint16_t ud_itab__303[] = { /* 0 */ 23, 971, 13, 1344, /* 4 */ 57, 1415, 1495, 108, }; static const uint16_t ud_itab__304[] = { /* 0 */ GROUP(305), GROUP(306), GROUP(307), GROUP(308), /* 4 */ GROUP(309), GROUP(310), GROUP(311), GROUP(312), }; static const uint16_t ud_itab__305[] = { /* 0 */ 22, INVALID, }; static const uint16_t ud_itab__306[] = { /* 0 */ 972, INVALID, }; static const uint16_t ud_itab__307[] = { /* 0 */ 12, INVALID, }; static const uint16_t ud_itab__308[] = { /* 0 */ 1345, INVALID, }; static const uint16_t ud_itab__309[] = { /* 0 */ 56, INVALID, }; static const uint16_t ud_itab__310[] = { /* 0 */ 1416, INVALID, }; static const uint16_t ud_itab__311[] = { /* 0 */ 1496, INVALID, }; static const uint16_t ud_itab__312[] = { /* 0 */ 107, INVALID, }; static const uint16_t ud_itab__313[] = { /* 0 */ 24, 973, 14, 1346, /* 4 */ 58, 1417, 1497, 109, }; static const uint16_t ud_itab__314[] = { /* 0 */ 1109, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__315[] = { /* 0 */ 74, 75, 76, }; static const uint16_t ud_itab__316[] = { /* 0 */ 170, 171, 172, }; static const uint16_t ud_itab__317[] = { /* 0 */ 73, INVALID, }; static const uint16_t ud_itab__318[] = { /* 0 */ GROUP(319), GROUP(320), GROUP(321), }; static const uint16_t ud_itab__319[] = { /* 0 */ 1260, 1261, }; static const uint16_t ud_itab__320[] = { /* 0 */ 1262, 1263, }; static const uint16_t ud_itab__321[] = { /* 0 */ INVALID, 1264, }; static const uint16_t ud_itab__322[] = { /* 0 */ GROUP(323), GROUP(324), GROUP(325), }; static const uint16_t ud_itab__323[] = { /* 0 */ 1112, 1113, }; static const uint16_t ud_itab__324[] = { /* 0 */ 1114, 1115, }; static const uint16_t ud_itab__325[] = { /* 0 */ INVALID, 1116, }; static const uint16_t ud_itab__326[] = { /* 0 */ 923, 924, 927, }; static const uint16_t ud_itab__327[] = { /* 0 */ 115, 116, 119, }; static const uint16_t ud_itab__328[] = { /* 0 */ 1404, 1405, 1406, }; static const uint16_t ud_itab__329[] = { /* 0 */ 791, 792, 793, }; static const uint16_t ud_itab__330[] = { /* 0 */ 1348, 1349, 1350, }; static const uint16_t ud_itab__331[] = { /* 0 */ 1280, 1287, 1268, 1276, /* 4 */ 1328, 1335, 1319, 1314, }; static const uint16_t ud_itab__332[] = { /* 0 */ 1285, 1288, 1269, 1275, /* 4 */ 1324, 1331, 1320, 1316, }; static const uint16_t ud_itab__333[] = { /* 0 */ GROUP(334), GROUP(335), INVALID, INVALID, /* 4 */ INVALID, GROUP(341), GROUP(357), GROUP(369), /* 8 */ INVALID, GROUP(394), INVALID, INVALID, /* c */ INVALID, GROUP(399), INVALID, INVALID, }; static const uint16_t ud_itab__334[] = { /* 0 */ 771, INVALID, }; static const uint16_t ud_itab__335[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, /* 8 */ INVALID, INVALID, INVALID, INVALID, /* c */ INVALID, INVALID, INVALID, INVALID, /* 10 */ 937, 939, GROUP(336), 895, /* 14 */ 1451, 1449, GROUP(337), 885, /* 18 */ INVALID, INVALID, INVALID, INVALID, /* 1c */ INVALID, INVALID, INVALID, INVALID, /* 20 */ INVALID, INVALID, INVALID, INVALID, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ 863, 865, INVALID, 908, /* 2c */ INVALID, INVALID, 1444, 130, /* 30 */ INVALID, INVALID, INVALID, INVALID, /* 34 */ INVALID, INVALID, INVALID, INVALID, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, /* 40 */ INVALID, INVALID, INVALID, INVALID, /* 44 */ INVALID, INVALID, INVALID, INVALID, /* 48 */ INVALID, INVALID, INVALID, INVALID, /* 4c */ INVALID, INVALID, INVALID, INVALID, /* 50 */ 901, 1389, 1308, 1293, /* 54 */ 62, 66, 977, 1501, /* 58 */ 28, 947, 146, 135, /* 5c */ 1421, 819, 190, 803, /* 60 */ INVALID, INVALID, INVALID, INVALID, /* 64 */ INVALID, INVALID, INVALID, INVALID, /* 68 */ INVALID, INVALID, INVALID, INVALID, /* 6c */ INVALID, INVALID, INVALID, INVALID, /* 70 */ INVALID, INVALID, INVALID, INVALID, /* 74 */ INVALID, INVALID, INVALID, GROUP(340), /* 78 */ INVALID, INVALID, INVALID, INVALID, /* 7c */ INVALID, INVALID, INVALID, INVALID, /* 80 */ INVALID, INVALID, INVALID, INVALID, /* 84 */ INVALID, INVALID, INVALID, INVALID, /* 88 */ INVALID, INVALID, INVALID, INVALID, /* 8c */ INVALID, INVALID, INVALID, INVALID, /* 90 */ INVALID, INVALID, INVALID, INVALID, /* 94 */ INVALID, INVALID, INVALID, INVALID, /* 98 */ INVALID, INVALID, INVALID, INVALID, /* 9c */ INVALID, INVALID, INVALID, INVALID, /* a0 */ INVALID, INVALID, INVALID, INVALID, /* a4 */ INVALID, INVALID, INVALID, INVALID, /* a8 */ INVALID, INVALID, INVALID, INVALID, /* ac */ INVALID, INVALID, GROUP(338), INVALID, /* b0 */ INVALID, INVALID, INVALID, INVALID, /* b4 */ INVALID, INVALID, INVALID, INVALID, /* b8 */ INVALID, INVALID, INVALID, INVALID, /* bc */ INVALID, INVALID, INVALID, INVALID, /* c0 */ INVALID, INVALID, 113, INVALID, /* c4 */ INVALID, INVALID, 1383, INVALID, /* c8 */ INVALID, INVALID, INVALID, INVALID, /* cc */ INVALID, INVALID, INVALID, INVALID, /* d0 */ INVALID, INVALID, INVALID, INVALID, /* d4 */ INVALID, INVALID, INVALID, INVALID, /* d8 */ INVALID, INVALID, INVALID, INVALID, /* dc */ INVALID, INVALID, INVALID, INVALID, /* e0 */ INVALID, INVALID, INVALID, INVALID, /* e4 */ INVALID, INVALID, INVALID, INVALID, /* e8 */ INVALID, INVALID, INVALID, INVALID, /* ec */ INVALID, INVALID, INVALID, INVALID, /* f0 */ INVALID, INVALID, INVALID, INVALID, /* f4 */ INVALID, INVALID, INVALID, INVALID, /* f8 */ INVALID, INVALID, INVALID, INVALID, /* fc */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__336[] = { /* 0 */ 893, 897, }; static const uint16_t ud_itab__337[] = { /* 0 */ 883, 887, }; static const uint16_t ud_itab__338[] = { /* 0 */ GROUP(339), INVALID, }; static const uint16_t ud_itab__339[] = { /* 0 */ INVALID, INVALID, INVALID, 1402, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__340[] = { /* 0 */ 1743, 1744, }; static const uint16_t ud_itab__341[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, /* 8 */ INVALID, INVALID, INVALID, INVALID, /* c */ INVALID, INVALID, INVALID, INVALID, /* 10 */ 933, 935, GROUP(342), 891, /* 14 */ 1453, 1447, GROUP(343), 881, /* 18 */ INVALID, INVALID, INVALID, INVALID, /* 1c */ INVALID, INVALID, INVALID, INVALID, /* 20 */ INVALID, INVALID, INVALID, INVALID, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ 859, 861, INVALID, 906, /* 2c */ INVALID, INVALID, 1442, 128, /* 30 */ INVALID, INVALID, INVALID, INVALID, /* 34 */ INVALID, INVALID, INVALID, INVALID, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, /* 40 */ INVALID, INVALID, INVALID, INVALID, /* 44 */ INVALID, INVALID, INVALID, INVALID, /* 48 */ INVALID, INVALID, INVALID, INVALID, /* 4c */ INVALID, INVALID, INVALID, INVALID, /* 50 */ 899, 1391, INVALID, INVALID, /* 54 */ 60, 64, 975, 1499, /* 58 */ 26, 945, 140, 144, /* 5c */ 1419, 817, 188, 801, /* 60 */ 1209, 1212, 1215, 986, /* 64 */ 1037, 1040, 1043, 992, /* 68 */ 1200, 1203, 1206, 989, /* 6c */ 1549, 1547, GROUP(344), 1519, /* 70 */ 1541, GROUP(345), GROUP(347), GROUP(349), /* 74 */ 1029, 1032, 1035, INVALID, /* 78 */ INVALID, INVALID, INVALID, INVALID, /* 7c */ 1551, 1555, GROUP(351), 1517, /* 80 */ INVALID, INVALID, INVALID, INVALID, /* 84 */ INVALID, INVALID, INVALID, INVALID, /* 88 */ INVALID, INVALID, INVALID, INVALID, /* 8c */ INVALID, INVALID, INVALID, INVALID, /* 90 */ INVALID, INVALID, INVALID, INVALID, /* 94 */ INVALID, INVALID, INVALID, INVALID, /* 98 */ INVALID, INVALID, INVALID, INVALID, /* 9c */ INVALID, INVALID, INVALID, INVALID, /* a0 */ INVALID, INVALID, INVALID, INVALID, /* a4 */ INVALID, INVALID, INVALID, INVALID, /* a8 */ INVALID, INVALID, INVALID, INVALID, /* ac */ INVALID, INVALID, INVALID, INVALID, /* b0 */ INVALID, INVALID, INVALID, INVALID, /* b4 */ INVALID, INVALID, INVALID, INVALID, /* b8 */ INVALID, INVALID, INVALID, INVALID, /* bc */ INVALID, INVALID, INVALID, INVALID, /* c0 */ INVALID, INVALID, 111, INVALID, /* c4 */ 1061, 1054, 1381, INVALID, /* c8 */ INVALID, INVALID, INVALID, INVALID, /* cc */ INVALID, INVALID, INVALID, INVALID, /* d0 */ 34, 1163, 1169, 1175, /* d4 */ 1530, 1095, 919, GROUP(352), /* d8 */ 1195, 1198, 1082, 1016, /* dc */ 1011, 1014, 1077, 1019, /* e0 */ 1022, 1150, 1156, 1025, /* e4 */ 1089, 1091, 161, 903, /* e8 */ 1189, 1192, 1079, 1118, /* ec */ 1005, 1008, 1073, 1266, /* f0 */ INVALID, GROUP(353), GROUP(354), GROUP(355), /* f4 */ INVALID, 1071, 1133, GROUP(356), /* f8 */ 1179, 1182, 1186, 1532, /* fc */ 995, 999, 1002, INVALID, }; static const uint16_t ud_itab__342[] = { /* 0 */ 889, INVALID, }; static const uint16_t ud_itab__343[] = { /* 0 */ 879, INVALID, }; static const uint16_t ud_itab__344[] = { /* 0 */ 869, 871, 912, }; static const uint16_t ud_itab__345[] = { /* 0 */ INVALID, INVALID, 1165, INVALID, /* 4 */ 1152, INVALID, GROUP(346), INVALID, }; static const uint16_t ud_itab__346[] = { /* 0 */ 1757, INVALID, }; static const uint16_t ud_itab__347[] = { /* 0 */ INVALID, INVALID, 1171, INVALID, /* 4 */ 1159, INVALID, GROUP(348), INVALID, }; static const uint16_t ud_itab__348[] = { /* 0 */ 1759, INVALID, }; static const uint16_t ud_itab__349[] = { /* 0 */ INVALID, INVALID, 1177, 1545, /* 4 */ INVALID, INVALID, GROUP(350), 1543, }; static const uint16_t ud_itab__350[] = { /* 0 */ 1761, INVALID, }; static const uint16_t ud_itab__351[] = { /* 0 */ 875, 877, 915, }; static const uint16_t ud_itab__352[] = { /* 0 */ 1085, INVALID, }; static const uint16_t ud_itab__353[] = { /* 0 */ 1756, INVALID, }; static const uint16_t ud_itab__354[] = { /* 0 */ 1758, INVALID, }; static const uint16_t ud_itab__355[] = { /* 0 */ 1760, INVALID, }; static const uint16_t ud_itab__356[] = { /* 0 */ INVALID, 1521, }; static const uint16_t ud_itab__357[] = { /* 0 */ 1585, 1588, 1591, 1594, /* 4 */ 1597, 1600, 1603, 1606, /* 8 */ 1609, 1615, 1612, 1618, /* c */ GROUP(358), GROUP(359), GROUP(360), GROUP(361), /* 10 */ INVALID, INVALID, INVALID, INVALID, /* 14 */ INVALID, INVALID, INVALID, 1713, /* 18 */ GROUP(362), GROUP(363), INVALID, INVALID, /* 1c */ 1576, 1579, 1582, INVALID, /* 20 */ 1687, 1689, 1691, 1693, /* 24 */ 1695, INVALID, INVALID, INVALID, /* 28 */ 1624, 1710, 1683, 1685, /* 2c */ GROUP(365), GROUP(366), GROUP(367), GROUP(368), /* 30 */ 1698, 1700, 1702, 1704, /* 34 */ 1706, 1708, INVALID, 1719, /* 38 */ 1626, 1628, 1630, 1632, /* 3c */ 1634, 1636, 1640, 1638, /* 40 */ 1642, 1644, INVALID, INVALID, /* 44 */ INVALID, INVALID, INVALID, INVALID, /* 48 */ INVALID, INVALID, INVALID, INVALID, /* 4c */ INVALID, INVALID, INVALID, INVALID, /* 50 */ INVALID, INVALID, INVALID, INVALID, /* 54 */ INVALID, INVALID, INVALID, INVALID, /* 58 */ INVALID, INVALID, INVALID, INVALID, /* 5c */ INVALID, INVALID, INVALID, INVALID, /* 60 */ INVALID, INVALID, INVALID, INVALID, /* 64 */ INVALID, INVALID, INVALID, INVALID, /* 68 */ INVALID, INVALID, INVALID, INVALID, /* 6c */ INVALID, INVALID, INVALID, INVALID, /* 70 */ INVALID, INVALID, INVALID, INVALID, /* 74 */ INVALID, INVALID, INVALID, INVALID, /* 78 */ INVALID, INVALID, INVALID, INVALID, /* 7c */ INVALID, INVALID, INVALID, INVALID, /* 80 */ INVALID, INVALID, INVALID, INVALID, /* 84 */ INVALID, INVALID, INVALID, INVALID, /* 88 */ INVALID, INVALID, INVALID, INVALID, /* 8c */ INVALID, INVALID, INVALID, INVALID, /* 90 */ INVALID, INVALID, INVALID, INVALID, /* 94 */ INVALID, INVALID, INVALID, INVALID, /* 98 */ INVALID, INVALID, INVALID, INVALID, /* 9c */ INVALID, INVALID, INVALID, INVALID, /* a0 */ INVALID, INVALID, INVALID, INVALID, /* a4 */ INVALID, INVALID, INVALID, INVALID, /* a8 */ INVALID, INVALID, INVALID, INVALID, /* ac */ INVALID, INVALID, INVALID, INVALID, /* b0 */ INVALID, INVALID, INVALID, INVALID, /* b4 */ INVALID, INVALID, INVALID, INVALID, /* b8 */ INVALID, INVALID, INVALID, INVALID, /* bc */ INVALID, INVALID, INVALID, INVALID, /* c0 */ INVALID, INVALID, INVALID, INVALID, /* c4 */ INVALID, INVALID, INVALID, INVALID, /* c8 */ INVALID, INVALID, INVALID, INVALID, /* cc */ INVALID, INVALID, INVALID, INVALID, /* d0 */ INVALID, INVALID, INVALID, INVALID, /* d4 */ INVALID, INVALID, INVALID, INVALID, /* d8 */ INVALID, INVALID, INVALID, 46, /* dc */ 42, 44, 38, 40, /* e0 */ INVALID, INVALID, INVALID, INVALID, /* e4 */ INVALID, INVALID, INVALID, INVALID, /* e8 */ INVALID, INVALID, INVALID, INVALID, /* ec */ INVALID, INVALID, INVALID, INVALID, /* f0 */ INVALID, INVALID, INVALID, INVALID, /* f4 */ INVALID, INVALID, INVALID, INVALID, /* f8 */ INVALID, INVALID, INVALID, INVALID, /* fc */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__358[] = { /* 0 */ 1738, INVALID, }; static const uint16_t ud_itab__359[] = { /* 0 */ 1736, INVALID, }; static const uint16_t ud_itab__360[] = { /* 0 */ 1741, INVALID, }; static const uint16_t ud_itab__361[] = { /* 0 */ 1742, INVALID, }; static const uint16_t ud_itab__362[] = { /* 0 */ 1728, INVALID, }; static const uint16_t ud_itab__363[] = { /* 0 */ GROUP(364), INVALID, }; static const uint16_t ud_itab__364[] = { /* 0 */ INVALID, 1729, }; static const uint16_t ud_itab__365[] = { /* 0 */ 1732, INVALID, }; static const uint16_t ud_itab__366[] = { /* 0 */ 1734, INVALID, }; static const uint16_t ud_itab__367[] = { /* 0 */ 1733, INVALID, }; static const uint16_t ud_itab__368[] = { /* 0 */ 1735, INVALID, }; static const uint16_t ud_itab__369[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ GROUP(370), GROUP(371), GROUP(372), INVALID, /* 8 */ 1646, 1648, 1650, 1652, /* c */ 1656, 1654, 1679, 1621, /* 10 */ INVALID, INVALID, INVALID, INVALID, /* 14 */ GROUP(374), 1057, GROUP(375), 202, /* 18 */ GROUP(379), GROUP(381), INVALID, INVALID, /* 1c */ INVALID, INVALID, INVALID, INVALID, /* 20 */ GROUP(383), 1559, GROUP(385), INVALID, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ INVALID, INVALID, INVALID, INVALID, /* 2c */ INVALID, INVALID, INVALID, INVALID, /* 30 */ INVALID, INVALID, INVALID, INVALID, /* 34 */ INVALID, INVALID, INVALID, INVALID, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, /* 40 */ 198, 196, 1681, INVALID, /* 44 */ 1514, INVALID, INVALID, INVALID, /* 48 */ INVALID, INVALID, GROUP(391), GROUP(392), /* 4c */ GROUP(393), INVALID, INVALID, INVALID, /* 50 */ INVALID, INVALID, INVALID, INVALID, /* 54 */ INVALID, INVALID, INVALID, INVALID, /* 58 */ INVALID, INVALID, INVALID, INVALID, /* 5c */ INVALID, INVALID, INVALID, INVALID, /* 60 */ 1717, 1715, 1723, 1721, /* 64 */ INVALID, INVALID, INVALID, INVALID, /* 68 */ INVALID, INVALID, INVALID, INVALID, /* 6c */ INVALID, INVALID, INVALID, INVALID, /* 70 */ INVALID, INVALID, INVALID, INVALID, /* 74 */ INVALID, INVALID, INVALID, INVALID, /* 78 */ INVALID, INVALID, INVALID, INVALID, /* 7c */ INVALID, INVALID, INVALID, INVALID, /* 80 */ INVALID, INVALID, INVALID, INVALID, /* 84 */ INVALID, INVALID, INVALID, INVALID, /* 88 */ INVALID, INVALID, INVALID, INVALID, /* 8c */ INVALID, INVALID, INVALID, INVALID, /* 90 */ INVALID, INVALID, INVALID, INVALID, /* 94 */ INVALID, INVALID, INVALID, INVALID, /* 98 */ INVALID, INVALID, INVALID, INVALID, /* 9c */ INVALID, INVALID, INVALID, INVALID, /* a0 */ INVALID, INVALID, INVALID, INVALID, /* a4 */ INVALID, INVALID, INVALID, INVALID, /* a8 */ INVALID, INVALID, INVALID, INVALID, /* ac */ INVALID, INVALID, INVALID, INVALID, /* b0 */ INVALID, INVALID, INVALID, INVALID, /* b4 */ INVALID, INVALID, INVALID, INVALID, /* b8 */ INVALID, INVALID, INVALID, INVALID, /* bc */ INVALID, INVALID, INVALID, INVALID, /* c0 */ INVALID, INVALID, INVALID, INVALID, /* c4 */ INVALID, INVALID, INVALID, INVALID, /* c8 */ INVALID, INVALID, INVALID, INVALID, /* cc */ INVALID, INVALID, INVALID, INVALID, /* d0 */ INVALID, INVALID, INVALID, INVALID, /* d4 */ INVALID, INVALID, INVALID, INVALID, /* d8 */ INVALID, INVALID, INVALID, INVALID, /* dc */ INVALID, INVALID, INVALID, 48, /* e0 */ INVALID, INVALID, INVALID, INVALID, /* e4 */ INVALID, INVALID, INVALID, INVALID, /* e8 */ INVALID, INVALID, INVALID, INVALID, /* ec */ INVALID, INVALID, INVALID, INVALID, /* f0 */ INVALID, INVALID, INVALID, INVALID, /* f4 */ INVALID, INVALID, INVALID, INVALID, /* f8 */ INVALID, INVALID, INVALID, INVALID, /* fc */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__370[] = { /* 0 */ 1739, INVALID, }; static const uint16_t ud_itab__371[] = { /* 0 */ 1737, INVALID, }; static const uint16_t ud_itab__372[] = { /* 0 */ GROUP(373), INVALID, }; static const uint16_t ud_itab__373[] = { /* 0 */ INVALID, 1740, }; static const uint16_t ud_itab__374[] = { /* 0 */ 1046, INVALID, }; static const uint16_t ud_itab__375[] = { /* 0 */ GROUP(376), GROUP(377), GROUP(378), }; static const uint16_t ud_itab__376[] = { /* 0 */ 1048, INVALID, }; static const uint16_t ud_itab__377[] = { /* 0 */ 1050, INVALID, }; static const uint16_t ud_itab__378[] = { /* 0 */ INVALID, 1052, }; static const uint16_t ud_itab__379[] = { /* 0 */ GROUP(380), INVALID, }; static const uint16_t ud_itab__380[] = { /* 0 */ INVALID, 1731, }; static const uint16_t ud_itab__381[] = { /* 0 */ GROUP(382), INVALID, }; static const uint16_t ud_itab__382[] = { /* 0 */ INVALID, 1730, }; static const uint16_t ud_itab__383[] = { /* 0 */ GROUP(384), INVALID, }; static const uint16_t ud_itab__384[] = { /* 0 */ 1065, INVALID, }; static const uint16_t ud_itab__385[] = { /* 0 */ GROUP(386), GROUP(388), }; static const uint16_t ud_itab__386[] = { /* 0 */ GROUP(387), INVALID, }; static const uint16_t ud_itab__387[] = { /* 0 */ 1066, INVALID, }; static const uint16_t ud_itab__388[] = { /* 0 */ GROUP(389), GROUP(390), }; static const uint16_t ud_itab__389[] = { /* 0 */ 1067, INVALID, }; static const uint16_t ud_itab__390[] = { /* 0 */ 1068, INVALID, }; static const uint16_t ud_itab__391[] = { /* 0 */ 1746, INVALID, }; static const uint16_t ud_itab__392[] = { /* 0 */ 1745, INVALID, }; static const uint16_t ud_itab__393[] = { /* 0 */ 1755, INVALID, }; static const uint16_t ud_itab__394[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, /* 8 */ INVALID, INVALID, INVALID, INVALID, /* c */ INVALID, INVALID, INVALID, INVALID, /* 10 */ GROUP(395), GROUP(396), GROUP(397), INVALID, /* 14 */ INVALID, INVALID, GROUP(398), INVALID, /* 18 */ INVALID, INVALID, INVALID, INVALID, /* 1c */ INVALID, INVALID, INVALID, INVALID, /* 20 */ INVALID, INVALID, INVALID, INVALID, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ INVALID, INVALID, 155, INVALID, /* 2c */ 169, 159, INVALID, INVALID, /* 30 */ INVALID, INVALID, INVALID, INVALID, /* 34 */ INVALID, INVALID, INVALID, INVALID, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, /* 40 */ INVALID, INVALID, INVALID, INVALID, /* 44 */ INVALID, INVALID, INVALID, INVALID, /* 48 */ INVALID, INVALID, INVALID, INVALID, /* 4c */ INVALID, INVALID, INVALID, INVALID, /* 50 */ INVALID, 1395, 1310, 1295, /* 54 */ INVALID, INVALID, INVALID, INVALID, /* 58 */ 32, 951, 157, 164, /* 5c */ 1425, 823, 194, 807, /* 60 */ INVALID, INVALID, INVALID, INVALID, /* 64 */ INVALID, INVALID, INVALID, INVALID, /* 68 */ INVALID, INVALID, INVALID, INVALID, /* 6c */ INVALID, INVALID, INVALID, 1524, /* 70 */ 1537, INVALID, INVALID, INVALID, /* 74 */ INVALID, INVALID, INVALID, INVALID, /* 78 */ INVALID, INVALID, INVALID, INVALID, /* 7c */ INVALID, INVALID, 917, 1526, /* 80 */ INVALID, INVALID, INVALID, INVALID, /* 84 */ INVALID, INVALID, INVALID, INVALID, /* 88 */ INVALID, INVALID, INVALID, INVALID, /* 8c */ INVALID, INVALID, INVALID, INVALID, /* 90 */ INVALID, INVALID, INVALID, INVALID, /* 94 */ INVALID, INVALID, INVALID, INVALID, /* 98 */ INVALID, INVALID, INVALID, INVALID, /* 9c */ INVALID, INVALID, INVALID, INVALID, /* a0 */ INVALID, INVALID, INVALID, INVALID, /* a4 */ INVALID, INVALID, INVALID, INVALID, /* a8 */ INVALID, INVALID, INVALID, INVALID, /* ac */ INVALID, INVALID, INVALID, INVALID, /* b0 */ INVALID, INVALID, INVALID, INVALID, /* b4 */ INVALID, INVALID, INVALID, INVALID, /* b8 */ INVALID, INVALID, INVALID, INVALID, /* bc */ INVALID, INVALID, INVALID, INVALID, /* c0 */ INVALID, INVALID, 121, INVALID, /* c4 */ INVALID, INVALID, INVALID, INVALID, /* c8 */ INVALID, INVALID, INVALID, INVALID, /* cc */ INVALID, INVALID, INVALID, INVALID, /* d0 */ INVALID, INVALID, INVALID, INVALID, /* d4 */ INVALID, INVALID, INVALID, INVALID, /* d8 */ INVALID, INVALID, INVALID, INVALID, /* dc */ INVALID, INVALID, INVALID, INVALID, /* e0 */ INVALID, INVALID, INVALID, INVALID, /* e4 */ INVALID, INVALID, 133, INVALID, /* e8 */ INVALID, INVALID, INVALID, INVALID, /* ec */ INVALID, INVALID, INVALID, INVALID, /* f0 */ INVALID, INVALID, INVALID, INVALID, /* f4 */ INVALID, INVALID, INVALID, INVALID, /* f8 */ INVALID, INVALID, INVALID, INVALID, /* fc */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__395[] = { /* 0 */ 1752, 1751, }; static const uint16_t ud_itab__396[] = { /* 0 */ 1754, 1753, }; static const uint16_t ud_itab__397[] = { /* 0 */ 1573, 1571, }; static const uint16_t ud_itab__398[] = { /* 0 */ 1569, 1567, }; static const uint16_t ud_itab__399[] = { /* 0 */ INVALID, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, /* 8 */ INVALID, INVALID, INVALID, INVALID, /* c */ INVALID, INVALID, INVALID, INVALID, /* 10 */ GROUP(402), GROUP(400), GROUP(401), INVALID, /* 14 */ INVALID, INVALID, INVALID, INVALID, /* 18 */ INVALID, INVALID, INVALID, INVALID, /* 1c */ INVALID, INVALID, INVALID, INVALID, /* 20 */ INVALID, INVALID, INVALID, INVALID, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ INVALID, INVALID, 153, INVALID, /* 2c */ 167, 149, INVALID, INVALID, /* 30 */ INVALID, INVALID, INVALID, INVALID, /* 34 */ INVALID, INVALID, INVALID, INVALID, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, /* 40 */ INVALID, INVALID, INVALID, INVALID, /* 44 */ INVALID, INVALID, INVALID, INVALID, /* 48 */ INVALID, INVALID, INVALID, INVALID, /* 4c */ INVALID, INVALID, INVALID, INVALID, /* 50 */ INVALID, 1393, INVALID, INVALID, /* 54 */ INVALID, INVALID, INVALID, INVALID, /* 58 */ 30, 949, 151, INVALID, /* 5c */ 1423, 821, 192, 805, /* 60 */ INVALID, INVALID, INVALID, INVALID, /* 64 */ INVALID, INVALID, INVALID, INVALID, /* 68 */ INVALID, INVALID, INVALID, INVALID, /* 6c */ INVALID, INVALID, INVALID, INVALID, /* 70 */ 1539, INVALID, INVALID, INVALID, /* 74 */ INVALID, INVALID, INVALID, INVALID, /* 78 */ INVALID, INVALID, INVALID, INVALID, /* 7c */ 1553, 1557, INVALID, INVALID, /* 80 */ INVALID, INVALID, INVALID, INVALID, /* 84 */ INVALID, INVALID, INVALID, INVALID, /* 88 */ INVALID, INVALID, INVALID, INVALID, /* 8c */ INVALID, INVALID, INVALID, INVALID, /* 90 */ INVALID, INVALID, INVALID, INVALID, /* 94 */ INVALID, INVALID, INVALID, INVALID, /* 98 */ INVALID, INVALID, INVALID, INVALID, /* 9c */ INVALID, INVALID, INVALID, INVALID, /* a0 */ INVALID, INVALID, INVALID, INVALID, /* a4 */ INVALID, INVALID, INVALID, INVALID, /* a8 */ INVALID, INVALID, INVALID, INVALID, /* ac */ INVALID, INVALID, INVALID, INVALID, /* b0 */ INVALID, INVALID, INVALID, INVALID, /* b4 */ INVALID, INVALID, INVALID, INVALID, /* b8 */ INVALID, INVALID, INVALID, INVALID, /* bc */ INVALID, INVALID, INVALID, INVALID, /* c0 */ INVALID, INVALID, 118, INVALID, /* c4 */ INVALID, INVALID, INVALID, INVALID, /* c8 */ INVALID, INVALID, INVALID, INVALID, /* cc */ INVALID, INVALID, INVALID, INVALID, /* d0 */ 36, INVALID, INVALID, INVALID, /* d4 */ INVALID, INVALID, INVALID, INVALID, /* d8 */ INVALID, INVALID, INVALID, INVALID, /* dc */ INVALID, INVALID, INVALID, INVALID, /* e0 */ INVALID, INVALID, INVALID, INVALID, /* e4 */ INVALID, INVALID, 137, INVALID, /* e8 */ INVALID, INVALID, INVALID, INVALID, /* ec */ INVALID, INVALID, INVALID, INVALID, /* f0 */ 1561, INVALID, INVALID, INVALID, /* f4 */ INVALID, INVALID, INVALID, INVALID, /* f8 */ INVALID, INVALID, INVALID, INVALID, /* fc */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__400[] = { /* 0 */ 1750, 1749, }; static const uint16_t ud_itab__401[] = { /* 0 */ 1565, 1563, }; static const uint16_t ud_itab__402[] = { /* 0 */ 1748, 1747, }; static const uint16_t ud_itab__403[] = { /* 0 */ GROUP(404), GROUP(335), INVALID, INVALID, /* 4 */ INVALID, GROUP(341), GROUP(357), GROUP(369), /* 8 */ INVALID, GROUP(394), INVALID, INVALID, /* c */ INVALID, GROUP(399), INVALID, INVALID, }; static const uint16_t ud_itab__404[] = { /* 0 */ 769, INVALID, }; static const uint16_t ud_itab__405[] = { /* 0 */ 826, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__406[] = { /* 0 */ 827, INVALID, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__407[] = { /* 0 */ 715, INVALID, }; static const uint16_t ud_itab__408[] = { /* 0 */ 723, 724, 725, }; static const uint16_t ud_itab__409[] = { /* 0 */ 1281, 1286, 1270, 1274, /* 4 */ 1327, 1334, 1321, 1315, }; static const uint16_t ud_itab__410[] = { /* 0 */ 1282, 1289, 1273, 1277, /* 4 */ 1326, 1333, 1330, 1313, }; static const uint16_t ud_itab__411[] = { /* 0 */ 1283, 1290, 1271, 1278, /* 4 */ 1325, 1332, 1322, 1317, }; static const uint16_t ud_itab__412[] = { /* 0 */ 1284, 1291, 1272, 1279, /* 4 */ 1329, 1336, 1323, 1318, }; static const uint16_t ud_itab__413[] = { /* 0 */ 3, INVALID, }; static const uint16_t ud_itab__414[] = { /* 0 */ 2, INVALID, }; static const uint16_t ud_itab__415[] = { /* 0 */ 1312, INVALID, }; static const uint16_t ud_itab__416[] = { /* 0 */ GROUP(417), GROUP(418), }; static const uint16_t ud_itab__417[] = { /* 0 */ 206, 503, 307, 357, /* 4 */ 587, 630, 387, 413, }; static const uint16_t ud_itab__418[] = { /* 0 */ 215, 216, 217, 218, /* 4 */ 219, 220, 221, 222, /* 8 */ 504, 505, 506, 507, /* c */ 508, 509, 510, 511, /* 10 */ 309, 310, 311, 312, /* 14 */ 313, 314, 315, 316, /* 18 */ 359, 360, 361, 362, /* 1c */ 363, 364, 365, 366, /* 20 */ 589, 590, 591, 592, /* 24 */ 593, 594, 595, 596, /* 28 */ 614, 615, 616, 617, /* 2c */ 618, 619, 620, 621, /* 30 */ 388, 389, 390, 391, /* 34 */ 392, 393, 394, 395, /* 38 */ 414, 415, 416, 417, /* 3c */ 418, 419, 420, 421, }; static const uint16_t ud_itab__419[] = { /* 0 */ GROUP(420), GROUP(421), }; static const uint16_t ud_itab__420[] = { /* 0 */ 476, INVALID, 573, 540, /* 4 */ 493, 492, 584, 583, }; static const uint16_t ud_itab__421[] = { /* 0 */ 477, 478, 479, 480, /* 4 */ 481, 482, 483, 484, /* 8 */ 658, 659, 660, 661, /* c */ 662, 663, 664, 665, /* 10 */ 522, INVALID, INVALID, INVALID, /* 14 */ INVALID, INVALID, INVALID, INVALID, /* 18 */ 549, 550, 551, 552, /* 1c */ 553, 554, 555, 556, /* 20 */ 233, 204, INVALID, INVALID, /* 24 */ 639, 657, INVALID, INVALID, /* 28 */ 485, 486, 487, 488, /* 2c */ 489, 490, 491, INVALID, /* 30 */ 203, 685, 529, 526, /* 34 */ 684, 528, 377, 454, /* 38 */ 527, 686, 537, 536, /* 3c */ 530, 534, 535, 376, }; static const uint16_t ud_itab__422[] = { /* 0 */ GROUP(423), GROUP(424), }; static const uint16_t ud_itab__423[] = { /* 0 */ 456, 520, 448, 450, /* 4 */ 462, 464, 460, 458, }; static const uint16_t ud_itab__424[] = { /* 0 */ 235, 236, 237, 238, /* 4 */ 239, 240, 241, 242, /* 8 */ 243, 244, 245, 246, /* c */ 247, 248, 249, 250, /* 10 */ 251, 252, 253, 254, /* 14 */ 255, 256, 257, 258, /* 18 */ 259, 260, 261, 262, /* 1c */ 263, 264, 265, 266, /* 20 */ INVALID, INVALID, INVALID, INVALID, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ INVALID, 656, INVALID, INVALID, /* 2c */ INVALID, INVALID, INVALID, INVALID, /* 30 */ INVALID, INVALID, INVALID, INVALID, /* 34 */ INVALID, INVALID, INVALID, INVALID, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__425[] = { /* 0 */ GROUP(426), GROUP(427), }; static const uint16_t ud_itab__426[] = { /* 0 */ 453, 471, 467, 470, /* 4 */ INVALID, 474, INVALID, 538, }; static const uint16_t ud_itab__427[] = { /* 0 */ 267, 268, 269, 270, /* 4 */ 271, 272, 273, 274, /* 8 */ 275, 276, 277, 278, /* c */ 279, 280, 281, 282, /* 10 */ 283, 284, 285, 286, /* 14 */ 287, 288, 289, 290, /* 18 */ 291, 292, 293, 294, /* 1c */ 295, 296, 297, 298, /* 20 */ 524, 523, 234, 455, /* 24 */ 525, 532, INVALID, INVALID, /* 28 */ 299, 300, 301, 302, /* 2c */ 303, 304, 305, 306, /* 30 */ 333, 334, 335, 336, /* 34 */ 337, 338, 339, 340, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__428[] = { /* 0 */ GROUP(429), GROUP(430), }; static const uint16_t ud_itab__429[] = { /* 0 */ 205, 494, 308, 358, /* 4 */ 588, 613, 378, 404, }; static const uint16_t ud_itab__430[] = { /* 0 */ 207, 208, 209, 210, /* 4 */ 211, 212, 213, 214, /* 8 */ 495, 496, 497, 498, /* c */ 499, 500, 501, 502, /* 10 */ 317, 318, 319, 320, /* 14 */ 321, 322, 323, 324, /* 18 */ 325, 326, 327, 328, /* 1c */ 329, 330, 331, 332, /* 20 */ 622, 623, 624, 625, /* 24 */ 626, 627, 628, 629, /* 28 */ 597, 598, 599, 600, /* 2c */ 601, 602, 603, 604, /* 30 */ 405, 406, 407, 408, /* 34 */ 409, 410, 411, 412, /* 38 */ 379, 380, 381, 382, /* 3c */ 383, 384, 385, 386, }; static const uint16_t ud_itab__431[] = { /* 0 */ GROUP(432), GROUP(433), }; static const uint16_t ud_itab__432[] = { /* 0 */ 475, 472, 574, 539, /* 4 */ 531, INVALID, 533, 585, }; static const uint16_t ud_itab__433[] = { /* 0 */ 431, 432, 433, 434, /* 4 */ 435, 436, 437, 438, /* 8 */ 666, 667, 668, 669, /* c */ 670, 671, 672, 673, /* 10 */ 575, 576, 577, 578, /* 14 */ 579, 580, 581, 582, /* 18 */ 541, 542, 543, 544, /* 1c */ 545, 546, 547, 548, /* 20 */ 640, 641, 642, 643, /* 24 */ 644, 645, 646, 647, /* 28 */ 648, 649, 650, 651, /* 2c */ 652, 653, 654, 655, /* 30 */ INVALID, INVALID, INVALID, INVALID, /* 34 */ INVALID, INVALID, INVALID, INVALID, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__434[] = { /* 0 */ GROUP(435), GROUP(436), }; static const uint16_t ud_itab__435[] = { /* 0 */ 457, 521, 447, 449, /* 4 */ 463, 465, 461, 459, }; static const uint16_t ud_itab__436[] = { /* 0 */ 223, 224, 225, 226, /* 4 */ 227, 228, 229, 230, /* 8 */ 512, 513, 514, 515, /* c */ 516, 517, 518, 519, /* 10 */ 367, 368, 369, 370, /* 14 */ 371, 372, 373, 374, /* 18 */ INVALID, 375, INVALID, INVALID, /* 1c */ INVALID, INVALID, INVALID, INVALID, /* 20 */ 631, 632, 633, 634, /* 24 */ 635, 636, 637, 638, /* 28 */ 605, 606, 607, 608, /* 2c */ 609, 610, 611, 612, /* 30 */ 422, 423, 424, 425, /* 34 */ 426, 427, 428, 429, /* 38 */ 396, 397, 398, 399, /* 3c */ 400, 401, 402, 403, }; static const uint16_t ud_itab__437[] = { /* 0 */ GROUP(438), GROUP(439), }; static const uint16_t ud_itab__438[] = { /* 0 */ 451, 473, 466, 468, /* 4 */ 231, 452, 232, 469, }; static const uint16_t ud_itab__439[] = { /* 0 */ 439, 440, 441, 442, /* 4 */ 443, 444, 445, 446, /* 8 */ 674, 675, 676, 677, /* c */ 678, 679, 680, 681, /* 10 */ 557, 558, 559, 560, /* 14 */ 561, 562, 563, 564, /* 18 */ 565, 566, 567, 568, /* 1c */ 569, 570, 571, 572, /* 20 */ 586, INVALID, INVALID, INVALID, /* 24 */ INVALID, INVALID, INVALID, INVALID, /* 28 */ 341, 342, 343, 344, /* 2c */ 345, 346, 347, 348, /* 30 */ 349, 350, 351, 352, /* 34 */ 353, 354, 355, 356, /* 38 */ INVALID, INVALID, INVALID, INVALID, /* 3c */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__440[] = { /* 0 */ 758, 759, 760, }; static const uint16_t ud_itab__441[] = { /* 0 */ 764, INVALID, }; static const uint16_t ud_itab__442[] = { /* 0 */ 1433, 1438, 962, 953, /* 4 */ 942, 695, 186, 689, }; static const uint16_t ud_itab__443[] = { /* 0 */ 1439, 1440, 963, 954, /* 4 */ 943, 696, 185, 688, }; static const uint16_t ud_itab__444[] = { /* 0 */ 708, 183, INVALID, INVALID, /* 4 */ INVALID, INVALID, INVALID, INVALID, }; static const uint16_t ud_itab__445[] = { /* 0 */ 707, 184, GROUP(446), 71, /* 4 */ 761, 762, 1256, INVALID, }; static const uint16_t ud_itab__446[] = { /* 0 */ 69, 70, }; struct ud_lookup_table_list_entry ud_lookup_table_list[] = { /* 000 */ { ud_itab__0, UD_TAB__OPC_TABLE, "opctbl" }, /* 001 */ { ud_itab__1, UD_TAB__OPC_MODE, "/m" }, /* 002 */ { ud_itab__2, UD_TAB__OPC_MODE, "/m" }, /* 003 */ { ud_itab__3, UD_TAB__OPC_MODE, "/m" }, /* 004 */ { ud_itab__4, UD_TAB__OPC_TABLE, "opctbl" }, /* 005 */ { ud_itab__5, UD_TAB__OPC_REG, "/reg" }, /* 006 */ { ud_itab__6, UD_TAB__OPC_MOD, "/mod" }, /* 007 */ { ud_itab__7, UD_TAB__OPC_REG, "/reg" }, /* 008 */ { ud_itab__8, UD_TAB__OPC_REG, "/reg" }, /* 009 */ { ud_itab__9, UD_TAB__OPC_RM, "/rm" }, /* 010 */ { ud_itab__10, UD_TAB__OPC_VENDOR, "/vendor" }, /* 011 */ { ud_itab__11, UD_TAB__OPC_VENDOR, "/vendor" }, /* 012 */ { ud_itab__12, UD_TAB__OPC_VENDOR, "/vendor" }, /* 013 */ { ud_itab__13, UD_TAB__OPC_VENDOR, "/vendor" }, /* 014 */ { ud_itab__14, UD_TAB__OPC_RM, "/rm" }, /* 015 */ { ud_itab__15, UD_TAB__OPC_RM, "/rm" }, /* 016 */ { ud_itab__16, UD_TAB__OPC_RM, "/rm" }, /* 017 */ { ud_itab__17, UD_TAB__OPC_VENDOR, "/vendor" }, /* 018 */ { ud_itab__18, UD_TAB__OPC_VENDOR, "/vendor" }, /* 019 */ { ud_itab__19, UD_TAB__OPC_VENDOR, "/vendor" }, /* 020 */ { ud_itab__20, UD_TAB__OPC_VENDOR, "/vendor" }, /* 021 */ { ud_itab__21, UD_TAB__OPC_VENDOR, "/vendor" }, /* 022 */ { ud_itab__22, UD_TAB__OPC_VENDOR, "/vendor" }, /* 023 */ { ud_itab__23, UD_TAB__OPC_VENDOR, "/vendor" }, /* 024 */ { ud_itab__24, UD_TAB__OPC_VENDOR, "/vendor" }, /* 025 */ { ud_itab__25, UD_TAB__OPC_RM, "/rm" }, /* 026 */ { ud_itab__26, UD_TAB__OPC_VENDOR, "/vendor" }, /* 027 */ { ud_itab__27, UD_TAB__OPC_REG, "/reg" }, /* 028 */ { ud_itab__28, UD_TAB__OPC_3DNOW, "/3dnow" }, /* 029 */ { ud_itab__29, UD_TAB__OPC_SSE, "/sse" }, /* 030 */ { ud_itab__30, UD_TAB__OPC_SSE, "/sse" }, /* 031 */ { ud_itab__31, UD_TAB__OPC_MOD, "/mod" }, /* 032 */ { ud_itab__32, UD_TAB__OPC_SSE, "/sse" }, /* 033 */ { ud_itab__33, UD_TAB__OPC_SSE, "/sse" }, /* 034 */ { ud_itab__34, UD_TAB__OPC_SSE, "/sse" }, /* 035 */ { ud_itab__35, UD_TAB__OPC_SSE, "/sse" }, /* 036 */ { ud_itab__36, UD_TAB__OPC_SSE, "/sse" }, /* 037 */ { ud_itab__37, UD_TAB__OPC_MOD, "/mod" }, /* 038 */ { ud_itab__38, UD_TAB__OPC_SSE, "/sse" }, /* 039 */ { ud_itab__39, UD_TAB__OPC_SSE, "/sse" }, /* 040 */ { ud_itab__40, UD_TAB__OPC_SSE, "/sse" }, /* 041 */ { ud_itab__41, UD_TAB__OPC_REG, "/reg" }, /* 042 */ { ud_itab__42, UD_TAB__OPC_SSE, "/sse" }, /* 043 */ { ud_itab__43, UD_TAB__OPC_SSE, "/sse" }, /* 044 */ { ud_itab__44, UD_TAB__OPC_SSE, "/sse" }, /* 045 */ { ud_itab__45, UD_TAB__OPC_SSE, "/sse" }, /* 046 */ { ud_itab__46, UD_TAB__OPC_SSE, "/sse" }, /* 047 */ { ud_itab__47, UD_TAB__OPC_SSE, "/sse" }, /* 048 */ { ud_itab__48, UD_TAB__OPC_SSE, "/sse" }, /* 049 */ { ud_itab__49, UD_TAB__OPC_SSE, "/sse" }, /* 050 */ { ud_itab__50, UD_TAB__OPC_MODE, "/m" }, /* 051 */ { ud_itab__51, UD_TAB__OPC_VENDOR, "/vendor" }, /* 052 */ { ud_itab__52, UD_TAB__OPC_MODE, "/m" }, /* 053 */ { ud_itab__53, UD_TAB__OPC_VENDOR, "/vendor" }, /* 054 */ { ud_itab__54, UD_TAB__OPC_TABLE, "opctbl" }, /* 055 */ { ud_itab__55, UD_TAB__OPC_SSE, "/sse" }, /* 056 */ { ud_itab__56, UD_TAB__OPC_MODE, "/m" }, /* 057 */ { ud_itab__57, UD_TAB__OPC_VENDOR, "/vendor" }, /* 058 */ { ud_itab__58, UD_TAB__OPC_VENDOR, "/vendor" }, /* 059 */ { ud_itab__59, UD_TAB__OPC_SSE, "/sse" }, /* 060 */ { ud_itab__60, UD_TAB__OPC_MODE, "/m" }, /* 061 */ { ud_itab__61, UD_TAB__OPC_VENDOR, "/vendor" }, /* 062 */ { ud_itab__62, UD_TAB__OPC_VENDOR, "/vendor" }, /* 063 */ { ud_itab__63, UD_TAB__OPC_SSE, "/sse" }, /* 064 */ { ud_itab__64, UD_TAB__OPC_SSE, "/sse" }, /* 065 */ { ud_itab__65, UD_TAB__OPC_SSE, "/sse" }, /* 066 */ { ud_itab__66, UD_TAB__OPC_SSE, "/sse" }, /* 067 */ { ud_itab__67, UD_TAB__OPC_SSE, "/sse" }, /* 068 */ { ud_itab__68, UD_TAB__OPC_SSE, "/sse" }, /* 069 */ { ud_itab__69, UD_TAB__OPC_SSE, "/sse" }, /* 070 */ { ud_itab__70, UD_TAB__OPC_SSE, "/sse" }, /* 071 */ { ud_itab__71, UD_TAB__OPC_SSE, "/sse" }, /* 072 */ { ud_itab__72, UD_TAB__OPC_SSE, "/sse" }, /* 073 */ { ud_itab__73, UD_TAB__OPC_SSE, "/sse" }, /* 074 */ { ud_itab__74, UD_TAB__OPC_SSE, "/sse" }, /* 075 */ { ud_itab__75, UD_TAB__OPC_SSE, "/sse" }, /* 076 */ { ud_itab__76, UD_TAB__OPC_SSE, "/sse" }, /* 077 */ { ud_itab__77, UD_TAB__OPC_SSE, "/sse" }, /* 078 */ { ud_itab__78, UD_TAB__OPC_SSE, "/sse" }, /* 079 */ { ud_itab__79, UD_TAB__OPC_SSE, "/sse" }, /* 080 */ { ud_itab__80, UD_TAB__OPC_SSE, "/sse" }, /* 081 */ { ud_itab__81, UD_TAB__OPC_SSE, "/sse" }, /* 082 */ { ud_itab__82, UD_TAB__OPC_SSE, "/sse" }, /* 083 */ { ud_itab__83, UD_TAB__OPC_SSE, "/sse" }, /* 084 */ { ud_itab__84, UD_TAB__OPC_SSE, "/sse" }, /* 085 */ { ud_itab__85, UD_TAB__OPC_SSE, "/sse" }, /* 086 */ { ud_itab__86, UD_TAB__OPC_SSE, "/sse" }, /* 087 */ { ud_itab__87, UD_TAB__OPC_SSE, "/sse" }, /* 088 */ { ud_itab__88, UD_TAB__OPC_SSE, "/sse" }, /* 089 */ { ud_itab__89, UD_TAB__OPC_SSE, "/sse" }, /* 090 */ { ud_itab__90, UD_TAB__OPC_SSE, "/sse" }, /* 091 */ { ud_itab__91, UD_TAB__OPC_SSE, "/sse" }, /* 092 */ { ud_itab__92, UD_TAB__OPC_SSE, "/sse" }, /* 093 */ { ud_itab__93, UD_TAB__OPC_SSE, "/sse" }, /* 094 */ { ud_itab__94, UD_TAB__OPC_SSE, "/sse" }, /* 095 */ { ud_itab__95, UD_TAB__OPC_SSE, "/sse" }, /* 096 */ { ud_itab__96, UD_TAB__OPC_SSE, "/sse" }, /* 097 */ { ud_itab__97, UD_TAB__OPC_SSE, "/sse" }, /* 098 */ { ud_itab__98, UD_TAB__OPC_SSE, "/sse" }, /* 099 */ { ud_itab__99, UD_TAB__OPC_SSE, "/sse" }, /* 100 */ { ud_itab__100, UD_TAB__OPC_SSE, "/sse" }, /* 101 */ { ud_itab__101, UD_TAB__OPC_SSE, "/sse" }, /* 102 */ { ud_itab__102, UD_TAB__OPC_SSE, "/sse" }, /* 103 */ { ud_itab__103, UD_TAB__OPC_SSE, "/sse" }, /* 104 */ { ud_itab__104, UD_TAB__OPC_SSE, "/sse" }, /* 105 */ { ud_itab__105, UD_TAB__OPC_SSE, "/sse" }, /* 106 */ { ud_itab__106, UD_TAB__OPC_SSE, "/sse" }, /* 107 */ { ud_itab__107, UD_TAB__OPC_SSE, "/sse" }, /* 108 */ { ud_itab__108, UD_TAB__OPC_SSE, "/sse" }, /* 109 */ { ud_itab__109, UD_TAB__OPC_SSE, "/sse" }, /* 110 */ { ud_itab__110, UD_TAB__OPC_SSE, "/sse" }, /* 111 */ { ud_itab__111, UD_TAB__OPC_SSE, "/sse" }, /* 112 */ { ud_itab__112, UD_TAB__OPC_SSE, "/sse" }, /* 113 */ { ud_itab__113, UD_TAB__OPC_SSE, "/sse" }, /* 114 */ { ud_itab__114, UD_TAB__OPC_SSE, "/sse" }, /* 115 */ { ud_itab__115, UD_TAB__OPC_SSE, "/sse" }, /* 116 */ { ud_itab__116, UD_TAB__OPC_TABLE, "opctbl" }, /* 117 */ { ud_itab__117, UD_TAB__OPC_SSE, "/sse" }, /* 118 */ { ud_itab__118, UD_TAB__OPC_SSE, "/sse" }, /* 119 */ { ud_itab__119, UD_TAB__OPC_SSE, "/sse" }, /* 120 */ { ud_itab__120, UD_TAB__OPC_SSE, "/sse" }, /* 121 */ { ud_itab__121, UD_TAB__OPC_SSE, "/sse" }, /* 122 */ { ud_itab__122, UD_TAB__OPC_SSE, "/sse" }, /* 123 */ { ud_itab__123, UD_TAB__OPC_SSE, "/sse" }, /* 124 */ { ud_itab__124, UD_TAB__OPC_SSE, "/sse" }, /* 125 */ { ud_itab__125, UD_TAB__OPC_SSE, "/sse" }, /* 126 */ { ud_itab__126, UD_TAB__OPC_SSE, "/sse" }, /* 127 */ { ud_itab__127, UD_TAB__OPC_SSE, "/sse" }, /* 128 */ { ud_itab__128, UD_TAB__OPC_OSIZE, "/o" }, /* 129 */ { ud_itab__129, UD_TAB__OPC_SSE, "/sse" }, /* 130 */ { ud_itab__130, UD_TAB__OPC_SSE, "/sse" }, /* 131 */ { ud_itab__131, UD_TAB__OPC_SSE, "/sse" }, /* 132 */ { ud_itab__132, UD_TAB__OPC_SSE, "/sse" }, /* 133 */ { ud_itab__133, UD_TAB__OPC_OSIZE, "/o" }, /* 134 */ { ud_itab__134, UD_TAB__OPC_SSE, "/sse" }, /* 135 */ { ud_itab__135, UD_TAB__OPC_SSE, "/sse" }, /* 136 */ { ud_itab__136, UD_TAB__OPC_SSE, "/sse" }, /* 137 */ { ud_itab__137, UD_TAB__OPC_SSE, "/sse" }, /* 138 */ { ud_itab__138, UD_TAB__OPC_SSE, "/sse" }, /* 139 */ { ud_itab__139, UD_TAB__OPC_SSE, "/sse" }, /* 140 */ { ud_itab__140, UD_TAB__OPC_SSE, "/sse" }, /* 141 */ { ud_itab__141, UD_TAB__OPC_SSE, "/sse" }, /* 142 */ { ud_itab__142, UD_TAB__OPC_SSE, "/sse" }, /* 143 */ { ud_itab__143, UD_TAB__OPC_SSE, "/sse" }, /* 144 */ { ud_itab__144, UD_TAB__OPC_SSE, "/sse" }, /* 145 */ { ud_itab__145, UD_TAB__OPC_SSE, "/sse" }, /* 146 */ { ud_itab__146, UD_TAB__OPC_SSE, "/sse" }, /* 147 */ { ud_itab__147, UD_TAB__OPC_SSE, "/sse" }, /* 148 */ { ud_itab__148, UD_TAB__OPC_SSE, "/sse" }, /* 149 */ { ud_itab__149, UD_TAB__OPC_SSE, "/sse" }, /* 150 */ { ud_itab__150, UD_TAB__OPC_SSE, "/sse" }, /* 151 */ { ud_itab__151, UD_TAB__OPC_SSE, "/sse" }, /* 152 */ { ud_itab__152, UD_TAB__OPC_SSE, "/sse" }, /* 153 */ { ud_itab__153, UD_TAB__OPC_SSE, "/sse" }, /* 154 */ { ud_itab__154, UD_TAB__OPC_SSE, "/sse" }, /* 155 */ { ud_itab__155, UD_TAB__OPC_SSE, "/sse" }, /* 156 */ { ud_itab__156, UD_TAB__OPC_SSE, "/sse" }, /* 157 */ { ud_itab__157, UD_TAB__OPC_SSE, "/sse" }, /* 158 */ { ud_itab__158, UD_TAB__OPC_SSE, "/sse" }, /* 159 */ { ud_itab__159, UD_TAB__OPC_SSE, "/sse" }, /* 160 */ { ud_itab__160, UD_TAB__OPC_SSE, "/sse" }, /* 161 */ { ud_itab__161, UD_TAB__OPC_SSE, "/sse" }, /* 162 */ { ud_itab__162, UD_TAB__OPC_SSE, "/sse" }, /* 163 */ { ud_itab__163, UD_TAB__OPC_SSE, "/sse" }, /* 164 */ { ud_itab__164, UD_TAB__OPC_SSE, "/sse" }, /* 165 */ { ud_itab__165, UD_TAB__OPC_SSE, "/sse" }, /* 166 */ { ud_itab__166, UD_TAB__OPC_SSE, "/sse" }, /* 167 */ { ud_itab__167, UD_TAB__OPC_SSE, "/sse" }, /* 168 */ { ud_itab__168, UD_TAB__OPC_SSE, "/sse" }, /* 169 */ { ud_itab__169, UD_TAB__OPC_SSE, "/sse" }, /* 170 */ { ud_itab__170, UD_TAB__OPC_SSE, "/sse" }, /* 171 */ { ud_itab__171, UD_TAB__OPC_SSE, "/sse" }, /* 172 */ { ud_itab__172, UD_TAB__OPC_SSE, "/sse" }, /* 173 */ { ud_itab__173, UD_TAB__OPC_SSE, "/sse" }, /* 174 */ { ud_itab__174, UD_TAB__OPC_OSIZE, "/o" }, /* 175 */ { ud_itab__175, UD_TAB__OPC_OSIZE, "/o" }, /* 176 */ { ud_itab__176, UD_TAB__OPC_SSE, "/sse" }, /* 177 */ { ud_itab__177, UD_TAB__OPC_SSE, "/sse" }, /* 178 */ { ud_itab__178, UD_TAB__OPC_REG, "/reg" }, /* 179 */ { ud_itab__179, UD_TAB__OPC_SSE, "/sse" }, /* 180 */ { ud_itab__180, UD_TAB__OPC_SSE, "/sse" }, /* 181 */ { ud_itab__181, UD_TAB__OPC_SSE, "/sse" }, /* 182 */ { ud_itab__182, UD_TAB__OPC_REG, "/reg" }, /* 183 */ { ud_itab__183, UD_TAB__OPC_SSE, "/sse" }, /* 184 */ { ud_itab__184, UD_TAB__OPC_SSE, "/sse" }, /* 185 */ { ud_itab__185, UD_TAB__OPC_SSE, "/sse" }, /* 186 */ { ud_itab__186, UD_TAB__OPC_REG, "/reg" }, /* 187 */ { ud_itab__187, UD_TAB__OPC_SSE, "/sse" }, /* 188 */ { ud_itab__188, UD_TAB__OPC_SSE, "/sse" }, /* 189 */ { ud_itab__189, UD_TAB__OPC_SSE, "/sse" }, /* 190 */ { ud_itab__190, UD_TAB__OPC_SSE, "/sse" }, /* 191 */ { ud_itab__191, UD_TAB__OPC_SSE, "/sse" }, /* 192 */ { ud_itab__192, UD_TAB__OPC_SSE, "/sse" }, /* 193 */ { ud_itab__193, UD_TAB__OPC_SSE, "/sse" }, /* 194 */ { ud_itab__194, UD_TAB__OPC_VENDOR, "/vendor" }, /* 195 */ { ud_itab__195, UD_TAB__OPC_VENDOR, "/vendor" }, /* 196 */ { ud_itab__196, UD_TAB__OPC_SSE, "/sse" }, /* 197 */ { ud_itab__197, UD_TAB__OPC_SSE, "/sse" }, /* 198 */ { ud_itab__198, UD_TAB__OPC_SSE, "/sse" }, /* 199 */ { ud_itab__199, UD_TAB__OPC_OSIZE, "/o" }, /* 200 */ { ud_itab__200, UD_TAB__OPC_OSIZE, "/o" }, /* 201 */ { ud_itab__201, UD_TAB__OPC_SSE, "/sse" }, /* 202 */ { ud_itab__202, UD_TAB__OPC_MOD, "/mod" }, /* 203 */ { ud_itab__203, UD_TAB__OPC_REG, "/reg" }, /* 204 */ { ud_itab__204, UD_TAB__OPC_RM, "/rm" }, /* 205 */ { ud_itab__205, UD_TAB__OPC_RM, "/rm" }, /* 206 */ { ud_itab__206, UD_TAB__OPC_RM, "/rm" }, /* 207 */ { ud_itab__207, UD_TAB__OPC_MOD, "/mod" }, /* 208 */ { ud_itab__208, UD_TAB__OPC_REG, "/reg" }, /* 209 */ { ud_itab__209, UD_TAB__OPC_RM, "/rm" }, /* 210 */ { ud_itab__210, UD_TAB__OPC_RM, "/rm" }, /* 211 */ { ud_itab__211, UD_TAB__OPC_RM, "/rm" }, /* 212 */ { ud_itab__212, UD_TAB__OPC_RM, "/rm" }, /* 213 */ { ud_itab__213, UD_TAB__OPC_RM, "/rm" }, /* 214 */ { ud_itab__214, UD_TAB__OPC_RM, "/rm" }, /* 215 */ { ud_itab__215, UD_TAB__OPC_MOD, "/mod" }, /* 216 */ { ud_itab__216, UD_TAB__OPC_REG, "/reg" }, /* 217 */ { ud_itab__217, UD_TAB__OPC_REG, "/reg" }, /* 218 */ { ud_itab__218, UD_TAB__OPC_RM, "/rm" }, /* 219 */ { ud_itab__219, UD_TAB__OPC_RM, "/rm" }, /* 220 */ { ud_itab__220, UD_TAB__OPC_RM, "/rm" }, /* 221 */ { ud_itab__221, UD_TAB__OPC_SSE, "/sse" }, /* 222 */ { ud_itab__222, UD_TAB__OPC_REG, "/reg" }, /* 223 */ { ud_itab__223, UD_TAB__OPC_SSE, "/sse" }, /* 224 */ { ud_itab__224, UD_TAB__OPC_SSE, "/sse" }, /* 225 */ { ud_itab__225, UD_TAB__OPC_SSE, "/sse" }, /* 226 */ { ud_itab__226, UD_TAB__OPC_SSE, "/sse" }, /* 227 */ { ud_itab__227, UD_TAB__OPC_MOD, "/mod" }, /* 228 */ { ud_itab__228, UD_TAB__OPC_REG, "/reg" }, /* 229 */ { ud_itab__229, UD_TAB__OPC_OSIZE, "/o" }, /* 230 */ { ud_itab__230, UD_TAB__OPC_SSE, "/sse" }, /* 231 */ { ud_itab__231, UD_TAB__OPC_VENDOR, "/vendor" }, /* 232 */ { ud_itab__232, UD_TAB__OPC_VENDOR, "/vendor" }, /* 233 */ { ud_itab__233, UD_TAB__OPC_VENDOR, "/vendor" }, /* 234 */ { ud_itab__234, UD_TAB__OPC_VENDOR, "/vendor" }, /* 235 */ { ud_itab__235, UD_TAB__OPC_REG, "/reg" }, /* 236 */ { ud_itab__236, UD_TAB__OPC_SSE, "/sse" }, /* 237 */ { ud_itab__237, UD_TAB__OPC_SSE, "/sse" }, /* 238 */ { ud_itab__238, UD_TAB__OPC_SSE, "/sse" }, /* 239 */ { ud_itab__239, UD_TAB__OPC_SSE, "/sse" }, /* 240 */ { ud_itab__240, UD_TAB__OPC_SSE, "/sse" }, /* 241 */ { ud_itab__241, UD_TAB__OPC_SSE, "/sse" }, /* 242 */ { ud_itab__242, UD_TAB__OPC_SSE, "/sse" }, /* 243 */ { ud_itab__243, UD_TAB__OPC_SSE, "/sse" }, /* 244 */ { ud_itab__244, UD_TAB__OPC_SSE, "/sse" }, /* 245 */ { ud_itab__245, UD_TAB__OPC_SSE, "/sse" }, /* 246 */ { ud_itab__246, UD_TAB__OPC_SSE, "/sse" }, /* 247 */ { ud_itab__247, UD_TAB__OPC_SSE, "/sse" }, /* 248 */ { ud_itab__248, UD_TAB__OPC_SSE, "/sse" }, /* 249 */ { ud_itab__249, UD_TAB__OPC_SSE, "/sse" }, /* 250 */ { ud_itab__250, UD_TAB__OPC_SSE, "/sse" }, /* 251 */ { ud_itab__251, UD_TAB__OPC_SSE, "/sse" }, /* 252 */ { ud_itab__252, UD_TAB__OPC_SSE, "/sse" }, /* 253 */ { ud_itab__253, UD_TAB__OPC_SSE, "/sse" }, /* 254 */ { ud_itab__254, UD_TAB__OPC_SSE, "/sse" }, /* 255 */ { ud_itab__255, UD_TAB__OPC_SSE, "/sse" }, /* 256 */ { ud_itab__256, UD_TAB__OPC_SSE, "/sse" }, /* 257 */ { ud_itab__257, UD_TAB__OPC_SSE, "/sse" }, /* 258 */ { ud_itab__258, UD_TAB__OPC_SSE, "/sse" }, /* 259 */ { ud_itab__259, UD_TAB__OPC_SSE, "/sse" }, /* 260 */ { ud_itab__260, UD_TAB__OPC_SSE, "/sse" }, /* 261 */ { ud_itab__261, UD_TAB__OPC_SSE, "/sse" }, /* 262 */ { ud_itab__262, UD_TAB__OPC_SSE, "/sse" }, /* 263 */ { ud_itab__263, UD_TAB__OPC_SSE, "/sse" }, /* 264 */ { ud_itab__264, UD_TAB__OPC_SSE, "/sse" }, /* 265 */ { ud_itab__265, UD_TAB__OPC_SSE, "/sse" }, /* 266 */ { ud_itab__266, UD_TAB__OPC_SSE, "/sse" }, /* 267 */ { ud_itab__267, UD_TAB__OPC_SSE, "/sse" }, /* 268 */ { ud_itab__268, UD_TAB__OPC_SSE, "/sse" }, /* 269 */ { ud_itab__269, UD_TAB__OPC_SSE, "/sse" }, /* 270 */ { ud_itab__270, UD_TAB__OPC_SSE, "/sse" }, /* 271 */ { ud_itab__271, UD_TAB__OPC_SSE, "/sse" }, /* 272 */ { ud_itab__272, UD_TAB__OPC_SSE, "/sse" }, /* 273 */ { ud_itab__273, UD_TAB__OPC_SSE, "/sse" }, /* 274 */ { ud_itab__274, UD_TAB__OPC_SSE, "/sse" }, /* 275 */ { ud_itab__275, UD_TAB__OPC_MOD, "/mod" }, /* 276 */ { ud_itab__276, UD_TAB__OPC_SSE, "/sse" }, /* 277 */ { ud_itab__277, UD_TAB__OPC_SSE, "/sse" }, /* 278 */ { ud_itab__278, UD_TAB__OPC_SSE, "/sse" }, /* 279 */ { ud_itab__279, UD_TAB__OPC_SSE, "/sse" }, /* 280 */ { ud_itab__280, UD_TAB__OPC_SSE, "/sse" }, /* 281 */ { ud_itab__281, UD_TAB__OPC_SSE, "/sse" }, /* 282 */ { ud_itab__282, UD_TAB__OPC_SSE, "/sse" }, /* 283 */ { ud_itab__283, UD_TAB__OPC_SSE, "/sse" }, /* 284 */ { ud_itab__284, UD_TAB__OPC_MODE, "/m" }, /* 285 */ { ud_itab__285, UD_TAB__OPC_MODE, "/m" }, /* 286 */ { ud_itab__286, UD_TAB__OPC_MODE, "/m" }, /* 287 */ { ud_itab__287, UD_TAB__OPC_MODE, "/m" }, /* 288 */ { ud_itab__288, UD_TAB__OPC_MODE, "/m" }, /* 289 */ { ud_itab__289, UD_TAB__OPC_MODE, "/m" }, /* 290 */ { ud_itab__290, UD_TAB__OPC_MODE, "/m" }, /* 291 */ { ud_itab__291, UD_TAB__OPC_MODE, "/m" }, /* 292 */ { ud_itab__292, UD_TAB__OPC_OSIZE, "/o" }, /* 293 */ { ud_itab__293, UD_TAB__OPC_MODE, "/m" }, /* 294 */ { ud_itab__294, UD_TAB__OPC_MODE, "/m" }, /* 295 */ { ud_itab__295, UD_TAB__OPC_OSIZE, "/o" }, /* 296 */ { ud_itab__296, UD_TAB__OPC_MODE, "/m" }, /* 297 */ { ud_itab__297, UD_TAB__OPC_MODE, "/m" }, /* 298 */ { ud_itab__298, UD_TAB__OPC_MODE, "/m" }, /* 299 */ { ud_itab__299, UD_TAB__OPC_MODE, "/m" }, /* 300 */ { ud_itab__300, UD_TAB__OPC_OSIZE, "/o" }, /* 301 */ { ud_itab__301, UD_TAB__OPC_OSIZE, "/o" }, /* 302 */ { ud_itab__302, UD_TAB__OPC_REG, "/reg" }, /* 303 */ { ud_itab__303, UD_TAB__OPC_REG, "/reg" }, /* 304 */ { ud_itab__304, UD_TAB__OPC_REG, "/reg" }, /* 305 */ { ud_itab__305, UD_TAB__OPC_MODE, "/m" }, /* 306 */ { ud_itab__306, UD_TAB__OPC_MODE, "/m" }, /* 307 */ { ud_itab__307, UD_TAB__OPC_MODE, "/m" }, /* 308 */ { ud_itab__308, UD_TAB__OPC_MODE, "/m" }, /* 309 */ { ud_itab__309, UD_TAB__OPC_MODE, "/m" }, /* 310 */ { ud_itab__310, UD_TAB__OPC_MODE, "/m" }, /* 311 */ { ud_itab__311, UD_TAB__OPC_MODE, "/m" }, /* 312 */ { ud_itab__312, UD_TAB__OPC_MODE, "/m" }, /* 313 */ { ud_itab__313, UD_TAB__OPC_REG, "/reg" }, /* 314 */ { ud_itab__314, UD_TAB__OPC_REG, "/reg" }, /* 315 */ { ud_itab__315, UD_TAB__OPC_OSIZE, "/o" }, /* 316 */ { ud_itab__316, UD_TAB__OPC_OSIZE, "/o" }, /* 317 */ { ud_itab__317, UD_TAB__OPC_MODE, "/m" }, /* 318 */ { ud_itab__318, UD_TAB__OPC_OSIZE, "/o" }, /* 319 */ { ud_itab__319, UD_TAB__OPC_MODE, "/m" }, /* 320 */ { ud_itab__320, UD_TAB__OPC_MODE, "/m" }, /* 321 */ { ud_itab__321, UD_TAB__OPC_MODE, "/m" }, /* 322 */ { ud_itab__322, UD_TAB__OPC_OSIZE, "/o" }, /* 323 */ { ud_itab__323, UD_TAB__OPC_MODE, "/m" }, /* 324 */ { ud_itab__324, UD_TAB__OPC_MODE, "/m" }, /* 325 */ { ud_itab__325, UD_TAB__OPC_MODE, "/m" }, /* 326 */ { ud_itab__326, UD_TAB__OPC_OSIZE, "/o" }, /* 327 */ { ud_itab__327, UD_TAB__OPC_OSIZE, "/o" }, /* 328 */ { ud_itab__328, UD_TAB__OPC_OSIZE, "/o" }, /* 329 */ { ud_itab__329, UD_TAB__OPC_OSIZE, "/o" }, /* 330 */ { ud_itab__330, UD_TAB__OPC_OSIZE, "/o" }, /* 331 */ { ud_itab__331, UD_TAB__OPC_REG, "/reg" }, /* 332 */ { ud_itab__332, UD_TAB__OPC_REG, "/reg" }, /* 333 */ { ud_itab__333, UD_TAB__OPC_VEX, "/vex" }, /* 334 */ { ud_itab__334, UD_TAB__OPC_MODE, "/m" }, /* 335 */ { ud_itab__335, UD_TAB__OPC_TABLE, "opctbl" }, /* 336 */ { ud_itab__336, UD_TAB__OPC_MOD, "/mod" }, /* 337 */ { ud_itab__337, UD_TAB__OPC_MOD, "/mod" }, /* 338 */ { ud_itab__338, UD_TAB__OPC_MOD, "/mod" }, /* 339 */ { ud_itab__339, UD_TAB__OPC_REG, "/reg" }, /* 340 */ { ud_itab__340, UD_TAB__OPC_VEX_L, "/vexl" }, /* 341 */ { ud_itab__341, UD_TAB__OPC_TABLE, "opctbl" }, /* 342 */ { ud_itab__342, UD_TAB__OPC_MOD, "/mod" }, /* 343 */ { ud_itab__343, UD_TAB__OPC_MOD, "/mod" }, /* 344 */ { ud_itab__344, UD_TAB__OPC_OSIZE, "/o" }, /* 345 */ { ud_itab__345, UD_TAB__OPC_REG, "/reg" }, /* 346 */ { ud_itab__346, UD_TAB__OPC_VEX_L, "/vexl" }, /* 347 */ { ud_itab__347, UD_TAB__OPC_REG, "/reg" }, /* 348 */ { ud_itab__348, UD_TAB__OPC_VEX_L, "/vexl" }, /* 349 */ { ud_itab__349, UD_TAB__OPC_REG, "/reg" }, /* 350 */ { ud_itab__350, UD_TAB__OPC_VEX_L, "/vexl" }, /* 351 */ { ud_itab__351, UD_TAB__OPC_OSIZE, "/o" }, /* 352 */ { ud_itab__352, UD_TAB__OPC_VEX_L, "/vexl" }, /* 353 */ { ud_itab__353, UD_TAB__OPC_VEX_L, "/vexl" }, /* 354 */ { ud_itab__354, UD_TAB__OPC_VEX_L, "/vexl" }, /* 355 */ { ud_itab__355, UD_TAB__OPC_VEX_L, "/vexl" }, /* 356 */ { ud_itab__356, UD_TAB__OPC_MOD, "/mod" }, /* 357 */ { ud_itab__357, UD_TAB__OPC_TABLE, "opctbl" }, /* 358 */ { ud_itab__358, UD_TAB__OPC_VEX_W, "/vexw" }, /* 359 */ { ud_itab__359, UD_TAB__OPC_VEX_W, "/vexw" }, /* 360 */ { ud_itab__360, UD_TAB__OPC_VEX_W, "/vexw" }, /* 361 */ { ud_itab__361, UD_TAB__OPC_VEX_W, "/vexw" }, /* 362 */ { ud_itab__362, UD_TAB__OPC_VEX_W, "/vexw" }, /* 363 */ { ud_itab__363, UD_TAB__OPC_VEX_W, "/vexw" }, /* 364 */ { ud_itab__364, UD_TAB__OPC_VEX_L, "/vexl" }, /* 365 */ { ud_itab__365, UD_TAB__OPC_VEX_W, "/vexw" }, /* 366 */ { ud_itab__366, UD_TAB__OPC_VEX_W, "/vexw" }, /* 367 */ { ud_itab__367, UD_TAB__OPC_VEX_W, "/vexw" }, /* 368 */ { ud_itab__368, UD_TAB__OPC_VEX_W, "/vexw" }, /* 369 */ { ud_itab__369, UD_TAB__OPC_TABLE, "opctbl" }, /* 370 */ { ud_itab__370, UD_TAB__OPC_VEX_W, "/vexw" }, /* 371 */ { ud_itab__371, UD_TAB__OPC_VEX_W, "/vexw" }, /* 372 */ { ud_itab__372, UD_TAB__OPC_VEX_W, "/vexw" }, /* 373 */ { ud_itab__373, UD_TAB__OPC_VEX_L, "/vexl" }, /* 374 */ { ud_itab__374, UD_TAB__OPC_VEX_W, "/vexw" }, /* 375 */ { ud_itab__375, UD_TAB__OPC_OSIZE, "/o" }, /* 376 */ { ud_itab__376, UD_TAB__OPC_VEX_W, "/vexw" }, /* 377 */ { ud_itab__377, UD_TAB__OPC_VEX_W, "/vexw" }, /* 378 */ { ud_itab__378, UD_TAB__OPC_VEX_W, "/vexw" }, /* 379 */ { ud_itab__379, UD_TAB__OPC_VEX_W, "/vexw" }, /* 380 */ { ud_itab__380, UD_TAB__OPC_VEX_L, "/vexl" }, /* 381 */ { ud_itab__381, UD_TAB__OPC_VEX_W, "/vexw" }, /* 382 */ { ud_itab__382, UD_TAB__OPC_VEX_L, "/vexl" }, /* 383 */ { ud_itab__383, UD_TAB__OPC_VEX_W, "/vexw" }, /* 384 */ { ud_itab__384, UD_TAB__OPC_VEX_L, "/vexl" }, /* 385 */ { ud_itab__385, UD_TAB__OPC_MODE, "/m" }, /* 386 */ { ud_itab__386, UD_TAB__OPC_VEX_W, "/vexw" }, /* 387 */ { ud_itab__387, UD_TAB__OPC_VEX_L, "/vexl" }, /* 388 */ { ud_itab__388, UD_TAB__OPC_VEX_W, "/vexw" }, /* 389 */ { ud_itab__389, UD_TAB__OPC_VEX_L, "/vexl" }, /* 390 */ { ud_itab__390, UD_TAB__OPC_VEX_L, "/vexl" }, /* 391 */ { ud_itab__391, UD_TAB__OPC_VEX_W, "/vexw" }, /* 392 */ { ud_itab__392, UD_TAB__OPC_VEX_W, "/vexw" }, /* 393 */ { ud_itab__393, UD_TAB__OPC_VEX_W, "/vexw" }, /* 394 */ { ud_itab__394, UD_TAB__OPC_TABLE, "opctbl" }, /* 395 */ { ud_itab__395, UD_TAB__OPC_MOD, "/mod" }, /* 396 */ { ud_itab__396, UD_TAB__OPC_MOD, "/mod" }, /* 397 */ { ud_itab__397, UD_TAB__OPC_MOD, "/mod" }, /* 398 */ { ud_itab__398, UD_TAB__OPC_MOD, "/mod" }, /* 399 */ { ud_itab__399, UD_TAB__OPC_TABLE, "opctbl" }, /* 400 */ { ud_itab__400, UD_TAB__OPC_MOD, "/mod" }, /* 401 */ { ud_itab__401, UD_TAB__OPC_MOD, "/mod" }, /* 402 */ { ud_itab__402, UD_TAB__OPC_MOD, "/mod" }, /* 403 */ { ud_itab__403, UD_TAB__OPC_VEX, "/vex" }, /* 404 */ { ud_itab__404, UD_TAB__OPC_MODE, "/m" }, /* 405 */ { ud_itab__405, UD_TAB__OPC_REG, "/reg" }, /* 406 */ { ud_itab__406, UD_TAB__OPC_REG, "/reg" }, /* 407 */ { ud_itab__407, UD_TAB__OPC_MODE, "/m" }, /* 408 */ { ud_itab__408, UD_TAB__OPC_OSIZE, "/o" }, /* 409 */ { ud_itab__409, UD_TAB__OPC_REG, "/reg" }, /* 410 */ { ud_itab__410, UD_TAB__OPC_REG, "/reg" }, /* 411 */ { ud_itab__411, UD_TAB__OPC_REG, "/reg" }, /* 412 */ { ud_itab__412, UD_TAB__OPC_REG, "/reg" }, /* 413 */ { ud_itab__413, UD_TAB__OPC_MODE, "/m" }, /* 414 */ { ud_itab__414, UD_TAB__OPC_MODE, "/m" }, /* 415 */ { ud_itab__415, UD_TAB__OPC_MODE, "/m" }, /* 416 */ { ud_itab__416, UD_TAB__OPC_MOD, "/mod" }, /* 417 */ { ud_itab__417, UD_TAB__OPC_REG, "/reg" }, /* 418 */ { ud_itab__418, UD_TAB__OPC_X87, "/x87" }, /* 419 */ { ud_itab__419, UD_TAB__OPC_MOD, "/mod" }, /* 420 */ { ud_itab__420, UD_TAB__OPC_REG, "/reg" }, /* 421 */ { ud_itab__421, UD_TAB__OPC_X87, "/x87" }, /* 422 */ { ud_itab__422, UD_TAB__OPC_MOD, "/mod" }, /* 423 */ { ud_itab__423, UD_TAB__OPC_REG, "/reg" }, /* 424 */ { ud_itab__424, UD_TAB__OPC_X87, "/x87" }, /* 425 */ { ud_itab__425, UD_TAB__OPC_MOD, "/mod" }, /* 426 */ { ud_itab__426, UD_TAB__OPC_REG, "/reg" }, /* 427 */ { ud_itab__427, UD_TAB__OPC_X87, "/x87" }, /* 428 */ { ud_itab__428, UD_TAB__OPC_MOD, "/mod" }, /* 429 */ { ud_itab__429, UD_TAB__OPC_REG, "/reg" }, /* 430 */ { ud_itab__430, UD_TAB__OPC_X87, "/x87" }, /* 431 */ { ud_itab__431, UD_TAB__OPC_MOD, "/mod" }, /* 432 */ { ud_itab__432, UD_TAB__OPC_REG, "/reg" }, /* 433 */ { ud_itab__433, UD_TAB__OPC_X87, "/x87" }, /* 434 */ { ud_itab__434, UD_TAB__OPC_MOD, "/mod" }, /* 435 */ { ud_itab__435, UD_TAB__OPC_REG, "/reg" }, /* 436 */ { ud_itab__436, UD_TAB__OPC_X87, "/x87" }, /* 437 */ { ud_itab__437, UD_TAB__OPC_MOD, "/mod" }, /* 438 */ { ud_itab__438, UD_TAB__OPC_REG, "/reg" }, /* 439 */ { ud_itab__439, UD_TAB__OPC_X87, "/x87" }, /* 440 */ { ud_itab__440, UD_TAB__OPC_ASIZE, "/a" }, /* 441 */ { ud_itab__441, UD_TAB__OPC_MODE, "/m" }, /* 442 */ { ud_itab__442, UD_TAB__OPC_REG, "/reg" }, /* 443 */ { ud_itab__443, UD_TAB__OPC_REG, "/reg" }, /* 444 */ { ud_itab__444, UD_TAB__OPC_REG, "/reg" }, /* 445 */ { ud_itab__445, UD_TAB__OPC_REG, "/reg" }, /* 446 */ { ud_itab__446, UD_TAB__OPC_MODE, "/m" }, }; /* itab entry operand definitions (for readability) */ #define O_AL { OP_AL, SZ_B } #define O_AX { OP_AX, SZ_W } #define O_Av { OP_A, SZ_V } #define O_C { OP_C, SZ_NA } #define O_CL { OP_CL, SZ_B } #define O_CS { OP_CS, SZ_NA } #define O_CX { OP_CX, SZ_W } #define O_D { OP_D, SZ_NA } #define O_DL { OP_DL, SZ_B } #define O_DS { OP_DS, SZ_NA } #define O_DX { OP_DX, SZ_W } #define O_E { OP_E, SZ_NA } #define O_ES { OP_ES, SZ_NA } #define O_Eb { OP_E, SZ_B } #define O_Ed { OP_E, SZ_D } #define O_Eq { OP_E, SZ_Q } #define O_Ev { OP_E, SZ_V } #define O_Ew { OP_E, SZ_W } #define O_Ey { OP_E, SZ_Y } #define O_Ez { OP_E, SZ_Z } #define O_FS { OP_FS, SZ_NA } #define O_Fv { OP_F, SZ_V } #define O_G { OP_G, SZ_NA } #define O_GS { OP_GS, SZ_NA } #define O_Gb { OP_G, SZ_B } #define O_Gd { OP_G, SZ_D } #define O_Gq { OP_G, SZ_Q } #define O_Gv { OP_G, SZ_V } #define O_Gw { OP_G, SZ_W } #define O_Gy { OP_G, SZ_Y } #define O_Gz { OP_G, SZ_Z } #define O_H { OP_H, SZ_X } #define O_Hqq { OP_H, SZ_QQ } #define O_Hx { OP_H, SZ_X } #define O_I1 { OP_I1, SZ_NA } #define O_I3 { OP_I3, SZ_NA } #define O_Ib { OP_I, SZ_B } #define O_Iv { OP_I, SZ_V } #define O_Iw { OP_I, SZ_W } #define O_Iz { OP_I, SZ_Z } #define O_Jb { OP_J, SZ_B } #define O_Jv { OP_J, SZ_V } #define O_Jz { OP_J, SZ_Z } #define O_L { OP_L, SZ_O } #define O_Lx { OP_L, SZ_X } #define O_M { OP_M, SZ_NA } #define O_Mb { OP_M, SZ_B } #define O_MbRd { OP_MR, SZ_BD } #define O_MbRv { OP_MR, SZ_BV } #define O_Md { OP_M, SZ_D } #define O_MdRy { OP_MR, SZ_DY } #define O_MdU { OP_MU, SZ_DO } #define O_Mdq { OP_M, SZ_DQ } #define O_Mo { OP_M, SZ_O } #define O_Mq { OP_M, SZ_Q } #define O_MqU { OP_MU, SZ_QO } #define O_Ms { OP_M, SZ_W } #define O_Mt { OP_M, SZ_T } #define O_Mv { OP_M, SZ_V } #define O_Mw { OP_M, SZ_W } #define O_MwRd { OP_MR, SZ_WD } #define O_MwRv { OP_MR, SZ_WV } #define O_MwRy { OP_MR, SZ_WY } #define O_MwU { OP_MU, SZ_WO } #define O_N { OP_N, SZ_Q } #define O_NONE { OP_NONE, SZ_NA } #define O_Ob { OP_O, SZ_B } #define O_Ov { OP_O, SZ_V } #define O_Ow { OP_O, SZ_W } #define O_P { OP_P, SZ_Q } #define O_Q { OP_Q, SZ_Q } #define O_R { OP_R, SZ_RDQ } #define O_R0b { OP_R0, SZ_B } #define O_R0v { OP_R0, SZ_V } #define O_R0w { OP_R0, SZ_W } #define O_R0y { OP_R0, SZ_Y } #define O_R0z { OP_R0, SZ_Z } #define O_R1b { OP_R1, SZ_B } #define O_R1v { OP_R1, SZ_V } #define O_R1w { OP_R1, SZ_W } #define O_R1y { OP_R1, SZ_Y } #define O_R1z { OP_R1, SZ_Z } #define O_R2b { OP_R2, SZ_B } #define O_R2v { OP_R2, SZ_V } #define O_R2w { OP_R2, SZ_W } #define O_R2y { OP_R2, SZ_Y } #define O_R2z { OP_R2, SZ_Z } #define O_R3b { OP_R3, SZ_B } #define O_R3v { OP_R3, SZ_V } #define O_R3w { OP_R3, SZ_W } #define O_R3y { OP_R3, SZ_Y } #define O_R3z { OP_R3, SZ_Z } #define O_R4b { OP_R4, SZ_B } #define O_R4v { OP_R4, SZ_V } #define O_R4w { OP_R4, SZ_W } #define O_R4y { OP_R4, SZ_Y } #define O_R4z { OP_R4, SZ_Z } #define O_R5b { OP_R5, SZ_B } #define O_R5v { OP_R5, SZ_V } #define O_R5w { OP_R5, SZ_W } #define O_R5y { OP_R5, SZ_Y } #define O_R5z { OP_R5, SZ_Z } #define O_R6b { OP_R6, SZ_B } #define O_R6v { OP_R6, SZ_V } #define O_R6w { OP_R6, SZ_W } #define O_R6y { OP_R6, SZ_Y } #define O_R6z { OP_R6, SZ_Z } #define O_R7b { OP_R7, SZ_B } #define O_R7v { OP_R7, SZ_V } #define O_R7w { OP_R7, SZ_W } #define O_R7y { OP_R7, SZ_Y } #define O_R7z { OP_R7, SZ_Z } #define O_S { OP_S, SZ_W } #define O_SS { OP_SS, SZ_NA } #define O_ST0 { OP_ST0, SZ_NA } #define O_ST1 { OP_ST1, SZ_NA } #define O_ST2 { OP_ST2, SZ_NA } #define O_ST3 { OP_ST3, SZ_NA } #define O_ST4 { OP_ST4, SZ_NA } #define O_ST5 { OP_ST5, SZ_NA } #define O_ST6 { OP_ST6, SZ_NA } #define O_ST7 { OP_ST7, SZ_NA } #define O_U { OP_U, SZ_O } #define O_Ux { OP_U, SZ_X } #define O_V { OP_V, SZ_DQ } #define O_Vdq { OP_V, SZ_DQ } #define O_Vqq { OP_V, SZ_QQ } #define O_Vsd { OP_V, SZ_Q } #define O_Vx { OP_V, SZ_X } #define O_W { OP_W, SZ_DQ } #define O_Wdq { OP_W, SZ_DQ } #define O_Wqq { OP_W, SZ_QQ } #define O_Wsd { OP_W, SZ_Q } #define O_Wx { OP_W, SZ_X } #define O_eAX { OP_eAX, SZ_Z } #define O_eCX { OP_eCX, SZ_Z } #define O_eDX { OP_eDX, SZ_Z } #define O_rAX { OP_rAX, SZ_V } #define O_rCX { OP_rCX, SZ_V } #define O_rDX { OP_rDX, SZ_V } #define O_sIb { OP_sI, SZ_B } #define O_sIv { OP_sI, SZ_V } #define O_sIz { OP_sI, SZ_Z } struct ud_itab_entry ud_itab[] = { /* 0000 */ { UD_Iinvalid, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0001 */ { UD_Iaaa, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0002 */ { UD_Iaad, O_Ib, O_NONE, O_NONE, O_NONE, P_none }, /* 0003 */ { UD_Iaam, O_Ib, O_NONE, O_NONE, O_NONE, P_none }, /* 0004 */ { UD_Iaas, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0005 */ { UD_Iadc, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0006 */ { UD_Iadc, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0007 */ { UD_Iadc, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0008 */ { UD_Iadc, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0009 */ { UD_Iadc, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 0010 */ { UD_Iadc, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw }, /* 0011 */ { UD_Iadc, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0012 */ { UD_Iadc, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 }, /* 0013 */ { UD_Iadc, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0014 */ { UD_Iadc, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0015 */ { UD_Iadd, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0016 */ { UD_Iadd, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0017 */ { UD_Iadd, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0018 */ { UD_Iadd, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0019 */ { UD_Iadd, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 0020 */ { UD_Iadd, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw }, /* 0021 */ { UD_Iadd, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0022 */ { UD_Iadd, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 }, /* 0023 */ { UD_Iadd, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0024 */ { UD_Iadd, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0025 */ { UD_Iaddpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0026 */ { UD_Ivaddpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0027 */ { UD_Iaddps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0028 */ { UD_Ivaddps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0029 */ { UD_Iaddsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0030 */ { UD_Ivaddsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0031 */ { UD_Iaddss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0032 */ { UD_Ivaddss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0033 */ { UD_Iaddsubpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0034 */ { UD_Ivaddsubpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0035 */ { UD_Iaddsubps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0036 */ { UD_Ivaddsubps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0037 */ { UD_Iaesdec, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0038 */ { UD_Ivaesdec, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0039 */ { UD_Iaesdeclast, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0040 */ { UD_Ivaesdeclast, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0041 */ { UD_Iaesenc, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0042 */ { UD_Ivaesenc, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0043 */ { UD_Iaesenclast, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0044 */ { UD_Ivaesenclast, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0045 */ { UD_Iaesimc, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0046 */ { UD_Ivaesimc, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0047 */ { UD_Iaeskeygenassist, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0048 */ { UD_Ivaeskeygenassist, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0049 */ { UD_Iand, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0050 */ { UD_Iand, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0051 */ { UD_Iand, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0052 */ { UD_Iand, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0053 */ { UD_Iand, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 0054 */ { UD_Iand, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw }, /* 0055 */ { UD_Iand, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0056 */ { UD_Iand, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 }, /* 0057 */ { UD_Iand, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0058 */ { UD_Iand, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0059 */ { UD_Iandpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0060 */ { UD_Ivandpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0061 */ { UD_Iandps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0062 */ { UD_Ivandps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0063 */ { UD_Iandnpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0064 */ { UD_Ivandnpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0065 */ { UD_Iandnps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0066 */ { UD_Ivandnps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0067 */ { UD_Iarpl, O_Ew, O_Gw, O_NONE, O_NONE, P_aso }, /* 0068 */ { UD_Imovsxd, O_Gq, O_Ed, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexx|P_rexr|P_rexb }, /* 0069 */ { UD_Icall, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0070 */ { UD_Icall, O_Eq, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 }, /* 0071 */ { UD_Icall, O_Fv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0072 */ { UD_Icall, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0073 */ { UD_Icall, O_Av, O_NONE, O_NONE, O_NONE, P_oso }, /* 0074 */ { UD_Icbw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw }, /* 0075 */ { UD_Icwde, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw }, /* 0076 */ { UD_Icdqe, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw }, /* 0077 */ { UD_Iclc, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0078 */ { UD_Icld, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0079 */ { UD_Iclflush, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0080 */ { UD_Iclgi, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0081 */ { UD_Icli, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0082 */ { UD_Iclts, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0083 */ { UD_Icmc, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0084 */ { UD_Icmovo, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0085 */ { UD_Icmovno, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0086 */ { UD_Icmovb, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0087 */ { UD_Icmovae, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0088 */ { UD_Icmovz, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0089 */ { UD_Icmovnz, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0090 */ { UD_Icmovbe, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0091 */ { UD_Icmova, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0092 */ { UD_Icmovs, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0093 */ { UD_Icmovns, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0094 */ { UD_Icmovp, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0095 */ { UD_Icmovnp, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0096 */ { UD_Icmovl, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0097 */ { UD_Icmovge, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0098 */ { UD_Icmovle, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0099 */ { UD_Icmovg, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0100 */ { UD_Icmp, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0101 */ { UD_Icmp, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0102 */ { UD_Icmp, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0103 */ { UD_Icmp, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0104 */ { UD_Icmp, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 0105 */ { UD_Icmp, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw }, /* 0106 */ { UD_Icmp, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0107 */ { UD_Icmp, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 }, /* 0108 */ { UD_Icmp, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0109 */ { UD_Icmp, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0110 */ { UD_Icmppd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0111 */ { UD_Ivcmppd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0112 */ { UD_Icmpps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0113 */ { UD_Ivcmpps, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0114 */ { UD_Icmpsb, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_seg }, /* 0115 */ { UD_Icmpsw, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw|P_seg }, /* 0116 */ { UD_Icmpsd, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw|P_seg }, /* 0117 */ { UD_Icmpsd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0118 */ { UD_Ivcmpsd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 0119 */ { UD_Icmpsq, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw|P_seg }, /* 0120 */ { UD_Icmpss, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0121 */ { UD_Ivcmpss, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 0122 */ { UD_Icmpxchg, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0123 */ { UD_Icmpxchg, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0124 */ { UD_Icmpxchg8b, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0125 */ { UD_Icmpxchg8b, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0126 */ { UD_Icmpxchg16b, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0127 */ { UD_Icomisd, O_Vsd, O_Wsd, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0128 */ { UD_Ivcomisd, O_Vsd, O_Wsd, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0129 */ { UD_Icomiss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0130 */ { UD_Ivcomiss, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0131 */ { UD_Icpuid, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0132 */ { UD_Icvtdq2pd, O_V, O_Wdq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0133 */ { UD_Ivcvtdq2pd, O_Vx, O_Wdq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0134 */ { UD_Icvtdq2ps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0135 */ { UD_Ivcvtdq2ps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0136 */ { UD_Icvtpd2dq, O_Vdq, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0137 */ { UD_Ivcvtpd2dq, O_Vdq, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0138 */ { UD_Icvtpd2pi, O_P, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0139 */ { UD_Icvtpd2ps, O_Vdq, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0140 */ { UD_Ivcvtpd2ps, O_Vdq, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0141 */ { UD_Icvtpi2ps, O_V, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0142 */ { UD_Icvtpi2pd, O_V, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0143 */ { UD_Icvtps2dq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0144 */ { UD_Ivcvtps2dq, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0145 */ { UD_Icvtps2pd, O_V, O_Wdq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0146 */ { UD_Ivcvtps2pd, O_Vx, O_Wdq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0147 */ { UD_Icvtps2pi, O_P, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0148 */ { UD_Icvtsd2si, O_Gy, O_MqU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0149 */ { UD_Ivcvtsd2si, O_Gy, O_MqU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0150 */ { UD_Icvtsd2ss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0151 */ { UD_Ivcvtsd2ss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0152 */ { UD_Icvtsi2sd, O_V, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0153 */ { UD_Ivcvtsi2sd, O_Vx, O_Hx, O_Ey, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0154 */ { UD_Icvtsi2ss, O_V, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0155 */ { UD_Ivcvtsi2ss, O_Vx, O_Hx, O_Ey, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0156 */ { UD_Icvtss2sd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0157 */ { UD_Ivcvtss2sd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0158 */ { UD_Icvtss2si, O_Gy, O_MdU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0159 */ { UD_Ivcvtss2si, O_Gy, O_MdU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0160 */ { UD_Icvttpd2dq, O_Vdq, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0161 */ { UD_Ivcvttpd2dq, O_Vdq, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0162 */ { UD_Icvttpd2pi, O_P, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0163 */ { UD_Icvttps2dq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0164 */ { UD_Ivcvttps2dq, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0165 */ { UD_Icvttps2pi, O_P, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0166 */ { UD_Icvttsd2si, O_Gy, O_MqU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0167 */ { UD_Ivcvttsd2si, O_Gy, O_MqU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0168 */ { UD_Icvttss2si, O_Gy, O_MdU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0169 */ { UD_Ivcvttss2si, O_Gy, O_MdU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0170 */ { UD_Icwd, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw }, /* 0171 */ { UD_Icdq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw }, /* 0172 */ { UD_Icqo, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw }, /* 0173 */ { UD_Idaa, O_NONE, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 0174 */ { UD_Idas, O_NONE, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 0175 */ { UD_Idec, O_R0z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0176 */ { UD_Idec, O_R1z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0177 */ { UD_Idec, O_R2z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0178 */ { UD_Idec, O_R3z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0179 */ { UD_Idec, O_R4z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0180 */ { UD_Idec, O_R5z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0181 */ { UD_Idec, O_R6z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0182 */ { UD_Idec, O_R7z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0183 */ { UD_Idec, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0184 */ { UD_Idec, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0185 */ { UD_Idiv, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0186 */ { UD_Idiv, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0187 */ { UD_Idivpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0188 */ { UD_Ivdivpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0189 */ { UD_Idivps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0190 */ { UD_Ivdivps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0191 */ { UD_Idivsd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0192 */ { UD_Ivdivsd, O_Vx, O_Hx, O_MqU, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0193 */ { UD_Idivss, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0194 */ { UD_Ivdivss, O_Vx, O_Hx, O_MdU, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0195 */ { UD_Idppd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0196 */ { UD_Ivdppd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 0197 */ { UD_Idpps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0198 */ { UD_Ivdpps, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0199 */ { UD_Iemms, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0200 */ { UD_Ienter, O_Iw, O_Ib, O_NONE, O_NONE, P_def64 }, /* 0201 */ { UD_Iextractps, O_MdRy, O_V, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 0202 */ { UD_Ivextractps, O_MdRy, O_Vx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 0203 */ { UD_If2xm1, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0204 */ { UD_Ifabs, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0205 */ { UD_Ifadd, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0206 */ { UD_Ifadd, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0207 */ { UD_Ifadd, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0208 */ { UD_Ifadd, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0209 */ { UD_Ifadd, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0210 */ { UD_Ifadd, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0211 */ { UD_Ifadd, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0212 */ { UD_Ifadd, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0213 */ { UD_Ifadd, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0214 */ { UD_Ifadd, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0215 */ { UD_Ifadd, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0216 */ { UD_Ifadd, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0217 */ { UD_Ifadd, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0218 */ { UD_Ifadd, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0219 */ { UD_Ifadd, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0220 */ { UD_Ifadd, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0221 */ { UD_Ifadd, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0222 */ { UD_Ifadd, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0223 */ { UD_Ifaddp, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0224 */ { UD_Ifaddp, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0225 */ { UD_Ifaddp, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0226 */ { UD_Ifaddp, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0227 */ { UD_Ifaddp, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0228 */ { UD_Ifaddp, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0229 */ { UD_Ifaddp, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0230 */ { UD_Ifaddp, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0231 */ { UD_Ifbld, O_Mt, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0232 */ { UD_Ifbstp, O_Mt, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0233 */ { UD_Ifchs, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0234 */ { UD_Ifclex, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0235 */ { UD_Ifcmovb, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0236 */ { UD_Ifcmovb, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0237 */ { UD_Ifcmovb, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0238 */ { UD_Ifcmovb, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0239 */ { UD_Ifcmovb, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0240 */ { UD_Ifcmovb, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0241 */ { UD_Ifcmovb, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0242 */ { UD_Ifcmovb, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0243 */ { UD_Ifcmove, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0244 */ { UD_Ifcmove, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0245 */ { UD_Ifcmove, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0246 */ { UD_Ifcmove, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0247 */ { UD_Ifcmove, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0248 */ { UD_Ifcmove, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0249 */ { UD_Ifcmove, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0250 */ { UD_Ifcmove, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0251 */ { UD_Ifcmovbe, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0252 */ { UD_Ifcmovbe, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0253 */ { UD_Ifcmovbe, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0254 */ { UD_Ifcmovbe, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0255 */ { UD_Ifcmovbe, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0256 */ { UD_Ifcmovbe, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0257 */ { UD_Ifcmovbe, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0258 */ { UD_Ifcmovbe, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0259 */ { UD_Ifcmovu, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0260 */ { UD_Ifcmovu, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0261 */ { UD_Ifcmovu, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0262 */ { UD_Ifcmovu, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0263 */ { UD_Ifcmovu, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0264 */ { UD_Ifcmovu, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0265 */ { UD_Ifcmovu, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0266 */ { UD_Ifcmovu, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0267 */ { UD_Ifcmovnb, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0268 */ { UD_Ifcmovnb, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0269 */ { UD_Ifcmovnb, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0270 */ { UD_Ifcmovnb, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0271 */ { UD_Ifcmovnb, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0272 */ { UD_Ifcmovnb, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0273 */ { UD_Ifcmovnb, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0274 */ { UD_Ifcmovnb, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0275 */ { UD_Ifcmovne, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0276 */ { UD_Ifcmovne, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0277 */ { UD_Ifcmovne, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0278 */ { UD_Ifcmovne, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0279 */ { UD_Ifcmovne, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0280 */ { UD_Ifcmovne, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0281 */ { UD_Ifcmovne, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0282 */ { UD_Ifcmovne, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0283 */ { UD_Ifcmovnbe, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0284 */ { UD_Ifcmovnbe, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0285 */ { UD_Ifcmovnbe, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0286 */ { UD_Ifcmovnbe, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0287 */ { UD_Ifcmovnbe, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0288 */ { UD_Ifcmovnbe, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0289 */ { UD_Ifcmovnbe, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0290 */ { UD_Ifcmovnbe, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0291 */ { UD_Ifcmovnu, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0292 */ { UD_Ifcmovnu, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0293 */ { UD_Ifcmovnu, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0294 */ { UD_Ifcmovnu, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0295 */ { UD_Ifcmovnu, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0296 */ { UD_Ifcmovnu, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0297 */ { UD_Ifcmovnu, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0298 */ { UD_Ifcmovnu, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0299 */ { UD_Ifucomi, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0300 */ { UD_Ifucomi, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0301 */ { UD_Ifucomi, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0302 */ { UD_Ifucomi, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0303 */ { UD_Ifucomi, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0304 */ { UD_Ifucomi, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0305 */ { UD_Ifucomi, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0306 */ { UD_Ifucomi, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0307 */ { UD_Ifcom, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0308 */ { UD_Ifcom, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0309 */ { UD_Ifcom, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0310 */ { UD_Ifcom, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0311 */ { UD_Ifcom, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0312 */ { UD_Ifcom, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0313 */ { UD_Ifcom, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0314 */ { UD_Ifcom, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0315 */ { UD_Ifcom, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0316 */ { UD_Ifcom, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0317 */ { UD_Ifcom2, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0318 */ { UD_Ifcom2, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0319 */ { UD_Ifcom2, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0320 */ { UD_Ifcom2, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0321 */ { UD_Ifcom2, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0322 */ { UD_Ifcom2, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0323 */ { UD_Ifcom2, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0324 */ { UD_Ifcom2, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0325 */ { UD_Ifcomp3, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0326 */ { UD_Ifcomp3, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0327 */ { UD_Ifcomp3, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0328 */ { UD_Ifcomp3, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0329 */ { UD_Ifcomp3, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0330 */ { UD_Ifcomp3, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0331 */ { UD_Ifcomp3, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0332 */ { UD_Ifcomp3, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0333 */ { UD_Ifcomi, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0334 */ { UD_Ifcomi, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0335 */ { UD_Ifcomi, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0336 */ { UD_Ifcomi, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0337 */ { UD_Ifcomi, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0338 */ { UD_Ifcomi, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0339 */ { UD_Ifcomi, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0340 */ { UD_Ifcomi, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0341 */ { UD_Ifucomip, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0342 */ { UD_Ifucomip, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0343 */ { UD_Ifucomip, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0344 */ { UD_Ifucomip, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0345 */ { UD_Ifucomip, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0346 */ { UD_Ifucomip, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0347 */ { UD_Ifucomip, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0348 */ { UD_Ifucomip, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0349 */ { UD_Ifcomip, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0350 */ { UD_Ifcomip, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0351 */ { UD_Ifcomip, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0352 */ { UD_Ifcomip, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0353 */ { UD_Ifcomip, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0354 */ { UD_Ifcomip, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0355 */ { UD_Ifcomip, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0356 */ { UD_Ifcomip, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0357 */ { UD_Ifcomp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0358 */ { UD_Ifcomp, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0359 */ { UD_Ifcomp, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0360 */ { UD_Ifcomp, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0361 */ { UD_Ifcomp, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0362 */ { UD_Ifcomp, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0363 */ { UD_Ifcomp, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0364 */ { UD_Ifcomp, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0365 */ { UD_Ifcomp, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0366 */ { UD_Ifcomp, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0367 */ { UD_Ifcomp5, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0368 */ { UD_Ifcomp5, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0369 */ { UD_Ifcomp5, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0370 */ { UD_Ifcomp5, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0371 */ { UD_Ifcomp5, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0372 */ { UD_Ifcomp5, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0373 */ { UD_Ifcomp5, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0374 */ { UD_Ifcomp5, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0375 */ { UD_Ifcompp, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0376 */ { UD_Ifcos, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0377 */ { UD_Ifdecstp, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0378 */ { UD_Ifdiv, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0379 */ { UD_Ifdiv, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0380 */ { UD_Ifdiv, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0381 */ { UD_Ifdiv, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0382 */ { UD_Ifdiv, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0383 */ { UD_Ifdiv, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0384 */ { UD_Ifdiv, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0385 */ { UD_Ifdiv, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0386 */ { UD_Ifdiv, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0387 */ { UD_Ifdiv, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0388 */ { UD_Ifdiv, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0389 */ { UD_Ifdiv, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0390 */ { UD_Ifdiv, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0391 */ { UD_Ifdiv, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0392 */ { UD_Ifdiv, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0393 */ { UD_Ifdiv, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0394 */ { UD_Ifdiv, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0395 */ { UD_Ifdiv, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0396 */ { UD_Ifdivp, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0397 */ { UD_Ifdivp, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0398 */ { UD_Ifdivp, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0399 */ { UD_Ifdivp, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0400 */ { UD_Ifdivp, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0401 */ { UD_Ifdivp, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0402 */ { UD_Ifdivp, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0403 */ { UD_Ifdivp, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0404 */ { UD_Ifdivr, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0405 */ { UD_Ifdivr, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0406 */ { UD_Ifdivr, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0407 */ { UD_Ifdivr, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0408 */ { UD_Ifdivr, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0409 */ { UD_Ifdivr, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0410 */ { UD_Ifdivr, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0411 */ { UD_Ifdivr, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0412 */ { UD_Ifdivr, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0413 */ { UD_Ifdivr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0414 */ { UD_Ifdivr, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0415 */ { UD_Ifdivr, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0416 */ { UD_Ifdivr, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0417 */ { UD_Ifdivr, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0418 */ { UD_Ifdivr, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0419 */ { UD_Ifdivr, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0420 */ { UD_Ifdivr, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0421 */ { UD_Ifdivr, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0422 */ { UD_Ifdivrp, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0423 */ { UD_Ifdivrp, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0424 */ { UD_Ifdivrp, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0425 */ { UD_Ifdivrp, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0426 */ { UD_Ifdivrp, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0427 */ { UD_Ifdivrp, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0428 */ { UD_Ifdivrp, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0429 */ { UD_Ifdivrp, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0430 */ { UD_Ifemms, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0431 */ { UD_Iffree, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0432 */ { UD_Iffree, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0433 */ { UD_Iffree, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0434 */ { UD_Iffree, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0435 */ { UD_Iffree, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0436 */ { UD_Iffree, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0437 */ { UD_Iffree, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0438 */ { UD_Iffree, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0439 */ { UD_Iffreep, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0440 */ { UD_Iffreep, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0441 */ { UD_Iffreep, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0442 */ { UD_Iffreep, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0443 */ { UD_Iffreep, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0444 */ { UD_Iffreep, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0445 */ { UD_Iffreep, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0446 */ { UD_Iffreep, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0447 */ { UD_Ificom, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0448 */ { UD_Ificom, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0449 */ { UD_Ificomp, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0450 */ { UD_Ificomp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0451 */ { UD_Ifild, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0452 */ { UD_Ifild, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0453 */ { UD_Ifild, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0454 */ { UD_Ifincstp, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0455 */ { UD_Ifninit, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0456 */ { UD_Ifiadd, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0457 */ { UD_Ifiadd, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0458 */ { UD_Ifidivr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0459 */ { UD_Ifidivr, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0460 */ { UD_Ifidiv, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0461 */ { UD_Ifidiv, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0462 */ { UD_Ifisub, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0463 */ { UD_Ifisub, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0464 */ { UD_Ifisubr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0465 */ { UD_Ifisubr, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0466 */ { UD_Ifist, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0467 */ { UD_Ifist, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0468 */ { UD_Ifistp, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0469 */ { UD_Ifistp, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0470 */ { UD_Ifistp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0471 */ { UD_Ifisttp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0472 */ { UD_Ifisttp, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0473 */ { UD_Ifisttp, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0474 */ { UD_Ifld, O_Mt, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0475 */ { UD_Ifld, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0476 */ { UD_Ifld, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0477 */ { UD_Ifld, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0478 */ { UD_Ifld, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0479 */ { UD_Ifld, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0480 */ { UD_Ifld, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0481 */ { UD_Ifld, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0482 */ { UD_Ifld, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0483 */ { UD_Ifld, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0484 */ { UD_Ifld, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0485 */ { UD_Ifld1, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0486 */ { UD_Ifldl2t, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0487 */ { UD_Ifldl2e, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0488 */ { UD_Ifldpi, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0489 */ { UD_Ifldlg2, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0490 */ { UD_Ifldln2, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0491 */ { UD_Ifldz, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0492 */ { UD_Ifldcw, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0493 */ { UD_Ifldenv, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0494 */ { UD_Ifmul, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0495 */ { UD_Ifmul, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0496 */ { UD_Ifmul, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0497 */ { UD_Ifmul, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0498 */ { UD_Ifmul, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0499 */ { UD_Ifmul, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0500 */ { UD_Ifmul, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0501 */ { UD_Ifmul, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0502 */ { UD_Ifmul, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0503 */ { UD_Ifmul, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0504 */ { UD_Ifmul, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0505 */ { UD_Ifmul, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0506 */ { UD_Ifmul, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0507 */ { UD_Ifmul, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0508 */ { UD_Ifmul, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0509 */ { UD_Ifmul, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0510 */ { UD_Ifmul, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0511 */ { UD_Ifmul, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0512 */ { UD_Ifmulp, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0513 */ { UD_Ifmulp, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0514 */ { UD_Ifmulp, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0515 */ { UD_Ifmulp, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0516 */ { UD_Ifmulp, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0517 */ { UD_Ifmulp, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0518 */ { UD_Ifmulp, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0519 */ { UD_Ifmulp, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0520 */ { UD_Ifimul, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0521 */ { UD_Ifimul, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0522 */ { UD_Ifnop, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0523 */ { UD_Ifndisi, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0524 */ { UD_Ifneni, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0525 */ { UD_Ifnsetpm, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0526 */ { UD_Ifpatan, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0527 */ { UD_Ifprem, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0528 */ { UD_Ifprem1, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0529 */ { UD_Ifptan, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0530 */ { UD_Ifrndint, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0531 */ { UD_Ifrstor, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0532 */ { UD_Ifrstpm, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0533 */ { UD_Ifnsave, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0534 */ { UD_Ifscale, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0535 */ { UD_Ifsin, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0536 */ { UD_Ifsincos, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0537 */ { UD_Ifsqrt, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0538 */ { UD_Ifstp, O_Mt, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0539 */ { UD_Ifstp, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0540 */ { UD_Ifstp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0541 */ { UD_Ifstp, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0542 */ { UD_Ifstp, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0543 */ { UD_Ifstp, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0544 */ { UD_Ifstp, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0545 */ { UD_Ifstp, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0546 */ { UD_Ifstp, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0547 */ { UD_Ifstp, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0548 */ { UD_Ifstp, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0549 */ { UD_Ifstp1, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0550 */ { UD_Ifstp1, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0551 */ { UD_Ifstp1, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0552 */ { UD_Ifstp1, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0553 */ { UD_Ifstp1, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0554 */ { UD_Ifstp1, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0555 */ { UD_Ifstp1, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0556 */ { UD_Ifstp1, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0557 */ { UD_Ifstp8, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0558 */ { UD_Ifstp8, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0559 */ { UD_Ifstp8, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0560 */ { UD_Ifstp8, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0561 */ { UD_Ifstp8, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0562 */ { UD_Ifstp8, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0563 */ { UD_Ifstp8, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0564 */ { UD_Ifstp8, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0565 */ { UD_Ifstp9, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0566 */ { UD_Ifstp9, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0567 */ { UD_Ifstp9, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0568 */ { UD_Ifstp9, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0569 */ { UD_Ifstp9, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0570 */ { UD_Ifstp9, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0571 */ { UD_Ifstp9, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0572 */ { UD_Ifstp9, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0573 */ { UD_Ifst, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0574 */ { UD_Ifst, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0575 */ { UD_Ifst, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0576 */ { UD_Ifst, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0577 */ { UD_Ifst, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0578 */ { UD_Ifst, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0579 */ { UD_Ifst, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0580 */ { UD_Ifst, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0581 */ { UD_Ifst, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0582 */ { UD_Ifst, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0583 */ { UD_Ifnstcw, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0584 */ { UD_Ifnstenv, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0585 */ { UD_Ifnstsw, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0586 */ { UD_Ifnstsw, O_AX, O_NONE, O_NONE, O_NONE, P_none }, /* 0587 */ { UD_Ifsub, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0588 */ { UD_Ifsub, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0589 */ { UD_Ifsub, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0590 */ { UD_Ifsub, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0591 */ { UD_Ifsub, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0592 */ { UD_Ifsub, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0593 */ { UD_Ifsub, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0594 */ { UD_Ifsub, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0595 */ { UD_Ifsub, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0596 */ { UD_Ifsub, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0597 */ { UD_Ifsub, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0598 */ { UD_Ifsub, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0599 */ { UD_Ifsub, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0600 */ { UD_Ifsub, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0601 */ { UD_Ifsub, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0602 */ { UD_Ifsub, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0603 */ { UD_Ifsub, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0604 */ { UD_Ifsub, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0605 */ { UD_Ifsubp, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0606 */ { UD_Ifsubp, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0607 */ { UD_Ifsubp, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0608 */ { UD_Ifsubp, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0609 */ { UD_Ifsubp, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0610 */ { UD_Ifsubp, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0611 */ { UD_Ifsubp, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0612 */ { UD_Ifsubp, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0613 */ { UD_Ifsubr, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0614 */ { UD_Ifsubr, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0615 */ { UD_Ifsubr, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0616 */ { UD_Ifsubr, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0617 */ { UD_Ifsubr, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0618 */ { UD_Ifsubr, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0619 */ { UD_Ifsubr, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0620 */ { UD_Ifsubr, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0621 */ { UD_Ifsubr, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0622 */ { UD_Ifsubr, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0623 */ { UD_Ifsubr, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0624 */ { UD_Ifsubr, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0625 */ { UD_Ifsubr, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0626 */ { UD_Ifsubr, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0627 */ { UD_Ifsubr, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0628 */ { UD_Ifsubr, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0629 */ { UD_Ifsubr, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0630 */ { UD_Ifsubr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0631 */ { UD_Ifsubrp, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0632 */ { UD_Ifsubrp, O_ST1, O_ST0, O_NONE, O_NONE, P_none }, /* 0633 */ { UD_Ifsubrp, O_ST2, O_ST0, O_NONE, O_NONE, P_none }, /* 0634 */ { UD_Ifsubrp, O_ST3, O_ST0, O_NONE, O_NONE, P_none }, /* 0635 */ { UD_Ifsubrp, O_ST4, O_ST0, O_NONE, O_NONE, P_none }, /* 0636 */ { UD_Ifsubrp, O_ST5, O_ST0, O_NONE, O_NONE, P_none }, /* 0637 */ { UD_Ifsubrp, O_ST6, O_ST0, O_NONE, O_NONE, P_none }, /* 0638 */ { UD_Ifsubrp, O_ST7, O_ST0, O_NONE, O_NONE, P_none }, /* 0639 */ { UD_Iftst, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0640 */ { UD_Ifucom, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0641 */ { UD_Ifucom, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0642 */ { UD_Ifucom, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0643 */ { UD_Ifucom, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0644 */ { UD_Ifucom, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0645 */ { UD_Ifucom, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0646 */ { UD_Ifucom, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0647 */ { UD_Ifucom, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0648 */ { UD_Ifucomp, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0649 */ { UD_Ifucomp, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0650 */ { UD_Ifucomp, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0651 */ { UD_Ifucomp, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0652 */ { UD_Ifucomp, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0653 */ { UD_Ifucomp, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0654 */ { UD_Ifucomp, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0655 */ { UD_Ifucomp, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0656 */ { UD_Ifucompp, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0657 */ { UD_Ifxam, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0658 */ { UD_Ifxch, O_ST0, O_ST0, O_NONE, O_NONE, P_none }, /* 0659 */ { UD_Ifxch, O_ST0, O_ST1, O_NONE, O_NONE, P_none }, /* 0660 */ { UD_Ifxch, O_ST0, O_ST2, O_NONE, O_NONE, P_none }, /* 0661 */ { UD_Ifxch, O_ST0, O_ST3, O_NONE, O_NONE, P_none }, /* 0662 */ { UD_Ifxch, O_ST0, O_ST4, O_NONE, O_NONE, P_none }, /* 0663 */ { UD_Ifxch, O_ST0, O_ST5, O_NONE, O_NONE, P_none }, /* 0664 */ { UD_Ifxch, O_ST0, O_ST6, O_NONE, O_NONE, P_none }, /* 0665 */ { UD_Ifxch, O_ST0, O_ST7, O_NONE, O_NONE, P_none }, /* 0666 */ { UD_Ifxch4, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0667 */ { UD_Ifxch4, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0668 */ { UD_Ifxch4, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0669 */ { UD_Ifxch4, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0670 */ { UD_Ifxch4, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0671 */ { UD_Ifxch4, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0672 */ { UD_Ifxch4, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0673 */ { UD_Ifxch4, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0674 */ { UD_Ifxch7, O_ST0, O_NONE, O_NONE, O_NONE, P_none }, /* 0675 */ { UD_Ifxch7, O_ST1, O_NONE, O_NONE, O_NONE, P_none }, /* 0676 */ { UD_Ifxch7, O_ST2, O_NONE, O_NONE, O_NONE, P_none }, /* 0677 */ { UD_Ifxch7, O_ST3, O_NONE, O_NONE, O_NONE, P_none }, /* 0678 */ { UD_Ifxch7, O_ST4, O_NONE, O_NONE, O_NONE, P_none }, /* 0679 */ { UD_Ifxch7, O_ST5, O_NONE, O_NONE, O_NONE, P_none }, /* 0680 */ { UD_Ifxch7, O_ST6, O_NONE, O_NONE, O_NONE, P_none }, /* 0681 */ { UD_Ifxch7, O_ST7, O_NONE, O_NONE, O_NONE, P_none }, /* 0682 */ { UD_Ifxrstor, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0683 */ { UD_Ifxsave, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0684 */ { UD_Ifxtract, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0685 */ { UD_Ifyl2x, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0686 */ { UD_Ifyl2xp1, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0687 */ { UD_Ihlt, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0688 */ { UD_Iidiv, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0689 */ { UD_Iidiv, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0690 */ { UD_Iin, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 0691 */ { UD_Iin, O_eAX, O_Ib, O_NONE, O_NONE, P_oso }, /* 0692 */ { UD_Iin, O_AL, O_DX, O_NONE, O_NONE, P_none }, /* 0693 */ { UD_Iin, O_eAX, O_DX, O_NONE, O_NONE, P_oso }, /* 0694 */ { UD_Iimul, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0695 */ { UD_Iimul, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0696 */ { UD_Iimul, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0697 */ { UD_Iimul, O_Gv, O_Ev, O_Iz, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0698 */ { UD_Iimul, O_Gv, O_Ev, O_sIb, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0699 */ { UD_Iinc, O_R0z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0700 */ { UD_Iinc, O_R1z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0701 */ { UD_Iinc, O_R2z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0702 */ { UD_Iinc, O_R3z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0703 */ { UD_Iinc, O_R4z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0704 */ { UD_Iinc, O_R5z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0705 */ { UD_Iinc, O_R6z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0706 */ { UD_Iinc, O_R7z, O_NONE, O_NONE, O_NONE, P_oso }, /* 0707 */ { UD_Iinc, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0708 */ { UD_Iinc, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0709 */ { UD_Iinsb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg }, /* 0710 */ { UD_Iinsw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_oso|P_seg }, /* 0711 */ { UD_Iinsd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_oso|P_seg }, /* 0712 */ { UD_Iint1, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0713 */ { UD_Iint3, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0714 */ { UD_Iint, O_Ib, O_NONE, O_NONE, O_NONE, P_none }, /* 0715 */ { UD_Iinto, O_NONE, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 0716 */ { UD_Iinvd, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0717 */ { UD_Iinvept, O_Gd, O_Mo, O_NONE, O_NONE, P_none }, /* 0718 */ { UD_Iinvept, O_Gq, O_Mo, O_NONE, O_NONE, P_none }, /* 0719 */ { UD_Iinvlpg, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0720 */ { UD_Iinvlpga, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0721 */ { UD_Iinvvpid, O_Gd, O_Mo, O_NONE, O_NONE, P_none }, /* 0722 */ { UD_Iinvvpid, O_Gq, O_Mo, O_NONE, O_NONE, P_none }, /* 0723 */ { UD_Iiretw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw }, /* 0724 */ { UD_Iiretd, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw }, /* 0725 */ { UD_Iiretq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw }, /* 0726 */ { UD_Ijo, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0727 */ { UD_Ijo, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0728 */ { UD_Ijno, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0729 */ { UD_Ijno, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0730 */ { UD_Ijb, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0731 */ { UD_Ijb, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0732 */ { UD_Ijae, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0733 */ { UD_Ijae, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0734 */ { UD_Ijz, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0735 */ { UD_Ijz, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0736 */ { UD_Ijnz, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0737 */ { UD_Ijnz, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0738 */ { UD_Ijbe, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0739 */ { UD_Ijbe, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0740 */ { UD_Ija, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0741 */ { UD_Ija, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0742 */ { UD_Ijs, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0743 */ { UD_Ijs, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0744 */ { UD_Ijns, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0745 */ { UD_Ijns, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0746 */ { UD_Ijp, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0747 */ { UD_Ijp, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0748 */ { UD_Ijnp, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0749 */ { UD_Ijnp, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0750 */ { UD_Ijl, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0751 */ { UD_Ijl, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0752 */ { UD_Ijge, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0753 */ { UD_Ijge, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0754 */ { UD_Ijle, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0755 */ { UD_Ijle, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0756 */ { UD_Ijg, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0757 */ { UD_Ijg, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0758 */ { UD_Ijcxz, O_Jb, O_NONE, O_NONE, O_NONE, P_aso|P_def64 }, /* 0759 */ { UD_Ijecxz, O_Jb, O_NONE, O_NONE, O_NONE, P_aso|P_def64 }, /* 0760 */ { UD_Ijrcxz, O_Jb, O_NONE, O_NONE, O_NONE, P_aso|P_def64 }, /* 0761 */ { UD_Ijmp, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 }, /* 0762 */ { UD_Ijmp, O_Fv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0763 */ { UD_Ijmp, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 0764 */ { UD_Ijmp, O_Av, O_NONE, O_NONE, O_NONE, P_oso }, /* 0765 */ { UD_Ijmp, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 }, /* 0766 */ { UD_Ilahf, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0767 */ { UD_Ilar, O_Gv, O_Ew, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0768 */ { UD_Ildmxcsr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0769 */ { UD_Ilds, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso }, /* 0770 */ { UD_Ilea, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0771 */ { UD_Iles, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso }, /* 0772 */ { UD_Ilfs, O_Gz, O_M, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0773 */ { UD_Ilgs, O_Gz, O_M, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0774 */ { UD_Ilidt, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0775 */ { UD_Ilss, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0776 */ { UD_Ileave, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0777 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0778 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0779 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0780 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0781 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0782 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0783 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0784 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0785 */ { UD_Ilgdt, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0786 */ { UD_Illdt, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0787 */ { UD_Ilmsw, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0788 */ { UD_Ilmsw, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0789 */ { UD_Ilock, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0790 */ { UD_Ilodsb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg }, /* 0791 */ { UD_Ilodsw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw }, /* 0792 */ { UD_Ilodsd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw }, /* 0793 */ { UD_Ilodsq, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw }, /* 0794 */ { UD_Iloopne, O_Jb, O_NONE, O_NONE, O_NONE, P_none }, /* 0795 */ { UD_Iloope, O_Jb, O_NONE, O_NONE, O_NONE, P_none }, /* 0796 */ { UD_Iloop, O_Jb, O_NONE, O_NONE, O_NONE, P_none }, /* 0797 */ { UD_Ilsl, O_Gv, O_Ew, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0798 */ { UD_Iltr, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0799 */ { UD_Imaskmovq, O_P, O_N, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0800 */ { UD_Imaxpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0801 */ { UD_Ivmaxpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0802 */ { UD_Imaxps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0803 */ { UD_Ivmaxps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0804 */ { UD_Imaxsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0805 */ { UD_Ivmaxsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0806 */ { UD_Imaxss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0807 */ { UD_Ivmaxss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0808 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0809 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0810 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0811 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0812 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0813 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0814 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0815 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0816 */ { UD_Iminpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0817 */ { UD_Ivminpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0818 */ { UD_Iminps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0819 */ { UD_Ivminps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0820 */ { UD_Iminsd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0821 */ { UD_Ivminsd, O_Vx, O_Hx, O_MqU, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0822 */ { UD_Iminss, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0823 */ { UD_Ivminss, O_Vx, O_Hx, O_MdU, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0824 */ { UD_Imonitor, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0825 */ { UD_Imontmul, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0826 */ { UD_Imov, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0827 */ { UD_Imov, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0828 */ { UD_Imov, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0829 */ { UD_Imov, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0830 */ { UD_Imov, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0831 */ { UD_Imov, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0832 */ { UD_Imov, O_MwRv, O_S, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0833 */ { UD_Imov, O_S, O_MwRv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0834 */ { UD_Imov, O_AL, O_Ob, O_NONE, O_NONE, P_none }, /* 0835 */ { UD_Imov, O_rAX, O_Ov, O_NONE, O_NONE, P_aso|P_oso|P_rexw }, /* 0836 */ { UD_Imov, O_Ob, O_AL, O_NONE, O_NONE, P_none }, /* 0837 */ { UD_Imov, O_Ov, O_rAX, O_NONE, O_NONE, P_aso|P_oso|P_rexw }, /* 0838 */ { UD_Imov, O_R0b, O_Ib, O_NONE, O_NONE, P_rexb }, /* 0839 */ { UD_Imov, O_R1b, O_Ib, O_NONE, O_NONE, P_rexb }, /* 0840 */ { UD_Imov, O_R2b, O_Ib, O_NONE, O_NONE, P_rexb }, /* 0841 */ { UD_Imov, O_R3b, O_Ib, O_NONE, O_NONE, P_rexb }, /* 0842 */ { UD_Imov, O_R4b, O_Ib, O_NONE, O_NONE, P_rexb }, /* 0843 */ { UD_Imov, O_R5b, O_Ib, O_NONE, O_NONE, P_rexb }, /* 0844 */ { UD_Imov, O_R6b, O_Ib, O_NONE, O_NONE, P_rexb }, /* 0845 */ { UD_Imov, O_R7b, O_Ib, O_NONE, O_NONE, P_rexb }, /* 0846 */ { UD_Imov, O_R0v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 0847 */ { UD_Imov, O_R1v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 0848 */ { UD_Imov, O_R2v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 0849 */ { UD_Imov, O_R3v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 0850 */ { UD_Imov, O_R4v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 0851 */ { UD_Imov, O_R5v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 0852 */ { UD_Imov, O_R6v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 0853 */ { UD_Imov, O_R7v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 0854 */ { UD_Imov, O_R, O_C, O_NONE, O_NONE, P_rexr|P_rexw|P_rexb }, /* 0855 */ { UD_Imov, O_R, O_D, O_NONE, O_NONE, P_rexr|P_rexw|P_rexb }, /* 0856 */ { UD_Imov, O_C, O_R, O_NONE, O_NONE, P_rexr|P_rexw|P_rexb }, /* 0857 */ { UD_Imov, O_D, O_R, O_NONE, O_NONE, P_rexr|P_rexw|P_rexb }, /* 0858 */ { UD_Imovapd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0859 */ { UD_Ivmovapd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0860 */ { UD_Imovapd, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0861 */ { UD_Ivmovapd, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0862 */ { UD_Imovaps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0863 */ { UD_Ivmovaps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0864 */ { UD_Imovaps, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0865 */ { UD_Ivmovaps, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0866 */ { UD_Imovd, O_P, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0867 */ { UD_Imovd, O_P, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0868 */ { UD_Imovd, O_V, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0869 */ { UD_Ivmovd, O_Vx, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0870 */ { UD_Imovd, O_V, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0871 */ { UD_Ivmovd, O_Vx, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0872 */ { UD_Imovd, O_Ey, O_P, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0873 */ { UD_Imovd, O_Ey, O_P, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0874 */ { UD_Imovd, O_Ey, O_V, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0875 */ { UD_Ivmovd, O_Ey, O_Vx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0876 */ { UD_Imovd, O_Ey, O_V, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0877 */ { UD_Ivmovd, O_Ey, O_Vx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0878 */ { UD_Imovhpd, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0879 */ { UD_Ivmovhpd, O_Vx, O_Hx, O_M, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0880 */ { UD_Imovhpd, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0881 */ { UD_Ivmovhpd, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0882 */ { UD_Imovhps, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0883 */ { UD_Ivmovhps, O_Vx, O_Hx, O_M, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0884 */ { UD_Imovhps, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0885 */ { UD_Ivmovhps, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0886 */ { UD_Imovlhps, O_V, O_U, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0887 */ { UD_Ivmovlhps, O_Vx, O_Hx, O_Ux, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0888 */ { UD_Imovlpd, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0889 */ { UD_Ivmovlpd, O_Vx, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0890 */ { UD_Imovlpd, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0891 */ { UD_Ivmovlpd, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0892 */ { UD_Imovlps, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0893 */ { UD_Ivmovlps, O_Vx, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0894 */ { UD_Imovlps, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0895 */ { UD_Ivmovlps, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0896 */ { UD_Imovhlps, O_V, O_U, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0897 */ { UD_Ivmovhlps, O_Vx, O_Ux, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0898 */ { UD_Imovmskpd, O_Gd, O_U, O_NONE, O_NONE, P_oso|P_rexr|P_rexb }, /* 0899 */ { UD_Ivmovmskpd, O_Gd, O_Ux, O_NONE, O_NONE, P_oso|P_rexr|P_rexb|P_vexl }, /* 0900 */ { UD_Imovmskps, O_Gd, O_U, O_NONE, O_NONE, P_oso|P_rexr|P_rexb }, /* 0901 */ { UD_Ivmovmskps, O_Gd, O_Ux, O_NONE, O_NONE, P_oso|P_rexr|P_rexb }, /* 0902 */ { UD_Imovntdq, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0903 */ { UD_Ivmovntdq, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0904 */ { UD_Imovnti, O_M, O_Gy, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0905 */ { UD_Imovntpd, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0906 */ { UD_Ivmovntpd, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0907 */ { UD_Imovntps, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0908 */ { UD_Ivmovntps, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0909 */ { UD_Imovntq, O_M, O_P, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0910 */ { UD_Imovq, O_P, O_Eq, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0911 */ { UD_Imovq, O_V, O_Eq, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0912 */ { UD_Ivmovq, O_Vx, O_Eq, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0913 */ { UD_Imovq, O_Eq, O_P, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0914 */ { UD_Imovq, O_Eq, O_V, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0915 */ { UD_Ivmovq, O_Eq, O_Vx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0916 */ { UD_Imovq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0917 */ { UD_Ivmovq, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0918 */ { UD_Imovq, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0919 */ { UD_Ivmovq, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0920 */ { UD_Imovq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0921 */ { UD_Imovq, O_Q, O_P, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0922 */ { UD_Imovsb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg }, /* 0923 */ { UD_Imovsw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw }, /* 0924 */ { UD_Imovsd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw }, /* 0925 */ { UD_Imovsd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0926 */ { UD_Imovsd, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0927 */ { UD_Imovsq, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw }, /* 0928 */ { UD_Imovss, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0929 */ { UD_Imovss, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0930 */ { UD_Imovsx, O_Gv, O_Eb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0931 */ { UD_Imovsx, O_Gy, O_Ew, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0932 */ { UD_Imovupd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0933 */ { UD_Ivmovupd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0934 */ { UD_Imovupd, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0935 */ { UD_Ivmovupd, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0936 */ { UD_Imovups, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0937 */ { UD_Ivmovups, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0938 */ { UD_Imovups, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0939 */ { UD_Ivmovups, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0940 */ { UD_Imovzx, O_Gv, O_Eb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0941 */ { UD_Imovzx, O_Gy, O_Ew, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0942 */ { UD_Imul, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0943 */ { UD_Imul, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0944 */ { UD_Imulpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0945 */ { UD_Ivmulpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0946 */ { UD_Imulps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0947 */ { UD_Ivmulps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0948 */ { UD_Imulsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0949 */ { UD_Ivmulsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0950 */ { UD_Imulss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0951 */ { UD_Ivmulss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0952 */ { UD_Imwait, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 0953 */ { UD_Ineg, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0954 */ { UD_Ineg, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0955 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0956 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0957 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0958 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0959 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0960 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0961 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0962 */ { UD_Inot, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0963 */ { UD_Inot, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0964 */ { UD_Ior, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0965 */ { UD_Ior, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0966 */ { UD_Ior, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0967 */ { UD_Ior, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0968 */ { UD_Ior, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 0969 */ { UD_Ior, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw }, /* 0970 */ { UD_Ior, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0971 */ { UD_Ior, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0972 */ { UD_Ior, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0973 */ { UD_Ior, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 0974 */ { UD_Iorpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0975 */ { UD_Ivorpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0976 */ { UD_Iorps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0977 */ { UD_Ivorps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0978 */ { UD_Iout, O_Ib, O_AL, O_NONE, O_NONE, P_none }, /* 0979 */ { UD_Iout, O_Ib, O_eAX, O_NONE, O_NONE, P_oso }, /* 0980 */ { UD_Iout, O_DX, O_AL, O_NONE, O_NONE, P_none }, /* 0981 */ { UD_Iout, O_DX, O_eAX, O_NONE, O_NONE, P_oso }, /* 0982 */ { UD_Ioutsb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg }, /* 0983 */ { UD_Ioutsw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_oso|P_seg }, /* 0984 */ { UD_Ioutsd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_oso|P_seg }, /* 0985 */ { UD_Ipacksswb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0986 */ { UD_Ivpacksswb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0987 */ { UD_Ipacksswb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0988 */ { UD_Ipackssdw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0989 */ { UD_Ivpackssdw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0990 */ { UD_Ipackssdw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0991 */ { UD_Ipackuswb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0992 */ { UD_Ivpackuswb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0993 */ { UD_Ipackuswb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0994 */ { UD_Ipaddb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0995 */ { UD_Ivpaddb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 0996 */ { UD_Ipaddb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0997 */ { UD_Ipaddw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0998 */ { UD_Ipaddw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 0999 */ { UD_Ivpaddw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1000 */ { UD_Ipaddd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1001 */ { UD_Ipaddd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1002 */ { UD_Ivpaddd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1003 */ { UD_Ipaddsb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1004 */ { UD_Ipaddsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1005 */ { UD_Ivpaddsb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1006 */ { UD_Ipaddsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1007 */ { UD_Ipaddsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1008 */ { UD_Ivpaddsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1009 */ { UD_Ipaddusb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1010 */ { UD_Ipaddusb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1011 */ { UD_Ivpaddusb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1012 */ { UD_Ipaddusw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1013 */ { UD_Ipaddusw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1014 */ { UD_Ivpaddusw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1015 */ { UD_Ipand, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1016 */ { UD_Ivpand, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1017 */ { UD_Ipand, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1018 */ { UD_Ipandn, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1019 */ { UD_Ivpandn, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1020 */ { UD_Ipandn, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1021 */ { UD_Ipavgb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1022 */ { UD_Ivpavgb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1023 */ { UD_Ipavgb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1024 */ { UD_Ipavgw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1025 */ { UD_Ivpavgw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1026 */ { UD_Ipavgw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1027 */ { UD_Ipcmpeqb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1028 */ { UD_Ipcmpeqb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1029 */ { UD_Ivpcmpeqb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1030 */ { UD_Ipcmpeqw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1031 */ { UD_Ipcmpeqw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1032 */ { UD_Ivpcmpeqw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1033 */ { UD_Ipcmpeqd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1034 */ { UD_Ipcmpeqd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1035 */ { UD_Ivpcmpeqd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1036 */ { UD_Ipcmpgtb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1037 */ { UD_Ivpcmpgtb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1038 */ { UD_Ipcmpgtb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1039 */ { UD_Ipcmpgtw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1040 */ { UD_Ivpcmpgtw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1041 */ { UD_Ipcmpgtw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1042 */ { UD_Ipcmpgtd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1043 */ { UD_Ivpcmpgtd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1044 */ { UD_Ipcmpgtd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1045 */ { UD_Ipextrb, O_MbRv, O_V, O_Ib, O_NONE, P_aso|P_rexx|P_rexr|P_rexb|P_def64 }, /* 1046 */ { UD_Ivpextrb, O_MbRv, O_Vx, O_Ib, O_NONE, P_aso|P_rexx|P_rexr|P_rexb|P_def64 }, /* 1047 */ { UD_Ipextrd, O_Ed, O_V, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexw|P_rexb }, /* 1048 */ { UD_Ivpextrd, O_Ed, O_Vx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexw|P_rexb }, /* 1049 */ { UD_Ipextrd, O_Ed, O_V, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexw|P_rexb }, /* 1050 */ { UD_Ivpextrd, O_Ed, O_Vx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexw|P_rexb }, /* 1051 */ { UD_Ipextrq, O_Eq, O_V, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexb|P_def64 }, /* 1052 */ { UD_Ivpextrq, O_Eq, O_Vx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexb|P_def64 }, /* 1053 */ { UD_Ipextrw, O_Gd, O_U, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexb }, /* 1054 */ { UD_Ivpextrw, O_Gd, O_Ux, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexb }, /* 1055 */ { UD_Ipextrw, O_Gd, O_N, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1056 */ { UD_Ipextrw, O_MwRd, O_V, O_Ib, O_NONE, P_aso|P_rexw|P_rexx|P_rexr|P_rexb }, /* 1057 */ { UD_Ivpextrw, O_MwRd, O_Vx, O_Ib, O_NONE, P_aso|P_rexw|P_rexx|P_rexr|P_rexb }, /* 1058 */ { UD_Ipinsrb, O_V, O_MbRd, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1059 */ { UD_Ipinsrw, O_P, O_MwRy, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 }, /* 1060 */ { UD_Ipinsrw, O_V, O_MwRy, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 }, /* 1061 */ { UD_Ivpinsrw, O_Vx, O_MwRy, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 }, /* 1062 */ { UD_Ipinsrd, O_V, O_Ed, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1063 */ { UD_Ipinsrd, O_V, O_Ed, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1064 */ { UD_Ipinsrq, O_V, O_Eq, O_Ib, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1065 */ { UD_Ivpinsrb, O_V, O_H, O_MbRd, O_Ib, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1066 */ { UD_Ivpinsrd, O_V, O_H, O_Ed, O_Ib, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1067 */ { UD_Ivpinsrd, O_V, O_H, O_Ed, O_Ib, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1068 */ { UD_Ivpinsrq, O_V, O_H, O_Eq, O_Ib, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1069 */ { UD_Ipmaddwd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1070 */ { UD_Ipmaddwd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1071 */ { UD_Ivpmaddwd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1072 */ { UD_Ipmaxsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1073 */ { UD_Ivpmaxsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1074 */ { UD_Ipmaxsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1075 */ { UD_Ipmaxub, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1076 */ { UD_Ipmaxub, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1077 */ { UD_Ivpmaxub, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1078 */ { UD_Ipminsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1079 */ { UD_Ivpminsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1080 */ { UD_Ipminsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1081 */ { UD_Ipminub, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1082 */ { UD_Ivpminub, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1083 */ { UD_Ipminub, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1084 */ { UD_Ipmovmskb, O_Gd, O_U, O_NONE, O_NONE, P_oso|P_rexr|P_rexw|P_rexb }, /* 1085 */ { UD_Ivpmovmskb, O_Gd, O_Ux, O_NONE, O_NONE, P_oso|P_rexr|P_rexw|P_rexb }, /* 1086 */ { UD_Ipmovmskb, O_Gd, O_N, O_NONE, O_NONE, P_oso|P_rexr|P_rexw|P_rexb }, /* 1087 */ { UD_Ipmulhuw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1088 */ { UD_Ipmulhuw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1089 */ { UD_Ivpmulhuw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1090 */ { UD_Ipmulhw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1091 */ { UD_Ivpmulhw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1092 */ { UD_Ipmulhw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1093 */ { UD_Ipmullw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1094 */ { UD_Ipmullw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1095 */ { UD_Ivpmullw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1096 */ { UD_Ipop, O_ES, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 1097 */ { UD_Ipop, O_SS, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 1098 */ { UD_Ipop, O_DS, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 1099 */ { UD_Ipop, O_GS, O_NONE, O_NONE, O_NONE, P_none }, /* 1100 */ { UD_Ipop, O_FS, O_NONE, O_NONE, O_NONE, P_none }, /* 1101 */ { UD_Ipop, O_R0v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1102 */ { UD_Ipop, O_R1v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1103 */ { UD_Ipop, O_R2v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1104 */ { UD_Ipop, O_R3v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1105 */ { UD_Ipop, O_R4v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1106 */ { UD_Ipop, O_R5v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1107 */ { UD_Ipop, O_R6v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1108 */ { UD_Ipop, O_R7v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1109 */ { UD_Ipop, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 }, /* 1110 */ { UD_Ipopa, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_inv64 }, /* 1111 */ { UD_Ipopad, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_inv64 }, /* 1112 */ { UD_Ipopfw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso }, /* 1113 */ { UD_Ipopfw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_def64 }, /* 1114 */ { UD_Ipopfd, O_NONE, O_NONE, O_NONE, O_NONE, P_oso }, /* 1115 */ { UD_Ipopfq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 1116 */ { UD_Ipopfq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 1117 */ { UD_Ipor, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1118 */ { UD_Ivpor, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1119 */ { UD_Ipor, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1120 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1121 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1122 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1123 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1124 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1125 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1126 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1127 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1128 */ { UD_Iprefetchnta, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1129 */ { UD_Iprefetcht0, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1130 */ { UD_Iprefetcht1, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1131 */ { UD_Iprefetcht2, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1132 */ { UD_Ipsadbw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1133 */ { UD_Ivpsadbw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1134 */ { UD_Ipsadbw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1135 */ { UD_Ipshufw, O_P, O_Q, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1136 */ { UD_Ipsllw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1137 */ { UD_Ipsllw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1138 */ { UD_Ipsllw, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1139 */ { UD_Ipsllw, O_N, O_Ib, O_NONE, O_NONE, P_none }, /* 1140 */ { UD_Ipslld, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1141 */ { UD_Ipslld, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1142 */ { UD_Ipslld, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1143 */ { UD_Ipslld, O_N, O_Ib, O_NONE, O_NONE, P_none }, /* 1144 */ { UD_Ipsllq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1145 */ { UD_Ipsllq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1146 */ { UD_Ipsllq, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1147 */ { UD_Ipsllq, O_N, O_Ib, O_NONE, O_NONE, P_none }, /* 1148 */ { UD_Ipsraw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1149 */ { UD_Ipsraw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1150 */ { UD_Ivpsraw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1151 */ { UD_Ipsraw, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1152 */ { UD_Ivpsraw, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb }, /* 1153 */ { UD_Ipsraw, O_N, O_Ib, O_NONE, O_NONE, P_none }, /* 1154 */ { UD_Ipsrad, O_N, O_Ib, O_NONE, O_NONE, P_none }, /* 1155 */ { UD_Ipsrad, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1156 */ { UD_Ivpsrad, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1157 */ { UD_Ipsrad, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1158 */ { UD_Ipsrad, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1159 */ { UD_Ivpsrad, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb }, /* 1160 */ { UD_Ipsrlw, O_N, O_Ib, O_NONE, O_NONE, P_none }, /* 1161 */ { UD_Ipsrlw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1162 */ { UD_Ipsrlw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1163 */ { UD_Ivpsrlw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1164 */ { UD_Ipsrlw, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1165 */ { UD_Ivpsrlw, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb }, /* 1166 */ { UD_Ipsrld, O_N, O_Ib, O_NONE, O_NONE, P_none }, /* 1167 */ { UD_Ipsrld, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1168 */ { UD_Ipsrld, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1169 */ { UD_Ivpsrld, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1170 */ { UD_Ipsrld, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1171 */ { UD_Ivpsrld, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb }, /* 1172 */ { UD_Ipsrlq, O_N, O_Ib, O_NONE, O_NONE, P_none }, /* 1173 */ { UD_Ipsrlq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1174 */ { UD_Ipsrlq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1175 */ { UD_Ivpsrlq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1176 */ { UD_Ipsrlq, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1177 */ { UD_Ivpsrlq, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb }, /* 1178 */ { UD_Ipsubb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1179 */ { UD_Ivpsubb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1180 */ { UD_Ipsubb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1181 */ { UD_Ipsubw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1182 */ { UD_Ivpsubw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1183 */ { UD_Ipsubw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1184 */ { UD_Ipsubd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1185 */ { UD_Ipsubd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1186 */ { UD_Ivpsubd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1187 */ { UD_Ipsubsb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1188 */ { UD_Ipsubsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1189 */ { UD_Ivpsubsb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1190 */ { UD_Ipsubsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1191 */ { UD_Ipsubsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1192 */ { UD_Ivpsubsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1193 */ { UD_Ipsubusb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1194 */ { UD_Ipsubusb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1195 */ { UD_Ivpsubusb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1196 */ { UD_Ipsubusw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1197 */ { UD_Ipsubusw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1198 */ { UD_Ivpsubusw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1199 */ { UD_Ipunpckhbw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1200 */ { UD_Ivpunpckhbw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1201 */ { UD_Ipunpckhbw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1202 */ { UD_Ipunpckhwd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1203 */ { UD_Ivpunpckhwd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1204 */ { UD_Ipunpckhwd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1205 */ { UD_Ipunpckhdq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1206 */ { UD_Ivpunpckhdq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1207 */ { UD_Ipunpckhdq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1208 */ { UD_Ipunpcklbw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1209 */ { UD_Ivpunpcklbw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1210 */ { UD_Ipunpcklbw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1211 */ { UD_Ipunpcklwd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1212 */ { UD_Ivpunpcklwd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1213 */ { UD_Ipunpcklwd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1214 */ { UD_Ipunpckldq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1215 */ { UD_Ivpunpckldq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1216 */ { UD_Ipunpckldq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1217 */ { UD_Ipi2fw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1218 */ { UD_Ipi2fd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1219 */ { UD_Ipf2iw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1220 */ { UD_Ipf2id, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1221 */ { UD_Ipfnacc, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1222 */ { UD_Ipfpnacc, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1223 */ { UD_Ipfcmpge, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1224 */ { UD_Ipfmin, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1225 */ { UD_Ipfrcp, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1226 */ { UD_Ipfrsqrt, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1227 */ { UD_Ipfsub, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1228 */ { UD_Ipfadd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1229 */ { UD_Ipfcmpgt, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1230 */ { UD_Ipfmax, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1231 */ { UD_Ipfrcpit1, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1232 */ { UD_Ipfrsqit1, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1233 */ { UD_Ipfsubr, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1234 */ { UD_Ipfacc, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1235 */ { UD_Ipfcmpeq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1236 */ { UD_Ipfmul, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1237 */ { UD_Ipfrcpit2, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1238 */ { UD_Ipmulhrw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1239 */ { UD_Ipswapd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1240 */ { UD_Ipavgusb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1241 */ { UD_Ipush, O_ES, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 1242 */ { UD_Ipush, O_CS, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 1243 */ { UD_Ipush, O_SS, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 1244 */ { UD_Ipush, O_DS, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 1245 */ { UD_Ipush, O_GS, O_NONE, O_NONE, O_NONE, P_none }, /* 1246 */ { UD_Ipush, O_FS, O_NONE, O_NONE, O_NONE, P_none }, /* 1247 */ { UD_Ipush, O_R0v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1248 */ { UD_Ipush, O_R1v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1249 */ { UD_Ipush, O_R2v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1250 */ { UD_Ipush, O_R3v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1251 */ { UD_Ipush, O_R4v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1252 */ { UD_Ipush, O_R5v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1253 */ { UD_Ipush, O_R6v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1254 */ { UD_Ipush, O_R7v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 }, /* 1255 */ { UD_Ipush, O_sIz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 1256 */ { UD_Ipush, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 }, /* 1257 */ { UD_Ipush, O_sIb, O_NONE, O_NONE, O_NONE, P_oso|P_def64 }, /* 1258 */ { UD_Ipusha, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_inv64 }, /* 1259 */ { UD_Ipushad, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_inv64 }, /* 1260 */ { UD_Ipushfw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso }, /* 1261 */ { UD_Ipushfw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_def64 }, /* 1262 */ { UD_Ipushfd, O_NONE, O_NONE, O_NONE, O_NONE, P_oso }, /* 1263 */ { UD_Ipushfq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_def64 }, /* 1264 */ { UD_Ipushfq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_def64 }, /* 1265 */ { UD_Ipxor, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1266 */ { UD_Ivpxor, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1267 */ { UD_Ipxor, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1268 */ { UD_Ircl, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1269 */ { UD_Ircl, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1270 */ { UD_Ircl, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1271 */ { UD_Ircl, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1272 */ { UD_Ircl, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1273 */ { UD_Ircl, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1274 */ { UD_Ircr, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1275 */ { UD_Ircr, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1276 */ { UD_Ircr, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1277 */ { UD_Ircr, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1278 */ { UD_Ircr, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1279 */ { UD_Ircr, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1280 */ { UD_Irol, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1281 */ { UD_Irol, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1282 */ { UD_Irol, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1283 */ { UD_Irol, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1284 */ { UD_Irol, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1285 */ { UD_Irol, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1286 */ { UD_Iror, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1287 */ { UD_Iror, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1288 */ { UD_Iror, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1289 */ { UD_Iror, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1290 */ { UD_Iror, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1291 */ { UD_Iror, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1292 */ { UD_Ircpps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1293 */ { UD_Ivrcpps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1294 */ { UD_Ircpss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1295 */ { UD_Ivrcpss, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1296 */ { UD_Irdmsr, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1297 */ { UD_Irdpmc, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1298 */ { UD_Irdtsc, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1299 */ { UD_Irdtscp, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1300 */ { UD_Irepne, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1301 */ { UD_Irep, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1302 */ { UD_Iret, O_Iw, O_NONE, O_NONE, O_NONE, P_none }, /* 1303 */ { UD_Iret, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1304 */ { UD_Iretf, O_Iw, O_NONE, O_NONE, O_NONE, P_none }, /* 1305 */ { UD_Iretf, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1306 */ { UD_Irsm, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1307 */ { UD_Irsqrtps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1308 */ { UD_Ivrsqrtps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1309 */ { UD_Irsqrtss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1310 */ { UD_Ivrsqrtss, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1311 */ { UD_Isahf, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1312 */ { UD_Isalc, O_NONE, O_NONE, O_NONE, O_NONE, P_inv64 }, /* 1313 */ { UD_Isar, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1314 */ { UD_Isar, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1315 */ { UD_Isar, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1316 */ { UD_Isar, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1317 */ { UD_Isar, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1318 */ { UD_Isar, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1319 */ { UD_Ishl, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1320 */ { UD_Ishl, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1321 */ { UD_Ishl, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1322 */ { UD_Ishl, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1323 */ { UD_Ishl, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1324 */ { UD_Ishl, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1325 */ { UD_Ishl, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1326 */ { UD_Ishl, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1327 */ { UD_Ishl, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1328 */ { UD_Ishl, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1329 */ { UD_Ishl, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1330 */ { UD_Ishl, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1331 */ { UD_Ishr, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1332 */ { UD_Ishr, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1333 */ { UD_Ishr, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1334 */ { UD_Ishr, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1335 */ { UD_Ishr, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1336 */ { UD_Ishr, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1337 */ { UD_Isbb, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1338 */ { UD_Isbb, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1339 */ { UD_Isbb, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1340 */ { UD_Isbb, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1341 */ { UD_Isbb, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 1342 */ { UD_Isbb, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw }, /* 1343 */ { UD_Isbb, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1344 */ { UD_Isbb, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1345 */ { UD_Isbb, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 }, /* 1346 */ { UD_Isbb, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1347 */ { UD_Iscasb, O_NONE, O_NONE, O_NONE, O_NONE, P_strz }, /* 1348 */ { UD_Iscasw, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw }, /* 1349 */ { UD_Iscasd, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw }, /* 1350 */ { UD_Iscasq, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw }, /* 1351 */ { UD_Iseto, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1352 */ { UD_Isetno, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1353 */ { UD_Isetb, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1354 */ { UD_Isetae, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1355 */ { UD_Isetz, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1356 */ { UD_Isetnz, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1357 */ { UD_Isetbe, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1358 */ { UD_Iseta, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1359 */ { UD_Isets, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1360 */ { UD_Isetns, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1361 */ { UD_Isetp, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1362 */ { UD_Isetnp, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1363 */ { UD_Isetl, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1364 */ { UD_Isetge, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1365 */ { UD_Isetle, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1366 */ { UD_Isetg, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1367 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1368 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1369 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1370 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1371 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1372 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1373 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1374 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1375 */ { UD_Isgdt, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1376 */ { UD_Ishld, O_Ev, O_Gv, O_Ib, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1377 */ { UD_Ishld, O_Ev, O_Gv, O_CL, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1378 */ { UD_Ishrd, O_Ev, O_Gv, O_Ib, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1379 */ { UD_Ishrd, O_Ev, O_Gv, O_CL, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1380 */ { UD_Ishufpd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1381 */ { UD_Ivshufpd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1382 */ { UD_Ishufps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1383 */ { UD_Ivshufps, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 1384 */ { UD_Isidt, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1385 */ { UD_Isldt, O_MwRv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1386 */ { UD_Ismsw, O_MwRv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1387 */ { UD_Ismsw, O_MwRv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1388 */ { UD_Isqrtps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1389 */ { UD_Ivsqrtps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1390 */ { UD_Isqrtpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1391 */ { UD_Ivsqrtpd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1392 */ { UD_Isqrtsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1393 */ { UD_Ivsqrtsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1394 */ { UD_Isqrtss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1395 */ { UD_Ivsqrtss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1396 */ { UD_Istc, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1397 */ { UD_Istd, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1398 */ { UD_Istgi, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1399 */ { UD_Isti, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1400 */ { UD_Iskinit, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1401 */ { UD_Istmxcsr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1402 */ { UD_Ivstmxcsr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1403 */ { UD_Istosb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg }, /* 1404 */ { UD_Istosw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw }, /* 1405 */ { UD_Istosd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw }, /* 1406 */ { UD_Istosq, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw }, /* 1407 */ { UD_Istr, O_MwRv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1408 */ { UD_Isub, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1409 */ { UD_Isub, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1410 */ { UD_Isub, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1411 */ { UD_Isub, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1412 */ { UD_Isub, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 1413 */ { UD_Isub, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw }, /* 1414 */ { UD_Isub, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1415 */ { UD_Isub, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1416 */ { UD_Isub, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 }, /* 1417 */ { UD_Isub, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1418 */ { UD_Isubpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1419 */ { UD_Ivsubpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1420 */ { UD_Isubps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1421 */ { UD_Ivsubps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1422 */ { UD_Isubsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1423 */ { UD_Ivsubsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1424 */ { UD_Isubss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1425 */ { UD_Ivsubss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1426 */ { UD_Iswapgs, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1427 */ { UD_Isyscall, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1428 */ { UD_Isysenter, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1429 */ { UD_Isysenter, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1430 */ { UD_Isysexit, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1431 */ { UD_Isysexit, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1432 */ { UD_Isysret, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1433 */ { UD_Itest, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1434 */ { UD_Itest, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1435 */ { UD_Itest, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1436 */ { UD_Itest, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 1437 */ { UD_Itest, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw }, /* 1438 */ { UD_Itest, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1439 */ { UD_Itest, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1440 */ { UD_Itest, O_Ev, O_Iz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1441 */ { UD_Iucomisd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1442 */ { UD_Ivucomisd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1443 */ { UD_Iucomiss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1444 */ { UD_Ivucomiss, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1445 */ { UD_Iud2, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1446 */ { UD_Iunpckhpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1447 */ { UD_Ivunpckhpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1448 */ { UD_Iunpckhps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1449 */ { UD_Ivunpckhps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1450 */ { UD_Iunpcklps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1451 */ { UD_Ivunpcklps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1452 */ { UD_Iunpcklpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1453 */ { UD_Ivunpcklpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1454 */ { UD_Iverr, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1455 */ { UD_Iverw, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1456 */ { UD_Ivmcall, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1457 */ { UD_Irdrand, O_R, O_NONE, O_NONE, O_NONE, P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1458 */ { UD_Ivmclear, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1459 */ { UD_Ivmxon, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1460 */ { UD_Ivmptrld, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1461 */ { UD_Ivmptrst, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1462 */ { UD_Ivmlaunch, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1463 */ { UD_Ivmresume, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1464 */ { UD_Ivmxoff, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1465 */ { UD_Ivmread, O_Ey, O_Gy, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_def64 }, /* 1466 */ { UD_Ivmwrite, O_Gy, O_Ey, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_def64 }, /* 1467 */ { UD_Ivmrun, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1468 */ { UD_Ivmmcall, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1469 */ { UD_Ivmload, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1470 */ { UD_Ivmsave, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1471 */ { UD_Iwait, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1472 */ { UD_Iwbinvd, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1473 */ { UD_Iwrmsr, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1474 */ { UD_Ixadd, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexx|P_rexb }, /* 1475 */ { UD_Ixadd, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1476 */ { UD_Ixchg, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1477 */ { UD_Ixchg, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1478 */ { UD_Ixchg, O_R0v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1479 */ { UD_Ixchg, O_R1v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1480 */ { UD_Ixchg, O_R2v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1481 */ { UD_Ixchg, O_R3v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1482 */ { UD_Ixchg, O_R4v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1483 */ { UD_Ixchg, O_R5v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1484 */ { UD_Ixchg, O_R6v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1485 */ { UD_Ixchg, O_R7v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1486 */ { UD_Ixgetbv, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1487 */ { UD_Ixlatb, O_NONE, O_NONE, O_NONE, O_NONE, P_rexw|P_seg }, /* 1488 */ { UD_Ixor, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1489 */ { UD_Ixor, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1490 */ { UD_Ixor, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1491 */ { UD_Ixor, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1492 */ { UD_Ixor, O_AL, O_Ib, O_NONE, O_NONE, P_none }, /* 1493 */ { UD_Ixor, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw }, /* 1494 */ { UD_Ixor, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1495 */ { UD_Ixor, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1496 */ { UD_Ixor, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 }, /* 1497 */ { UD_Ixor, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1498 */ { UD_Ixorpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1499 */ { UD_Ivxorpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1500 */ { UD_Ixorps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1501 */ { UD_Ivxorps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1502 */ { UD_Ixcryptecb, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1503 */ { UD_Ixcryptcbc, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1504 */ { UD_Ixcryptctr, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1505 */ { UD_Ixcryptcfb, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1506 */ { UD_Ixcryptofb, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1507 */ { UD_Ixrstor, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1508 */ { UD_Ixsave, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1509 */ { UD_Ixsetbv, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1510 */ { UD_Ixsha1, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1511 */ { UD_Ixsha256, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1512 */ { UD_Ixstore, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1513 */ { UD_Ipclmulqdq, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1514 */ { UD_Ivpclmulqdq, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 1515 */ { UD_Igetsec, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1516 */ { UD_Imovdqa, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1517 */ { UD_Ivmovdqa, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1518 */ { UD_Imovdqa, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1519 */ { UD_Ivmovdqa, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1520 */ { UD_Imaskmovdqu, O_V, O_U, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1521 */ { UD_Ivmaskmovdqu, O_Vx, O_Ux, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1522 */ { UD_Imovdq2q, O_P, O_U, O_NONE, O_NONE, P_aso|P_rexb }, /* 1523 */ { UD_Imovdqu, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1524 */ { UD_Ivmovdqu, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1525 */ { UD_Imovdqu, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1526 */ { UD_Ivmovdqu, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1527 */ { UD_Imovq2dq, O_V, O_N, O_NONE, O_NONE, P_aso|P_rexr }, /* 1528 */ { UD_Ipaddq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1529 */ { UD_Ipaddq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1530 */ { UD_Ivpaddq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1531 */ { UD_Ipsubq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1532 */ { UD_Ivpsubq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1533 */ { UD_Ipsubq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1534 */ { UD_Ipmuludq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1535 */ { UD_Ipmuludq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1536 */ { UD_Ipshufhw, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1537 */ { UD_Ivpshufhw, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1538 */ { UD_Ipshuflw, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1539 */ { UD_Ivpshuflw, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1540 */ { UD_Ipshufd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1541 */ { UD_Ivpshufd, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1542 */ { UD_Ipslldq, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1543 */ { UD_Ivpslldq, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb }, /* 1544 */ { UD_Ipsrldq, O_U, O_Ib, O_NONE, O_NONE, P_rexb }, /* 1545 */ { UD_Ivpsrldq, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb }, /* 1546 */ { UD_Ipunpckhqdq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1547 */ { UD_Ivpunpckhqdq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1548 */ { UD_Ipunpcklqdq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1549 */ { UD_Ivpunpcklqdq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1550 */ { UD_Ihaddpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1551 */ { UD_Ivhaddpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1552 */ { UD_Ihaddps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1553 */ { UD_Ivhaddps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1554 */ { UD_Ihsubpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1555 */ { UD_Ivhsubpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1556 */ { UD_Ihsubps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1557 */ { UD_Ivhsubps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1558 */ { UD_Iinsertps, O_V, O_Md, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1559 */ { UD_Ivinsertps, O_Vx, O_Hx, O_Md, O_Ib, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1560 */ { UD_Ilddqu, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1561 */ { UD_Ivlddqu, O_Vx, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1562 */ { UD_Imovddup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1563 */ { UD_Ivmovddup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1564 */ { UD_Imovddup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1565 */ { UD_Ivmovddup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1566 */ { UD_Imovshdup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1567 */ { UD_Ivmovshdup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1568 */ { UD_Imovshdup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1569 */ { UD_Ivmovshdup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1570 */ { UD_Imovsldup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1571 */ { UD_Ivmovsldup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1572 */ { UD_Imovsldup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1573 */ { UD_Ivmovsldup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1574 */ { UD_Ipabsb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1575 */ { UD_Ipabsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1576 */ { UD_Ivpabsb, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1577 */ { UD_Ipabsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1578 */ { UD_Ipabsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1579 */ { UD_Ivpabsw, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1580 */ { UD_Ipabsd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1581 */ { UD_Ipabsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1582 */ { UD_Ivpabsd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1583 */ { UD_Ipshufb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1584 */ { UD_Ipshufb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1585 */ { UD_Ivpshufb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1586 */ { UD_Iphaddw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1587 */ { UD_Iphaddw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1588 */ { UD_Ivphaddw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1589 */ { UD_Iphaddd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1590 */ { UD_Iphaddd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1591 */ { UD_Ivphaddd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1592 */ { UD_Iphaddsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1593 */ { UD_Iphaddsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1594 */ { UD_Ivphaddsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1595 */ { UD_Ipmaddubsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1596 */ { UD_Ipmaddubsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1597 */ { UD_Ivpmaddubsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1598 */ { UD_Iphsubw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1599 */ { UD_Iphsubw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1600 */ { UD_Ivphsubw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1601 */ { UD_Iphsubd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1602 */ { UD_Iphsubd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1603 */ { UD_Ivphsubd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1604 */ { UD_Iphsubsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1605 */ { UD_Iphsubsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1606 */ { UD_Ivphsubsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1607 */ { UD_Ipsignb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1608 */ { UD_Ipsignb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1609 */ { UD_Ivpsignb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1610 */ { UD_Ipsignd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1611 */ { UD_Ipsignd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1612 */ { UD_Ivpsignd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1613 */ { UD_Ipsignw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1614 */ { UD_Ipsignw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1615 */ { UD_Ivpsignw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1616 */ { UD_Ipmulhrsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1617 */ { UD_Ipmulhrsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1618 */ { UD_Ivpmulhrsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1619 */ { UD_Ipalignr, O_P, O_Q, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1620 */ { UD_Ipalignr, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1621 */ { UD_Ivpalignr, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 1622 */ { UD_Ipblendvb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1623 */ { UD_Ipmuldq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1624 */ { UD_Ivpmuldq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1625 */ { UD_Ipminsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1626 */ { UD_Ivpminsb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1627 */ { UD_Ipminsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1628 */ { UD_Ivpminsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1629 */ { UD_Ipminuw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1630 */ { UD_Ivpminuw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1631 */ { UD_Ipminud, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1632 */ { UD_Ivpminud, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1633 */ { UD_Ipmaxsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1634 */ { UD_Ivpmaxsb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1635 */ { UD_Ipmaxsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1636 */ { UD_Ivpmaxsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1637 */ { UD_Ipmaxud, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1638 */ { UD_Ivpmaxud, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1639 */ { UD_Ipmaxuw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1640 */ { UD_Ivpmaxuw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1641 */ { UD_Ipmulld, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1642 */ { UD_Ivpmulld, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1643 */ { UD_Iphminposuw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1644 */ { UD_Ivphminposuw, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1645 */ { UD_Iroundps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1646 */ { UD_Ivroundps, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1647 */ { UD_Iroundpd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1648 */ { UD_Ivroundpd, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1649 */ { UD_Iroundss, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1650 */ { UD_Ivroundss, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 1651 */ { UD_Iroundsd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1652 */ { UD_Ivroundsd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 1653 */ { UD_Iblendpd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1654 */ { UD_Ivblendpd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1655 */ { UD_Iblendps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1656 */ { UD_Ivblendps, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 1657 */ { UD_Iblendvpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1658 */ { UD_Iblendvps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1659 */ { UD_Ibound, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso }, /* 1660 */ { UD_Ibsf, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1661 */ { UD_Ibsr, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1662 */ { UD_Ibswap, O_R0y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1663 */ { UD_Ibswap, O_R1y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1664 */ { UD_Ibswap, O_R2y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1665 */ { UD_Ibswap, O_R3y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1666 */ { UD_Ibswap, O_R4y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1667 */ { UD_Ibswap, O_R5y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1668 */ { UD_Ibswap, O_R6y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1669 */ { UD_Ibswap, O_R7y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb }, /* 1670 */ { UD_Ibt, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1671 */ { UD_Ibt, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1672 */ { UD_Ibtc, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1673 */ { UD_Ibtc, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1674 */ { UD_Ibtr, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1675 */ { UD_Ibtr, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1676 */ { UD_Ibts, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1677 */ { UD_Ibts, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb }, /* 1678 */ { UD_Ipblendw, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1679 */ { UD_Ivpblendw, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb }, /* 1680 */ { UD_Impsadbw, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1681 */ { UD_Ivmpsadbw, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1682 */ { UD_Imovntdqa, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1683 */ { UD_Ivmovntdqa, O_Vx, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb|P_vexl }, /* 1684 */ { UD_Ipackusdw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1685 */ { UD_Ivpackusdw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb|P_vexl }, /* 1686 */ { UD_Ipmovsxbw, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1687 */ { UD_Ivpmovsxbw, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1688 */ { UD_Ipmovsxbd, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1689 */ { UD_Ivpmovsxbd, O_Vx, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1690 */ { UD_Ipmovsxbq, O_V, O_MwU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1691 */ { UD_Ivpmovsxbq, O_Vx, O_MwU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1692 */ { UD_Ipmovsxwd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1693 */ { UD_Ivpmovsxwd, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1694 */ { UD_Ipmovsxwq, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1695 */ { UD_Ivpmovsxwq, O_Vx, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1696 */ { UD_Ipmovsxdq, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1697 */ { UD_Ipmovzxbw, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1698 */ { UD_Ivpmovzxbw, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1699 */ { UD_Ipmovzxbd, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1700 */ { UD_Ivpmovzxbd, O_Vx, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1701 */ { UD_Ipmovzxbq, O_V, O_MwU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1702 */ { UD_Ivpmovzxbq, O_Vx, O_MwU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1703 */ { UD_Ipmovzxwd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1704 */ { UD_Ivpmovzxwd, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1705 */ { UD_Ipmovzxwq, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1706 */ { UD_Ivpmovzxwq, O_Vx, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1707 */ { UD_Ipmovzxdq, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1708 */ { UD_Ivpmovzxdq, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1709 */ { UD_Ipcmpeqq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1710 */ { UD_Ivpcmpeqq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1711 */ { UD_Ipopcnt, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1712 */ { UD_Iptest, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1713 */ { UD_Ivptest, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb|P_vexl }, /* 1714 */ { UD_Ipcmpestri, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1715 */ { UD_Ivpcmpestri, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1716 */ { UD_Ipcmpestrm, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1717 */ { UD_Ivpcmpestrm, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1718 */ { UD_Ipcmpgtq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1719 */ { UD_Ivpcmpgtq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1720 */ { UD_Ipcmpistri, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1721 */ { UD_Ivpcmpistri, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1722 */ { UD_Ipcmpistrm, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1723 */ { UD_Ivpcmpistrm, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1724 */ { UD_Imovbe, O_Gv, O_Mv, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1725 */ { UD_Imovbe, O_Mv, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1726 */ { UD_Icrc32, O_Gy, O_Eb, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1727 */ { UD_Icrc32, O_Gy, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb }, /* 1728 */ { UD_Ivbroadcastss, O_V, O_Md, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1729 */ { UD_Ivbroadcastsd, O_Vqq, O_Mq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1730 */ { UD_Ivextractf128, O_Wdq, O_Vqq, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1731 */ { UD_Ivinsertf128, O_Vqq, O_Hqq, O_Wdq, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1732 */ { UD_Ivmaskmovps, O_V, O_H, O_M, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1733 */ { UD_Ivmaskmovps, O_M, O_H, O_V, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1734 */ { UD_Ivmaskmovpd, O_V, O_H, O_M, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1735 */ { UD_Ivmaskmovpd, O_M, O_H, O_V, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1736 */ { UD_Ivpermilpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1737 */ { UD_Ivpermilpd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1738 */ { UD_Ivpermilps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1739 */ { UD_Ivpermilps, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1740 */ { UD_Ivperm2f128, O_Vqq, O_Hqq, O_Wqq, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1741 */ { UD_Ivtestps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1742 */ { UD_Ivtestpd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1743 */ { UD_Ivzeroupper, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1744 */ { UD_Ivzeroall, O_NONE, O_NONE, O_NONE, O_NONE, P_none }, /* 1745 */ { UD_Ivblendvpd, O_Vx, O_Hx, O_Wx, O_Lx, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1746 */ { UD_Ivblendvps, O_Vx, O_Hx, O_Wx, O_Lx, P_aso|P_rexr|P_rexx|P_rexb|P_vexl }, /* 1747 */ { UD_Ivmovsd, O_V, O_H, O_U, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1748 */ { UD_Ivmovsd, O_V, O_Mq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1749 */ { UD_Ivmovsd, O_U, O_H, O_V, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1750 */ { UD_Ivmovsd, O_Mq, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1751 */ { UD_Ivmovss, O_V, O_H, O_U, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1752 */ { UD_Ivmovss, O_V, O_Md, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1753 */ { UD_Ivmovss, O_U, O_H, O_V, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1754 */ { UD_Ivmovss, O_Md, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1755 */ { UD_Ivpblendvb, O_V, O_H, O_W, O_L, P_aso|P_rexr|P_rexx|P_rexb }, /* 1756 */ { UD_Ivpsllw, O_V, O_H, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1757 */ { UD_Ivpsllw, O_H, O_V, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1758 */ { UD_Ivpslld, O_V, O_H, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1759 */ { UD_Ivpslld, O_H, O_V, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1760 */ { UD_Ivpsllq, O_V, O_H, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, /* 1761 */ { UD_Ivpsllq, O_H, O_V, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb }, }; const char* ud_mnemonics_str[] = { "aaa", "aad", "aam", "aas", "adc", "add", "addpd", "addps", "addsd", "addss", "addsubpd", "addsubps", "aesdec", "aesdeclast", "aesenc", "aesenclast", "aesimc", "aeskeygenassist", "and", "andnpd", "andnps", "andpd", "andps", "arpl", "blendpd", "blendps", "blendvpd", "blendvps", "bound", "bsf", "bsr", "bswap", "bt", "btc", "btr", "bts", "call", "cbw", "cdq", "cdqe", "clc", "cld", "clflush", "clgi", "cli", "clts", "cmc", "cmova", "cmovae", "cmovb", "cmovbe", "cmovg", "cmovge", "cmovl", "cmovle", "cmovno", "cmovnp", "cmovns", "cmovnz", "cmovo", "cmovp", "cmovs", "cmovz", "cmp", "cmppd", "cmpps", "cmpsb", "cmpsd", "cmpsq", "cmpss", "cmpsw", "cmpxchg", "cmpxchg16b", "cmpxchg8b", "comisd", "comiss", "cpuid", "cqo", "crc32", "cvtdq2pd", "cvtdq2ps", "cvtpd2dq", "cvtpd2pi", "cvtpd2ps", "cvtpi2pd", "cvtpi2ps", "cvtps2dq", "cvtps2pd", "cvtps2pi", "cvtsd2si", "cvtsd2ss", "cvtsi2sd", "cvtsi2ss", "cvtss2sd", "cvtss2si", "cvttpd2dq", "cvttpd2pi", "cvttps2dq", "cvttps2pi", "cvttsd2si", "cvttss2si", "cwd", "cwde", "daa", "das", "dec", "div", "divpd", "divps", "divsd", "divss", "dppd", "dpps", "emms", "enter", "extractps", "f2xm1", "fabs", "fadd", "faddp", "fbld", "fbstp", "fchs", "fclex", "fcmovb", "fcmovbe", "fcmove", "fcmovnb", "fcmovnbe", "fcmovne", "fcmovnu", "fcmovu", "fcom", "fcom2", "fcomi", "fcomip", "fcomp", "fcomp3", "fcomp5", "fcompp", "fcos", "fdecstp", "fdiv", "fdivp", "fdivr", "fdivrp", "femms", "ffree", "ffreep", "fiadd", "ficom", "ficomp", "fidiv", "fidivr", "fild", "fimul", "fincstp", "fist", "fistp", "fisttp", "fisub", "fisubr", "fld", "fld1", "fldcw", "fldenv", "fldl2e", "fldl2t", "fldlg2", "fldln2", "fldpi", "fldz", "fmul", "fmulp", "fndisi", "fneni", "fninit", "fnop", "fnsave", "fnsetpm", "fnstcw", "fnstenv", "fnstsw", "fpatan", "fprem", "fprem1", "fptan", "frndint", "frstor", "frstpm", "fscale", "fsin", "fsincos", "fsqrt", "fst", "fstp", "fstp1", "fstp8", "fstp9", "fsub", "fsubp", "fsubr", "fsubrp", "ftst", "fucom", "fucomi", "fucomip", "fucomp", "fucompp", "fxam", "fxch", "fxch4", "fxch7", "fxrstor", "fxsave", "fxtract", "fyl2x", "fyl2xp1", "getsec", "haddpd", "haddps", "hlt", "hsubpd", "hsubps", "idiv", "imul", "in", "inc", "insb", "insd", "insertps", "insw", "int", "int1", "int3", "into", "invd", "invept", "invlpg", "invlpga", "invvpid", "iretd", "iretq", "iretw", "ja", "jae", "jb", "jbe", "jcxz", "jecxz", "jg", "jge", "jl", "jle", "jmp", "jno", "jnp", "jns", "jnz", "jo", "jp", "jrcxz", "js", "jz", "lahf", "lar", "lddqu", "ldmxcsr", "lds", "lea", "leave", "les", "lfence", "lfs", "lgdt", "lgs", "lidt", "lldt", "lmsw", "lock", "lodsb", "lodsd", "lodsq", "lodsw", "loop", "loope", "loopne", "lsl", "lss", "ltr", "maskmovdqu", "maskmovq", "maxpd", "maxps", "maxsd", "maxss", "mfence", "minpd", "minps", "minsd", "minss", "monitor", "montmul", "mov", "movapd", "movaps", "movbe", "movd", "movddup", "movdq2q", "movdqa", "movdqu", "movhlps", "movhpd", "movhps", "movlhps", "movlpd", "movlps", "movmskpd", "movmskps", "movntdq", "movntdqa", "movnti", "movntpd", "movntps", "movntq", "movq", "movq2dq", "movsb", "movsd", "movshdup", "movsldup", "movsq", "movss", "movsw", "movsx", "movsxd", "movupd", "movups", "movzx", "mpsadbw", "mul", "mulpd", "mulps", "mulsd", "mulss", "mwait", "neg", "nop", "not", "or", "orpd", "orps", "out", "outsb", "outsd", "outsw", "pabsb", "pabsd", "pabsw", "packssdw", "packsswb", "packusdw", "packuswb", "paddb", "paddd", "paddq", "paddsb", "paddsw", "paddusb", "paddusw", "paddw", "palignr", "pand", "pandn", "pavgb", "pavgusb", "pavgw", "pblendvb", "pblendw", "pclmulqdq", "pcmpeqb", "pcmpeqd", "pcmpeqq", "pcmpeqw", "pcmpestri", "pcmpestrm", "pcmpgtb", "pcmpgtd", "pcmpgtq", "pcmpgtw", "pcmpistri", "pcmpistrm", "pextrb", "pextrd", "pextrq", "pextrw", "pf2id", "pf2iw", "pfacc", "pfadd", "pfcmpeq", "pfcmpge", "pfcmpgt", "pfmax", "pfmin", "pfmul", "pfnacc", "pfpnacc", "pfrcp", "pfrcpit1", "pfrcpit2", "pfrsqit1", "pfrsqrt", "pfsub", "pfsubr", "phaddd", "phaddsw", "phaddw", "phminposuw", "phsubd", "phsubsw", "phsubw", "pi2fd", "pi2fw", "pinsrb", "pinsrd", "pinsrq", "pinsrw", "pmaddubsw", "pmaddwd", "pmaxsb", "pmaxsd", "pmaxsw", "pmaxub", "pmaxud", "pmaxuw", "pminsb", "pminsd", "pminsw", "pminub", "pminud", "pminuw", "pmovmskb", "pmovsxbd", "pmovsxbq", "pmovsxbw", "pmovsxdq", "pmovsxwd", "pmovsxwq", "pmovzxbd", "pmovzxbq", "pmovzxbw", "pmovzxdq", "pmovzxwd", "pmovzxwq", "pmuldq", "pmulhrsw", "pmulhrw", "pmulhuw", "pmulhw", "pmulld", "pmullw", "pmuludq", "pop", "popa", "popad", "popcnt", "popfd", "popfq", "popfw", "por", "prefetch", "prefetchnta", "prefetcht0", "prefetcht1", "prefetcht2", "psadbw", "pshufb", "pshufd", "pshufhw", "pshuflw", "pshufw", "psignb", "psignd", "psignw", "pslld", "pslldq", "psllq", "psllw", "psrad", "psraw", "psrld", "psrldq", "psrlq", "psrlw", "psubb", "psubd", "psubq", "psubsb", "psubsw", "psubusb", "psubusw", "psubw", "pswapd", "ptest", "punpckhbw", "punpckhdq", "punpckhqdq", "punpckhwd", "punpcklbw", "punpckldq", "punpcklqdq", "punpcklwd", "push", "pusha", "pushad", "pushfd", "pushfq", "pushfw", "pxor", "rcl", "rcpps", "rcpss", "rcr", "rdmsr", "rdpmc", "rdrand", "rdtsc", "rdtscp", "rep", "repne", "ret", "retf", "rol", "ror", "roundpd", "roundps", "roundsd", "roundss", "rsm", "rsqrtps", "rsqrtss", "sahf", "salc", "sar", "sbb", "scasb", "scasd", "scasq", "scasw", "seta", "setae", "setb", "setbe", "setg", "setge", "setl", "setle", "setno", "setnp", "setns", "setnz", "seto", "setp", "sets", "setz", "sfence", "sgdt", "shl", "shld", "shr", "shrd", "shufpd", "shufps", "sidt", "skinit", "sldt", "smsw", "sqrtpd", "sqrtps", "sqrtsd", "sqrtss", "stc", "std", "stgi", "sti", "stmxcsr", "stosb", "stosd", "stosq", "stosw", "str", "sub", "subpd", "subps", "subsd", "subss", "swapgs", "syscall", "sysenter", "sysexit", "sysret", "test", "ucomisd", "ucomiss", "ud2", "unpckhpd", "unpckhps", "unpcklpd", "unpcklps", "vaddpd", "vaddps", "vaddsd", "vaddss", "vaddsubpd", "vaddsubps", "vaesdec", "vaesdeclast", "vaesenc", "vaesenclast", "vaesimc", "vaeskeygenassist", "vandnpd", "vandnps", "vandpd", "vandps", "vblendpd", "vblendps", "vblendvpd", "vblendvps", "vbroadcastsd", "vbroadcastss", "vcmppd", "vcmpps", "vcmpsd", "vcmpss", "vcomisd", "vcomiss", "vcvtdq2pd", "vcvtdq2ps", "vcvtpd2dq", "vcvtpd2ps", "vcvtps2dq", "vcvtps2pd", "vcvtsd2si", "vcvtsd2ss", "vcvtsi2sd", "vcvtsi2ss", "vcvtss2sd", "vcvtss2si", "vcvttpd2dq", "vcvttps2dq", "vcvttsd2si", "vcvttss2si", "vdivpd", "vdivps", "vdivsd", "vdivss", "vdppd", "vdpps", "verr", "verw", "vextractf128", "vextractps", "vhaddpd", "vhaddps", "vhsubpd", "vhsubps", "vinsertf128", "vinsertps", "vlddqu", "vmaskmovdqu", "vmaskmovpd", "vmaskmovps", "vmaxpd", "vmaxps", "vmaxsd", "vmaxss", "vmcall", "vmclear", "vminpd", "vminps", "vminsd", "vminss", "vmlaunch", "vmload", "vmmcall", "vmovapd", "vmovaps", "vmovd", "vmovddup", "vmovdqa", "vmovdqu", "vmovhlps", "vmovhpd", "vmovhps", "vmovlhps", "vmovlpd", "vmovlps", "vmovmskpd", "vmovmskps", "vmovntdq", "vmovntdqa", "vmovntpd", "vmovntps", "vmovq", "vmovsd", "vmovshdup", "vmovsldup", "vmovss", "vmovupd", "vmovups", "vmpsadbw", "vmptrld", "vmptrst", "vmread", "vmresume", "vmrun", "vmsave", "vmulpd", "vmulps", "vmulsd", "vmulss", "vmwrite", "vmxoff", "vmxon", "vorpd", "vorps", "vpabsb", "vpabsd", "vpabsw", "vpackssdw", "vpacksswb", "vpackusdw", "vpackuswb", "vpaddb", "vpaddd", "vpaddq", "vpaddsb", "vpaddsw", "vpaddusb", "vpaddusw", "vpaddw", "vpalignr", "vpand", "vpandn", "vpavgb", "vpavgw", "vpblendvb", "vpblendw", "vpclmulqdq", "vpcmpeqb", "vpcmpeqd", "vpcmpeqq", "vpcmpeqw", "vpcmpestri", "vpcmpestrm", "vpcmpgtb", "vpcmpgtd", "vpcmpgtq", "vpcmpgtw", "vpcmpistri", "vpcmpistrm", "vperm2f128", "vpermilpd", "vpermilps", "vpextrb", "vpextrd", "vpextrq", "vpextrw", "vphaddd", "vphaddsw", "vphaddw", "vphminposuw", "vphsubd", "vphsubsw", "vphsubw", "vpinsrb", "vpinsrd", "vpinsrq", "vpinsrw", "vpmaddubsw", "vpmaddwd", "vpmaxsb", "vpmaxsd", "vpmaxsw", "vpmaxub", "vpmaxud", "vpmaxuw", "vpminsb", "vpminsd", "vpminsw", "vpminub", "vpminud", "vpminuw", "vpmovmskb", "vpmovsxbd", "vpmovsxbq", "vpmovsxbw", "vpmovsxwd", "vpmovsxwq", "vpmovzxbd", "vpmovzxbq", "vpmovzxbw", "vpmovzxdq", "vpmovzxwd", "vpmovzxwq", "vpmuldq", "vpmulhrsw", "vpmulhuw", "vpmulhw", "vpmulld", "vpmullw", "vpor", "vpsadbw", "vpshufb", "vpshufd", "vpshufhw", "vpshuflw", "vpsignb", "vpsignd", "vpsignw", "vpslld", "vpslldq", "vpsllq", "vpsllw", "vpsrad", "vpsraw", "vpsrld", "vpsrldq", "vpsrlq", "vpsrlw", "vpsubb", "vpsubd", "vpsubq", "vpsubsb", "vpsubsw", "vpsubusb", "vpsubusw", "vpsubw", "vptest", "vpunpckhbw", "vpunpckhdq", "vpunpckhqdq", "vpunpckhwd", "vpunpcklbw", "vpunpckldq", "vpunpcklqdq", "vpunpcklwd", "vpxor", "vrcpps", "vrcpss", "vroundpd", "vroundps", "vroundsd", "vroundss", "vrsqrtps", "vrsqrtss", "vshufpd", "vshufps", "vsqrtpd", "vsqrtps", "vsqrtsd", "vsqrtss", "vstmxcsr", "vsubpd", "vsubps", "vsubsd", "vsubss", "vtestpd", "vtestps", "vucomisd", "vucomiss", "vunpckhpd", "vunpckhps", "vunpcklpd", "vunpcklps", "vxorpd", "vxorps", "vzeroall", "vzeroupper", "wait", "wbinvd", "wrmsr", "xadd", "xchg", "xcryptcbc", "xcryptcfb", "xcryptctr", "xcryptecb", "xcryptofb", "xgetbv", "xlatb", "xor", "xorpd", "xorps", "xrstor", "xsave", "xsetbv", "xsha1", "xsha256", "xstore", "invalid", "3dnow", "none", "db", "pause" };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/itab.h
C/C++ Header
#ifndef UD_ITAB_H #define UD_ITAB_H /* itab.h -- generated by udis86:scripts/ud_itab.py, do no edit */ /* ud_table_type -- lookup table types (see decode.c) */ enum ud_table_type { UD_TAB__OPC_VEX, UD_TAB__OPC_TABLE, UD_TAB__OPC_X87, UD_TAB__OPC_MOD, UD_TAB__OPC_RM, UD_TAB__OPC_OSIZE, UD_TAB__OPC_MODE, UD_TAB__OPC_VEX_L, UD_TAB__OPC_3DNOW, UD_TAB__OPC_REG, UD_TAB__OPC_ASIZE, UD_TAB__OPC_VEX_W, UD_TAB__OPC_SSE, UD_TAB__OPC_VENDOR }; /* ud_mnemonic -- mnemonic constants */ enum ud_mnemonic_code { UD_Iaaa, UD_Iaad, UD_Iaam, UD_Iaas, UD_Iadc, UD_Iadd, UD_Iaddpd, UD_Iaddps, UD_Iaddsd, UD_Iaddss, UD_Iaddsubpd, UD_Iaddsubps, UD_Iaesdec, UD_Iaesdeclast, UD_Iaesenc, UD_Iaesenclast, UD_Iaesimc, UD_Iaeskeygenassist, UD_Iand, UD_Iandnpd, UD_Iandnps, UD_Iandpd, UD_Iandps, UD_Iarpl, UD_Iblendpd, UD_Iblendps, UD_Iblendvpd, UD_Iblendvps, UD_Ibound, UD_Ibsf, UD_Ibsr, UD_Ibswap, UD_Ibt, UD_Ibtc, UD_Ibtr, UD_Ibts, UD_Icall, UD_Icbw, UD_Icdq, UD_Icdqe, UD_Iclc, UD_Icld, UD_Iclflush, UD_Iclgi, UD_Icli, UD_Iclts, UD_Icmc, UD_Icmova, UD_Icmovae, UD_Icmovb, UD_Icmovbe, UD_Icmovg, UD_Icmovge, UD_Icmovl, UD_Icmovle, UD_Icmovno, UD_Icmovnp, UD_Icmovns, UD_Icmovnz, UD_Icmovo, UD_Icmovp, UD_Icmovs, UD_Icmovz, UD_Icmp, UD_Icmppd, UD_Icmpps, UD_Icmpsb, UD_Icmpsd, UD_Icmpsq, UD_Icmpss, UD_Icmpsw, UD_Icmpxchg, UD_Icmpxchg16b, UD_Icmpxchg8b, UD_Icomisd, UD_Icomiss, UD_Icpuid, UD_Icqo, UD_Icrc32, UD_Icvtdq2pd, UD_Icvtdq2ps, UD_Icvtpd2dq, UD_Icvtpd2pi, UD_Icvtpd2ps, UD_Icvtpi2pd, UD_Icvtpi2ps, UD_Icvtps2dq, UD_Icvtps2pd, UD_Icvtps2pi, UD_Icvtsd2si, UD_Icvtsd2ss, UD_Icvtsi2sd, UD_Icvtsi2ss, UD_Icvtss2sd, UD_Icvtss2si, UD_Icvttpd2dq, UD_Icvttpd2pi, UD_Icvttps2dq, UD_Icvttps2pi, UD_Icvttsd2si, UD_Icvttss2si, UD_Icwd, UD_Icwde, UD_Idaa, UD_Idas, UD_Idec, UD_Idiv, UD_Idivpd, UD_Idivps, UD_Idivsd, UD_Idivss, UD_Idppd, UD_Idpps, UD_Iemms, UD_Ienter, UD_Iextractps, UD_If2xm1, UD_Ifabs, UD_Ifadd, UD_Ifaddp, UD_Ifbld, UD_Ifbstp, UD_Ifchs, UD_Ifclex, UD_Ifcmovb, UD_Ifcmovbe, UD_Ifcmove, UD_Ifcmovnb, UD_Ifcmovnbe, UD_Ifcmovne, UD_Ifcmovnu, UD_Ifcmovu, UD_Ifcom, UD_Ifcom2, UD_Ifcomi, UD_Ifcomip, UD_Ifcomp, UD_Ifcomp3, UD_Ifcomp5, UD_Ifcompp, UD_Ifcos, UD_Ifdecstp, UD_Ifdiv, UD_Ifdivp, UD_Ifdivr, UD_Ifdivrp, UD_Ifemms, UD_Iffree, UD_Iffreep, UD_Ifiadd, UD_Ificom, UD_Ificomp, UD_Ifidiv, UD_Ifidivr, UD_Ifild, UD_Ifimul, UD_Ifincstp, UD_Ifist, UD_Ifistp, UD_Ifisttp, UD_Ifisub, UD_Ifisubr, UD_Ifld, UD_Ifld1, UD_Ifldcw, UD_Ifldenv, UD_Ifldl2e, UD_Ifldl2t, UD_Ifldlg2, UD_Ifldln2, UD_Ifldpi, UD_Ifldz, UD_Ifmul, UD_Ifmulp, UD_Ifndisi, UD_Ifneni, UD_Ifninit, UD_Ifnop, UD_Ifnsave, UD_Ifnsetpm, UD_Ifnstcw, UD_Ifnstenv, UD_Ifnstsw, UD_Ifpatan, UD_Ifprem, UD_Ifprem1, UD_Ifptan, UD_Ifrndint, UD_Ifrstor, UD_Ifrstpm, UD_Ifscale, UD_Ifsin, UD_Ifsincos, UD_Ifsqrt, UD_Ifst, UD_Ifstp, UD_Ifstp1, UD_Ifstp8, UD_Ifstp9, UD_Ifsub, UD_Ifsubp, UD_Ifsubr, UD_Ifsubrp, UD_Iftst, UD_Ifucom, UD_Ifucomi, UD_Ifucomip, UD_Ifucomp, UD_Ifucompp, UD_Ifxam, UD_Ifxch, UD_Ifxch4, UD_Ifxch7, UD_Ifxrstor, UD_Ifxsave, UD_Ifxtract, UD_Ifyl2x, UD_Ifyl2xp1, UD_Igetsec, UD_Ihaddpd, UD_Ihaddps, UD_Ihlt, UD_Ihsubpd, UD_Ihsubps, UD_Iidiv, UD_Iimul, UD_Iin, UD_Iinc, UD_Iinsb, UD_Iinsd, UD_Iinsertps, UD_Iinsw, UD_Iint, UD_Iint1, UD_Iint3, UD_Iinto, UD_Iinvd, UD_Iinvept, UD_Iinvlpg, UD_Iinvlpga, UD_Iinvvpid, UD_Iiretd, UD_Iiretq, UD_Iiretw, UD_Ija, UD_Ijae, UD_Ijb, UD_Ijbe, UD_Ijcxz, UD_Ijecxz, UD_Ijg, UD_Ijge, UD_Ijl, UD_Ijle, UD_Ijmp, UD_Ijno, UD_Ijnp, UD_Ijns, UD_Ijnz, UD_Ijo, UD_Ijp, UD_Ijrcxz, UD_Ijs, UD_Ijz, UD_Ilahf, UD_Ilar, UD_Ilddqu, UD_Ildmxcsr, UD_Ilds, UD_Ilea, UD_Ileave, UD_Iles, UD_Ilfence, UD_Ilfs, UD_Ilgdt, UD_Ilgs, UD_Ilidt, UD_Illdt, UD_Ilmsw, UD_Ilock, UD_Ilodsb, UD_Ilodsd, UD_Ilodsq, UD_Ilodsw, UD_Iloop, UD_Iloope, UD_Iloopne, UD_Ilsl, UD_Ilss, UD_Iltr, UD_Imaskmovdqu, UD_Imaskmovq, UD_Imaxpd, UD_Imaxps, UD_Imaxsd, UD_Imaxss, UD_Imfence, UD_Iminpd, UD_Iminps, UD_Iminsd, UD_Iminss, UD_Imonitor, UD_Imontmul, UD_Imov, UD_Imovapd, UD_Imovaps, UD_Imovbe, UD_Imovd, UD_Imovddup, UD_Imovdq2q, UD_Imovdqa, UD_Imovdqu, UD_Imovhlps, UD_Imovhpd, UD_Imovhps, UD_Imovlhps, UD_Imovlpd, UD_Imovlps, UD_Imovmskpd, UD_Imovmskps, UD_Imovntdq, UD_Imovntdqa, UD_Imovnti, UD_Imovntpd, UD_Imovntps, UD_Imovntq, UD_Imovq, UD_Imovq2dq, UD_Imovsb, UD_Imovsd, UD_Imovshdup, UD_Imovsldup, UD_Imovsq, UD_Imovss, UD_Imovsw, UD_Imovsx, UD_Imovsxd, UD_Imovupd, UD_Imovups, UD_Imovzx, UD_Impsadbw, UD_Imul, UD_Imulpd, UD_Imulps, UD_Imulsd, UD_Imulss, UD_Imwait, UD_Ineg, UD_Inop, UD_Inot, UD_Ior, UD_Iorpd, UD_Iorps, UD_Iout, UD_Ioutsb, UD_Ioutsd, UD_Ioutsw, UD_Ipabsb, UD_Ipabsd, UD_Ipabsw, UD_Ipackssdw, UD_Ipacksswb, UD_Ipackusdw, UD_Ipackuswb, UD_Ipaddb, UD_Ipaddd, UD_Ipaddq, UD_Ipaddsb, UD_Ipaddsw, UD_Ipaddusb, UD_Ipaddusw, UD_Ipaddw, UD_Ipalignr, UD_Ipand, UD_Ipandn, UD_Ipavgb, UD_Ipavgusb, UD_Ipavgw, UD_Ipblendvb, UD_Ipblendw, UD_Ipclmulqdq, UD_Ipcmpeqb, UD_Ipcmpeqd, UD_Ipcmpeqq, UD_Ipcmpeqw, UD_Ipcmpestri, UD_Ipcmpestrm, UD_Ipcmpgtb, UD_Ipcmpgtd, UD_Ipcmpgtq, UD_Ipcmpgtw, UD_Ipcmpistri, UD_Ipcmpistrm, UD_Ipextrb, UD_Ipextrd, UD_Ipextrq, UD_Ipextrw, UD_Ipf2id, UD_Ipf2iw, UD_Ipfacc, UD_Ipfadd, UD_Ipfcmpeq, UD_Ipfcmpge, UD_Ipfcmpgt, UD_Ipfmax, UD_Ipfmin, UD_Ipfmul, UD_Ipfnacc, UD_Ipfpnacc, UD_Ipfrcp, UD_Ipfrcpit1, UD_Ipfrcpit2, UD_Ipfrsqit1, UD_Ipfrsqrt, UD_Ipfsub, UD_Ipfsubr, UD_Iphaddd, UD_Iphaddsw, UD_Iphaddw, UD_Iphminposuw, UD_Iphsubd, UD_Iphsubsw, UD_Iphsubw, UD_Ipi2fd, UD_Ipi2fw, UD_Ipinsrb, UD_Ipinsrd, UD_Ipinsrq, UD_Ipinsrw, UD_Ipmaddubsw, UD_Ipmaddwd, UD_Ipmaxsb, UD_Ipmaxsd, UD_Ipmaxsw, UD_Ipmaxub, UD_Ipmaxud, UD_Ipmaxuw, UD_Ipminsb, UD_Ipminsd, UD_Ipminsw, UD_Ipminub, UD_Ipminud, UD_Ipminuw, UD_Ipmovmskb, UD_Ipmovsxbd, UD_Ipmovsxbq, UD_Ipmovsxbw, UD_Ipmovsxdq, UD_Ipmovsxwd, UD_Ipmovsxwq, UD_Ipmovzxbd, UD_Ipmovzxbq, UD_Ipmovzxbw, UD_Ipmovzxdq, UD_Ipmovzxwd, UD_Ipmovzxwq, UD_Ipmuldq, UD_Ipmulhrsw, UD_Ipmulhrw, UD_Ipmulhuw, UD_Ipmulhw, UD_Ipmulld, UD_Ipmullw, UD_Ipmuludq, UD_Ipop, UD_Ipopa, UD_Ipopad, UD_Ipopcnt, UD_Ipopfd, UD_Ipopfq, UD_Ipopfw, UD_Ipor, UD_Iprefetch, UD_Iprefetchnta, UD_Iprefetcht0, UD_Iprefetcht1, UD_Iprefetcht2, UD_Ipsadbw, UD_Ipshufb, UD_Ipshufd, UD_Ipshufhw, UD_Ipshuflw, UD_Ipshufw, UD_Ipsignb, UD_Ipsignd, UD_Ipsignw, UD_Ipslld, UD_Ipslldq, UD_Ipsllq, UD_Ipsllw, UD_Ipsrad, UD_Ipsraw, UD_Ipsrld, UD_Ipsrldq, UD_Ipsrlq, UD_Ipsrlw, UD_Ipsubb, UD_Ipsubd, UD_Ipsubq, UD_Ipsubsb, UD_Ipsubsw, UD_Ipsubusb, UD_Ipsubusw, UD_Ipsubw, UD_Ipswapd, UD_Iptest, UD_Ipunpckhbw, UD_Ipunpckhdq, UD_Ipunpckhqdq, UD_Ipunpckhwd, UD_Ipunpcklbw, UD_Ipunpckldq, UD_Ipunpcklqdq, UD_Ipunpcklwd, UD_Ipush, UD_Ipusha, UD_Ipushad, UD_Ipushfd, UD_Ipushfq, UD_Ipushfw, UD_Ipxor, UD_Ircl, UD_Ircpps, UD_Ircpss, UD_Ircr, UD_Irdmsr, UD_Irdpmc, UD_Irdrand, UD_Irdtsc, UD_Irdtscp, UD_Irep, UD_Irepne, UD_Iret, UD_Iretf, UD_Irol, UD_Iror, UD_Iroundpd, UD_Iroundps, UD_Iroundsd, UD_Iroundss, UD_Irsm, UD_Irsqrtps, UD_Irsqrtss, UD_Isahf, UD_Isalc, UD_Isar, UD_Isbb, UD_Iscasb, UD_Iscasd, UD_Iscasq, UD_Iscasw, UD_Iseta, UD_Isetae, UD_Isetb, UD_Isetbe, UD_Isetg, UD_Isetge, UD_Isetl, UD_Isetle, UD_Isetno, UD_Isetnp, UD_Isetns, UD_Isetnz, UD_Iseto, UD_Isetp, UD_Isets, UD_Isetz, UD_Isfence, UD_Isgdt, UD_Ishl, UD_Ishld, UD_Ishr, UD_Ishrd, UD_Ishufpd, UD_Ishufps, UD_Isidt, UD_Iskinit, UD_Isldt, UD_Ismsw, UD_Isqrtpd, UD_Isqrtps, UD_Isqrtsd, UD_Isqrtss, UD_Istc, UD_Istd, UD_Istgi, UD_Isti, UD_Istmxcsr, UD_Istosb, UD_Istosd, UD_Istosq, UD_Istosw, UD_Istr, UD_Isub, UD_Isubpd, UD_Isubps, UD_Isubsd, UD_Isubss, UD_Iswapgs, UD_Isyscall, UD_Isysenter, UD_Isysexit, UD_Isysret, UD_Itest, UD_Iucomisd, UD_Iucomiss, UD_Iud2, UD_Iunpckhpd, UD_Iunpckhps, UD_Iunpcklpd, UD_Iunpcklps, UD_Ivaddpd, UD_Ivaddps, UD_Ivaddsd, UD_Ivaddss, UD_Ivaddsubpd, UD_Ivaddsubps, UD_Ivaesdec, UD_Ivaesdeclast, UD_Ivaesenc, UD_Ivaesenclast, UD_Ivaesimc, UD_Ivaeskeygenassist, UD_Ivandnpd, UD_Ivandnps, UD_Ivandpd, UD_Ivandps, UD_Ivblendpd, UD_Ivblendps, UD_Ivblendvpd, UD_Ivblendvps, UD_Ivbroadcastsd, UD_Ivbroadcastss, UD_Ivcmppd, UD_Ivcmpps, UD_Ivcmpsd, UD_Ivcmpss, UD_Ivcomisd, UD_Ivcomiss, UD_Ivcvtdq2pd, UD_Ivcvtdq2ps, UD_Ivcvtpd2dq, UD_Ivcvtpd2ps, UD_Ivcvtps2dq, UD_Ivcvtps2pd, UD_Ivcvtsd2si, UD_Ivcvtsd2ss, UD_Ivcvtsi2sd, UD_Ivcvtsi2ss, UD_Ivcvtss2sd, UD_Ivcvtss2si, UD_Ivcvttpd2dq, UD_Ivcvttps2dq, UD_Ivcvttsd2si, UD_Ivcvttss2si, UD_Ivdivpd, UD_Ivdivps, UD_Ivdivsd, UD_Ivdivss, UD_Ivdppd, UD_Ivdpps, UD_Iverr, UD_Iverw, UD_Ivextractf128, UD_Ivextractps, UD_Ivhaddpd, UD_Ivhaddps, UD_Ivhsubpd, UD_Ivhsubps, UD_Ivinsertf128, UD_Ivinsertps, UD_Ivlddqu, UD_Ivmaskmovdqu, UD_Ivmaskmovpd, UD_Ivmaskmovps, UD_Ivmaxpd, UD_Ivmaxps, UD_Ivmaxsd, UD_Ivmaxss, UD_Ivmcall, UD_Ivmclear, UD_Ivminpd, UD_Ivminps, UD_Ivminsd, UD_Ivminss, UD_Ivmlaunch, UD_Ivmload, UD_Ivmmcall, UD_Ivmovapd, UD_Ivmovaps, UD_Ivmovd, UD_Ivmovddup, UD_Ivmovdqa, UD_Ivmovdqu, UD_Ivmovhlps, UD_Ivmovhpd, UD_Ivmovhps, UD_Ivmovlhps, UD_Ivmovlpd, UD_Ivmovlps, UD_Ivmovmskpd, UD_Ivmovmskps, UD_Ivmovntdq, UD_Ivmovntdqa, UD_Ivmovntpd, UD_Ivmovntps, UD_Ivmovq, UD_Ivmovsd, UD_Ivmovshdup, UD_Ivmovsldup, UD_Ivmovss, UD_Ivmovupd, UD_Ivmovups, UD_Ivmpsadbw, UD_Ivmptrld, UD_Ivmptrst, UD_Ivmread, UD_Ivmresume, UD_Ivmrun, UD_Ivmsave, UD_Ivmulpd, UD_Ivmulps, UD_Ivmulsd, UD_Ivmulss, UD_Ivmwrite, UD_Ivmxoff, UD_Ivmxon, UD_Ivorpd, UD_Ivorps, UD_Ivpabsb, UD_Ivpabsd, UD_Ivpabsw, UD_Ivpackssdw, UD_Ivpacksswb, UD_Ivpackusdw, UD_Ivpackuswb, UD_Ivpaddb, UD_Ivpaddd, UD_Ivpaddq, UD_Ivpaddsb, UD_Ivpaddsw, UD_Ivpaddusb, UD_Ivpaddusw, UD_Ivpaddw, UD_Ivpalignr, UD_Ivpand, UD_Ivpandn, UD_Ivpavgb, UD_Ivpavgw, UD_Ivpblendvb, UD_Ivpblendw, UD_Ivpclmulqdq, UD_Ivpcmpeqb, UD_Ivpcmpeqd, UD_Ivpcmpeqq, UD_Ivpcmpeqw, UD_Ivpcmpestri, UD_Ivpcmpestrm, UD_Ivpcmpgtb, UD_Ivpcmpgtd, UD_Ivpcmpgtq, UD_Ivpcmpgtw, UD_Ivpcmpistri, UD_Ivpcmpistrm, UD_Ivperm2f128, UD_Ivpermilpd, UD_Ivpermilps, UD_Ivpextrb, UD_Ivpextrd, UD_Ivpextrq, UD_Ivpextrw, UD_Ivphaddd, UD_Ivphaddsw, UD_Ivphaddw, UD_Ivphminposuw, UD_Ivphsubd, UD_Ivphsubsw, UD_Ivphsubw, UD_Ivpinsrb, UD_Ivpinsrd, UD_Ivpinsrq, UD_Ivpinsrw, UD_Ivpmaddubsw, UD_Ivpmaddwd, UD_Ivpmaxsb, UD_Ivpmaxsd, UD_Ivpmaxsw, UD_Ivpmaxub, UD_Ivpmaxud, UD_Ivpmaxuw, UD_Ivpminsb, UD_Ivpminsd, UD_Ivpminsw, UD_Ivpminub, UD_Ivpminud, UD_Ivpminuw, UD_Ivpmovmskb, UD_Ivpmovsxbd, UD_Ivpmovsxbq, UD_Ivpmovsxbw, UD_Ivpmovsxwd, UD_Ivpmovsxwq, UD_Ivpmovzxbd, UD_Ivpmovzxbq, UD_Ivpmovzxbw, UD_Ivpmovzxdq, UD_Ivpmovzxwd, UD_Ivpmovzxwq, UD_Ivpmuldq, UD_Ivpmulhrsw, UD_Ivpmulhuw, UD_Ivpmulhw, UD_Ivpmulld, UD_Ivpmullw, UD_Ivpor, UD_Ivpsadbw, UD_Ivpshufb, UD_Ivpshufd, UD_Ivpshufhw, UD_Ivpshuflw, UD_Ivpsignb, UD_Ivpsignd, UD_Ivpsignw, UD_Ivpslld, UD_Ivpslldq, UD_Ivpsllq, UD_Ivpsllw, UD_Ivpsrad, UD_Ivpsraw, UD_Ivpsrld, UD_Ivpsrldq, UD_Ivpsrlq, UD_Ivpsrlw, UD_Ivpsubb, UD_Ivpsubd, UD_Ivpsubq, UD_Ivpsubsb, UD_Ivpsubsw, UD_Ivpsubusb, UD_Ivpsubusw, UD_Ivpsubw, UD_Ivptest, UD_Ivpunpckhbw, UD_Ivpunpckhdq, UD_Ivpunpckhqdq, UD_Ivpunpckhwd, UD_Ivpunpcklbw, UD_Ivpunpckldq, UD_Ivpunpcklqdq, UD_Ivpunpcklwd, UD_Ivpxor, UD_Ivrcpps, UD_Ivrcpss, UD_Ivroundpd, UD_Ivroundps, UD_Ivroundsd, UD_Ivroundss, UD_Ivrsqrtps, UD_Ivrsqrtss, UD_Ivshufpd, UD_Ivshufps, UD_Ivsqrtpd, UD_Ivsqrtps, UD_Ivsqrtsd, UD_Ivsqrtss, UD_Ivstmxcsr, UD_Ivsubpd, UD_Ivsubps, UD_Ivsubsd, UD_Ivsubss, UD_Ivtestpd, UD_Ivtestps, UD_Ivucomisd, UD_Ivucomiss, UD_Ivunpckhpd, UD_Ivunpckhps, UD_Ivunpcklpd, UD_Ivunpcklps, UD_Ivxorpd, UD_Ivxorps, UD_Ivzeroall, UD_Ivzeroupper, UD_Iwait, UD_Iwbinvd, UD_Iwrmsr, UD_Ixadd, UD_Ixchg, UD_Ixcryptcbc, UD_Ixcryptcfb, UD_Ixcryptctr, UD_Ixcryptecb, UD_Ixcryptofb, UD_Ixgetbv, UD_Ixlatb, UD_Ixor, UD_Ixorpd, UD_Ixorps, UD_Ixrstor, UD_Ixsave, UD_Ixsetbv, UD_Ixsha1, UD_Ixsha256, UD_Ixstore, UD_Iinvalid, UD_I3dnow, UD_Inone, UD_Idb, UD_Ipause, UD_MAX_MNEMONIC_CODE }; extern const char * ud_mnemonics_str[]; #endif /* UD_ITAB_H */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/syn-att.c
C
/* udis86 - libudis86/syn-att.c * * Copyright (c) 2002-2009 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "types.h" #include "extern.h" #include "decode.h" #include "itab.h" #include "syn.h" #include "udint.h" /* ----------------------------------------------------------------------------- * opr_cast() - Prints an operand cast. * ----------------------------------------------------------------------------- */ static void opr_cast(struct ud* u, struct ud_operand* op) { switch(op->size) { case 16 : case 32 : ud_asmprintf(u, "*"); break; default: break; } } /* ----------------------------------------------------------------------------- * gen_operand() - Generates assembly output for each operand. * ----------------------------------------------------------------------------- */ static void gen_operand(struct ud* u, struct ud_operand* op) { switch(op->type) { case UD_OP_CONST: ud_asmprintf(u, "$0x%x", op->lval.udword); break; case UD_OP_REG: ud_asmprintf(u, "%%%s", ud_reg_tab[op->base - UD_R_AL]); break; case UD_OP_MEM: if (u->br_far) { opr_cast(u, op); } if (u->pfx_seg) { ud_asmprintf(u, "%%%s:", ud_reg_tab[u->pfx_seg - UD_R_AL]); } if (op->offset != 0) { ud_syn_print_mem_disp(u, op, 0); } if (op->base) { ud_asmprintf(u, "(%%%s", ud_reg_tab[op->base - UD_R_AL]); } if (op->index) { if (op->base) { ud_asmprintf(u, ","); } else { ud_asmprintf(u, "("); } ud_asmprintf(u, "%%%s", ud_reg_tab[op->index - UD_R_AL]); } if (op->scale) { ud_asmprintf(u, ",%d", op->scale); } if (op->base || op->index) { ud_asmprintf(u, ")"); } break; case UD_OP_IMM: ud_asmprintf(u, "$"); ud_syn_print_imm(u, op); break; case UD_OP_JIMM: ud_syn_print_addr(u, ud_syn_rel_target(u, op)); break; case UD_OP_PTR: switch (op->size) { case 32: ud_asmprintf(u, "$0x%x, $0x%x", op->lval.ptr.seg, op->lval.ptr.off & 0xFFFF); break; case 48: ud_asmprintf(u, "$0x%x, $0x%x", op->lval.ptr.seg, op->lval.ptr.off); break; } break; default: return; } } /* ============================================================================= * translates to AT&T syntax * ============================================================================= */ extern void ud_translate_att(struct ud *u) { int size = 0; int star = 0; /* check if P_OSO prefix is used */ if (! P_OSO(u->itab_entry->prefix) && u->pfx_opr) { switch (u->dis_mode) { case 16: ud_asmprintf(u, "o32 "); break; case 32: case 64: ud_asmprintf(u, "o16 "); break; } } /* check if P_ASO prefix was used */ if (! P_ASO(u->itab_entry->prefix) && u->pfx_adr) { switch (u->dis_mode) { case 16: ud_asmprintf(u, "a32 "); break; case 32: ud_asmprintf(u, "a16 "); break; case 64: ud_asmprintf(u, "a32 "); break; } } if (u->pfx_lock) ud_asmprintf(u, "lock "); if (u->pfx_rep) { ud_asmprintf(u, "rep "); } else if (u->pfx_repe) { ud_asmprintf(u, "repe "); } else if (u->pfx_repne) { ud_asmprintf(u, "repne "); } /* special instructions */ switch (u->mnemonic) { case UD_Iretf: ud_asmprintf(u, "lret "); break; case UD_Idb: ud_asmprintf(u, ".byte 0x%x", u->operand[0].lval.ubyte); return; case UD_Ijmp: case UD_Icall: if (u->br_far) ud_asmprintf(u, "l"); if (u->operand[0].type == UD_OP_REG) { star = 1; } ud_asmprintf(u, "%s", ud_lookup_mnemonic(u->mnemonic)); break; case UD_Ibound: case UD_Ienter: if (u->operand[0].type != UD_NONE) gen_operand(u, &u->operand[0]); if (u->operand[1].type != UD_NONE) { ud_asmprintf(u, ","); gen_operand(u, &u->operand[1]); } return; default: ud_asmprintf(u, "%s", ud_lookup_mnemonic(u->mnemonic)); } if (size == 8) { ud_asmprintf(u, "b"); } else if (size == 16) { ud_asmprintf(u, "w"); } else if (size == 64) { ud_asmprintf(u, "q"); } if (star) { ud_asmprintf(u, " *"); } else { ud_asmprintf(u, " "); } if (u->operand[3].type != UD_NONE) { gen_operand(u, &u->operand[3]); ud_asmprintf(u, ", "); } if (u->operand[2].type != UD_NONE) { gen_operand(u, &u->operand[2]); ud_asmprintf(u, ", "); } if (u->operand[1].type != UD_NONE) { gen_operand(u, &u->operand[1]); ud_asmprintf(u, ", "); } if (u->operand[0].type != UD_NONE) { gen_operand(u, &u->operand[0]); } } /* vim: set ts=2 sw=2 expandtab */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/syn-intel.c
C
/* udis86 - libudis86/syn-intel.c * * Copyright (c) 2002-2013 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "types.h" #include "extern.h" #include "decode.h" #include "itab.h" #include "syn.h" #include "udint.h" /* ----------------------------------------------------------------------------- * opr_cast() - Prints an operand cast. * ----------------------------------------------------------------------------- */ static void opr_cast(struct ud* u, struct ud_operand* op) { if (u->br_far) { ud_asmprintf(u, "far "); } switch(op->size) { case 8: ud_asmprintf(u, "byte " ); break; case 16: ud_asmprintf(u, "word " ); break; case 32: ud_asmprintf(u, "dword "); break; case 64: ud_asmprintf(u, "qword "); break; case 80: ud_asmprintf(u, "tword "); break; case 128: ud_asmprintf(u, "oword "); break; case 256: ud_asmprintf(u, "yword "); break; default: break; } } /* ----------------------------------------------------------------------------- * gen_operand() - Generates assembly output for each operand. * ----------------------------------------------------------------------------- */ static void gen_operand(struct ud* u, struct ud_operand* op, int syn_cast) { switch(op->type) { case UD_OP_REG: ud_asmprintf(u, "%s", ud_reg_tab[op->base - UD_R_AL]); break; case UD_OP_MEM: if (syn_cast) { opr_cast(u, op); } ud_asmprintf(u, "["); if (u->pfx_seg) { ud_asmprintf(u, "%s:", ud_reg_tab[u->pfx_seg - UD_R_AL]); } if (op->base) { ud_asmprintf(u, "%s", ud_reg_tab[op->base - UD_R_AL]); } if (op->index) { ud_asmprintf(u, "%s%s", op->base != UD_NONE? "+" : "", ud_reg_tab[op->index - UD_R_AL]); if (op->scale) { ud_asmprintf(u, "*%d", op->scale); } } if (op->offset != 0) { ud_syn_print_mem_disp(u, op, (op->base != UD_NONE || op->index != UD_NONE) ? 1 : 0); } ud_asmprintf(u, "]"); break; case UD_OP_IMM: ud_syn_print_imm(u, op); break; case UD_OP_JIMM: ud_syn_print_addr(u, ud_syn_rel_target(u, op)); break; case UD_OP_PTR: switch (op->size) { case 32: ud_asmprintf(u, "word 0x%x:0x%x", op->lval.ptr.seg, op->lval.ptr.off & 0xFFFF); break; case 48: ud_asmprintf(u, "dword 0x%x:0x%x", op->lval.ptr.seg, op->lval.ptr.off); break; } break; case UD_OP_CONST: if (syn_cast) opr_cast(u, op); ud_asmprintf(u, "%d", op->lval.udword); break; default: return; } } /* ============================================================================= * translates to intel syntax * ============================================================================= */ extern void ud_translate_intel(struct ud* u) { /* check if P_OSO prefix is used */ if (!P_OSO(u->itab_entry->prefix) && u->pfx_opr) { switch (u->dis_mode) { case 16: ud_asmprintf(u, "o32 "); break; case 32: case 64: ud_asmprintf(u, "o16 "); break; } } /* check if P_ASO prefix was used */ if (!P_ASO(u->itab_entry->prefix) && u->pfx_adr) { switch (u->dis_mode) { case 16: ud_asmprintf(u, "a32 "); break; case 32: ud_asmprintf(u, "a16 "); break; case 64: ud_asmprintf(u, "a32 "); break; } } if (u->pfx_seg && u->operand[0].type != UD_OP_MEM && u->operand[1].type != UD_OP_MEM ) { ud_asmprintf(u, "%s ", ud_reg_tab[u->pfx_seg - UD_R_AL]); } if (u->pfx_lock) { ud_asmprintf(u, "lock "); } if (u->pfx_rep) { ud_asmprintf(u, "rep "); } else if (u->pfx_repe) { ud_asmprintf(u, "repe "); } else if (u->pfx_repne) { ud_asmprintf(u, "repne "); } /* print the instruction mnemonic */ ud_asmprintf(u, "%s", ud_lookup_mnemonic(u->mnemonic)); if (u->operand[0].type != UD_NONE) { int cast = 0; ud_asmprintf(u, " "); if (u->operand[0].type == UD_OP_MEM) { if (u->operand[1].type == UD_OP_IMM || u->operand[1].type == UD_OP_CONST || u->operand[1].type == UD_NONE || (u->operand[0].size != u->operand[1].size)) { cast = 1; } else if (u->operand[1].type == UD_OP_REG && u->operand[1].base == UD_R_CL) { switch (u->mnemonic) { case UD_Ircl: case UD_Irol: case UD_Iror: case UD_Ircr: case UD_Ishl: case UD_Ishr: case UD_Isar: cast = 1; break; default: break; } } } gen_operand(u, &u->operand[0], cast); } if (u->operand[1].type != UD_NONE) { int cast = 0; ud_asmprintf(u, ", "); if (u->operand[1].type == UD_OP_MEM && u->operand[0].size != u->operand[1].size && !ud_opr_is_sreg(&u->operand[0])) { cast = 1; } gen_operand(u, &u->operand[1], cast); } if (u->operand[2].type != UD_NONE) { int cast = 0; ud_asmprintf(u, ", "); if (u->operand[2].type == UD_OP_MEM && u->operand[2].size != u->operand[1].size) { cast = 1; } gen_operand(u, &u->operand[2], cast); } if (u->operand[3].type != UD_NONE) { ud_asmprintf(u, ", "); gen_operand(u, &u->operand[3], 0); } } /* vim: set ts=2 sw=2 expandtab */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/syn.c
C
/* udis86 - libudis86/syn.c * * Copyright (c) 2002-2013 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "types.h" #include "decode.h" #include "syn.h" #include "udint.h" /* * Register Table - Order Matters (types.h)! * */ const char* ud_reg_tab[] = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh", "spl", "bpl", "sil", "dil", "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b", "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w", "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d", "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "es", "cs", "ss", "ds", "fs", "gs", "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", "cr8", "cr9", "cr10", "cr11", "cr12", "cr13", "cr14", "cr15", "dr0", "dr1", "dr2", "dr3", "dr4", "dr5", "dr6", "dr7", "dr8", "dr9", "dr10", "dr11", "dr12", "dr13", "dr14", "dr15", "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", "st0", "st1", "st2", "st3", "st4", "st5", "st6", "st7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15", "ymm0", "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", "ymm6", "ymm7", "ymm8", "ymm9", "ymm10", "ymm11", "ymm12", "ymm13", "ymm14", "ymm15", "rip" }; uint64_t ud_syn_rel_target(struct ud *u, struct ud_operand *opr) { const uint64_t trunc_mask = 0xffffffffffffffffull >> (64 - u->opr_mode); switch (opr->size) { case 8 : return (u->pc + opr->lval.sbyte) & trunc_mask; case 16: return (u->pc + opr->lval.sword) & trunc_mask; case 32: return (u->pc + opr->lval.sdword) & trunc_mask; default: UD_ASSERT(!"invalid relative offset size."); return 0ull; } } /* * asmprintf * Printf style function for printing translated assembly * output. Returns the number of characters written and * moves the buffer pointer forward. On an overflow, * returns a negative number and truncates the output. */ int ud_asmprintf(struct ud *u, const char *fmt, ...) { int ret; int avail; va_list ap; va_start(ap, fmt); avail = u->asm_buf_size - u->asm_buf_fill - 1 /* nullchar */; ret = vsnprintf((char*) u->asm_buf + u->asm_buf_fill, avail, fmt, ap); if (ret < 0 || ret > avail) { u->asm_buf_fill = u->asm_buf_size - 1; } else { u->asm_buf_fill += ret; } va_end(ap); return ret; } void ud_syn_print_addr(struct ud *u, uint64_t addr) { const char *name = NULL; if (u->sym_resolver) { int64_t offset = 0; name = u->sym_resolver(u, addr, &offset); if (name) { if (offset) { ud_asmprintf(u, "%s%+" FMT64 "d", name, offset); } else { ud_asmprintf(u, "%s", name); } return; } } ud_asmprintf(u, "0x%" FMT64 "x", addr); } void ud_syn_print_imm(struct ud* u, const struct ud_operand *op) { uint64_t v; if (op->_oprcode == OP_sI && op->size != u->opr_mode) { if (op->size == 8) { v = (int64_t)op->lval.sbyte; } else { UD_ASSERT(op->size == 32); v = (int64_t)op->lval.sdword; } if (u->opr_mode < 64) { v = v & ((1ull << u->opr_mode) - 1ull); } } else { switch (op->size) { case 8 : v = op->lval.ubyte; break; case 16: v = op->lval.uword; break; case 32: v = op->lval.udword; break; case 64: v = op->lval.uqword; break; default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */ } } ud_asmprintf(u, "0x%" FMT64 "x", v); } void ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *op, int sign) { UD_ASSERT(op->offset != 0); if (op->base == UD_NONE && op->index == UD_NONE) { uint64_t v; UD_ASSERT(op->scale == UD_NONE && op->offset != 8); /* unsigned mem-offset */ switch (op->offset) { case 16: v = op->lval.uword; break; case 32: v = op->lval.udword; break; case 64: v = op->lval.uqword; break; default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */ } ud_asmprintf(u, "0x%" FMT64 "x", v); } else { int64_t v; UD_ASSERT(op->offset != 64); switch (op->offset) { case 8 : v = op->lval.sbyte; break; case 16: v = op->lval.sword; break; case 32: v = op->lval.sdword; break; default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */ } if (v < 0) { ud_asmprintf(u, "-0x%" FMT64 "x", -v); } else if (v > 0) { ud_asmprintf(u, "%s0x%" FMT64 "x", sign? "+" : "", v); } } } /* vim: set ts=2 sw=2 expandtab */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/syn.h
C/C++ Header
/* udis86 - libudis86/syn.h * * Copyright (c) 2002-2009 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef UD_SYN_H #define UD_SYN_H #include "types.h" #ifndef __UD_STANDALONE__ # include <stdarg.h> #endif /* __UD_STANDALONE__ */ extern const char* ud_reg_tab[]; uint64_t ud_syn_rel_target(struct ud*, struct ud_operand*); #ifdef __GNUC__ int ud_asmprintf(struct ud *u, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); #else int ud_asmprintf(struct ud *u, const char *fmt, ...); #endif void ud_syn_print_addr(struct ud *u, uint64_t addr); void ud_syn_print_imm(struct ud* u, const struct ud_operand *op); void ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *, int sign); #endif /* UD_SYN_H */ /* vim: set ts=2 sw=2 expandtab */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/types.h
C/C++ Header
/* udis86 - libudis86/types.h * * Copyright (c) 2002-2013 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef UD_TYPES_H #define UD_TYPES_H #ifdef __KERNEL__ /* * -D__KERNEL__ is automatically passed on the command line when * building something as part of the Linux kernel. Assume standalone * mode. */ # include <linux/kernel.h> # include <linux/string.h> # ifndef __UD_STANDALONE__ # define __UD_STANDALONE__ 1 # endif #endif /* __KERNEL__ */ #if !defined(__UD_STANDALONE__) # include <stdint.h> # include <stdio.h> #endif /* gcc specific extensions */ #ifdef __GNUC__ # define UD_ATTR_PACKED __attribute__((packed)) #else # define UD_ATTR_PACKED #endif /* UD_ATTR_PACKED */ /* ----------------------------------------------------------------------------- * All possible "types" of objects in udis86. Order is Important! * ----------------------------------------------------------------------------- */ enum ud_type { UD_NONE, /* 8 bit GPRs */ UD_R_AL, UD_R_CL, UD_R_DL, UD_R_BL, UD_R_AH, UD_R_CH, UD_R_DH, UD_R_BH, UD_R_SPL, UD_R_BPL, UD_R_SIL, UD_R_DIL, UD_R_R8B, UD_R_R9B, UD_R_R10B, UD_R_R11B, UD_R_R12B, UD_R_R13B, UD_R_R14B, UD_R_R15B, /* 16 bit GPRs */ UD_R_AX, UD_R_CX, UD_R_DX, UD_R_BX, UD_R_SP, UD_R_BP, UD_R_SI, UD_R_DI, UD_R_R8W, UD_R_R9W, UD_R_R10W, UD_R_R11W, UD_R_R12W, UD_R_R13W, UD_R_R14W, UD_R_R15W, /* 32 bit GPRs */ UD_R_EAX, UD_R_ECX, UD_R_EDX, UD_R_EBX, UD_R_ESP, UD_R_EBP, UD_R_ESI, UD_R_EDI, UD_R_R8D, UD_R_R9D, UD_R_R10D, UD_R_R11D, UD_R_R12D, UD_R_R13D, UD_R_R14D, UD_R_R15D, /* 64 bit GPRs */ UD_R_RAX, UD_R_RCX, UD_R_RDX, UD_R_RBX, UD_R_RSP, UD_R_RBP, UD_R_RSI, UD_R_RDI, UD_R_R8, UD_R_R9, UD_R_R10, UD_R_R11, UD_R_R12, UD_R_R13, UD_R_R14, UD_R_R15, /* segment registers */ UD_R_ES, UD_R_CS, UD_R_SS, UD_R_DS, UD_R_FS, UD_R_GS, /* control registers*/ UD_R_CR0, UD_R_CR1, UD_R_CR2, UD_R_CR3, UD_R_CR4, UD_R_CR5, UD_R_CR6, UD_R_CR7, UD_R_CR8, UD_R_CR9, UD_R_CR10, UD_R_CR11, UD_R_CR12, UD_R_CR13, UD_R_CR14, UD_R_CR15, /* debug registers */ UD_R_DR0, UD_R_DR1, UD_R_DR2, UD_R_DR3, UD_R_DR4, UD_R_DR5, UD_R_DR6, UD_R_DR7, UD_R_DR8, UD_R_DR9, UD_R_DR10, UD_R_DR11, UD_R_DR12, UD_R_DR13, UD_R_DR14, UD_R_DR15, /* mmx registers */ UD_R_MM0, UD_R_MM1, UD_R_MM2, UD_R_MM3, UD_R_MM4, UD_R_MM5, UD_R_MM6, UD_R_MM7, /* x87 registers */ UD_R_ST0, UD_R_ST1, UD_R_ST2, UD_R_ST3, UD_R_ST4, UD_R_ST5, UD_R_ST6, UD_R_ST7, /* extended multimedia registers */ UD_R_XMM0, UD_R_XMM1, UD_R_XMM2, UD_R_XMM3, UD_R_XMM4, UD_R_XMM5, UD_R_XMM6, UD_R_XMM7, UD_R_XMM8, UD_R_XMM9, UD_R_XMM10, UD_R_XMM11, UD_R_XMM12, UD_R_XMM13, UD_R_XMM14, UD_R_XMM15, /* 256B multimedia registers */ UD_R_YMM0, UD_R_YMM1, UD_R_YMM2, UD_R_YMM3, UD_R_YMM4, UD_R_YMM5, UD_R_YMM6, UD_R_YMM7, UD_R_YMM8, UD_R_YMM9, UD_R_YMM10, UD_R_YMM11, UD_R_YMM12, UD_R_YMM13, UD_R_YMM14, UD_R_YMM15, UD_R_RIP, /* Operand Types */ UD_OP_REG, UD_OP_MEM, UD_OP_PTR, UD_OP_IMM, UD_OP_JIMM, UD_OP_CONST }; #include "itab.h" union ud_lval { int8_t sbyte; uint8_t ubyte; int16_t sword; uint16_t uword; int32_t sdword; uint32_t udword; int64_t sqword; uint64_t uqword; struct { uint16_t seg; uint32_t off; } ptr; }; /* ----------------------------------------------------------------------------- * struct ud_operand - Disassembled instruction Operand. * ----------------------------------------------------------------------------- */ struct ud_operand { enum ud_type type; uint16_t size; enum ud_type base; enum ud_type index; uint8_t scale; uint8_t offset; union ud_lval lval; /* * internal use only */ uint64_t _legacy; /* this will be removed in 1.8 */ uint8_t _oprcode; }; /* ----------------------------------------------------------------------------- * struct ud - The udis86 object. * ----------------------------------------------------------------------------- */ struct ud { /* * input buffering */ int (*inp_hook) (struct ud*); #ifndef __UD_STANDALONE__ FILE* inp_file; #endif const uint8_t* inp_buf; size_t inp_buf_size; size_t inp_buf_index; uint8_t inp_curr; size_t inp_ctr; uint8_t inp_sess[64]; int inp_end; int inp_peek; void (*translator)(struct ud*); uint64_t insn_offset; char insn_hexcode[64]; /* * Assembly output buffer */ char *asm_buf; size_t asm_buf_size; size_t asm_buf_fill; char asm_buf_int[128]; /* * Symbol resolver for use in the translation phase. */ const char* (*sym_resolver)(struct ud*, uint64_t addr, int64_t *offset); uint8_t dis_mode; uint64_t pc; uint8_t vendor; enum ud_mnemonic_code mnemonic; struct ud_operand operand[4]; uint8_t error; uint8_t _rex; uint8_t pfx_rex; uint8_t pfx_seg; uint8_t pfx_opr; uint8_t pfx_adr; uint8_t pfx_lock; uint8_t pfx_str; uint8_t pfx_rep; uint8_t pfx_repe; uint8_t pfx_repne; uint8_t opr_mode; uint8_t adr_mode; uint8_t br_far; uint8_t br_near; uint8_t have_modrm; uint8_t modrm; uint8_t modrm_offset; uint8_t vex_op; uint8_t vex_b1; uint8_t vex_b2; uint8_t primary_opcode; void * user_opaque_data; struct ud_itab_entry * itab_entry; struct ud_lookup_table_list_entry *le; }; /* ----------------------------------------------------------------------------- * Type-definitions * ----------------------------------------------------------------------------- */ typedef enum ud_type ud_type_t; typedef enum ud_mnemonic_code ud_mnemonic_code_t; typedef struct ud ud_t; typedef struct ud_operand ud_operand_t; #define UD_SYN_INTEL ud_translate_intel #define UD_SYN_ATT ud_translate_att #define UD_EOI (-1) #define UD_INP_CACHE_SZ 32 #define UD_VENDOR_AMD 0 #define UD_VENDOR_INTEL 1 #define UD_VENDOR_ANY 2 #endif /* vim: set ts=2 sw=2 expandtab */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/udint.h
C/C++ Header
/* udis86 - libudis86/udint.h -- definitions for internal use only * * Copyright (c) 2002-2009 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _UDINT_H_ #define _UDINT_H_ #include "types.h" #ifdef HAVE_CONFIG_H # include <config.h> #endif /* HAVE_CONFIG_H */ #if defined(UD_DEBUG) && HAVE_ASSERT_H # include <assert.h> # define UD_ASSERT(_x) assert(_x) #else # define UD_ASSERT(_x) #endif /* !HAVE_ASSERT_H */ #if defined(UD_DEBUG) #define UDERR(u, msg) \ do { \ (u)->error = 1; \ fprintf(stderr, "decode-error: %s:%d: %s", \ __FILE__, __LINE__, (msg)); \ } while (0) #else #define UDERR(u, m) \ do { \ (u)->error = 1; \ } while (0) #endif /* !LOGERR */ #define UD_RETURN_ON_ERROR(u) \ do { \ if ((u)->error != 0) { \ return (u)->error; \ } \ } while (0) #define UD_RETURN_WITH_ERROR(u, m) \ do { \ UDERR(u, m); \ return (u)->error; \ } while (0) #ifndef __UD_STANDALONE__ # define UD_NON_STANDALONE(x) x #else # define UD_NON_STANDALONE(x) #endif /* printf formatting int64 specifier */ #ifdef FMT64 # undef FMT64 #endif #if defined(_MSC_VER) || defined(__BORLANDC__) # define FMT64 "I64" #else # if defined(__APPLE__) # define FMT64 "ll" # elif defined(__amd64__) || defined(__x86_64__) # define FMT64 "l" # else # define FMT64 "ll" # endif /* !x64 */ #endif /* define an inline macro */ #if defined(_MSC_VER) || defined(__BORLANDC__) # define UD_INLINE __inline /* MS Visual Studio requires __inline instead of inline for C code */ #else # define UD_INLINE inline #endif #endif /* _UDINT_H_ */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/libudis86/udis86.c
C
/* udis86 - libudis86/udis86.c * * Copyright (c) 2002-2013 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "udint.h" #include "extern.h" #include "decode.h" #if !defined(__UD_STANDALONE__) # if HAVE_STRING_H # include <string.h> # endif #endif /* !__UD_STANDALONE__ */ static void ud_inp_init(struct ud *u); /* ============================================================================= * ud_init * Initializes ud_t object. * ============================================================================= */ extern void ud_init(struct ud* u) { memset((void*)u, 0, sizeof(struct ud)); ud_set_mode(u, 16); u->mnemonic = UD_Iinvalid; ud_set_pc(u, 0); #ifndef __UD_STANDALONE__ ud_set_input_file(u, stdin); #endif /* __UD_STANDALONE__ */ ud_set_asm_buffer(u, u->asm_buf_int, sizeof(u->asm_buf_int)); } /* ============================================================================= * ud_disassemble * Disassembles one instruction and returns the number of * bytes disassembled. A zero means end of disassembly. * ============================================================================= */ extern unsigned int ud_disassemble(struct ud* u) { int len; if (u->inp_end) { return 0; } if ((len = ud_decode(u)) > 0) { if (u->translator != NULL) { u->asm_buf[0] = '\0'; u->translator(u); } } return len; } /* ============================================================================= * ud_set_mode() - Set Disassemly Mode. * ============================================================================= */ extern void ud_set_mode(struct ud* u, uint8_t m) { switch(m) { case 16: case 32: case 64: u->dis_mode = m ; return; default: u->dis_mode = 16; return; } } /* ============================================================================= * ud_set_vendor() - Set vendor. * ============================================================================= */ extern void ud_set_vendor(struct ud* u, unsigned v) { switch(v) { case UD_VENDOR_INTEL: u->vendor = v; break; case UD_VENDOR_ANY: u->vendor = v; break; default: u->vendor = UD_VENDOR_AMD; } } /* ============================================================================= * ud_set_pc() - Sets code origin. * ============================================================================= */ extern void ud_set_pc(struct ud* u, uint64_t o) { u->pc = o; } /* ============================================================================= * ud_set_syntax() - Sets the output syntax. * ============================================================================= */ extern void ud_set_syntax(struct ud* u, void (*t)(struct ud*)) { u->translator = t; } /* ============================================================================= * ud_insn() - returns the disassembled instruction * ============================================================================= */ const char* ud_insn_asm(const struct ud* u) { return u->asm_buf; } /* ============================================================================= * ud_insn_offset() - Returns the offset. * ============================================================================= */ uint64_t ud_insn_off(const struct ud* u) { return u->insn_offset; } /* ============================================================================= * ud_insn_hex() - Returns hex form of disassembled instruction. * ============================================================================= */ const char* ud_insn_hex(struct ud* u) { u->insn_hexcode[0] = 0; if (!u->error) { unsigned int i; const unsigned char *src_ptr = ud_insn_ptr(u); char* src_hex; src_hex = (char*) u->insn_hexcode; /* for each byte used to decode instruction */ for (i = 0; i < ud_insn_len(u) && i < sizeof(u->insn_hexcode) / 2; ++i, ++src_ptr) { sprintf(src_hex, "%02x", *src_ptr & 0xFF); src_hex += 2; } } return u->insn_hexcode; } /* ============================================================================= * ud_insn_ptr * Returns a pointer to buffer containing the bytes that were * disassembled. * ============================================================================= */ extern const uint8_t* ud_insn_ptr(const struct ud* u) { return (u->inp_buf == NULL) ? u->inp_sess : u->inp_buf + (u->inp_buf_index - u->inp_ctr); } /* ============================================================================= * ud_insn_len * Returns the count of bytes disassembled. * ============================================================================= */ extern unsigned int ud_insn_len(const struct ud* u) { return u->inp_ctr; } /* ============================================================================= * ud_insn_get_opr * Return the operand struct representing the nth operand of * the currently disassembled instruction. Returns NULL if * there's no such operand. * ============================================================================= */ const struct ud_operand* ud_insn_opr(const struct ud *u, unsigned int n) { if (n > 3 || u->operand[n].type == UD_NONE) { return NULL; } else { return &u->operand[n]; } } /* ============================================================================= * ud_opr_is_sreg * Returns non-zero if the given operand is of a segment register type. * ============================================================================= */ int ud_opr_is_sreg(const struct ud_operand *opr) { return opr->type == UD_OP_REG && opr->base >= UD_R_ES && opr->base <= UD_R_GS; } /* ============================================================================= * ud_opr_is_sreg * Returns non-zero if the given operand is of a general purpose * register type. * ============================================================================= */ int ud_opr_is_gpr(const struct ud_operand *opr) { return opr->type == UD_OP_REG && opr->base >= UD_R_AL && opr->base <= UD_R_R15; } /* ============================================================================= * ud_set_user_opaque_data * ud_get_user_opaque_data * Get/set user opaqute data pointer * ============================================================================= */ void ud_set_user_opaque_data(struct ud * u, void* opaque) { u->user_opaque_data = opaque; } void* ud_get_user_opaque_data(const struct ud *u) { return u->user_opaque_data; } /* ============================================================================= * ud_set_asm_buffer * Allow the user to set an assembler output buffer. If `buf` is NULL, * we switch back to the internal buffer. * ============================================================================= */ void ud_set_asm_buffer(struct ud *u, char *buf, size_t size) { if (buf == NULL) { ud_set_asm_buffer(u, u->asm_buf_int, sizeof(u->asm_buf_int)); } else { u->asm_buf = buf; u->asm_buf_size = size; } } /* ============================================================================= * ud_set_sym_resolver * Set symbol resolver for relative targets used in the translation * phase. * * The resolver is a function that takes a uint64_t address and returns a * symbolic name for the that address. The function also takes a second * argument pointing to an integer that the client can optionally set to a * non-zero value for offsetted targets. (symbol+offset) The function may * also return NULL, in which case the translator only prints the target * address. * * The function pointer maybe NULL which resets symbol resolution. * ============================================================================= */ void ud_set_sym_resolver(struct ud *u, const char* (*resolver)(struct ud*, uint64_t addr, int64_t *offset)) { u->sym_resolver = resolver; } /* ============================================================================= * ud_insn_mnemonic * Return the current instruction mnemonic. * ============================================================================= */ enum ud_mnemonic_code ud_insn_mnemonic(const struct ud *u) { return u->mnemonic; } /* ============================================================================= * ud_lookup_mnemonic * Looks up mnemonic code in the mnemonic string table. * Returns NULL if the mnemonic code is invalid. * ============================================================================= */ const char* ud_lookup_mnemonic(enum ud_mnemonic_code c) { if (c < UD_MAX_MNEMONIC_CODE) { return ud_mnemonics_str[c]; } else { return NULL; } } /* * ud_inp_init * Initializes the input system. */ static void ud_inp_init(struct ud *u) { u->inp_hook = NULL; u->inp_buf = NULL; u->inp_buf_size = 0; u->inp_buf_index = 0; u->inp_curr = 0; u->inp_ctr = 0; u->inp_end = 0; u->inp_peek = UD_EOI; UD_NON_STANDALONE(u->inp_file = NULL); } /* ============================================================================= * ud_inp_set_hook * Sets input hook. * ============================================================================= */ void ud_set_input_hook(register struct ud* u, int (*hook)(struct ud*)) { ud_inp_init(u); u->inp_hook = hook; } /* ============================================================================= * ud_inp_set_buffer * Set buffer as input. * ============================================================================= */ void ud_set_input_buffer(register struct ud* u, const uint8_t* buf, size_t len) { ud_inp_init(u); u->inp_buf = buf; u->inp_buf_size = len; u->inp_buf_index = 0; } #ifndef __UD_STANDALONE__ /* ============================================================================= * ud_input_set_file * Set FILE as input. * ============================================================================= */ static int inp_file_hook(struct ud* u) { return fgetc(u->inp_file); } void ud_set_input_file(register struct ud* u, FILE* f) { ud_inp_init(u); u->inp_hook = inp_file_hook; u->inp_file = f; } #endif /* __UD_STANDALONE__ */ /* ============================================================================= * ud_input_skip * Skip n input bytes. * ============================================================================ */ void ud_input_skip(struct ud* u, size_t n) { if (u->inp_end) { return; } if (u->inp_buf == NULL) { while (n--) { int c = u->inp_hook(u); if (c == UD_EOI) { goto eoi; } } return; } else { if (n > u->inp_buf_size || u->inp_buf_index > u->inp_buf_size - n) { u->inp_buf_index = u->inp_buf_size; goto eoi; } u->inp_buf_index += n; return; } eoi: u->inp_end = 1; UDERR(u, "cannot skip, eoi received\b"); return; } /* ============================================================================= * ud_input_end * Returns non-zero on end-of-input. * ============================================================================= */ int ud_input_end(const struct ud *u) { return u->inp_end; } /* vim:set ts=2 sw=2 expandtab */
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/udcli/udcli.c
C
/* udis86 - udcli/udcli.c * * Copyright (c) 2002-2013 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #ifdef _MSC_VER #include "..\udis86.h" #define PACKAGE_STRING "udis86 pre-1.8" #else #include <udis86.h> #include <config.h> #endif #if defined(__APPLE__) # define FMT64 "ll" #elif defined(__amd64__) || defined(__x86_64__) # define FMT64 "l" # else # define FMT64 "ll" #endif #if defined(__DJGPP__) || defined(_WIN32) # include <io.h> # include <fcntl.h> #endif #ifdef __DJGPP__ # include <unistd.h> /* for isatty() */ # define _setmode setmode # define _fileno fileno # define _O_BINARY O_BINARY #endif /* help string */ static char help[] = { "Usage: %s [-option[s]] file\n" "Options:\n" " -16 : Set the disassembly mode to 16 bits. \n" " -32 : Set the disassembly mode to 32 bits. (default)\n" " -64 : Set the disassembly mode to 64 bits.\n" " -intel : Set the output to INTEL (NASM like) syntax. (default)\n" " -att : Set the output to AT&T (GAS like) syntax.\n" " -v <v> : Set vendor. <v> = {intel, amd}.\n" " -o <pc> : Set the value of program counter to <pc>. (default = 0)\n" " -s <n> : Set the number of bytes to skip before disassembly to <n>.\n" " -c <n> : Set the number of bytes to disassemble to <n>.\n" " -x : Set the input mode to whitespace separated 8-bit numbers in\n" " hexadecimal representation. Example: 0f 01 ae 00\n" " -noff : Do not display the offset of instructions.\n" " -nohex : Do not display the hexadecimal code of instructions.\n" " -h : Display this help message.\n" " --version: Show version.\n" "\n" "Udcli is a front-end to the Udis86 Disassembler Library.\n" "http://udis86.sourceforge.net/\n" }; FILE* fptr = NULL; uint64_t o_skip = 0; uint64_t o_count = 0; unsigned char o_do_count= 0; unsigned char o_do_off = 1; unsigned char o_do_hex = 1; unsigned char o_do_x = 0; unsigned o_vendor = UD_VENDOR_AMD; int input_hook_x(ud_t* u); int input_hook_file(ud_t* u); int main(int argc, char **argv) { char *prog_path = *argv; char *s; ud_t ud_obj; /* initialize */ ud_init(&ud_obj); ud_set_mode(&ud_obj, 32); ud_set_syntax(&ud_obj, UD_SYN_INTEL); #ifdef __DJGPP__ if ( !isatty( fileno( stdin ) ) ) #endif #if defined(__DJGPP) || defined(_WIN32) _setmode(_fileno(stdin), _O_BINARY); #endif fptr = stdin; argv++; /* loop through the args */ while(--argc > 0) { if (strcmp(*argv, "-h") == 0) { printf(help, prog_path); exit(EXIT_SUCCESS); } else if (strcmp(*argv,"-16") == 0) { ud_set_mode(&ud_obj, 16); } else if (strcmp(*argv,"-32") == 0) { ud_set_mode(&ud_obj, 32); } else if (strcmp(*argv,"-64") == 0) { ud_set_mode(&ud_obj, 64); } else if (strcmp(*argv,"-intel") == 0) ud_set_syntax(&ud_obj, UD_SYN_INTEL); else if (strcmp(*argv,"-att") == 0) ud_set_syntax(&ud_obj, UD_SYN_ATT); else if (strcmp(*argv,"-noff") == 0) o_do_off = 0; else if (strcmp(*argv,"-nohex") == 0) o_do_hex = 0; else if (strcmp(*argv,"-x") == 0) o_do_x = 1; else if (strcmp(*argv,"-s") == 0) if (--argc) { s = *(++argv); if (sscanf(s, "%" FMT64 "u", &o_skip) == 0) fprintf(stderr, "Invalid value given for -s.\n"); } else { fprintf(stderr, "No value given for -s.\n"); printf(help, prog_path); exit(EXIT_FAILURE); } else if (strcmp(*argv,"-c") == 0) if (--argc) { o_do_count= 1; s = *(++argv); if (sscanf(s, "%" FMT64 "u", &o_count) == 0) fprintf(stderr, "Invalid value given for -c.\n"); } else { fprintf(stderr, "No value given for -c.\n"); printf(help, prog_path); exit(EXIT_FAILURE); } else if (strcmp(*argv,"-v") == 0) if (--argc) { s = *(++argv); if (*s == 'i') ud_set_vendor(&ud_obj, UD_VENDOR_INTEL); } else { fprintf(stderr, "No value given for -v.\n"); printf(help, prog_path); exit(EXIT_FAILURE); } else if (strcmp(*argv,"-o") == 0) { if (--argc) { uint64_t pc = 0; s = *(++argv); if (sscanf(s, "%" FMT64 "x", &pc) == 0) fprintf(stderr, "Invalid value given for -o.\n"); ud_set_pc(&ud_obj, pc); } else { fprintf(stderr, "No value given for -o.\n"); printf(help, prog_path); exit(EXIT_FAILURE); } } else if ( strcmp( *argv, "--version" ) == 0 ) { fprintf(stderr, "%s\n", PACKAGE_STRING ); exit(0); } else if((*argv)[0] == '-') { fprintf(stderr, "Invalid option %s.\n", *argv); printf(help, prog_path); exit(EXIT_FAILURE); } else { static int i = 0; s = *argv; if (i) { fprintf(stderr, "Multiple files specified.\n"); exit(EXIT_FAILURE); } else i = 1; if ((fptr = fopen(s, "rb")) == NULL) { fprintf(stderr, "Failed to open file: %s.\n", s); exit(EXIT_FAILURE); } } argv++; } if (o_do_x) ud_set_input_hook(&ud_obj, input_hook_x); else ud_set_input_hook(&ud_obj, input_hook_file); if (o_skip) { o_count += o_skip; ud_input_skip(&ud_obj, o_skip); } /* disassembly loop */ while (ud_disassemble(&ud_obj)) { if (o_do_off) printf("%016" FMT64 "x ", ud_insn_off(&ud_obj)); if (o_do_hex) { const char* hex1, *hex2; hex1 = ud_insn_hex(&ud_obj); hex2 = hex1 + 16; printf("%-16.16s %-24s", hex1, ud_insn_asm(&ud_obj)); if (strlen(hex1) > 16) { printf("\n"); if (o_do_off) printf("%15s -", ""); printf("%-16s", hex2); } } else printf(" %-24s", ud_insn_asm(&ud_obj)); printf("\n"); } exit(EXIT_SUCCESS); return 0; } int input_hook_x(ud_t* u) { unsigned int c, i; if (o_do_count) { if (! o_count) return UD_EOI; else --o_count; } i = fscanf(fptr, "%x", &c); if (i == EOF) return UD_EOI; if (i == 0) { fprintf(stderr, "Error: Invalid input, should be in hexadecimal form (8-bit).\n"); return UD_EOI; } if (c > 0xFF) fprintf(stderr, "Warning: Casting non-8-bit input (%x), to %x.\n", c, c & 0xFF); return (int) (c & 0xFF); } int input_hook_file(ud_t* u) { int c; if (o_do_count) { if (! o_count) { return -1; } else o_count -- ; } if ((c = fgetc(fptr)) == EOF) return UD_EOI; return c; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/utils/disassembly/udis86/udis86.h
C/C++ Header
/* udis86 - udis86.h * * Copyright (c) 2002-2009 Vivek Thampi * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef UDIS86_H #define UDIS86_H #include "libudis86/types.h" #include "libudis86/extern.h" #include "libudis86/itab.h" #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/win-wrapper/reg-wrapper.cpp
C++
#include <Windows.h> #include "reg-wrapper.h" #include <shlwapi.h> #include <algorithm> #pragma comment(lib, "shlwapi.lib") namespace UNONE { // RegKey ---------------------------------------------------------------------- RegistryKey::RegistryKey() : key_(NULL) , watch_event_(NULL) { } RegistryKey::RegistryKey(HKEY rootkey, const char* subkey, REGSAM access) : key_(NULL) , watch_event_(NULL) { if (rootkey) { if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK)) Create(rootkey, subkey, access); else Open(rootkey, subkey, access); } } RegistryKey::~RegistryKey() { Close(); } LONG RegistryKey::Create( HKEY rootkey, const char* subkey, REGSAM access ) { DWORD disposition_value; return CreateWithDisposition(rootkey, subkey, &disposition_value, access); } LONG RegistryKey::CreateWithDisposition( HKEY rootkey, const char* subkey, DWORD* disposition, REGSAM access ) { Close(); LONG result = RegCreateKeyExA(rootkey, subkey, 0, NULL, REG_OPTION_NON_VOLATILE, access, NULL, &key_, disposition); return result; } LONG RegistryKey::CreateKey( const char* name, REGSAM access ) { HKEY subkey = NULL; LONG result = RegCreateKeyExA(key_, name, 0, NULL, REG_OPTION_NON_VOLATILE, access, NULL, &subkey, NULL); Close(); key_ = subkey; return result; } LONG RegistryKey::Open( HKEY rootkey, const char* subkey, REGSAM access ) { Close(); LONG result = RegOpenKeyExA(rootkey, subkey, 0, access, &key_); return result; } LONG RegistryKey::OpenKey( const char* relative_key_name, REGSAM access ) { HKEY subkey = NULL; LONG result = RegOpenKeyExA(key_, relative_key_name, 0, access, &subkey); // We have to close the current opened key before replacing it with the new // one. Close(); key_ = subkey; return result; } void RegistryKey::Close() { StopWatching(); if (key_) { ::RegCloseKey(key_); key_ = NULL; } } bool RegistryKey::HasValue( const char* value_name ) const { return RegQueryValueExA(key_, value_name, 0, NULL, NULL, NULL) == ERROR_SUCCESS; } DWORD RegistryKey::GetValueCount() const { DWORD count = 0; LONG result = RegQueryInfoKeyA(key_, NULL, 0, NULL, NULL, NULL, NULL, &count, NULL, NULL, NULL, NULL); return (result == ERROR_SUCCESS) ? count : 0; } LONG RegistryKey::GetValueNameAt( int index, std::string& name ) const { char buf[256]; DWORD bufsize = sizeof(buf) / sizeof(buf[0]); LONG r = ::RegEnumValueA(key_, index, buf, &bufsize, NULL, NULL, NULL, NULL); if (r == ERROR_SUCCESS) name = buf; return r; } LONG RegistryKey::DeleteKey( const char* name ) { LONG result = SHDeleteKeyA(key_, name); return result; } LONG RegistryKey::DeleteKey(HKEY rootkey, const char* subkey, REGSAM access /* = 0 */) { LONG result = ERROR_SUCCESS; access &= (KEY_WOW64_32KEY | KEY_WOW64_64KEY); access |= DELETE; std::string subkey_str = subkey; std::string parent_key; std::string key_name; do { RegistryKey reg; if (subkey == NULL) { result = ERROR_INVALID_PARAMETER; break; } // delete subkeys result = reg.Open(rootkey, subkey, access); if (result != ERROR_SUCCESS) break; result = reg.DeleteKey(NULL); if (result != ERROR_SUCCESS) break; reg.Close(); if (subkey_str.find("\\") == std::string::npos) { result = RegDeleteKeyA(rootkey, subkey); } else { key_name = subkey_str.substr(subkey_str.rfind("\\")+1); parent_key = subkey_str.substr(0, subkey_str.rfind("\\")); result = reg.Open(rootkey, parent_key.c_str(), access); if (result != ERROR_SUCCESS) break; result = RegDeleteKeyA(reg.Handle(), key_name.c_str()); reg.Close(); } } while (0); return result; } LONG RegistryKey::DeleteValue( const char* name ) { LONG result = RegDeleteValueA(key_, name); return result; } LONG RegistryKey::ReadValueDW( const char* name, DWORD* out_value ) const { DWORD type = REG_DWORD; DWORD size = sizeof(DWORD); DWORD local_value = 0; LONG result = ReadValue(name, &local_value, &size, &type); if (result == ERROR_SUCCESS) { if ((type == REG_DWORD || type == REG_BINARY) && size == sizeof(DWORD)) *out_value = local_value; else result = ERROR_CANTREAD; } return result; } LONG RegistryKey::ReadInt64( const char* name, __int64* out_value ) const { DWORD type = REG_QWORD; __int64 local_value = 0; DWORD size = sizeof(local_value); LONG result = ReadValue(name, &local_value, &size, &type); if (result == ERROR_SUCCESS) { if ((type == REG_QWORD || type == REG_BINARY) && size == sizeof(local_value)) *out_value = local_value; else result = ERROR_CANTREAD; } return result; } LONG RegistryKey::ReadValue(const char* name, std::basic_string<char>& out_value) const { const size_t kMaxStringLength = 1024; // This is after expansion. // Use the one of the other forms of ReadValue if 1024 is too small for you. char raw_value[kMaxStringLength]; DWORD type = REG_SZ, size = sizeof(raw_value); LONG result = ReadValue(name, raw_value, &size, &type); if (result == ERROR_SUCCESS) { if (type == REG_SZ) { out_value = raw_value; } else if (type == REG_EXPAND_SZ) { char expanded[kMaxStringLength]; size = ExpandEnvironmentStringsA(raw_value, expanded, kMaxStringLength); // Success: returns the number of char's copied // Fail: buffer too small, returns the size required // Fail: other, returns 0 if (size == 0 || size > kMaxStringLength) { result = ERROR_MORE_DATA; } else { out_value = expanded; } } else { // Not a string. Oops. result = ERROR_CANTREAD; } } return result; } LONG RegistryKey::ReadValue(const char* name, void* data, DWORD* dsize, DWORD* dtype) const { LONG result = RegQueryValueExA(key_, name, 0, dtype, reinterpret_cast<LPBYTE>(data), dsize); return result; } LONG RegistryKey::ReadValues( const char* name, std::vector<std::basic_string<char>>& values ) { values.clear(); DWORD type = REG_MULTI_SZ; DWORD size = 0; LONG result = ReadValue(name, NULL, &size, &type); if (FAILED(result) || size == 0) return result; if (type != REG_MULTI_SZ) return ERROR_CANTREAD; std::vector<char> buffer(size / sizeof(char)); result = ReadValue(name, &buffer[0], &size, NULL); if (FAILED(result) || size == 0) return result; // Parse the double-null-terminated list of strings. // Note: This code is paranoid to not read outside of |buf|, in the case where // it may not be properly terminated. const char* entry = &buffer[0]; const char* buffer_end = entry + (size / sizeof(char)); while (entry < buffer_end && entry[0] != '\0') { const char* entry_end = std::find(entry, buffer_end, '\0'); values.push_back(std::basic_string<char>(entry, entry_end)); entry = entry_end + 1; } return 0; } LONG RegistryKey::WriteValue(const char* name, DWORD in_value) { return WriteValue(name, &in_value, static_cast<DWORD>(sizeof(in_value)), REG_DWORD); } LONG RegistryKey::WriteValue(const char* name, const std::basic_string<char>& in_value) { return WriteValue(name, in_value.c_str(), static_cast<DWORD>(sizeof(char) * (in_value.size() + 1)), REG_SZ); } LONG RegistryKey::WriteValue(const char* name, const void* data, DWORD dsize, DWORD dtype) { LONG result = RegSetValueExA(key_, name, 0, dtype, reinterpret_cast<LPBYTE>(const_cast<void*>(data)), dsize); return result; } LONG RegistryKey::StartWatching() { if (!watch_event_) watch_event_ = CreateEventA(NULL, TRUE, FALSE, NULL); DWORD filter = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_ATTRIBUTES | REG_NOTIFY_CHANGE_LAST_SET | REG_NOTIFY_CHANGE_SECURITY; // Watch the registry key for a change of value. LONG result = RegNotifyChangeKeyValue(key_, TRUE, filter, watch_event_, TRUE); if (result != ERROR_SUCCESS) { CloseHandle(watch_event_); watch_event_ = 0; } return result; } bool RegistryKey::HasChanged() { if (watch_event_) { if (WaitForSingleObject(watch_event_, 0) == WAIT_OBJECT_0) { StartWatching(); return true; } } return false; } LONG RegistryKey::StopWatching() { LONG result = ERROR_INVALID_HANDLE; if (watch_event_) { CloseHandle(watch_event_); watch_event_ = 0; result = ERROR_SUCCESS; } return result; } // RegistryValueIterator ------------------------------------------------------ RegistryValueIterator::RegistryValueIterator(HKEY root_key, const char* folder_key) { LONG result = RegOpenKeyExA(root_key, folder_key, 0, KEY_READ, &key_); if (result != ERROR_SUCCESS) { key_ = NULL; } else { DWORD count = 0; result = ::RegQueryInfoKeyA(key_, NULL, 0, NULL, NULL, NULL, NULL, &count, NULL, NULL, NULL, NULL); if (result != ERROR_SUCCESS) { ::RegCloseKey(key_); key_ = NULL; } else { index_ = count - 1; } } Read(); } RegistryValueIterator::~RegistryValueIterator() { if (key_) ::RegCloseKey(key_); } DWORD RegistryValueIterator::ValueCount() const { DWORD count = 0; LONG result = ::RegQueryInfoKeyA(key_, NULL, 0, NULL, NULL, NULL, NULL, &count, NULL, NULL, NULL, NULL); if (result != ERROR_SUCCESS) return 0; return count; } bool RegistryValueIterator::Valid() const { return key_ != NULL && index_ >= 0; } void RegistryValueIterator::operator++() { --index_; Read(); } bool RegistryValueIterator::Read() { if (Valid()) { DWORD ncount = sizeof(name_) / sizeof(name_[0]); value_size_ = 0; LONG r = ::RegEnumValueA(key_, index_, name_, &ncount, NULL, &type_, (BYTE*)value_.c_str(), &value_size_); if (ERROR_MORE_DATA == r) { ncount = sizeof(name_) / sizeof(name_[0]); value_.resize(value_size_); r = ::RegEnumValueA(key_, index_, name_, &ncount, NULL, &type_, (BYTE*)value_.c_str(), &value_size_); if (ERROR_SUCCESS == r) { return true; } } } name_[0] = '\0'; value_.clear(); value_size_ = 0; return false; } // RegistryKeyIterator -------------------------------------------------------- RegistryKeyIterator::RegistryKeyIterator(HKEY root_key, const char* folder_key) { LONG result = RegOpenKeyExA(root_key, folder_key, 0, KEY_READ, &key_); if (result != ERROR_SUCCESS) { key_ = NULL; } else { DWORD count = 0; LONG result = ::RegQueryInfoKeyA(key_, NULL, 0, NULL, &count, NULL, NULL, NULL, NULL, NULL, NULL, NULL); if (result != ERROR_SUCCESS) { ::RegCloseKey(key_); key_ = NULL; } else { index_ = count - 1; } } Read(); } RegistryKeyIterator::~RegistryKeyIterator() { if (key_) ::RegCloseKey(key_); } DWORD RegistryKeyIterator::SubkeyCount() const { DWORD count = 0; LONG result = ::RegQueryInfoKeyA(key_, NULL, 0, NULL, &count, NULL, NULL, NULL, NULL, NULL, NULL, NULL); if (result != ERROR_SUCCESS) return 0; return count; } bool RegistryKeyIterator::Valid() const { return key_ != NULL && index_ >= 0; } void RegistryKeyIterator::operator++() { --index_; Read(); } bool RegistryKeyIterator::Read() { if (Valid()) { DWORD ncount = sizeof(name_) / sizeof(name_[0]); FILETIME written; LONG r = ::RegEnumKeyExA(key_, index_, name_, &ncount, NULL, NULL, NULL, &written); if (ERROR_SUCCESS == r) return true; } name_[0] = '\0'; return false; } } // namespace UNONE
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/win-wrapper/reg-wrapper.h
C/C++ Header
#ifndef _UNONE_REGISTRY_H_ #define _UNONE_REGISTRY_H_ #pragma once #include <windows.h> #include <string> #include <vector> namespace UNONE { // Utility class to read, write and manipulate the Windows Registry. // Registry vocabulary primer: a "key" is like a folder, in which there // are "values", which are <name, data> pairs, with an associated data type. // // Note: // ReadValue family of functions guarantee that the return arguments // are not touched in case of failure. class RegistryKey { public: RegistryKey(); RegistryKey(HKEY rootkey, const char* subkey, REGSAM access); ~RegistryKey(); LONG Create(HKEY rootkey, const char* subkey, REGSAM access); LONG CreateWithDisposition(HKEY rootkey, const char* subkey, DWORD* disposition, REGSAM access); // Creates a subkey or open it if it already exists. LONG CreateKey(const char* name, REGSAM access); // Opens an existing reg key. LONG Open(HKEY rootkey, const char* subkey, REGSAM access); // Opens an existing reg key, given the relative key name. LONG OpenKey(const char* relative_key_name, REGSAM access); // Closes this reg key. void Close(); // Returns false if this key does not have the specified value, of if an error // occurrs while attempting to access it. bool HasValue(const char* value_name) const; // Returns the number of values for this key, of 0 if the number cannot be // determined. DWORD GetValueCount() const; // Determine the nth value's name. LONG GetValueNameAt(int index, std::string& name) const; // True while the key is valid. bool Valid() const { return key_ != NULL; } // Kill a key and everything that live below it; please be careful when using // it. // delete subkeys only LONG DeleteKey(const char* name); // Kill a key and everything that live below it and itself // access is KEY_WOW64_32KEY or KEY_WOW64_64KEY // delete subkeys and self static LONG DeleteKey(HKEY rootkey, const char* subkey, REGSAM access = 0); // Deletes a single value within the key. LONG DeleteValue(const char* name); // Getters: // Returns an int32 value. If |name| is NULL or empty, returns the default // value, if any. LONG ReadValueDW(const char* name, DWORD* out_value) const; // Returns an int64 value. If |name| is NULL or empty, returns the default // value, if any. LONG ReadInt64(const char* name, __int64* out_value) const; // Returns a string value. If |name| is NULL or empty, returns the default // value, if any. LONG ReadValue(const char* name, std::string& out_value) const; // Reads a REG_MULTI_SZ registry field into a vector of strings. Clears // |values| initially and adds further strings to the list. Returns // ERROR_CANTREAD if type is not REG_MULTI_SZ. LONG ReadValues(const char* name, std::vector<std::string>& values); // Returns raw data. If |name| is NULL or empty, returns the default // value, if any. LONG ReadValue(const char* name, void* data, DWORD* dsize, DWORD* dtype) const; // Setters: // Sets an int32 value. LONG WriteValue(const char* name, DWORD in_value); // Sets a string value. LONG WriteValue(const char* name, const std::string& in_value) ; // Sets raw data, including type. LONG WriteValue(const char* name, const void* data, DWORD dsize, DWORD dtype); // Starts watching the key to see if any of its values have changed. // The key must have been opened with the KEY_NOTIFY access privilege. LONG StartWatching(); // If StartWatching hasn't been called, always returns false. // Otherwise, returns true if anything under the key has changed. // This can't be const because the |watch_event_| may be refreshed. bool HasChanged(); // Will automatically be called by destructor if not manually called // beforehand. Returns true if it was watching, false otherwise. LONG StopWatching(); inline bool IsWatching() const { return watch_event_ != 0; } HANDLE watch_event() const { return watch_event_; } HKEY Handle() const { return key_; } private: HKEY key_; // The registry key being iterated. HANDLE watch_event_; }; // Iterates the entries found in a particular folder on the registry. class RegistryValueIterator { public: RegistryValueIterator(HKEY root_key, const char* folder_key); ~RegistryValueIterator(); DWORD ValueCount() const; // True while the iterator is valid. bool Valid() const; // Advances to the next registry entry. void operator++(); const char* Name() const { return name_; } std::string Value() const { return value_; } DWORD ValueSize() const { return value_size_; } DWORD Type() const { return type_; } int Index() const { return index_; } private: // Read in the current values. bool Read(); // The registry key being iterated. HKEY key_; // Current index of the iteration. int index_; // Current values. char name_[MAX_PATH]; std::string value_; DWORD value_size_; DWORD type_; }; class RegistryKeyIterator { public: RegistryKeyIterator(HKEY root_key, const char* folder_key); ~RegistryKeyIterator(); DWORD SubkeyCount() const; // True while the iterator is valid. bool Valid() const; // Advances to the next entry in the folder. void operator++(); const char* Name() const { return name_; } int Index() const { return index_; } private: // Read in the current values. bool Read(); // The registry key being iterated. HKEY key_; // Current index of the iteration. int index_; char name_[MAX_PATH]; }; } // namespace UNONE #endif // BASE_WIN_REGISTRY_H_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/win-wrapper/win-wrapper.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "win-wrapper.h" #include "../common/common.h" #include <QString> #include <QtCore> #include <arkdrv-api/arkdrv-api.h> #include <shlwapi.h> #pragma comment(lib, "shlwapi.lib") std::wstring FormatFileTime(FILETIME *file_tm) { SYSTEMTIME systm; FileTimeToSystemTime(file_tm, &systm); UNONE::TmConvertZoneTime(systm, NULL); return UNONE::TmFormatSystemTimeW(systm, L"Y-M-D H:W:S"); } std::wstring CalcFileTime(FILETIME *file_tm) { SYSTEMTIME systm; FileTimeToSystemTime(file_tm, &systm); LARGE_INTEGER li; li.HighPart = file_tm->dwHighDateTime; li.LowPart = file_tm->dwLowDateTime; auto val = UNONE::TmFileTimeToMs(*file_tm); int hours = val / (3600 * 1000); int mins = (val % (3600 * 1000)) / (60 * 1000); int secs = (val % (60 * 1000)) / 1000; int mss = (val % (1000)); return UNONE::StrFormatW(L"%d:%02d:%02d.%03d", hours, mins, secs, mss); } bool RetrieveThreadTimes(DWORD tid, std::wstring& ct, std::wstring& kt, std::wstring& ut) { HANDLE thd = ArkDrvApi::Process::OpenThread(THREAD_QUERY_INFORMATION, FALSE, tid); if (!thd) { return false; } FILETIME create_tm; FILETIME exit_tm; FILETIME kern_tm; FILETIME user_tm; if (!GetThreadTimes(thd, &create_tm, &exit_tm, &kern_tm, &user_tm)) { CloseHandle(thd); return false; } CloseHandle(thd); ct = FormatFileTime(&create_tm); kt = CalcFileTime(&kern_tm); ut = CalcFileTime(&user_tm); return true; } std::wstring ProcessCreateTime(__in DWORD pid) { HANDLE Process = ArkDrvApi::Process::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); if (!Process) { return L""; } FILETIME create_tm; FILETIME exit_tm; FILETIME kern_tm; FILETIME user_tm; if (!GetProcessTimes(Process, &create_tm, &exit_tm, &kern_tm, &user_tm)) { CloseHandle(Process); return L""; } CloseHandle(Process); return FormatFileTime(&create_tm); } LONGLONG ProcessCreateTimeValue(__in DWORD pid) { HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); if (!phd) { return 0; } FILETIME create_tm; FILETIME exit_tm; FILETIME kern_tm; FILETIME user_tm; if (!GetProcessTimes(phd, &create_tm, &exit_tm, &kern_tm, &user_tm)) { CloseHandle(phd); return 0; } CloseHandle(phd); return UNONE::TmFileTimeToMs(create_tm); } #include <Dbghelp.h> #pragma comment(lib, "Dbghelp.lib") bool CreateDump(DWORD pid, const std::wstring& path, bool mini) { if (UNONE::PsIsX64(pid) && !UNONE::PsIsX64(GetCurrentProcessId())) { MsgBoxError("Can't dump 64-bit process."); return false; } MINIDUMP_TYPE dmp_type; if (mini) { dmp_type = (MINIDUMP_TYPE)(MiniDumpWithThreadInfo | MiniDumpWithFullMemoryInfo | MiniDumpWithProcessThreadData | MiniDumpWithHandleData | MiniDumpWithDataSegs); } else { dmp_type = (MINIDUMP_TYPE)(MiniDumpWithThreadInfo | MiniDumpWithFullMemoryInfo | MiniDumpWithTokenInformation | MiniDumpWithProcessThreadData | MiniDumpWithDataSegs | MiniDumpWithFullMemory | MiniDumpWithHandleData); } HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); if (!phd) { return false; } HANDLE fd = CreateFileW(path.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fd == INVALID_HANDLE_VALUE) { CloseHandle(phd); return false; } BOOL ret = MiniDumpWriteDump(phd, pid, fd, dmp_type, NULL, NULL, NULL); CloseHandle(fd); CloseHandle(phd); if (ret) { MsgBoxInfo(QObject::tr("Create dump ok.")); } else { MsgBoxError(QObject::tr("Create dump failed.")); } return ret == TRUE; } // Clipboard void ClipboardCopyData(const std::string &data) { OpenClipboard(NULL); EmptyClipboard(); HGLOBAL hd = GlobalAlloc(GMEM_MOVEABLE, data.size() + 1); LPWSTR buf = (LPWSTR)GlobalLock(hd); memcpy(buf, data.c_str(), data.size()); GlobalUnlock(hd); EmptyClipboard(); SetClipboardData(CF_TEXT, buf); CloseClipboard(); } BOOL CALLBACK RetrieveWndCallback(HWND wnd, LPARAM param) { DWORD pid; std::vector<HWND> &wnds = *(std::vector<HWND>*)param; wnds.push_back(wnd); return TRUE; } std::vector<HWND> GetSystemWnds() { std::vector<HWND> wnds; EnumChildWindows(GetDesktopWindow(), (WNDENUMPROC)RetrieveWndCallback, (LPARAM)&wnds); return wnds; } int64_t FileTimeToInt64(FILETIME tm) { int64_t high = (int64_t)tm.dwHighDateTime; return high << 32 | tm.dwLowDateTime; } double GetSystemUsageOfCPU() { static int64_t s_idle = 0, s_kernel = 0, s_user = 0; FILETIME tm1, tm2, tm3; GetSystemTimes(&tm1, &tm2, &tm3); auto idle = FileTimeToInt64(tm1) - s_idle; auto kernel = FileTimeToInt64(tm2) - s_kernel; auto user = FileTimeToInt64(tm3) - s_user; s_idle = FileTimeToInt64(tm1); s_kernel = FileTimeToInt64(tm2); s_user = FileTimeToInt64(tm3); return (double)(kernel + user - idle) * 100 / (kernel + user); } double GetSystemUsageOfMemory() { PERFORMANCE_INFORMATION perf = { 0 }; GetPerformanceInfo(&perf, sizeof(perf)); return (1.0 - (double)perf.PhysicalAvailable / perf.PhysicalTotal) * 100; } SIZE_T GetProcessPrivateWorkingSet(DWORD pid) { PROCESS_MEMORY_COUNTERS_EX mm_info; if (!UNONE::MmGetProcessMemoryInfo(pid, mm_info)) return 0; HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); if (!phd) { return 0; } PPSAPI_WORKING_SET_INFORMATION ws; DWORD size = sizeof(PSAPI_WORKING_SET_BLOCK) * 1024 * 1024 * 4; ws = (PPSAPI_WORKING_SET_INFORMATION)new char[size]; mm_info.WorkingSetSize; if (!QueryWorkingSet(phd, ws, size)) { ERR(L"QueryWorkingSet pid:%d, err:%d", pid, GetLastError()); return 0; } SIZE_T shared = 0; for (size_t i = 0; i < ws->NumberOfEntries; i++) { if (ws->WorkingSetInfo[i].Shared) shared += PAGE_SIZE; } delete[] ws; CloseHandle(phd); return shared; } void SetWindowOnTop(HWND wnd, bool ontop) { DWORD style = ::GetWindowLong(wnd, GWL_EXSTYLE); if (ontop) { style |= WS_EX_TOPMOST; ::SetWindowLong(wnd, GWL_EXSTYLE, style); ::SetWindowPos(wnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOSIZE | SWP_SHOWWINDOW); } else { style &= ~WS_EX_TOPMOST; ::SetWindowLong(wnd, GWL_EXSTYLE, style); ::SetWindowPos(wnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOSIZE | SWP_SHOWWINDOW); } } void WinShowProperties(const std::wstring &path) { SHELLEXECUTEINFOW shell; shell.hwnd = NULL; shell.lpVerb = L"properties"; shell.lpFile = path.c_str(); shell.lpDirectory = NULL; shell.lpParameters = NULL; shell.nShow = SW_SHOWNORMAL; shell.fMask = SEE_MASK_INVOKEIDLIST; shell.lpIDList = NULL; shell.cbSize = sizeof(SHELLEXECUTEINFOW); ShellExecuteExW(&shell); } bool GetCertOwner(const QString &path, QString &owner) { std::vector<UNONE::CertInfoW> infos; bool ret = UNONE::SeGetCertInfoW(path.toStdWString(), infos); if (ret) { owner = WStrToQ(infos[0].owner); } return ret; } struct OBJECTNAME_THREAD_DATA { HANDLE hd; HANDLE query_evt; HANDLE alloc_evt; HANDLE start_evt; WCHAR* ObjectName; }; #include <memory> static __NtQueryObject pNtQueryObjectPtr = NULL; DWORD WINAPI ObGetObjectNameThread(LPVOID params) { auto caller = (OBJECTNAME_THREAD_DATA*)params; HANDLE hd = caller->hd; HANDLE query_evt = caller->query_evt; HANDLE alloc_evt = caller->alloc_evt; HANDLE start_evt = caller->start_evt; WCHAR* &obj_name = caller->ObjectName; NTSTATUS status; ULONG bufsize; POBJECT_NAME_INFORMATION buf; SetEvent(start_evt); if (pNtQueryObjectPtr == NULL) { return false; } status = pNtQueryObjectPtr(hd, ObjectNameInformation, NULL, 0, &bufsize); if (status != STATUS_INFO_LENGTH_MISMATCH) { return false; } std::unique_ptr<CHAR> ptr(new(std::nothrow) CHAR[bufsize]); buf = (POBJECT_NAME_INFORMATION)ptr.get(); if (buf == nullptr) { } status = pNtQueryObjectPtr(hd, ObjectNameInformation, buf, bufsize, &bufsize); if (!NT_SUCCESS(status)) { return false; } auto& name_buf = buf->Name.Buffer; auto& name_size = buf->Name.Length; if (name_buf == NULL) { return false; } SetEvent(query_evt); WaitForSingleObject(alloc_evt, INFINITE); obj_name = (WCHAR*)malloc(name_size + 2); memset(obj_name, 0, name_size + 2); if (obj_name != NULL) { memcpy(obj_name, name_buf, name_size); } SetEvent(query_evt); return true; } bool ObGetObjectName(HANDLE hd, std::string& obj_name) { bool ret = false; OBJECTNAME_THREAD_DATA caller; caller.hd = hd; auto& query_evt = caller.query_evt = CreateEventA(NULL, FALSE, FALSE, NULL); if (query_evt == NULL) { return false; } auto& alloc_evt = caller.alloc_evt = CreateEventA(NULL, FALSE, FALSE, NULL); if (alloc_evt == NULL) { CloseHandle(query_evt); return false; } auto& start_evt = caller.start_evt = CreateEventA(NULL, FALSE, FALSE, NULL); if (start_evt == NULL) { CloseHandle(query_evt); CloseHandle(alloc_evt); return false; } auto& temp_name = caller.ObjectName = NULL; DWORD Tid; if (pNtQueryObjectPtr == NULL) { pNtQueryObjectPtr = (__NtQueryObject)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtQueryObject"); } HANDLE thd = CreateThread(NULL, 0, ObGetObjectNameThread, &caller, 0, &Tid); if (thd != NULL) { DWORD stat = WaitForSingleObject(start_evt, 5000); if (stat == WAIT_OBJECT_0) { stat = WaitForSingleObject(query_evt, 10); if (stat == WAIT_TIMEOUT) { TerminateThread(thd, ERROR_TIMEOUT); } else { SetEvent(alloc_evt); WaitForSingleObject(query_evt, INFINITE); if (temp_name != NULL) { obj_name = std::move(UNONE::StrToA(temp_name)); free(temp_name); ret = true; } } } CloseHandle(thd); } CloseHandle(start_evt); CloseHandle(query_evt); CloseHandle(alloc_evt); return ret; } bool ExtractResource(const QString &res, const QString &path) { QFile f(res); if (!f.open(QIODevice::ReadOnly)) { return false; } auto &&data = f.readAll().toStdString(); auto &&dst = path.toStdWString(); UNONE::FsCreateDirW(UNONE::FsPathToDirW(dst)); if (!UNONE::FsWriteFileDataW(dst, data)) { return false; } return true; } bool WriteFileDataW(__in const std::wstring& fpath, __in int64_t offset, __in const std::string& fdata) { bool result = false; bool read_only = false; DWORD saved_attr = GetFileAttributesW(fpath.c_str()); if (saved_attr != INVALID_FILE_ATTRIBUTES) { if (saved_attr & FILE_ATTRIBUTE_READONLY) { read_only = true; SetFileAttributesW(fpath.c_str(), saved_attr&(~FILE_ATTRIBUTE_READONLY)); } } HANDLE fd = CreateFileW(fpath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fd != INVALID_HANDLE_VALUE) { DWORD writelen; LARGE_INTEGER li; li.QuadPart = offset; SetFilePointer(fd, li.LowPart, &li.HighPart, FILE_BEGIN); if (WriteFile(fd, fdata.data(), (DWORD)fdata.size(), &writelen, NULL)) { if (fdata.size() == writelen) { result = true; } else { ERR(L"WriteFile %s err, expected-size:%d actual-size:%d", fpath.c_str(), fdata.size(), writelen); } } else { ERR(L"WriteFile %s err:%d", fpath.c_str(), GetLastError()); } CloseHandle(fd); } else { ERR(L"CreateFileW %s err:%d", fpath.c_str(), GetLastError()); } if (read_only) SetFileAttributesW(fpath.c_str(), saved_attr); return result; } bool ReadFileDataW(__in const std::wstring &fpath, __in int64_t offset, __in int64_t readsize, __out std::string &fdata) { bool result = false; DWORD fsize = 0; HANDLE fd = CreateFileW(fpath.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (fd == INVALID_HANDLE_VALUE) { ERR(L"CreateFileW %s err:%d", fpath.c_str(), GetLastError()); return false; } fsize = GetFileSize(fd, NULL); if (fsize == INVALID_FILE_SIZE) { ERR(L"GetFileSize %s err:%d", fpath.c_str(), GetLastError()); CloseHandle(fd); return false; } if ((offset+readsize) > fsize) { WARN(L"read offset out of bound"); readsize = fsize - offset; } LARGE_INTEGER li; li.QuadPart = offset; SetFilePointer(fd, li.LowPart, &li.HighPart, FILE_BEGIN); char* buff = new(std::nothrow) char[readsize]; if (buff == NULL) { ERR(L"alloc memory err"); CloseHandle(fd); return false; } DWORD readlen; if (ReadFile(fd, buff, readsize, &readlen, NULL)) { if (readlen == readsize) { try { fdata.assign(buff, readsize); result = true; } catch (std::exception& e) { fdata.clear(); ERR("c++ exception: %s", e.what()); } catch (...) { fdata.clear(); ERR("c++ exception: unknown"); } } else { ERR(L"ReadFile %s err, expected-size:%d actual-size:%d", fpath.c_str(), readsize, readlen); } } else { ERR(L"ReadFile %s err:%d", fpath.c_str(), GetLastError()); } delete[] buff; CloseHandle(fd); return result; } bool ReadStdout(const std::wstring& cmdline, std::wstring& output, DWORD& exitcode, DWORD timeout /*= INFINITE*/) { const int blksize = 512; SECURITY_ATTRIBUTES sa; sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = NULL; sa.nLength = sizeof(sa); HANDLE rstdin = NULL; HANDLE wstdout = NULL; BOOL ret = CreatePipe(&rstdin, &wstdout, &sa, 64 * 0x1000); if (!ret) { ERR("CreatePipe failed, err:%d", GetLastError()); return false; } STARTUPINFOW si = { 0 }; PROCESS_INFORMATION pi = { 0 }; GetStartupInfoW(&si); si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; si.wShowWindow = SW_HIDE; si.hStdOutput = wstdout; si.hStdError = wstdout; ret = CreateProcessW(NULL, (LPWSTR)cmdline.c_str(), NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi); CloseHandle(wstdout); if (!ret) { CloseHandle(rstdin); ERR(L"CreateProcessW %s failed, err:%d", cmdline.c_str(), GetLastError()); return false; } if (WaitForSingleObject(pi.hProcess, timeout) == WAIT_TIMEOUT) { TerminateProcess(pi.hProcess, 1); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); CloseHandle(rstdin); return false; } GetExitCodeProcess(pi.hProcess, &exitcode); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); bool result = false; char *buf = new(std::nothrow) char[blksize]; if (buf == nullptr) { CloseHandle(rstdin); return false; } while (1) { DWORD readlen = 0; if (ReadFile(rstdin, buf, blksize, &readlen, NULL)) { output.append(UNONE::StrToW(std::string(buf, readlen))); if (blksize > readlen) { result = true; break; } } else { if (GetLastError() == ERROR_BROKEN_PIPE) { result = true; break; } } } CloseHandle(rstdin); delete[] buf; return result; } DWORD PsGetPidByWindowW(wchar_t *cls, wchar_t *title) { DWORD pid = INVALID_PID; HWND wnd = FindWindowW(cls, title); if (wnd != NULL) { GetWindowThreadProcessId(wnd, &pid); } return pid; } DWORD OsGetExplorerPid() { return PsGetPidByWindowW(L"Progman", L"Program Manager"); } /*++ Description: load driver registry Arguments: file_path - driver file path srv_name - driver service name Return: bool --*/ bool ObLoadDriverRegistryW(__in const std::wstring &file_path, __in std::wstring srv_name) { HKEY subkey = NULL; do { std::wstring driver_path = UNONE::FsPathStandardW(L"\\??\\" + file_path); DWORD dispos; std::wstring key_name = L"SYSTEM\\CurrentControlSet\\services\\" + srv_name; LONG result = RegCreateKeyExW(HKEY_LOCAL_MACHINE, key_name.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &subkey, &dispos); if (result != ERROR_SUCCESS) { UNONE_ERROR(L"RegCreateKeyExW %s err:%d", key_name.c_str(), result); return false; } DWORD start = SERVICE_DEMAND_START; result = RegSetValueExW(subkey, L"Start", 0, REG_DWORD, (BYTE*)&start, sizeof(start)); if (result != ERROR_SUCCESS) { UNONE_ERROR(L"RegSetValueW err:%d", result); break; } DWORD type = SERVICE_KERNEL_DRIVER; result = RegSetValueExW(subkey, L"Type", 0, REG_DWORD, (BYTE*)&type, sizeof(type)); if (result != ERROR_SUCCESS) { UNONE_ERROR(L"RegSetValueW err:%d", result); break; } DWORD errctl = SERVICE_ERROR_NORMAL; result = RegSetValueExW(subkey, L"ErrorControl", 0, REG_DWORD, (BYTE*)&errctl, sizeof(errctl)); if (result != ERROR_SUCCESS) { UNONE_ERROR(L"RegSetValueW err:%d", result); break; } result = RegSetValueExW(subkey, L"ImagePath", 0, REG_EXPAND_SZ, (BYTE*)driver_path.c_str(), (DWORD)driver_path.size() * 2); if (result != ERROR_SUCCESS) { UNONE_ERROR(L"RegSetValueW err:%d", result); break; } } while (0); if (subkey) RegCloseKey(subkey); return true; } bool ObUnloadDriverRegistryW(__in const std::wstring &srv_name) { std::wstring key_name = L"SYSTEM\\CurrentControlSet\\services\\" + srv_name; SHDeleteKeyW(HKEY_LOCAL_MACHINE, key_name.c_str()); return true; } std::wstring ArkPsGetProcessPathW(__in DWORD pid = GetCurrentProcessId()) { bool activate = false; auto &&path = UNONE::PsGetProcessPathW(pid); if (path.empty()) { UNONE::InterCreateTlsValue(ArkDrvApi::Process::OpenProcessR0, UNONE::PROCESS_VID); path = UNONE::PsGetProcessPathW(pid); activate = true; } if (activate) UNONE::InterDeleteTlsValue(UNONE::PROCESS_VID); return path; } bool PsKillProcess(__in DWORD pid) { bool result = false; HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_TERMINATE, FALSE, pid); if (phd) { if (TerminateProcess(phd, 1)) result = true; CloseHandle(phd); } return result; } // temp function ULONG64 GetFreeLibraryAddress32(DWORD pid) { ULONG64 addr = 0; #ifdef _AMD64_ std::vector<UNONE::MODULE_BASE_INFOW> mods; UNONE::PsGetModulesInfoW(pid, mods); auto it = std::find_if(std::begin(mods), std::end(mods), [](UNONE::MODULE_BASE_INFOW &info) { return UNONE::StrCompareIW(info.BaseDllName, L"kernel32.dll"); }); if (it == std::end(mods)) { UNONE_ERROR("not found kernel32.dll"); return NULL; } ULONG64 base = it->DllBase; auto &&path = UNONE::OsSyswow64DirW() + L"\\kernel32.dll"; auto image = UNONE::PeMapImageByPathW(path); if (!image) { UNONE_ERROR("MapImage %s failed, err:%d", path.c_str(), GetLastError()); return NULL; } auto pFreeLibrary = UNONE::PeGetProcAddress(image, "FreeLibrary"); UNONE::PeUnmapImage(image); if (pFreeLibrary == NULL) { UNONE_ERROR("PsGetProcAddress err:%d", GetLastError()); return NULL; } addr = (ULONG64)pFreeLibrary - (ULONG64)image + base; #else addr = (ULONG64)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "FreeLibrary"); #endif return addr; } ULONG64 GetFreeLibraryAddress(DWORD pid) { ULONG64 addr = 0; if (UNONE::PsIsX64(pid)) { addr = (ULONG64)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "FreeLibrary"); } else { addr = GetFreeLibraryAddress32(pid); } return addr; } std::string OsWinVersionInfo() { //from https://github.com/BlackINT3/unone std::string winver; auto major = UNONE::OsMajorVer(); auto minor = UNONE::OsMinorVer(); auto release = UNONE::OsBuildNumber(); SYSTEM_INFO info; GetSystemInfo(&info); OSVERSIONINFOEX os; os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); GetVersionEx((OSVERSIONINFO *)&os); if (major == 10 && minor == 0) { if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) { if (release >= 22000) winver = "Windows 11"; else winver = "Windows 10"; } else { switch (release) { case 14393: winver = "Windows Server 2016"; break; case 17763: case 18363: case 19041: case 19042: winver = "Windows Server 2019"; break; case 20348: winver = "Windows Server 2022"; break; } } } else { switch (major) { case 4: switch (minor) { case 0: if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) winver = "Windows NT 4.0"; else if (os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) winver = "Windows 95"; break; case 10: winver = "Windows 98"; break; case 90: winver = "Windows ME"; break; } break; case 5: switch (major) { case 0: winver = "Windows 2000"; break; case 1: winver = "Windows XP"; break; case 2: if (os.wProductType == VER_NT_WORKSTATION && info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) winver = "Windows XP Professional x64 Edition"; else if (GetSystemMetrics(SM_SERVERR2) == 0) winver = "Windows Server 2003"; else if (GetSystemMetrics(SM_SERVERR2) != 0) winver = "Windows Server 2003 R2"; break; } break; case 6: switch (minor) { case 0: if (os.wProductType == VER_NT_WORKSTATION) winver = "Windows Vista"; else winver = "Windows Server 2008"; break; case 1: if (os.wProductType == VER_NT_WORKSTATION) winver = "Windows 7"; else winver = "Windows Server 2008 R2"; break; case 2: if (os.wProductType == VER_NT_WORKSTATION) winver = "Windows 8"; else winver = "Windows Server 2012"; break; case 3: if (os.wProductType == VER_NT_WORKSTATION) winver = "Windows 8.1"; else winver = "Windows Server 2012 R2"; } break; } } return winver; } std::string OsReleaseNumber() { /* //c++11 std::map<DWORD, DWORD> tables = { { 10240, 1507 }, { 10586, 1511} ,{ 14393, 1607 } ,{ 15063, 1703 } ,{ 16299, 1709 } ,{ 17134, 1803 } , { 17763, 1809 }, { 18362, 1903 } ,{ 18363, 1909 } ,{ 19041, 2004 }, { 19042, 20H2 } };*/ std::pair<DWORD, std::string> pairs[] = { std::make_pair(10240, "1507"), std::make_pair(10586, "1511"), std::make_pair(14393, "1607"), std::make_pair(15063, "1703"), std::make_pair(16299, "1709"), std::make_pair(17134, "1803"), std::make_pair(17763, "1809"), std::make_pair(18362, "1903"), std::make_pair(18363, "1909"), std::make_pair(19041, "2004"), std::make_pair(19042, "20H2"), std::make_pair(19043, "21H1"), std::make_pair(19044, "21H2"), std::make_pair(22000, "21H2"), }; std::map<DWORD, std::string> tables(pairs, pairs + _countof(pairs)); DWORD build = UNONE::OsBuildNumber(); auto it = tables.find(build); if (it != tables.end()) return it->second; return ""; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/common/win-wrapper/win-wrapper.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <vector> #include <map> #include <string> #include <array> #include <QString> #include "../common.h" #include "reg-wrapper.h" #define KB (1024) #define MB (1024*KB) #define GB (1024*MB) #define TB (1024*GB) bool RetrieveThreadTimes(DWORD tid, std::wstring& ct, std::wstring& kt, std::wstring& ut); std::wstring FormatFileTime(FILETIME *file_tm); std::wstring ProcessCreateTime(__in DWORD pid); LONGLONG ProcessCreateTimeValue(__in DWORD pid); bool CreateDump(DWORD pid, const std::wstring& path, bool mini); void ClipboardCopyData(const std::string &data); std::vector<HWND> GetSystemWnds(); int64_t FileTimeToInt64(FILETIME tm); double GetSystemUsageOfCPU(); double GetSystemUsageOfMemory(); SIZE_T GetProcessPrivateWorkingSet(DWORD pid); void SetWindowOnTop(HWND wnd, bool ontop); void WinShowProperties(const std::wstring &path); bool GetCertOwner(const QString &path, QString &owner); bool ObGetObjectName(HANDLE hd, std::string& obj_name); bool ExtractResource(const QString &res, const QString &path); bool WriteFileDataW(__in const std::wstring& fpath, __in int64_t offset, __in const std::string& fdata); bool ReadFileDataW(__in const std::wstring &fpath, __in int64_t offset, __in int64_t readsize, __out std::string &fdata); bool ReadStdout(const std::wstring& cmdline, std::wstring& output, DWORD& exitcode, DWORD timeout = INFINITE); DWORD PsGetPidByWindowW(wchar_t *cls, wchar_t *title); DWORD OsGetExplorerPid(); bool ObLoadDriverRegistryW(__in const std::wstring &file_path, __in std::wstring srv_name); bool ObUnloadDriverRegistryW(__in const std::wstring &srv_name); bool PsKillProcess(__in DWORD pid); ULONG64 GetFreeLibraryAddress(DWORD pid); std::string OsWinVersionInfo(); std::string OsReleaseNumber();
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/driver/driver.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "../../common/common.h" #include "../../../OpenArkDrv/arkdrv-api/arkdrv-api.h" #include <Windows.h> #include <tchar.h> #include "driver.h" #include "Wincrypt.h" #pragma comment(lib, "Crypt32.lib") struct { int s = 0; int name = s++; int base = s++; int path = s++; int number = s++; int desc = s++; int ver = s++; int corp = s++; } DRV; bool DriversSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); auto column = left.column(); if ((column == DRV.base || column == DRV.number)) return s1.toString().toULongLong(nullptr, 16) < s2.toString().toULongLong(nullptr, 16); return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } KernelDriver::KernelDriver() { } KernelDriver::~KernelDriver() { } void KernelDriver::onTabChanged(int index) { switch (index) { case TAB_KERNEL_DRIVER_LIST: ShowDrivers(); break; default: break; } CommonTabObject::onTabChanged(index); } bool KernelDriver::eventFilter(QObject *obj, QEvent *e) { if (e->type() == QEvent::ContextMenu) { QMenu *menu = nullptr; if (obj == ui_->driverView->viewport()) menu = drivers_menu_; QContextMenuEvent *ctxevt = dynamic_cast<QContextMenuEvent*>(e); if (ctxevt && menu) { menu->move(ctxevt->globalPos()); menu->show(); } } return QWidget::eventFilter(obj, e); } void KernelDriver::ModuleInit(Ui::Kernel *mainui, Kernel *kernel) { this->ui_ = mainui; this->kernel_ = kernel; Init(ui_->tabDriver, TAB_KERNEL, TAB_KERNEL_DRIVER); InitDriversView(); InitDriverKitView(); } void KernelDriver::InitDriversView() { QTreeView *view = ui_->driverView; drivers_model_ = new QStandardItemModel; proxy_drivers_ = new DriversSortFilterProxyModel(view); std::vector<std::pair<int, QString>> layout = { { 138, tr("Name") }, { 135, tr("Base") }, { 285, tr("Path") }, { 60, tr("Number") }, { 180, tr("Description") }, { 120, tr("Version") }, { 160, tr("Company") } }; SetDefaultTreeViewStyle(view, drivers_model_, proxy_drivers_, layout); view->viewport()->installEventFilter(this); view->installEventFilter(this); drivers_menu_ = new QMenu(); drivers_menu_->addAction(tr("Refresh"), this, [&] { ShowDrivers(); }); drivers_menu_->addAction(tr("Copy"), this, [&] { ClipboardCopyData(DriversItemData(GetCurViewColumn(ui_->driverView)).toStdString()); }); drivers_menu_->addAction(tr("Sendto Scanner"), this, [&] { kernel_->GetParent()->SetActiveTab(TAB_SCANNER); emit kernel_->signalOpen(DriversItemData(DRV.path)); }); drivers_menu_->addAction(tr("Explore File"), this, [&] { ExploreFile(DriversItemData(DRV.path)); }); drivers_menu_->addAction(tr("Properties..."), this, [&] { WinShowProperties(DriversItemData(DRV.path).toStdWString()); }); } void KernelDriver::InitDriverKitView() { ui_->groupWDF->setVisible(false); connect(ui_->browseBtn, &QPushButton::clicked, this, [&]() { QString file = QFileDialog::getOpenFileName(kernel_, tr("Open File"), "", tr("Driver Files (*.sys);;All Files (*.*)")); kernel_->onOpenFile(file); }); connect(ui_->installBtn, SIGNAL(clicked()), this, SLOT(onInstallNormallyDriver())); connect(ui_->uninstallBtn, SIGNAL(clicked()), this, SLOT(onUninstallDriver())); connect(ui_->writeRegBtn, &QPushButton::clicked, [&] { auto driver = QToWStr(ui_->driverFileEdit->text()); auto service = QToWStr(ui_->serviceEdit->text()); ObLoadDriverRegistryW(driver, service) ? LabelSuccess(ui_->infoLabel, tr("Write registry ok...")) : LabelError(ui_->infoLabel, tr("Write registry failed, open console window to view detail...")); }); connect(ui_->cleanRegBtn, &QPushButton::clicked, [&] { auto service = QToWStr(ui_->serviceEdit->text()); ObUnloadDriverRegistryW(service) ? LabelSuccess(ui_->infoLabel, tr("Clean registry ok...")) : LabelError(ui_->infoLabel, tr("Clean registry failed, open console window to view detail...")); }); } void KernelDriver::onSignDriver() { QString driver = ui_->driverFileEdit->text(); SignExpiredDriver(driver) ? LabelSuccess(ui_->infoLabel, tr("Sign ok...")) : LabelError(ui_->infoLabel, tr("Sign failed, open console window to view detail...")); } void KernelDriver::onInstallNormallyDriver() { InstallDriver(ui_->driverFileEdit->text(), ui_->serviceEdit->text()) ? LabelSuccess(ui_->infoLabel, tr("Install ok...")) : LabelError(ui_->infoLabel, tr("Install failed, open console window to view detail...")); } void KernelDriver::onInstallUnsignedDriver() { onSignDriver(); RECOVER_SIGN_TIME(); onInstallNormallyDriver(); } void KernelDriver::onInstallExpiredDriver() { RECOVER_SIGN_TIME(); onInstallNormallyDriver(); } void KernelDriver::onUninstallDriver() { UninstallDriver(ui_->serviceEdit->text()) ? LabelSuccess(ui_->infoLabel, tr("Uninstall ok...")) : LabelError(ui_->infoLabel, tr("Uninstall failed, open console window to view detail...")); } bool KernelDriver::InstallDriver(QString driver, QString name) { if (driver.isEmpty()) { QERR_W("driver path is empty"); return false; } auto &&path = driver.toStdWString(); return UNONE::ObLoadDriverW(path, name.toStdWString()); } bool KernelDriver::UninstallDriver(QString service) { if (service.isEmpty()) { QERR_W("service is empty"); return false; } return UNONE::ObUnloadDriverW(service.toStdWString()); } void KernelDriver::ShowDrivers() { DISABLE_RECOVER(); ClearItemModelData(drivers_model_, 0); std::vector<LPVOID> drivers; UNONE::ObGetDriverList(drivers); int number = 0; for (auto d : drivers) { static int major = UNONE::OsMajorVer(); auto &&w_path = UNONE::ObGetDriverPathW(d); if (major <= 5) { if (UNONE::StrIndexIW(w_path, L"\\Windows") == 0) { static auto &&drive = UNONE::OsEnvironmentW(L"%SystemDrive%"); w_path = drive + w_path; } else if (w_path.find(L'\\') == std::wstring::npos && w_path.find(L'/') == std::wstring::npos) { static auto &&driverdir = UNONE::OsSystem32DirW() + L"\\drivers\\"; w_path = driverdir + w_path; } } auto &&path = WStrToQ(w_path); auto &&name = WStrToQ(UNONE::ObGetDriverNameW(d)); bool microsoft = true; bool existed = true; auto info = CacheGetFileBaseInfo(path); if (info.desc.isEmpty()) { if (!UNONE::FsIsExistedW(info.path.toStdWString())) { info.desc = tr("[-] Driver file not existed!"); existed = false; } } if (!info.corp.contains("Microsoft", Qt::CaseInsensitive)) { microsoft = false; } auto name_item = new QStandardItem(name); auto base_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%p", d))); auto path_item = new QStandardItem(path); auto number_item = new QStandardItem(QString("%1").arg(number)); auto desc_item = new QStandardItem(info.desc); auto ver_item = new QStandardItem(info.ver); auto corp_item = new QStandardItem(info.corp); auto count = drivers_model_->rowCount(); drivers_model_->setItem(count, DRV.name, name_item); drivers_model_->setItem(count, DRV.base, base_item); drivers_model_->setItem(count, DRV.path, path_item); drivers_model_->setItem(count, DRV.number, number_item); drivers_model_->setItem(count, DRV.desc, desc_item); drivers_model_->setItem(count, DRV.ver, ver_item); drivers_model_->setItem(count, DRV.corp, corp_item); if (!existed) SetLineBgColor(drivers_model_, count, Qt::red); else if (!microsoft) SetLineBgColor(drivers_model_, count, QBrush(0xffffaa)); number++; } } QString KernelDriver::DriversItemData(int column) { return GetCurItemViewData(ui_->driverView, column); } bool ImportPrivateKey(const std::string &private_key, WCHAR *passwd, WCHAR *category) { bool ret = false; HCERTSTORE cert_store = NULL; HCERTSTORE cert_dst_store = NULL; PCCERT_CONTEXT cert = NULL; HCRYPTPROV crypt_prov = NULL; do { CRYPT_DATA_BLOB blob; blob.cbData = private_key.size(); blob.pbData = (unsigned char *)private_key.c_str(); cert_store = PFXImportCertStore(&blob, passwd, CRYPT_EXPORTABLE); if (!cert_store) { ERR("PFXImportCertStore err:%d", GetLastError()); break; } DWORD key_spec = 0; BOOL free_prov = FALSE; cert = CertEnumCertificatesInStore(cert_store, NULL); if (!cert) { ERR("CertEnumCertificatesInStore err:%d", GetLastError()); break; } if (!CryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_COMPARE_KEY_FLAG, NULL, &crypt_prov, &key_spec, &free_prov) || !crypt_prov) { ERR("CryptAcquireCertificatePrivateKey err:%d", GetLastError()); break; } cert_dst_store = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG, category); if (!cert_dst_store) { ERR("CertOpenStore err:%d", GetLastError()); break; } ret = CertAddCertificateContextToStore(cert_dst_store, cert, CERT_STORE_ADD_REPLACE_EXISTING, NULL); if (!ret) { ERR("CertAddCertificateContextToStore err:%d", GetLastError()); break; } ret = true; } while (0); if (cert) CertFreeCertificateContext(cert); if (crypt_prov) CryptReleaseContext(crypt_prov, 0); if (cert_dst_store) CertCloseStore(cert_dst_store, 0); if (cert_store) CertCloseStore(cert_store, 0); return ret; } bool SignExpiredDriver(QString driver) { if (driver.isEmpty()) { QERR_W("driver is empty"); return false; } QString res = ":/OpenArk/sign/CSignTool.pfx"; QFile pfx(res); if (!pfx.open(QFileDevice::ReadOnly)) { QERR_W("open resource file %s err", QToWChars(res)); return false; } if (!ImportPrivateKey(pfx.readAll().toStdString(), _T("TrustAsia.com"), _T("My"))) { QERR_W("import pfx certificate file %s err", QToWChars(res)); return false; } auto &&toodir = UNONE::OsEnvironmentW(L"%AppData%\\TrustAsia\\DSignTool"); auto &&signtool = toodir + L"\\CSignTool.exe"; auto &&signcfg = toodir + L"\\Config.xml"; ExtractResource(":/OpenArk/sign/CSignTool.exe", WStrToQ(signtool)); ExtractResource(":/OpenArk/sign/Config.xml", WStrToQ(signcfg)); RECOVER_SIGN_TIME(); std::wstring cmdline; std::wstring &&path = driver.toStdWString(); UNONE::StrFormatW(cmdline, L"%s sign /r Driver /f \"%s\" /ac", signtool.c_str(), path.c_str()); PROCESS_INFORMATION pi; if (!UNONE::PsCreateProcessW(cmdline, SW_HIDE, &pi)) { QERR_W("run cmdline:%s err", cmdline.c_str()); return false; } WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); return true; } std::wstring ParseDriverPath(UCHAR *symlnk) { std::wstring &&path = UNONE::StrToW((char*)symlnk); std::wstring sysroot = L"\\SystemRoot"; auto pos = path.find(sysroot); if (pos == 0) path.replace(0, sysroot.size(), UNONE::OsWinDirW()); UNONE::StrReplaceW(path, L"\\??\\"); return path; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/driver/driver.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include "../../common/cpp-wrapper/cpp-wrapper.h" #include <QString> #pragma once #include <windows.h> #include <vector> #include "ui_kernel.h" #include "../kernel.h" #include "../common/common.h" class Ui::Kernel; class Kernel; enum { TAB_KERNEL_DRIVER_LIST, TAB_KERNEL_DRIVER_KIT, }; PROXY_FILTER(DriversSortFilterProxyModel); class KernelDriver : public CommonTabObject { Q_OBJECT public: enum { Region, View, }; KernelDriver(); ~KernelDriver(); public: bool eventFilter(QObject *obj, QEvent *e); void ModuleInit(Ui::Kernel *mainui, Kernel *kernel); bool InstallDriver(QString driver, QString name); bool UninstallDriver(QString service); void ShowDrivers(); private slots: void onTabChanged(int index); void onSignDriver(); void onInstallNormallyDriver(); void onInstallUnsignedDriver(); void onInstallExpiredDriver(); void onUninstallDriver(); private: void InitDriversView(); void InitDriverKitView(); QString DriversItemData(int column); private: Ui::Kernel *ui_; Kernel *kernel_; QMenu *drivers_menu_; QStandardItemModel *drivers_model_; DriversSortFilterProxyModel *proxy_drivers_; }; bool SignExpiredDriver(QString driver); std::wstring ParseDriverPath(UCHAR *symlnk); #define RECOVER_SIGN_TIME() \ SYSTEMTIME saved = { 0 };\ GetLocalTime(&saved);\ FILETIME ft;\ SystemTimeToFileTime(&saved, &ft);\ auto ticks = GetTickCount();\ SYSTEMTIME cur = { 0 };\ cur.wYear = 2012;\ cur.wMonth = 1;\ cur.wDay = 1;\ SetLocalTime(&cur);\ ON_SCOPE_EXIT([&] { \ LARGE_INTEGER li;\ li.LowPart = ft.dwLowDateTime;\ li.HighPart = ft.dwHighDateTime;\ li.QuadPart += (GetTickCount() - ticks) * 10000; \ ft.dwHighDateTime = li.HighPart; \ ft.dwLowDateTime = li.LowPart; \ FileTimeToSystemTime(&ft, &saved); \ SetLocalTime(&saved); \ });
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/kernel.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "kernel.h" #include "driver/driver.h" #include "../common/common.h" #include "../common/utils/disassembly/disassembly.h" #include "../openark/openark.h" #include "wingui/wingui.h" #include "../../../OpenArkDrv/arkdrv-api/arkdrv-api.h" struct { int s = 0; int addr = s++; int type = s++; int path = s++; int desc = s++; int ver = s++; int corp = s++; } NOTIFY; bool NotifySortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { bool ok; auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); auto column = left.column(); if ((column == NOTIFY.addr)) return s1.toString().toULongLong(&ok, 16) < s2.toString().toULongLong(&ok, 16); return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } bool HotkeySortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } Kernel::Kernel(QWidget *parent, int tabid) : CommonMainTabObject::CommonMainTabObject((OpenArk*)parent) { ui.setupUi(this); setAcceptDrops(true); network_ = nullptr; storage_ = nullptr; memory_ = nullptr; driver_ = nullptr; object_ = nullptr; network_ = new KernelNetwork(); network_->ModuleInit(&ui, this); storage_ = new KernelStorage(); storage_->ModuleInit(&ui, this); object_ = new KernelObject(); object_->ModuleInit(&ui, this); memory_ = new KernelMemory(); memory_->ModuleInit(&ui, this); driver_ = new KernelDriver(); driver_->ModuleInit(&ui, this); InitKernelEntryView(); InitNotifyView(); InitHotkeyView(); CommonMainTabObject::Init(ui.tabWidget, tabid); connect(this, SIGNAL(signalOpen(QString)), parent_, SLOT(onOpen(QString))); } Kernel::~Kernel() { } bool Kernel::eventFilter(QObject *obj, QEvent *e) { bool filtered = false; if (e->type() == QEvent::ContextMenu) { QMenu *menu = nullptr; if (obj == ui.notifyView->viewport()) menu = notify_menu_; else if (obj == ui.hotkeyView->viewport()) menu = hotkey_menu_; QContextMenuEvent *ctxevt = dynamic_cast<QContextMenuEvent*>(e); if (ctxevt && menu) { menu->move(ctxevt->globalPos()); menu->show(); } } else if (e->type() == QEvent::MouseMove) { QMouseEvent *mouse = static_cast<QMouseEvent *>(e); if (obj == ui.hkFilterEdit) { if (ui.hkFilterEdit->text().isEmpty()) { QString tips(tr("Tips:If you not found the hotkeys,please check the shortcut keys of IME software.(eg:Microsoft/Sogou/Google IME, etc.)")); QToolTip::showText(mouse->globalPos(), tips); return true; } } } if (network_) network_->eventFilter(obj, e); if (driver_) driver_->eventFilter(obj, e); if (filtered) { dynamic_cast<QKeyEvent*>(e)->ignore(); return true; } return QWidget::eventFilter(obj, e); } void Kernel::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasFormat("text/uri-list")) event->acceptProposedAction(); } void Kernel::dropEvent(QDropEvent *event) { if (!event->mimeData()->hasUrls()) return; QString path = event->mimeData()->urls()[0].toLocalFile(); onOpenFile(path); } void Kernel::onClickKernelMode() { QString &&drvname = UNONE::OsIs64() ? "OpenArkDrv64.sys" : "OpenArkDrv32.sys"; QString &&srvname = WStrToQ(UNONE::FsPathToPureNameW(drvname.toStdWString())); if (!arkdrv_conn_) { QString drvpath; drvpath = WStrToQ(UNONE::OsEnvironmentW(QToWStr(L"%Temp%\\" + drvname))); DeleteFileW(QToWChars(drvpath)); ExtractResource(":/OpenArk/driver/" + drvname, drvpath); bool installed; if (UNONE::OsMajorVer() <= 6) { SignExpiredDriver(drvpath); RECOVER_SIGN_TIME(); installed = driver_->InstallDriver(drvpath, srvname); } else { installed = driver_->InstallDriver(drvpath, srvname); } if (!installed) { QERR_W("InstallDriver %s err", QToWChars(drvpath)); return; } if (!ArkDrvApi::ConnectDriver()) { ERR("ConnectDriver err"); return; } ui.kernelModeBtn->setText(tr("Exit KernelMode")); INFO("Enter KernelMode ok"); } else { if (!ArkDrvApi::DisconnectDriver()) { ERR("DisconnectDriver err"); return; } if (!driver_->UninstallDriver(srvname)) { QERR_W("UninstallDriver %s err", QToWChars(srvname)); return; } ui.kernelModeBtn->setText(tr("Enter KernelMode")); INFO("Exit KernelMode ok"); } onRefreshKernelMode(); } void Kernel::onRefreshKernelMode() { bool conn = ArkDrvApi::HeartBeatPulse(); if (conn && !arkdrv_conn_) { ui.kernelModeStatus->setText(tr("[KernelMode] Enter successfully...")); ui.kernelModeStatus->setStyleSheet("color:green"); ui.kernelModeBtn->setText(tr("Exit KernelMode")); arkdrv_conn_ = true; onTabChanged(ui.tabWidget->currentIndex()); } if (!conn && arkdrv_conn_) { ui.kernelModeStatus->setText(tr("[KernelMode] Exit successfully...")); ui.kernelModeStatus->setStyleSheet("color:red"); ui.kernelModeBtn->setText(tr("Enter KernelMode")); arkdrv_conn_ = false; } } void Kernel::onOpenFile(QString path) { if (!UNONE::FsIsFileW(path.toStdWString())) return; path = WStrToQ(UNONE::FsPathStandardW(path.toStdWString())); ui.driverFileEdit->setText(path); auto &&name = UNONE::FsPathToPureNameW(path.toStdWString()); ui.serviceEdit->setText(WStrToQ(name)); } void Kernel::onTabChanged(int index) { if (parent_->GetActiveTab() != TAB_KERNEL) return; switch (index) { case TAB_KERNEL_NOTIFY: ShowSystemNotify(); break; case TAB_KERNEL_HOTKEY: ShowSystemHotkey(); break; default: break; } CommonMainTabObject::onTabChanged(index); } void Kernel::InitKernelEntryView() { kerninfo_model_ = new QStandardItemModel; SetDefaultTableViewStyle(ui.kernelInfoView, kerninfo_model_); ui.kernelModeStatus->setText(tr("[KernelMode] Enter kernel mode needed before using the features(Hotkey/Notify/Memory...)")); ui.kernelModeStatus->setStyleSheet("color:red"); kerninfo_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Value")); ui.kernelInfoView->setColumnWidth(0, 120); int up_seq = 0; auto AddSummaryUpItem = [&](QString name, QString value) { kerninfo_model_->setItem(up_seq, 0, new QStandardItem(name)); kerninfo_model_->setItem(up_seq, 1, new QStandardItem(value)); up_seq++; }; SYSTEM_INFO sys; GetSystemInfo(&sys); sys.dwNumberOfProcessors; OSVERSIONINFOEXW info; info.dwOSVersionInfoSize = sizeof(info); GetVersionExW((LPOSVERSIONINFOW)&info); PERFORMANCE_INFORMATION perf = { 0 }; GetPerformanceInfo(&perf, sizeof(perf)); double gb = round((double)(perf.PhysicalTotal*perf.PageSize) / 1024 / 1024 / 1024); AddSummaryUpItem(tr("OperateSystem"), StrToQ(OsWinVersionInfo())); auto major = UNONE::OsMajorVer(); AddSummaryUpItem(tr("MajorVersion"), DWordToDecQ(major)); AddSummaryUpItem(tr("MiniorVersion"), DWordToDecQ(UNONE::OsMinorVer())); if (major >= 10) AddSummaryUpItem(tr("ReleaseNumber"), StrToQ(OsReleaseNumber())); AddSummaryUpItem(tr("BuildNumber"), DWordToDecQ(UNONE::OsBuildNumber())); AddSummaryUpItem(tr("MajorServicePack"), DWordToDecQ(info.wServicePackMajor)); AddSummaryUpItem(tr("MiniorServicePack"), DWordToDecQ(info.wServicePackMinor)); auto range = ArkDrvApi::Memory::MemoryRange(); AddSummaryUpItem(tr("R3 AddressRange"), StrToQ(UNONE::StrFormatA("0x%llX - 0x%llX", range.r3start, range.r3end))); AddSummaryUpItem(tr("R0 AddressRange"), StrToQ(UNONE::StrFormatA("0x%llX - 0x%llX", range.r0start, range.r0end))); AddSummaryUpItem(tr("Page Size"), StrToQ(UNONE::StrFormatA("%d KB", sys.dwPageSize / 1024))); AddSummaryUpItem(tr("Physical Memory"), StrToQ(UNONE::StrFormatA("%d GB", (int)gb))); AddSummaryUpItem(tr("CPU Count"), DWordToDecQ(sys.dwNumberOfProcessors)); AddSummaryUpItem(tr("SystemRoot"), WStrToQ(UNONE::OsWinDirW())); connect(ui.kernelModeBtn, SIGNAL(clicked()), this, SLOT(onClickKernelMode())); connect(ui.kernelInfoView, &QTableView::doubleClicked, [&](QModelIndex idx) { QString &txt = idx.data().toString(); if (txt == tr("ReleaseNumber") || txt == tr("BuildNumber")) { ShellOpenUrl("https://docs.microsoft.com/en-us/windows/release-health/release-information"); } }); arkdrv_conn_ = false; auto timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(onRefreshKernelMode())); timer->setInterval(1000); timer->start(); } void Kernel::InitNotifyView() { QTreeView *view = ui.notifyView; notify_model_ = new QStandardItemModel; proxy_notify_ = new NotifySortFilterProxyModel(view); std::vector<std::pair<int, QString>> layout = { { 150, tr("Callback Entry") }, { 100, tr("Type") }, { 360, tr("Path") }, { 230, tr("Description") }, { 120, tr("Version") }, { 160, tr("Company") } }; SetDefaultTreeViewStyle(view, notify_model_, proxy_notify_, layout); view->viewport()->installEventFilter(this); view->installEventFilter(this); notify_menu_ = new QMenu(); notify_menu_->addAction(tr("Refresh"), this, [&] { ShowSystemNotify(); }); notify_menu_->addSeparator(); notify_menu_->addAction(tr("Delete Notify"), this, [&] { ULONG64 addr; addr = QHexToQWord(NotifyItemData(NOTIFY.addr)); NOTIFY_TYPE type; auto &&qstr = NotifyItemData(NOTIFY.type); if (qstr == tr("CreateProcess")) type = CREATE_PROCESS; else if (qstr == tr("CreateThread")) type = CREATE_THREAD; else if (qstr == tr("LoadImage")) type = LOAD_IMAGE; else if (qstr == tr("CmpCallback")) type = CM_REGISTRY; ArkDrvApi::Notify::NotifyRemove(type, addr); ShowSystemNotify(); }); notify_menu_->addAction(tr("Disassemble Notify"), this, [&] { QString &&qstr = NotifyItemData(NOTIFY.addr); ULONG64 addr = QHexToQWord(qstr); ULONG size = 0x100; auto memrw = new KernelMemoryRW(); memrw->ViewMemory(GetCurrentProcessId(), addr, size); memrw->OpenNewWindow(qobject_cast<QWidget*>(this->parent()), addr, size); //SetActiveTab(QVector<int>({ KernelTabMemory, KernelMemory::View })); }); notify_menu_->addSeparator(); notify_menu_->addAction(tr("Copy"), this, [&] { ClipboardCopyData(NotifyItemData(GetCurViewColumn(ui.driverView)).toStdString()); }); notify_menu_->addAction(tr("Sendto Scanner"), this, [&] { parent_->SetActiveTab(TAB_SCANNER); emit signalOpen(NotifyItemData(NOTIFY.path)); }); notify_menu_->addAction(tr("Explore File"), this, [&] { ExploreFile(NotifyItemData(NOTIFY.path)); }); notify_menu_->addAction(tr("Properties..."), this, [&]() { WinShowProperties(NotifyItemData(NOTIFY.path).toStdWString()); }); } void Kernel::InitHotkeyView() { QTreeView *view = ui.hotkeyView; hotkey_model_ = new QStandardItemModel; proxy_hotkey_ = new HotkeySortFilterProxyModel(view); static std::vector<std::pair<int, QString>> layout = { { 150, tr("Name") }, { 100, tr("PID.TID") }, { 180, tr("Hotkey") }, { 150, tr("HotkeyObject") }, { 100, tr("HotkeyID") }, { 100, tr("HWND") }, { 180, tr("Title") }, { 180, tr("ClassName") }, { 300, tr("Path") }, { 160, tr("Description") } }; SetDefaultTreeViewStyle(view, hotkey_model_, proxy_hotkey_, layout); view->viewport()->installEventFilter(this); view->installEventFilter(this); ui.hkFilterEdit->installEventFilter(this); ui.hkFilterEdit->setMouseTracking(true); hotkey_menu_ = new QMenu(); hotkey_menu_->addAction(tr("Refresh"), this, [&] { ShowSystemHotkey(); }); hotkey_menu_->addSeparator(); hotkey_menu_->addAction(tr("Delete Hotkey"), this, [&] { ULONG32 vkid = QHexToDWord(HotkeyItemData(LAYOUT_INDEX("HotkeyID"))); auto arr = HotkeyItemData(LAYOUT_INDEX("PID.TID")).split("."); ULONG32 pid = QDecToDWord(arr[0]); ULONG32 tid = QDecToDWord(arr[1]); HOTKEY_ITEM item; item.id = vkid; item.pid = pid; item.tid = tid; if (!ArkDrvApi::WinGUI::HotkeyRemoveInfo(item)) { auto err = UNONE::StrFormatW(L"Remove Hotkey %d.%d id:%x err:%s", pid, tid, vkid, UNONE::OsDosErrorMsgW(GetLastError()).c_str()); MsgBoxError(WStrToQ(err)); return; } INFO(L"Remove Hotkey %d.%d id:%x ok", pid, tid, vkid); proxy_hotkey_->removeRows(ui.hotkeyView->currentIndex().row(), 1); }); hotkey_menu_->addSeparator(); hotkey_menu_->addAction(tr("Sendto Scanner"), this, [&] { parent_->SetActiveTab(TAB_SCANNER); emit signalOpen(HotkeyItemData(LAYOUT_INDEX("Path"))); }); hotkey_menu_->addAction(tr("Explore File"), this, [&] { ExploreFile(HotkeyItemData(LAYOUT_INDEX("Path"))); }); hotkey_menu_->addAction(tr("Properties..."), this, [&]() { WinShowProperties(HotkeyItemData(LAYOUT_INDEX("Path")).toStdWString()); }); connect(ui.hkFilterEdit, &QLineEdit::textChanged, [&](QString str) { ShowSystemHotkey(); }); } void Kernel::ShowSystemNotify() { DISABLE_RECOVER(); ClearItemModelData(notify_model_, 0); std::vector<DRIVER_ITEM> infos; ArkDrvApi::Driver::DriverEnumInfo(infos); auto OutputNotify = [&](std::vector<ULONG64> &routines, QString type) { for (auto routine : routines) { QString path; for (auto info : infos) { if (IN_RANGE(routine, info.base, info.size)) { path = WStrToQ(ParseDriverPath(info.path)); break; } } bool microsoft = true; bool existed = true; auto info = CacheGetFileBaseInfo(path); if (info.desc.isEmpty()) { if (!UNONE::FsIsExistedW(info.path.toStdWString())) { info.desc = tr("[-] Driver file not existed!"); existed = false; } } if (!info.corp.contains("Microsoft", Qt::CaseInsensitive)) { microsoft = false; } QStandardItem *addr_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%llX", routine))); QStandardItem *type_item = new QStandardItem(type); QStandardItem *path_item = new QStandardItem(path); QStandardItem *desc_item = new QStandardItem(info.desc); QStandardItem *ver_item = new QStandardItem(info.ver); QStandardItem *corp_item = new QStandardItem(info.corp); auto count = notify_model_->rowCount(); notify_model_->setItem(count, NOTIFY.addr, addr_item); notify_model_->setItem(count, NOTIFY.type, type_item); notify_model_->setItem(count, NOTIFY.path, path_item); notify_model_->setItem(count, NOTIFY.desc, desc_item); notify_model_->setItem(count, NOTIFY.ver, ver_item); notify_model_->setItem(count, NOTIFY.corp, corp_item); if (!existed) SetLineBgColor(notify_model_, count, Qt::red); else if (!microsoft) SetLineBgColor(notify_model_, count, QBrush(0xffffaa)); } }; std::vector<ULONG64> routines; if (!ArkDrvApi::Notify::NotifyEnumProcess(routines)) QERR_W("NotifyEnumProcess err"); OutputNotify(routines, tr("CreateProcess")); if (!ArkDrvApi::Notify::NotifyEnumThread(routines)) QERR_W("NotifyEnumThread err"); OutputNotify(routines, tr("CreateThread")); if (!ArkDrvApi::Notify::NotifyEnumImage(routines)) QERR_W("NotifyEnumImage err"); OutputNotify(routines, tr("LoadImage")); if (!ArkDrvApi::Notify::NotifyEnumRegistry(routines)) QERR_W("NotifyEnumRegistry err"); OutputNotify(routines, tr("CmpCallback")); } void Kernel::ShowSystemHotkey() { DISABLE_RECOVER(); ClearItemModelData(hotkey_model_, 0); auto flt = ui.hkFilterEdit->text(); std::vector<HOTKEY_ITEM> infos; ArkDrvApi::WinGUI::HotkeyEnumInfo(infos); for (auto item : infos) { auto pid = item.pid; ProcInfo cache; CacheGetProcInfo(pid, cache); auto &&path = QToWStr(cache.path); auto &&name = UNONE::FsPathToNameW(path); if (name.empty()) name = UNONE::StrToW((char*)item.name); auto info = CacheGetFileBaseInfo(WStrToQ(path)); auto name_str = WStrToQ(name); auto wnd_str = WStrToQ(UNONE::StrFormatW(L"0x%X", item.wnd)); auto title_str = WStrToQ(UNONE::PsGetWndTextW((HWND)item.wnd)); auto class_str = WStrToQ(UNONE::PsGetWndClassNameW((HWND)item.wnd)); auto hk_str = WStrToQ(UNONE::StrFormatW(L"0x%p", item.hkobj)); auto ptid_str = WStrToQ(UNONE::StrFormatW(L"%d.%d", item.pid, item.tid)); auto vk_str = StrToQ(HotkeyVkToString(item.vk, item.mod1, item.mod2)); auto vkid_str = WStrToQ(UNONE::StrFormatW(L"0x%X", item.id)); auto path_str = WStrToQ(path); auto desc_str = info.desc; if (!flt.isEmpty()) { if (!name_str.contains(flt, Qt::CaseInsensitive) && !wnd_str.contains(flt, Qt::CaseInsensitive) && !title_str.contains(flt, Qt::CaseInsensitive) && !class_str.contains(flt, Qt::CaseInsensitive) && !hk_str.contains(flt, Qt::CaseInsensitive) && !vk_str.contains(flt, Qt::CaseInsensitive) && !ptid_str.contains(flt, Qt::CaseInsensitive) && !path_str.contains(flt, Qt::CaseInsensitive) && !desc_str.contains(flt, Qt::CaseInsensitive) ) continue; } auto name_item = new QStandardItem(LoadIcon(WStrToQ(path)), name_str); auto wnd_item = new QStandardItem(wnd_str); auto title_item = new QStandardItem(title_str); auto class_item = new QStandardItem(class_str); auto hk_item = new QStandardItem(hk_str); auto ptid_item = new QStandardItem(ptid_str); auto vk_item = new QStandardItem(vk_str); auto vkid_item = new QStandardItem(vkid_str); auto path_item = new QStandardItem(path_str); auto desc_item = new QStandardItem(desc_str); auto count = hotkey_model_->rowCount(); int i = 0; hotkey_model_->setItem(count, i++, name_item); hotkey_model_->setItem(count, i++, ptid_item); hotkey_model_->setItem(count, i++, vk_item); hotkey_model_->setItem(count, i++, hk_item); hotkey_model_->setItem(count, i++, vkid_item); hotkey_model_->setItem(count, i++, wnd_item); hotkey_model_->setItem(count, i++, title_item); hotkey_model_->setItem(count, i++, class_item); hotkey_model_->setItem(count, i++, path_item); hotkey_model_->setItem(count, i++, desc_item); } } QString Kernel::NotifyItemData(int column) { return GetCurItemViewData(ui.notifyView, column); } QString Kernel::HotkeyItemData(int column) { return GetCurItemViewData(ui.hotkeyView, column); }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/kernel.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <QtCore> #include <QtWidgets> #include <Windows.h> #include "ui_kernel.h" #include "../common/qt-wrapper/qt-wrapper.h" #include "../common/ui-wrapper/ui-wrapper.h" #include "network/network.h" #include "storage/storage.h" #include "object/object.h" #include "memory/memory.h" #include "driver/driver.h" enum { TAB_KERNEL_ENTRY, TAB_KERNEL_DRIVER, TAB_KERNEL_NOTIFY, TAB_KERNEL_HOTKEY, TAB_KERNEL_OBJECT, TAB_KERNEL_MEMORY, TAB_KERNEL_STORAGE, TAB_KERNEL_NETWORK, TAB_KERNEL_MAX, }; class KernelNetwork; class KernelStorage; class KernelObject; class KernelMemory; class KernelDriver; class OpenArk; class Ui::Kernel; PROXY_FILTER(NotifySortFilterProxyModel); PROXY_FILTER(HotkeySortFilterProxyModel); class Kernel : public CommonMainTabObject { Q_OBJECT public: Kernel(QWidget *parent, int tabid); ~Kernel(); protected: bool eventFilter(QObject *obj, QEvent *e); void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); private slots: void onTabChanged(int index); void onClickKernelMode(); void onRefreshKernelMode(); public slots: void onOpenFile(QString path); signals: void signalOpen(QString); private: void InitKernelEntryView(); void InitNotifyView(); void InitHotkeyView(); void ShowSystemNotify(); void ShowSystemHotkey(); QString NotifyItemData(int column); QString HotkeyItemData(int column); private: bool arkdrv_conn_; KernelNetwork *network_; KernelStorage *storage_; KernelObject *object_; KernelMemory *memory_; KernelDriver *driver_; Ui::Kernel ui; QMenu *notify_menu_; QMenu *hotkey_menu_; QStandardItemModel *kerninfo_model_; QStandardItemModel *notify_model_; QStandardItemModel *hotkey_model_; NotifySortFilterProxyModel *proxy_notify_; HotkeySortFilterProxyModel *proxy_hotkey_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/memory/memory.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "memory.h" #include <common/common.h> #include <common/utils/disassembly/disassembly.h> #include <common/qt-wrapper/qt-wrapper.h> #include <openark/openark.h> #include <kernel/driver/driver.h> #include <arkdrv-api/arkdrv-api.h> #include <QtUiTools/QtUiTools> #define DEFINE_WIDGET(type, value) auto value = memui_->findChild<type>(#value) KernelMemory::KernelMemory() { } KernelMemory::~KernelMemory() { } void KernelMemory::onTabChanged(int index) { CommonTabObject::onTabChanged(index); } bool KernelMemory::eventFilter(QObject *obj, QEvent *e) { return QWidget::eventFilter(obj, e); } void KernelMemory::ModuleInit(Ui::Kernel *mainui, Kernel *kernel) { this->ui = mainui; Init(ui->tabMemory, TAB_KERNEL, TAB_KERNEL_MEMORY); auto memrw_ = new KernelMemoryRW(); auto memwidget = memrw_->GetWidget(); memwidget->setParent(ui->tabMemoryView); memwidget->layout()->removeWidget(memwidget); ui->verticalLayout_7->addWidget(memwidget); memwidget->show(); } KernelMemoryRW::KernelMemoryRW() { free_init_ = false; maxsize_ = -1; QUiLoader loader; QFile file(":/UI/ui/memory-rw.ui"); file.open(QFile::ReadOnly); memui_ = loader.load(&file); memui_->setAttribute(Qt::WA_DeleteOnClose); file.close(); setAttribute(Qt::WA_DeleteOnClose); connect(memui_, &QWidget::destroyed, this, &QWidget::close); memui_->installEventFilter(this); DEFINE_WIDGET(QPushButton*, readMemBtn); connect(readMemBtn, &QPushButton::clicked, this, [&] { DEFINE_WIDGET(QLineEdit*, pidEdit); DEFINE_WIDGET(QLineEdit*, readAddrEdit); DEFINE_WIDGET(QLineEdit*, readSizeEdit); ULONG64 addr = VariantInt64(readAddrEdit->text().toStdString()); ULONG size = VariantInt(readSizeEdit->text().toStdString()); ULONG pid = VariantInt(pidEdit->text().toStdString(), 10); if (size > PAGE_SIZE * 100) { QMessageBox::warning(this, tr("Warning"), tr("Read size too big, UI maybe no responsible."), QMessageBox::Ok); return; } ViewMemory(pid, addr, size); }); DEFINE_WIDGET(QPushButton*, dumpToFileBtn); connect(dumpToFileBtn, &QPushButton::clicked, this, [&] { DEFINE_WIDGET(QLineEdit*, pidEdit); DEFINE_WIDGET(QLineEdit*, readAddrEdit); DEFINE_WIDGET(QLineEdit*, readSizeEdit); DEFINE_WIDGET(QLabel*, statusLabel); ULONG64 addr = VariantInt64(readAddrEdit->text().toStdString()); ULONG size = VariantInt(readSizeEdit->text().toStdString()); ULONG pid = VariantInt(pidEdit->text().toStdString(), 10); std::string buf; if (!ArkDrvApi::Memory::MemoryRead(pid, addr, size, buf)) { LabelError(statusLabel, tr("Read Memory error, addr:0x%1 size:0x%2").arg(QString::number(addr, 16).toUpper()).arg(QString::number(size, 16).toUpper())); return; } QString filename = WStrToQ(UNONE::StrFormatW(L"%s_%llX_%X", QToWChars(CacheGetProcInfo(pid).name), addr, size)); QString dumpmem = QFileDialog::getSaveFileName(this, tr("Save to"), filename, tr("DumpMemory(*)")); if (!dumpmem.isEmpty()) { UNONE::FsWriteFileDataW(dumpmem.toStdWString(), buf) ? LabelSuccess(statusLabel, tr("Dump memory to file ok")): LabelError(statusLabel, tr("Dump memory to file error")); } }); DEFINE_WIDGET(QPushButton*, writeMemBtn); connect(writeMemBtn, &QPushButton::clicked, this, [&] { DEFINE_WIDGET(QLineEdit*, writeDataEdit); auto data = writeDataEdit->text().toStdString(); UNONE::StrReplaceA(data, " "); data = UNONE::StrHexStrToStreamA(data); WriteMemory(data); }); DEFINE_WIDGET(QPushButton*, writeStringBtn); connect(writeStringBtn, &QPushButton::clicked, this, [&] { DEFINE_WIDGET(QLineEdit*, writeDataEdit); auto data = writeDataEdit->text().toStdString(); WriteMemory(data); }); DEFINE_WIDGET(QLineEdit*, pidEdit); connect(pidEdit, &QLineEdit::textChanged, [&](const QString&) { DEFINE_WIDGET(QLineEdit*, pidEdit); DEFINE_WIDGET(QLabel*, pnameLabel); DEFINE_WIDGET(QLabel*, iconLabel); ULONG pid = VariantInt(pidEdit->text().toStdString(), 10); auto &&name = CacheGetProcInfo(pid).name; if (name.isEmpty()) return; pnameLabel->setText(name); auto pixmap = LoadIcon(CacheGetProcInfo(pid).path).pixmap(iconLabel->size()).scaled(iconLabel->size(), Qt::KeepAspectRatio); iconLabel->setScaledContents(true); iconLabel->setPixmap(pixmap); }); emit pidEdit->textChanged("4"); } KernelMemoryRW::~KernelMemoryRW() { if (free_init_) free_callback_(free_vars_); } bool KernelMemoryRW::eventFilter(QObject *obj, QEvent *e) { if (e->type() == QEvent::KeyPress) { QKeyEvent *keyevt = dynamic_cast<QKeyEvent*>(e); if (keyevt->matches(QKeySequence::Cancel)) { memui_->close(); } } return QWidget::eventFilter(obj, e); } void KernelMemoryRW::ViewMemory(ULONG pid, ULONG64 addr, ULONG size) { bool readok = false; char *mem = nullptr; ULONG memsize = 0; std::string buf; DEFINE_WIDGET(QLineEdit*, pidEdit); pidEdit->setText(QString::number(pid)); auto minsize = MIN(maxsize_, size); if (ArkDrvApi::Memory::MemoryRead(pid, addr, minsize, buf)) { mem = (char*)buf.c_str(); memsize = buf.size(); readok = true; } auto hexdump = HexDumpMemory(addr, mem, memsize); if (size > memsize) { auto hexdump2 = HexDumpMemory(addr+size, nullptr, size-memsize); hexdump.append(hexdump2); } bool isx64 = true; if (ArkDrvApi::Memory::IsKernelAddress(addr)) { isx64 = UNONE::OsIs64(); } else { EN_VID_PROCESS(); isx64 = UNONE::PsIsX64(pid); } auto disasm = DisasmMemory(addr, mem, minsize, isx64 ? 64 : 32); DEFINE_WIDGET(QTextEdit*, hexEdit); DEFINE_WIDGET(QTextEdit*, disasmEdit); DEFINE_WIDGET(QLabel*, regionLabel); DEFINE_WIDGET(QLabel*, statusLabel); hexEdit->setText(StrToQ(hexdump)); disasmEdit->setText(StrToQ(disasm)); std::vector<DRIVER_ITEM> infos; ArkDrvApi::Driver::DriverEnumInfo(infos); QString path; for (auto info : infos) { if (IN_RANGE(addr, info.base, info.size)) { path = WStrToQ(ParseDriverPath(info.path)); regionLabel->setText(path); break; } } readok ? LabelSuccess(statusLabel, tr("Read Memory successfully, addr:0x%1 size:0x%2").arg(QString::number(addr, 16).toUpper()).arg(QString::number(size, 16).toUpper())) : LabelError(statusLabel, tr("Read Memory error, addr:0x%1 size:0x%2").arg(QString::number(addr, 16).toUpper()).arg(QString::number(size, 16).toUpper())); } void KernelMemoryRW::ViewMemory(ULONG pid, std::string data) { return ViewMemory(pid, (ULONG64)data.c_str(), data.size()); } void KernelMemoryRW::WriteMemory(std::string data) { DEFINE_WIDGET(QLineEdit*, pidEdit); DEFINE_WIDGET(QLineEdit*, writeAddrEdit); DEFINE_WIDGET(QLabel*, statusLabel); ULONG64 addr = VariantInt64(writeAddrEdit->text().toStdString()); if (ArkDrvApi::Memory::IsKernelAddress(addr)) { if (QMessageBox::warning(this, tr("Warning"), tr("Write kernel memory maybe cause BSOD, are you sure to write?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { return; } } ULONG pid = VariantInt(pidEdit->text().toStdString(), 10); ArkDrvApi::Memory::MemoryWrite(pid, addr, data) ? LabelSuccess(statusLabel, tr("Write Memory successfully, addr:0x%1").arg(QString::number(addr, 16).toUpper())) : LabelError(statusLabel, tr("Write Memory error, addr:0x%1").arg(QString::number(addr, 16).toUpper())); }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/memory/memory.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <windows.h> #include <vector> #include "ui_kernel.h" #include "../kernel.h" #include "../common/common.h" class Ui::Kernel; class Kernel; class KernelMemoryRW; class KernelMemory : public CommonTabObject { Q_OBJECT public: enum { Region, View, }; KernelMemory(); ~KernelMemory(); public: bool eventFilter(QObject *obj, QEvent *e); void ModuleInit(Ui::Kernel *mainui, Kernel *kernel); private slots: void onTabChanged(int index); private: Ui::Kernel *ui; KernelMemoryRW *memrw_; }; class KernelMemoryRW : public QWidget { Q_OBJECT public: KernelMemoryRW(); ~KernelMemoryRW(); private: QWidget *memui_; bool free_init_; std::function<void(QList<QVariant>)> free_callback_; QList<QVariant> free_vars_; ULONG maxsize_; public: bool eventFilter(QObject *obj, QEvent *e); void RegFreeCallback(std::function<void(QList<QVariant>)> callback, QList<QVariant> vars) { free_callback_ = callback; free_vars_ = vars; free_init_ = true; }; void SetMaxSize(ULONG maxsize) { maxsize_ = maxsize; }; void ViewMemory(ULONG pid, ULONG64 addr, ULONG size); void ViewMemory(ULONG pid, std::string data); void WriteMemory(std::string data); void OpenNewWindow(QWidget *parent, ULONG64 addr, ULONG size) { auto memwidget = this->GetWidget(); memwidget->findChild<QLineEdit*>("readAddrEdit")->setText(QString("0x%1").arg(QString::number(addr,16).toUpper())); memwidget->findChild<QLineEdit*>("writeAddrEdit")->setText(QString("0x%1").arg(QString::number(addr, 16).toUpper())); memwidget->findChild<QLineEdit*>("readSizeEdit")->setText(QString("0x%1").arg(QString::number(size, 16).toUpper())); memwidget->setParent(parent); memwidget->setWindowTitle(tr("Memory Read-Write")); memwidget->setWindowFlags(Qt::Window); memwidget->resize(1000, 530); memwidget->show(); } QWidget *GetWidget() const { return memui_; }; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/network/include/fwpmtypes.h
C/C++ Header
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 7.00.0555 */ /* Compiler settings for fwpmtypes.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ /* @@MIDL_FILE_HEADING( ) */ #pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 500 #endif /* verify that the <rpcsal.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCSAL_H_VERSION__ #define __REQUIRED_RPCSAL_H_VERSION__ 100 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif // __RPCNDR_H_VERSION__ #ifndef __fwpmtypes_h__ #define __fwpmtypes_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ /* header files for imported files */ #include "fwptypes.h" #include "iketypes.h" #include "ipsectypes.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_fwpmtypes_0000_0000 */ /* [local] */ #if _MSC_VER >= 800 #if _MSC_VER >= 1200 #pragma warning(push) #endif #pragma warning(disable:4201) #endif #ifndef _DEFINE_DL_ADDRESS_TYPE_ #define _DEFINE_DL_ADDRESS_TYPE_ typedef /* [public][public][v1_enum] */ enum __MIDL___MIDL_itf_fwpmtypes_0000_0000_0001 { DlUnicast = 0, DlMulticast = ( DlUnicast + 1 ) , DlBroadcast = ( DlMulticast + 1 ) } DL_ADDRESS_TYPE; typedef /* [v1_enum] */ enum __MIDL___MIDL_itf_fwpmtypes_0000_0000_0001 *PDL_ADDRESS_TYPE; #endif typedef struct FWPM_DISPLAY_DATA0_ { wchar_t *name; wchar_t *description; } FWPM_DISPLAY_DATA0; typedef /* [v1_enum] */ enum FWPM_CHANGE_TYPE_ { FWPM_CHANGE_ADD = 1, FWPM_CHANGE_DELETE = ( FWPM_CHANGE_ADD + 1 ) , FWPM_CHANGE_TYPE_MAX = ( FWPM_CHANGE_DELETE + 1 ) } FWPM_CHANGE_TYPE; #define FWPM_SUBSCRIPTION_FLAG_NOTIFY_ON_ADD (0x00000001) #define FWPM_SUBSCRIPTION_FLAG_NOTIFY_ON_DELETE (0x00000002) typedef enum FWPM_SERVICE_STATE_ { FWPM_SERVICE_STOPPED = 0, FWPM_SERVICE_START_PENDING = ( FWPM_SERVICE_STOPPED + 1 ) , FWPM_SERVICE_STOP_PENDING = ( FWPM_SERVICE_START_PENDING + 1 ) , FWPM_SERVICE_RUNNING = ( FWPM_SERVICE_STOP_PENDING + 1 ) , FWPM_SERVICE_STATE_MAX = ( FWPM_SERVICE_RUNNING + 1 ) } FWPM_SERVICE_STATE; #define FWPM_NET_EVENT_KEYWORD_INBOUND_MCAST (0x00000001) #define FWPM_NET_EVENT_KEYWORD_INBOUND_BCAST (0x00000002) typedef enum FWPM_ENGINE_OPTION_ { FWPM_ENGINE_COLLECT_NET_EVENTS = 0, FWPM_ENGINE_NET_EVENT_MATCH_ANY_KEYWORDS = ( FWPM_ENGINE_COLLECT_NET_EVENTS + 1 ) , FWPM_ENGINE_NAME_CACHE = ( FWPM_ENGINE_NET_EVENT_MATCH_ANY_KEYWORDS + 1 ) , FWPM_ENGINE_OPTION_MAX = ( FWPM_ENGINE_NAME_CACHE + 1 ) } FWPM_ENGINE_OPTION; #define FWPM_SESSION_FLAG_DYNAMIC (0x00000001) #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPM_SESSION_FLAG_RESERVED (0x10000000) #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct FWPM_SESSION0_ { GUID sessionKey; FWPM_DISPLAY_DATA0 displayData; UINT32 flags; UINT32 txnWaitTimeoutInMSec; DWORD processId; SID *sid; wchar_t *username; BOOL kernelMode; } FWPM_SESSION0; typedef struct FWPM_SESSION_ENUM_TEMPLATE0_ { UINT64 reserved; } FWPM_SESSION_ENUM_TEMPLATE0; #define FWPM_PROVIDER_FLAG_PERSISTENT (0x00000001) #define FWPM_PROVIDER_FLAG_DISABLED (0x00000010) typedef struct FWPM_PROVIDER0_ { GUID providerKey; FWPM_DISPLAY_DATA0 displayData; UINT32 flags; FWP_BYTE_BLOB providerData; wchar_t *serviceName; } FWPM_PROVIDER0; typedef struct FWPM_PROVIDER_ENUM_TEMPLATE0_ { UINT64 reserved; } FWPM_PROVIDER_ENUM_TEMPLATE0; typedef struct FWPM_PROVIDER_CHANGE0_ { FWPM_CHANGE_TYPE changeType; GUID providerKey; } FWPM_PROVIDER_CHANGE0; typedef struct FWPM_PROVIDER_SUBSCRIPTION0_ { FWPM_PROVIDER_ENUM_TEMPLATE0 *enumTemplate; UINT32 flags; GUID sessionKey; } FWPM_PROVIDER_SUBSCRIPTION0; #define FWPM_PROVIDER_CONTEXT_FLAG_PERSISTENT (0x00000001) typedef struct FWPM_CLASSIFY_OPTION0_ { FWP_CLASSIFY_OPTION_TYPE type; FWP_VALUE0 value; } FWPM_CLASSIFY_OPTION0; typedef struct FWPM_CLASSIFY_OPTIONS0_ { UINT32 numOptions; FWPM_CLASSIFY_OPTION0 *options; } FWPM_CLASSIFY_OPTIONS0; typedef /* [v1_enum] */ enum FWPM_PROVIDER_CONTEXT_TYPE_ { FWPM_IPSEC_KEYING_CONTEXT = 0, FWPM_IPSEC_IKE_QM_TRANSPORT_CONTEXT = ( FWPM_IPSEC_KEYING_CONTEXT + 1 ) , FWPM_IPSEC_IKE_QM_TUNNEL_CONTEXT = ( FWPM_IPSEC_IKE_QM_TRANSPORT_CONTEXT + 1 ) , FWPM_IPSEC_AUTHIP_QM_TRANSPORT_CONTEXT = ( FWPM_IPSEC_IKE_QM_TUNNEL_CONTEXT + 1 ) , FWPM_IPSEC_AUTHIP_QM_TUNNEL_CONTEXT = ( FWPM_IPSEC_AUTHIP_QM_TRANSPORT_CONTEXT + 1 ) , FWPM_IPSEC_IKE_MM_CONTEXT = ( FWPM_IPSEC_AUTHIP_QM_TUNNEL_CONTEXT + 1 ) , FWPM_IPSEC_AUTHIP_MM_CONTEXT = ( FWPM_IPSEC_IKE_MM_CONTEXT + 1 ) , FWPM_CLASSIFY_OPTIONS_CONTEXT = ( FWPM_IPSEC_AUTHIP_MM_CONTEXT + 1 ) , FWPM_GENERAL_CONTEXT = ( FWPM_CLASSIFY_OPTIONS_CONTEXT + 1 ) , FWPM_IPSEC_IKEV2_QM_TUNNEL_CONTEXT = ( FWPM_GENERAL_CONTEXT + 1 ) , FWPM_IPSEC_IKEV2_MM_CONTEXT = ( FWPM_IPSEC_IKEV2_QM_TUNNEL_CONTEXT + 1 ) , FWPM_IPSEC_DOSP_CONTEXT = ( FWPM_IPSEC_IKEV2_MM_CONTEXT + 1 ) , FWPM_PROVIDER_CONTEXT_TYPE_MAX = ( FWPM_IPSEC_DOSP_CONTEXT + 1 ) } FWPM_PROVIDER_CONTEXT_TYPE; typedef struct FWPM_PROVIDER_CONTEXT0_ { GUID providerContextKey; FWPM_DISPLAY_DATA0 displayData; UINT32 flags; GUID *providerKey; FWP_BYTE_BLOB providerData; FWPM_PROVIDER_CONTEXT_TYPE type; union { IPSEC_KEYING_POLICY0 *keyingPolicy; IPSEC_TRANSPORT_POLICY0 *ikeQmTransportPolicy; IPSEC_TUNNEL_POLICY0 *ikeQmTunnelPolicy; IPSEC_TRANSPORT_POLICY0 *authipQmTransportPolicy; IPSEC_TUNNEL_POLICY0 *authipQmTunnelPolicy; IKEEXT_POLICY0 *ikeMmPolicy; IKEEXT_POLICY0 *authIpMmPolicy; FWP_BYTE_BLOB *dataBuffer; FWPM_CLASSIFY_OPTIONS0 *classifyOptions; /* Empty union arm */ } ; UINT64 providerContextId; } FWPM_PROVIDER_CONTEXT0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct FWPM_PROVIDER_CONTEXT1_ { GUID providerContextKey; FWPM_DISPLAY_DATA0 displayData; UINT32 flags; GUID *providerKey; FWP_BYTE_BLOB providerData; FWPM_PROVIDER_CONTEXT_TYPE type; union { IPSEC_KEYING_POLICY0 *keyingPolicy; IPSEC_TRANSPORT_POLICY1 *ikeQmTransportPolicy; IPSEC_TUNNEL_POLICY1 *ikeQmTunnelPolicy; IPSEC_TRANSPORT_POLICY1 *authipQmTransportPolicy; IPSEC_TUNNEL_POLICY1 *authipQmTunnelPolicy; IKEEXT_POLICY1 *ikeMmPolicy; IKEEXT_POLICY1 *authIpMmPolicy; FWP_BYTE_BLOB *dataBuffer; FWPM_CLASSIFY_OPTIONS0 *classifyOptions; IPSEC_TUNNEL_POLICY1 *ikeV2QmTunnelPolicy; IKEEXT_POLICY1 *ikeV2MmPolicy; IPSEC_DOSP_OPTIONS0 *idpOptions; } ; UINT64 providerContextId; } FWPM_PROVIDER_CONTEXT1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct FWPM_PROVIDER_CONTEXT_ENUM_TEMPLATE0_ { GUID *providerKey; FWPM_PROVIDER_CONTEXT_TYPE providerContextType; } FWPM_PROVIDER_CONTEXT_ENUM_TEMPLATE0; typedef struct FWPM_PROVIDER_CONTEXT_CHANGE0_ { FWPM_CHANGE_TYPE changeType; GUID providerContextKey; UINT64 providerContextId; } FWPM_PROVIDER_CONTEXT_CHANGE0; typedef struct FWPM_PROVIDER_CONTEXT_SUBSCRIPTION0_ { FWPM_PROVIDER_CONTEXT_ENUM_TEMPLATE0 *enumTemplate; UINT32 flags; GUID sessionKey; } FWPM_PROVIDER_CONTEXT_SUBSCRIPTION0; #define FWPM_SUBLAYER_FLAG_PERSISTENT (0x00000001) typedef struct FWPM_SUBLAYER0_ { GUID subLayerKey; FWPM_DISPLAY_DATA0 displayData; UINT32 flags; GUID *providerKey; FWP_BYTE_BLOB providerData; UINT16 weight; } FWPM_SUBLAYER0; typedef struct FWPM_SUBLAYER_ENUM_TEMPLATE0_ { GUID *providerKey; } FWPM_SUBLAYER_ENUM_TEMPLATE0; typedef struct FWPM_SUBLAYER_CHANGE0_ { FWPM_CHANGE_TYPE changeType; GUID subLayerKey; } FWPM_SUBLAYER_CHANGE0; typedef struct FWPM_SUBLAYER_SUBSCRIPTION0_ { FWPM_SUBLAYER_ENUM_TEMPLATE0 *enumTemplate; UINT32 flags; GUID sessionKey; } FWPM_SUBLAYER_SUBSCRIPTION0; #define FWPM_LAYER_FLAG_KERNEL (0x00000001) #define FWPM_LAYER_FLAG_BUILTIN (0x00000002) #define FWPM_LAYER_FLAG_CLASSIFY_MOSTLY (0x00000004) #define FWPM_LAYER_FLAG_BUFFERED (0x00000008) typedef /* [v1_enum] */ enum FWPM_FIELD_TYPE_ { FWPM_FIELD_RAW_DATA = 0, FWPM_FIELD_IP_ADDRESS = ( FWPM_FIELD_RAW_DATA + 1 ) , FWPM_FIELD_FLAGS = ( FWPM_FIELD_IP_ADDRESS + 1 ) , FWPM_FIELD_TYPE_MAX = ( FWPM_FIELD_FLAGS + 1 ) } FWPM_FIELD_TYPE; typedef struct FWPM_FIELD0_ { GUID *fieldKey; FWPM_FIELD_TYPE type; FWP_DATA_TYPE dataType; } FWPM_FIELD0; typedef struct FWPM_LAYER0_ { GUID layerKey; FWPM_DISPLAY_DATA0 displayData; UINT32 flags; UINT32 numFields; FWPM_FIELD0 *field; GUID defaultSubLayerKey; UINT16 layerId; } FWPM_LAYER0; typedef struct FWPM_LAYER_ENUM_TEMPLATE0_ { UINT64 reserved; } FWPM_LAYER_ENUM_TEMPLATE0; #define FWPM_CALLOUT_FLAG_PERSISTENT (0x00010000) #define FWPM_CALLOUT_FLAG_USES_PROVIDER_CONTEXT (0x00020000) #define FWPM_CALLOUT_FLAG_REGISTERED (0x00040000) typedef struct FWPM_CALLOUT0_ { GUID calloutKey; FWPM_DISPLAY_DATA0 displayData; UINT32 flags; GUID *providerKey; FWP_BYTE_BLOB providerData; GUID applicableLayer; UINT32 calloutId; } FWPM_CALLOUT0; typedef struct FWPM_CALLOUT_ENUM_TEMPLATE0_ { GUID *providerKey; GUID layerKey; } FWPM_CALLOUT_ENUM_TEMPLATE0; typedef struct FWPM_CALLOUT_CHANGE0_ { FWPM_CHANGE_TYPE changeType; GUID calloutKey; UINT32 calloutId; } FWPM_CALLOUT_CHANGE0; typedef struct FWPM_CALLOUT_SUBSCRIPTION0_ { FWPM_CALLOUT_ENUM_TEMPLATE0 *enumTemplate; UINT32 flags; GUID sessionKey; } FWPM_CALLOUT_SUBSCRIPTION0; typedef struct FWPM_ACTION0_ { FWP_ACTION_TYPE type; /* [switch_type] */ union { GUID filterType; GUID calloutKey; } ; } FWPM_ACTION0; typedef struct FWPM_FILTER_CONDITION0_ { GUID fieldKey; FWP_MATCH_TYPE matchType; FWP_CONDITION_VALUE0 conditionValue; } FWPM_FILTER_CONDITION0; #define FWPM_FILTER_FLAG_NONE (0x00000000) #define FWPM_FILTER_FLAG_PERSISTENT (0x00000001) #define FWPM_FILTER_FLAG_BOOTTIME (0x00000002) #define FWPM_FILTER_FLAG_HAS_PROVIDER_CONTEXT (0x00000004) #define FWPM_FILTER_FLAG_CLEAR_ACTION_RIGHT (0x00000008) #define FWPM_FILTER_FLAG_PERMIT_IF_CALLOUT_UNREGISTERED (0x00000010) #define FWPM_FILTER_FLAG_DISABLED (0x00000020) typedef struct FWPM_FILTER0_ { GUID filterKey; FWPM_DISPLAY_DATA0 displayData; UINT32 flags; GUID *providerKey; FWP_BYTE_BLOB providerData; GUID layerKey; GUID subLayerKey; FWP_VALUE0 weight; UINT32 numFilterConditions; FWPM_FILTER_CONDITION0 *filterCondition; FWPM_ACTION0 action; /* [switch_type] */ union { UINT64 rawContext; GUID providerContextKey; } ; GUID *reserved; UINT64 filterId; FWP_VALUE0 effectiveWeight; } FWPM_FILTER0; typedef struct FWPM_FILTER_ENUM_TEMPLATE0_ { GUID *providerKey; GUID layerKey; FWP_FILTER_ENUM_TYPE enumType; UINT32 flags; FWPM_PROVIDER_CONTEXT_ENUM_TEMPLATE0 *providerContextTemplate; UINT32 numFilterConditions; FWPM_FILTER_CONDITION0 *filterCondition; UINT32 actionMask; GUID *calloutKey; } FWPM_FILTER_ENUM_TEMPLATE0; typedef struct FWPM_FILTER_CHANGE0_ { FWPM_CHANGE_TYPE changeType; GUID filterKey; UINT64 filterId; } FWPM_FILTER_CHANGE0; typedef struct FWPM_FILTER_SUBSCRIPTION0_ { FWPM_FILTER_ENUM_TEMPLATE0 *enumTemplate; UINT32 flags; GUID sessionKey; } FWPM_FILTER_SUBSCRIPTION0; typedef struct FWPM_LAYER_STATISTICS0_ { GUID layerId; UINT32 classifyPermitCount; UINT32 classifyBlockCount; UINT32 classifyVetoCount; UINT32 numCacheEntries; } FWPM_LAYER_STATISTICS0; typedef struct FWPM_STATISTICS0_ { UINT32 numLayerStatistics; FWPM_LAYER_STATISTICS0 *layerStatistics; UINT32 inboundAllowedConnectionsV4; UINT32 inboundBlockedConnectionsV4; UINT32 outboundAllowedConnectionsV4; UINT32 outboundBlockedConnectionsV4; UINT32 inboundAllowedConnectionsV6; UINT32 inboundBlockedConnectionsV6; UINT32 outboundAllowedConnectionsV6; UINT32 outboundBlockedConnectionsV6; UINT32 inboundActiveConnectionsV4; UINT32 outboundActiveConnectionsV4; UINT32 inboundActiveConnectionsV6; UINT32 outboundActiveConnectionsV6; } FWPM_STATISTICS0; #define FWPM_NET_EVENT_FLAG_IP_PROTOCOL_SET (0x00000001) #define FWPM_NET_EVENT_FLAG_LOCAL_ADDR_SET (0x00000002) #define FWPM_NET_EVENT_FLAG_REMOTE_ADDR_SET (0x00000004) #define FWPM_NET_EVENT_FLAG_LOCAL_PORT_SET (0x00000008) #define FWPM_NET_EVENT_FLAG_REMOTE_PORT_SET (0x00000010) #define FWPM_NET_EVENT_FLAG_APP_ID_SET (0x00000020) #define FWPM_NET_EVENT_FLAG_USER_ID_SET (0x00000040) #define FWPM_NET_EVENT_FLAG_SCOPE_ID_SET (0x00000080) #define FWPM_NET_EVENT_FLAG_IP_VERSION_SET (0x00000100) #define FWPM_NET_EVENT_FLAG_REAUTH_REASON_SET (0x00000200) typedef struct FWPM_NET_EVENT_HEADER0_ { FILETIME timeStamp; UINT32 flags; FWP_IP_VERSION ipVersion; UINT8 ipProtocol; union { UINT32 localAddrV4; FWP_BYTE_ARRAY16 localAddrV6; } ; union { UINT32 remoteAddrV4; FWP_BYTE_ARRAY16 remoteAddrV6; } ; UINT16 localPort; UINT16 remotePort; UINT32 scopeId; FWP_BYTE_BLOB appId; SID *userId; } FWPM_NET_EVENT_HEADER0; typedef struct FWPM_NET_EVENT_HEADER1_ { FILETIME timeStamp; UINT32 flags; FWP_IP_VERSION ipVersion; UINT8 ipProtocol; union { UINT32 localAddrV4; FWP_BYTE_ARRAY16 localAddrV6; /* Empty union arm */ } ; union { UINT32 remoteAddrV4; FWP_BYTE_ARRAY16 remoteAddrV6; /* Empty union arm */ } ; UINT16 localPort; UINT16 remotePort; UINT32 scopeId; FWP_BYTE_BLOB appId; SID *userId; union { struct { FWP_AF addressFamily; union { struct { FWP_BYTE_ARRAY6 dstAddrEth; FWP_BYTE_ARRAY6 srcAddrEth; DL_ADDRESS_TYPE addrType; FWP_ETHER_ENCAP_METHOD encapMethod; UINT16 etherType; UINT32 snapControl; UINT32 snapOui; UINT16 vlanTag; UINT64 ifLuid; } ; } ; } ; /* Empty union arm */ } ; } FWPM_NET_EVENT_HEADER1; typedef /* [v1_enum] */ enum FWPM_NET_EVENT_TYPE_ { FWPM_NET_EVENT_TYPE_IKEEXT_MM_FAILURE = 0, FWPM_NET_EVENT_TYPE_IKEEXT_QM_FAILURE = ( FWPM_NET_EVENT_TYPE_IKEEXT_MM_FAILURE + 1 ) , FWPM_NET_EVENT_TYPE_IKEEXT_EM_FAILURE = ( FWPM_NET_EVENT_TYPE_IKEEXT_QM_FAILURE + 1 ) , FWPM_NET_EVENT_TYPE_CLASSIFY_DROP = ( FWPM_NET_EVENT_TYPE_IKEEXT_EM_FAILURE + 1 ) , FWPM_NET_EVENT_TYPE_IPSEC_KERNEL_DROP = ( FWPM_NET_EVENT_TYPE_CLASSIFY_DROP + 1 ) , FWPM_NET_EVENT_TYPE_IPSEC_DOSP_DROP = ( FWPM_NET_EVENT_TYPE_IPSEC_KERNEL_DROP + 1 ) , FWPM_NET_EVENT_TYPE_MAX = ( FWPM_NET_EVENT_TYPE_IPSEC_DOSP_DROP + 1 ) } FWPM_NET_EVENT_TYPE; #define IKEEXT_CERT_HASH_LEN 20 #define FWPM_NET_EVENT_IKEEXT_MM_FAILURE_FLAG_BENIGN (0x00000001) #define FWPM_NET_EVENT_IKEEXT_MM_FAILURE_FLAG_MULTIPLE (0x00000002) typedef struct FWPM_NET_EVENT_IKEEXT_MM_FAILURE0_ { UINT32 failureErrorCode; IPSEC_FAILURE_POINT failurePoint; UINT32 flags; IKEEXT_KEY_MODULE_TYPE keyingModuleType; IKEEXT_MM_SA_STATE mmState; IKEEXT_SA_ROLE saRole; IKEEXT_AUTHENTICATION_METHOD_TYPE mmAuthMethod; UINT8 endCertHash[ 20 ]; UINT64 mmId; UINT64 mmFilterId; } FWPM_NET_EVENT_IKEEXT_MM_FAILURE0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct FWPM_NET_EVENT_IKEEXT_MM_FAILURE1_ { UINT32 failureErrorCode; IPSEC_FAILURE_POINT failurePoint; UINT32 flags; IKEEXT_KEY_MODULE_TYPE keyingModuleType; IKEEXT_MM_SA_STATE mmState; IKEEXT_SA_ROLE saRole; IKEEXT_AUTHENTICATION_METHOD_TYPE mmAuthMethod; UINT8 endCertHash[ 20 ]; UINT64 mmId; UINT64 mmFilterId; wchar_t *localPrincipalNameForAuth; wchar_t *remotePrincipalNameForAuth; UINT32 numLocalPrincipalGroupSids; LPWSTR *localPrincipalGroupSids; UINT32 numRemotePrincipalGroupSids; LPWSTR *remotePrincipalGroupSids; } FWPM_NET_EVENT_IKEEXT_MM_FAILURE1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct FWPM_NET_EVENT_IKEEXT_QM_FAILURE0_ { UINT32 failureErrorCode; IPSEC_FAILURE_POINT failurePoint; IKEEXT_KEY_MODULE_TYPE keyingModuleType; IKEEXT_QM_SA_STATE qmState; IKEEXT_SA_ROLE saRole; IPSEC_TRAFFIC_TYPE saTrafficType; union { /* Empty union arm */ FWP_CONDITION_VALUE0 localSubNet; } ; union { /* Empty union arm */ FWP_CONDITION_VALUE0 remoteSubNet; } ; UINT64 qmFilterId; } FWPM_NET_EVENT_IKEEXT_QM_FAILURE0; #define FWPM_NET_EVENT_IKEEXT_EM_FAILURE_FLAG_MULTIPLE (0x00000001) #define FWPM_NET_EVENT_IKEEXT_EM_FAILURE_FLAG_BENIGN (0x00000002) typedef struct FWPM_NET_EVENT_IKEEXT_EM_FAILURE0_ { UINT32 failureErrorCode; IPSEC_FAILURE_POINT failurePoint; UINT32 flags; IKEEXT_EM_SA_STATE emState; IKEEXT_SA_ROLE saRole; IKEEXT_AUTHENTICATION_METHOD_TYPE emAuthMethod; UINT8 endCertHash[ 20 ]; UINT64 mmId; UINT64 qmFilterId; } FWPM_NET_EVENT_IKEEXT_EM_FAILURE0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct FWPM_NET_EVENT_IKEEXT_EM_FAILURE1_ { UINT32 failureErrorCode; IPSEC_FAILURE_POINT failurePoint; UINT32 flags; IKEEXT_EM_SA_STATE emState; IKEEXT_SA_ROLE saRole; IKEEXT_AUTHENTICATION_METHOD_TYPE emAuthMethod; UINT8 endCertHash[ 20 ]; UINT64 mmId; UINT64 qmFilterId; wchar_t *localPrincipalNameForAuth; wchar_t *remotePrincipalNameForAuth; UINT32 numLocalPrincipalGroupSids; LPWSTR *localPrincipalGroupSids; UINT32 numRemotePrincipalGroupSids; LPWSTR *remotePrincipalGroupSids; IPSEC_TRAFFIC_TYPE saTrafficType; } FWPM_NET_EVENT_IKEEXT_EM_FAILURE1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct FWPM_NET_EVENT_CLASSIFY_DROP0_ { UINT64 filterId; UINT16 layerId; } FWPM_NET_EVENT_CLASSIFY_DROP0; typedef struct FWPM_NET_EVENT_CLASSIFY_DROP1_ { UINT64 filterId; UINT16 layerId; UINT32 reauthReason; UINT32 originalProfile; UINT32 currentProfile; UINT32 msFwpDirection; BOOL isLoopback; } FWPM_NET_EVENT_CLASSIFY_DROP1; typedef struct FWPM_NET_EVENT_IPSEC_KERNEL_DROP0_ { INT32 failureStatus; FWP_DIRECTION direction; IPSEC_SA_SPI spi; UINT64 filterId; UINT16 layerId; } FWPM_NET_EVENT_IPSEC_KERNEL_DROP0; typedef struct FWPM_NET_EVENT_IPSEC_DOSP_DROP0_ { FWP_IP_VERSION ipVersion; union { UINT32 publicHostV4Addr; UINT8 publicHostV6Addr[ 16 ]; } ; union { UINT32 internalHostV4Addr; UINT8 internalHostV6Addr[ 16 ]; } ; INT32 failureStatus; FWP_DIRECTION direction; } FWPM_NET_EVENT_IPSEC_DOSP_DROP0; typedef struct FWPM_NET_EVENT0_ { FWPM_NET_EVENT_HEADER0 header; FWPM_NET_EVENT_TYPE type; union { FWPM_NET_EVENT_IKEEXT_MM_FAILURE0 *ikeMmFailure; FWPM_NET_EVENT_IKEEXT_QM_FAILURE0 *ikeQmFailure; FWPM_NET_EVENT_IKEEXT_EM_FAILURE0 *ikeEmFailure; FWPM_NET_EVENT_CLASSIFY_DROP0 *classifyDrop; FWPM_NET_EVENT_IPSEC_KERNEL_DROP0 *ipsecDrop; FWPM_NET_EVENT_IPSEC_DOSP_DROP0 *idpDrop; } ; } FWPM_NET_EVENT0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct FWPM_NET_EVENT1_ { FWPM_NET_EVENT_HEADER1 header; FWPM_NET_EVENT_TYPE type; union { FWPM_NET_EVENT_IKEEXT_MM_FAILURE1 *ikeMmFailure; FWPM_NET_EVENT_IKEEXT_QM_FAILURE0 *ikeQmFailure; FWPM_NET_EVENT_IKEEXT_EM_FAILURE1 *ikeEmFailure; FWPM_NET_EVENT_CLASSIFY_DROP1 *classifyDrop; FWPM_NET_EVENT_IPSEC_KERNEL_DROP0 *ipsecDrop; FWPM_NET_EVENT_IPSEC_DOSP_DROP0 *idpDrop; } ; } FWPM_NET_EVENT1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct FWPM_NET_EVENT_ENUM_TEMPLATE0_ { FILETIME startTime; FILETIME endTime; UINT32 numFilterConditions; FWPM_FILTER_CONDITION0 *filterCondition; } FWPM_NET_EVENT_ENUM_TEMPLATE0; typedef struct FWPM_NET_EVENT_SUBSCRIPTION0_ { FWPM_NET_EVENT_ENUM_TEMPLATE0 *enumTemplate; UINT32 flags; GUID sessionKey; } FWPM_NET_EVENT_SUBSCRIPTION0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef /* [v1_enum] */ enum FWPM_SYSTEM_PORT_TYPE_ { FWPM_SYSTEM_PORT_RPC_EPMAP = 0, FWPM_SYSTEM_PORT_TEREDO = ( FWPM_SYSTEM_PORT_RPC_EPMAP + 1 ) , FWPM_SYSTEM_PORT_IPHTTPS_IN = ( FWPM_SYSTEM_PORT_TEREDO + 1 ) , FWPM_SYSTEM_PORT_IPHTTPS_OUT = ( FWPM_SYSTEM_PORT_IPHTTPS_IN + 1 ) , FWPM_SYSTEM_PORT_TYPE_MAX = ( FWPM_SYSTEM_PORT_IPHTTPS_OUT + 1 ) } FWPM_SYSTEM_PORT_TYPE; typedef struct FWPM_SYSTEM_PORTS_BY_TYPE0_ { FWPM_SYSTEM_PORT_TYPE type; UINT32 numPorts; UINT16 *ports; } FWPM_SYSTEM_PORTS_BY_TYPE0; typedef struct FWPM_SYSTEM_PORTS0_ { UINT32 numTypes; FWPM_SYSTEM_PORTS_BY_TYPE0 *types; } FWPM_SYSTEM_PORTS0; #endif // (NTDDI_VERSION >= NTDDI_WIN7) #if _MSC_VER >= 800 #if _MSC_VER >= 1200 #pragma warning(pop) #else #pragma warning(default:4201) #endif #endif extern RPC_IF_HANDLE __MIDL_itf_fwpmtypes_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_fwpmtypes_0000_0000_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/network/include/fwpmu.h
C/C++ Header
/* Copyright (c) Microsoft Corporation SYNOPSIS Declares the management portion of the FWP API. */ #if (NTDDI_VERSION >= NTDDI_WIN6) /////////////////////////////////////////////////////////////////////////////// // // GUIDs for built-in layers. // /////////////////////////////////////////////////////////////////////////////// // c86fd1bf-21cd-497e-a0bb-17425c885c58 DEFINE_GUID( FWPM_LAYER_INBOUND_IPPACKET_V4, 0xc86fd1bf, 0x21cd, 0x497e, 0xa0, 0xbb, 0x17, 0x42, 0x5c, 0x88, 0x5c, 0x58 ); // b5a230d0-a8c0-44f2-916e-991b53ded1f7 DEFINE_GUID( FWPM_LAYER_INBOUND_IPPACKET_V4_DISCARD, 0xb5a230d0, 0xa8c0, 0x44f2, 0x91, 0x6e, 0x99, 0x1b, 0x53, 0xde, 0xd1, 0xf7 ); // f52032cb-991c-46e7-971d-2601459a91ca DEFINE_GUID( FWPM_LAYER_INBOUND_IPPACKET_V6, 0xf52032cb, 0x991c, 0x46e7, 0x97, 0x1d, 0x26, 0x01, 0x45, 0x9a, 0x91, 0xca ); // bb24c279-93b4-47a2-83ad-ae1698b50885 DEFINE_GUID( FWPM_LAYER_INBOUND_IPPACKET_V6_DISCARD, 0xbb24c279, 0x93b4, 0x47a2, 0x83, 0xad, 0xae, 0x16, 0x98, 0xb5, 0x08, 0x85 ); // 1e5c9fae-8a84-4135-a331-950b54229ecd DEFINE_GUID( FWPM_LAYER_OUTBOUND_IPPACKET_V4, 0x1e5c9fae, 0x8a84, 0x4135, 0xa3, 0x31, 0x95, 0x0b, 0x54, 0x22, 0x9e, 0xcd ); // 08e4bcb5-b647-48f3-953c-e5ddbd03937e DEFINE_GUID( FWPM_LAYER_OUTBOUND_IPPACKET_V4_DISCARD, 0x08e4bcb5, 0xb647, 0x48f3, 0x95, 0x3c, 0xe5, 0xdd, 0xbd, 0x03, 0x93, 0x7e ); // a3b3ab6b-3564-488c-9117-f34e82142763 DEFINE_GUID( FWPM_LAYER_OUTBOUND_IPPACKET_V6, 0xa3b3ab6b, 0x3564, 0x488c, 0x91, 0x17, 0xf3, 0x4e, 0x82, 0x14, 0x27, 0x63 ); // 9513d7c4-a934-49dc-91a7-6ccb80cc02e3 DEFINE_GUID( FWPM_LAYER_OUTBOUND_IPPACKET_V6_DISCARD, 0x9513d7c4, 0xa934, 0x49dc, 0x91, 0xa7, 0x6c, 0xcb, 0x80, 0xcc, 0x02, 0xe3 ); // a82acc24-4ee1-4ee1-b465-fd1d25cb10a4 DEFINE_GUID( FWPM_LAYER_IPFORWARD_V4, 0xa82acc24, 0x4ee1, 0x4ee1, 0xb4, 0x65, 0xfd, 0x1d, 0x25, 0xcb, 0x10, 0xa4 ); // 9e9ea773-2fae-4210-8f17-34129ef369eb DEFINE_GUID( FWPM_LAYER_IPFORWARD_V4_DISCARD, 0x9e9ea773, 0x2fae, 0x4210, 0x8f, 0x17, 0x34, 0x12, 0x9e, 0xf3, 0x69, 0xeb ); // 7b964818-19c7-493a-b71f-832c3684d28c DEFINE_GUID( FWPM_LAYER_IPFORWARD_V6, 0x7b964818, 0x19c7, 0x493a, 0xb7, 0x1f, 0x83, 0x2c, 0x36, 0x84, 0xd2, 0x8c ); // 31524a5d-1dfe-472f-bb93-518ee945d8a2 DEFINE_GUID( FWPM_LAYER_IPFORWARD_V6_DISCARD, 0x31524a5d, 0x1dfe, 0x472f, 0xbb, 0x93, 0x51, 0x8e, 0xe9, 0x45, 0xd8, 0xa2 ); // 5926dfc8-e3cf-4426-a283-dc393f5d0f9d DEFINE_GUID( FWPM_LAYER_INBOUND_TRANSPORT_V4, 0x5926dfc8, 0xe3cf, 0x4426, 0xa2, 0x83, 0xdc, 0x39, 0x3f, 0x5d, 0x0f, 0x9d ); // ac4a9833-f69d-4648-b261-6dc84835ef39 DEFINE_GUID( FWPM_LAYER_INBOUND_TRANSPORT_V4_DISCARD, 0xac4a9833, 0xf69d, 0x4648, 0xb2, 0x61, 0x6d, 0xc8, 0x48, 0x35, 0xef, 0x39 ); // 634a869f-fc23-4b90-b0c1-bf620a36ae6f DEFINE_GUID( FWPM_LAYER_INBOUND_TRANSPORT_V6, 0x634a869f, 0xfc23, 0x4b90, 0xb0, 0xc1, 0xbf, 0x62, 0x0a, 0x36, 0xae, 0x6f ); // 2a6ff955-3b2b-49d2-9848-ad9d72dcaab7 DEFINE_GUID( FWPM_LAYER_INBOUND_TRANSPORT_V6_DISCARD, 0x2a6ff955, 0x3b2b, 0x49d2, 0x98, 0x48, 0xad, 0x9d, 0x72, 0xdc, 0xaa, 0xb7 ); // 09e61aea-d214-46e2-9b21-b26b0b2f28c8 DEFINE_GUID( FWPM_LAYER_OUTBOUND_TRANSPORT_V4, 0x09e61aea, 0xd214, 0x46e2, 0x9b, 0x21, 0xb2, 0x6b, 0x0b, 0x2f, 0x28, 0xc8 ); // c5f10551-bdb0-43d7-a313-50e211f4d68a DEFINE_GUID( FWPM_LAYER_OUTBOUND_TRANSPORT_V4_DISCARD, 0xc5f10551, 0xbdb0, 0x43d7, 0xa3, 0x13, 0x50, 0xe2, 0x11, 0xf4, 0xd6, 0x8a ); // e1735bde-013f-4655-b351-a49e15762df0 DEFINE_GUID( FWPM_LAYER_OUTBOUND_TRANSPORT_V6, 0xe1735bde, 0x013f, 0x4655, 0xb3, 0x51, 0xa4, 0x9e, 0x15, 0x76, 0x2d, 0xf0 ); // f433df69-ccbd-482e-b9b2-57165658c3b3 DEFINE_GUID( FWPM_LAYER_OUTBOUND_TRANSPORT_V6_DISCARD, 0xf433df69, 0xccbd, 0x482e, 0xb9, 0xb2, 0x57, 0x16, 0x56, 0x58, 0xc3, 0xb3 ); // 3b89653c-c170-49e4-b1cd-e0eeeee19a3e DEFINE_GUID( FWPM_LAYER_STREAM_V4, 0x3b89653c, 0xc170, 0x49e4, 0xb1, 0xcd, 0xe0, 0xee, 0xee, 0xe1, 0x9a, 0x3e ); // 25c4c2c2-25ff-4352-82f9-c54a4a4726dc DEFINE_GUID( FWPM_LAYER_STREAM_V4_DISCARD, 0x25c4c2c2, 0x25ff, 0x4352, 0x82, 0xf9, 0xc5, 0x4a, 0x4a, 0x47, 0x26, 0xdc ); // 47c9137a-7ec4-46b3-b6e4-48e926b1eda4 DEFINE_GUID( FWPM_LAYER_STREAM_V6, 0x47c9137a, 0x7ec4, 0x46b3, 0xb6, 0xe4, 0x48, 0xe9, 0x26, 0xb1, 0xed, 0xa4 ); // 10a59fc7-b628-4c41-9eb8-cf37d55103cf DEFINE_GUID( FWPM_LAYER_STREAM_V6_DISCARD, 0x10a59fc7, 0xb628, 0x4c41, 0x9e, 0xb8, 0xcf, 0x37, 0xd5, 0x51, 0x03, 0xcf ); // 3d08bf4e-45f6-4930-a922-417098e20027 DEFINE_GUID( FWPM_LAYER_DATAGRAM_DATA_V4, 0x3d08bf4e, 0x45f6, 0x4930, 0xa9, 0x22, 0x41, 0x70, 0x98, 0xe2, 0x00, 0x27 ); // 18e330c6-7248-4e52-aaab-472ed67704fd DEFINE_GUID( FWPM_LAYER_DATAGRAM_DATA_V4_DISCARD, 0x18e330c6, 0x7248, 0x4e52, 0xaa, 0xab, 0x47, 0x2e, 0xd6, 0x77, 0x04, 0xfd ); // fa45fe2f-3cba-4427-87fc-57b9a4b10d00 DEFINE_GUID( FWPM_LAYER_DATAGRAM_DATA_V6, 0xfa45fe2f, 0x3cba, 0x4427, 0x87, 0xfc, 0x57, 0xb9, 0xa4, 0xb1, 0x0d, 0x00 ); // 09d1dfe1-9b86-4a42-be9d-8c315b92a5d0 DEFINE_GUID( FWPM_LAYER_DATAGRAM_DATA_V6_DISCARD, 0x09d1dfe1, 0x9b86, 0x4a42, 0xbe, 0x9d, 0x8c, 0x31, 0x5b, 0x92, 0xa5, 0xd0 ); // 61499990-3cb6-4e84-b950-53b94b6964f3 DEFINE_GUID( FWPM_LAYER_INBOUND_ICMP_ERROR_V4, 0x61499990, 0x3cb6, 0x4e84, 0xb9, 0x50, 0x53, 0xb9, 0x4b, 0x69, 0x64, 0xf3 ); // a6b17075-ebaf-4053-a4e7-213c8121ede5 DEFINE_GUID( FWPM_LAYER_INBOUND_ICMP_ERROR_V4_DISCARD, 0xa6b17075, 0xebaf, 0x4053, 0xa4, 0xe7, 0x21, 0x3c, 0x81, 0x21, 0xed, 0xe5 ); // 65f9bdff-3b2d-4e5d-b8c6-c720651fe898 DEFINE_GUID( FWPM_LAYER_INBOUND_ICMP_ERROR_V6, 0x65f9bdff, 0x3b2d, 0x4e5d, 0xb8, 0xc6, 0xc7, 0x20, 0x65, 0x1f, 0xe8, 0x98 ); // a6e7ccc0-08fb-468d-a472-9771d5595e09 DEFINE_GUID( FWPM_LAYER_INBOUND_ICMP_ERROR_V6_DISCARD, 0xa6e7ccc0, 0x08fb, 0x468d, 0xa4, 0x72, 0x97, 0x71, 0xd5, 0x59, 0x5e, 0x09 ); // 41390100-564c-4b32-bc1d-718048354d7c DEFINE_GUID( FWPM_LAYER_OUTBOUND_ICMP_ERROR_V4, 0x41390100, 0x564c, 0x4b32, 0xbc, 0x1d, 0x71, 0x80, 0x48, 0x35, 0x4d, 0x7c ); // b3598d36-0561-4588-a6bf-e955e3f6264b DEFINE_GUID( FWPM_LAYER_OUTBOUND_ICMP_ERROR_V4_DISCARD, 0xb3598d36, 0x0561, 0x4588, 0xa6, 0xbf, 0xe9, 0x55, 0xe3, 0xf6, 0x26, 0x4b ); // 7fb03b60-7b8d-4dfa-badd-980176fc4e12 DEFINE_GUID( FWPM_LAYER_OUTBOUND_ICMP_ERROR_V6, 0x7fb03b60, 0x7b8d, 0x4dfa, 0xba, 0xdd, 0x98, 0x01, 0x76, 0xfc, 0x4e, 0x12 ); // 65f2e647-8d0c-4f47-b19b-33a4d3f1357c DEFINE_GUID( FWPM_LAYER_OUTBOUND_ICMP_ERROR_V6_DISCARD, 0x65f2e647, 0x8d0c, 0x4f47, 0xb1, 0x9b, 0x33, 0xa4, 0xd3, 0xf1, 0x35, 0x7c ); // 1247d66d-0b60-4a15-8d44-7155d0f53a0c DEFINE_GUID( FWPM_LAYER_ALE_RESOURCE_ASSIGNMENT_V4, 0x1247d66d, 0x0b60, 0x4a15, 0x8d, 0x44, 0x71, 0x55, 0xd0, 0xf5, 0x3a, 0x0c ); // 0b5812a2-c3ff-4eca-b88d-c79e20ac6322 DEFINE_GUID( FWPM_LAYER_ALE_RESOURCE_ASSIGNMENT_V4_DISCARD, 0x0b5812a2, 0xc3ff, 0x4eca, 0xb8, 0x8d, 0xc7, 0x9e, 0x20, 0xac, 0x63, 0x22 ); // 55a650e1-5f0a-4eca-a653-88f53b26aa8c DEFINE_GUID( FWPM_LAYER_ALE_RESOURCE_ASSIGNMENT_V6, 0x55a650e1, 0x5f0a, 0x4eca, 0xa6, 0x53, 0x88, 0xf5, 0x3b, 0x26, 0xaa, 0x8c ); // cbc998bb-c51f-4c1a-bb4f-9775fcacab2f DEFINE_GUID( FWPM_LAYER_ALE_RESOURCE_ASSIGNMENT_V6_DISCARD, 0xcbc998bb, 0xc51f, 0x4c1a, 0xbb, 0x4f, 0x97, 0x75, 0xfc, 0xac, 0xab, 0x2f ); // 88bb5dad-76d7-4227-9c71-df0a3ed7be7e DEFINE_GUID( FWPM_LAYER_ALE_AUTH_LISTEN_V4, 0x88bb5dad, 0x76d7, 0x4227, 0x9c, 0x71, 0xdf, 0x0a, 0x3e, 0xd7, 0xbe, 0x7e ); // 371dfada-9f26-45fd-b4eb-c29eb212893f DEFINE_GUID( FWPM_LAYER_ALE_AUTH_LISTEN_V4_DISCARD, 0x371dfada, 0x9f26, 0x45fd, 0xb4, 0xeb, 0xc2, 0x9e, 0xb2, 0x12, 0x89, 0x3f ); // 7ac9de24-17dd-4814-b4bd-a9fbc95a321b DEFINE_GUID( FWPM_LAYER_ALE_AUTH_LISTEN_V6, 0x7ac9de24, 0x17dd, 0x4814, 0xb4, 0xbd, 0xa9, 0xfb, 0xc9, 0x5a, 0x32, 0x1b ); // 60703b07-63c8-48e9-ada3-12b1af40a617 DEFINE_GUID( FWPM_LAYER_ALE_AUTH_LISTEN_V6_DISCARD, 0x60703b07, 0x63c8, 0x48e9, 0xad, 0xa3, 0x12, 0xb1, 0xaf, 0x40, 0xa6, 0x17 ); // e1cd9fe7-f4b5-4273-96c0-592e487b8650 DEFINE_GUID( FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4, 0xe1cd9fe7, 0xf4b5, 0x4273, 0x96, 0xc0, 0x59, 0x2e, 0x48, 0x7b, 0x86, 0x50 ); // 9eeaa99b-bd22-4227-919f-0073c63357b1 DEFINE_GUID( FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V4_DISCARD, 0x9eeaa99b, 0xbd22, 0x4227, 0x91, 0x9f, 0x00, 0x73, 0xc6, 0x33, 0x57, 0xb1 ); // a3b42c97-9f04-4672-b87e-cee9c483257f DEFINE_GUID( FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6, 0xa3b42c97, 0x9f04, 0x4672, 0xb8, 0x7e, 0xce, 0xe9, 0xc4, 0x83, 0x25, 0x7f ); // 89455b97-dbe1-453f-a224-13da895af396 DEFINE_GUID( FWPM_LAYER_ALE_AUTH_RECV_ACCEPT_V6_DISCARD, 0x89455b97, 0xdbe1, 0x453f, 0xa2, 0x24, 0x13, 0xda, 0x89, 0x5a, 0xf3, 0x96 ); // c38d57d1-05a7-4c33-904f-7fbceee60e82 DEFINE_GUID( FWPM_LAYER_ALE_AUTH_CONNECT_V4, 0xc38d57d1, 0x05a7, 0x4c33, 0x90, 0x4f, 0x7f, 0xbc, 0xee, 0xe6, 0x0e, 0x82 ); // d632a801-f5ba-4ad6-96e3-607017d9836a DEFINE_GUID( FWPM_LAYER_ALE_AUTH_CONNECT_V4_DISCARD, 0xd632a801, 0xf5ba, 0x4ad6, 0x96, 0xe3, 0x60, 0x70, 0x17, 0xd9, 0x83, 0x6a ); // 4a72393b-319f-44bc-84c3-ba54dcb3b6b4 DEFINE_GUID( FWPM_LAYER_ALE_AUTH_CONNECT_V6, 0x4a72393b, 0x319f, 0x44bc, 0x84, 0xc3, 0xba, 0x54, 0xdc, 0xb3, 0xb6, 0xb4 ); // c97bc3b8-c9a3-4e33-8695-8e17aad4de09 DEFINE_GUID( FWPM_LAYER_ALE_AUTH_CONNECT_V6_DISCARD, 0xc97bc3b8, 0xc9a3, 0x4e33, 0x86, 0x95, 0x8e, 0x17, 0xaa, 0xd4, 0xde, 0x09 ); // af80470a-5596-4c13-9992-539e6fe57967 DEFINE_GUID( FWPM_LAYER_ALE_FLOW_ESTABLISHED_V4, 0xaf80470a, 0x5596, 0x4c13, 0x99, 0x92, 0x53, 0x9e, 0x6f, 0xe5, 0x79, 0x67 ); // 146ae4a9-a1d2-4d43-a31a-4c42682b8e4f DEFINE_GUID( FWPM_LAYER_ALE_FLOW_ESTABLISHED_V4_DISCARD, 0x146ae4a9, 0xa1d2, 0x4d43, 0xa3, 0x1a, 0x4c, 0x42, 0x68, 0x2b, 0x8e, 0x4f ); // 7021d2b3-dfa4-406e-afeb-6afaf7e70efd DEFINE_GUID( FWPM_LAYER_ALE_FLOW_ESTABLISHED_V6, 0x7021d2b3, 0xdfa4, 0x406e, 0xaf, 0xeb, 0x6a, 0xfa, 0xf7, 0xe7, 0x0e, 0xfd ); // 46928636-bbca-4b76-941d-0fa7f5d7d372 DEFINE_GUID( FWPM_LAYER_ALE_FLOW_ESTABLISHED_V6_DISCARD, 0x46928636, 0xbbca, 0x4b76, 0x94, 0x1d, 0x0f, 0xa7, 0xf5, 0xd7, 0xd3, 0x72 ); #if (NTDDI_VERSION >= NTDDI_WIN7) // effb7edb-0055-4f9a-a23a-4ff8131ad191 DEFINE_GUID( FWPM_LAYER_INBOUND_MAC_FRAME_802_3, 0xeffb7edb, 0x0055, 0x4f9a, 0xa2, 0x31, 0x4f, 0xf8, 0x13, 0x1a, 0xd1, 0x91 ); // 694673bc-d6db-4870-adee-0acdbdb7f4b2 DEFINE_GUID( FWPM_LAYER_OUTBOUND_MAC_FRAME_802_3, 0x694673bc, 0xd6db, 0x4870, 0xad, 0xee, 0x0a, 0xcd, 0xbd, 0xb7, 0xf4, 0xb2 ); #endif // f02b1526-a459-4a51-b9e3-759de52b9d2c DEFINE_GUID( FWPM_LAYER_IPSEC_KM_DEMUX_V4, 0xf02b1526, 0xa459, 0x4a51, 0xb9, 0xe3, 0x75, 0x9d, 0xe5, 0x2b, 0x9d, 0x2c ); // 2f755cf6-2fd4-4e88-b3e4-a91bca495235 DEFINE_GUID( FWPM_LAYER_IPSEC_KM_DEMUX_V6, 0x2f755cf6, 0x2fd4, 0x4e88, 0xb3, 0xe4, 0xa9, 0x1b, 0xca, 0x49, 0x52, 0x35 ); // eda65c74-610d-4bc5-948f-3c4f89556867 DEFINE_GUID( FWPM_LAYER_IPSEC_V4, 0xeda65c74, 0x610d, 0x4bc5, 0x94, 0x8f, 0x3c, 0x4f, 0x89, 0x55, 0x68, 0x67 ); // 13c48442-8d87-4261-9a29-59d2abc348b4 DEFINE_GUID( FWPM_LAYER_IPSEC_V6, 0x13c48442, 0x8d87, 0x4261, 0x9a, 0x29, 0x59, 0xd2, 0xab, 0xc3, 0x48, 0xb4 ); // b14b7bdb-dbbd-473e-bed4-8b4708d4f270 DEFINE_GUID( FWPM_LAYER_IKEEXT_V4, 0xb14b7bdb, 0xdbbd, 0x473e, 0xbe, 0xd4, 0x8b, 0x47, 0x08, 0xd4, 0xf2, 0x70 ); // b64786b3-f687-4eb9-89d2-8ef32acdabe2 DEFINE_GUID( FWPM_LAYER_IKEEXT_V6, 0xb64786b3, 0xf687, 0x4eb9, 0x89, 0xd2, 0x8e, 0xf3, 0x2a, 0xcd, 0xab, 0xe2 ); // 75a89dda-95e4-40f3-adc7-7688a9c847e1 DEFINE_GUID( FWPM_LAYER_RPC_UM, 0x75a89dda, 0x95e4, 0x40f3, 0xad, 0xc7, 0x76, 0x88, 0xa9, 0xc8, 0x47, 0xe1 ); // 9247bc61-eb07-47ee-872c-bfd78bfd1616 DEFINE_GUID( FWPM_LAYER_RPC_EPMAP, 0x9247bc61, 0xeb07, 0x47ee, 0x87, 0x2c, 0xbf, 0xd7, 0x8b, 0xfd, 0x16, 0x16 ); // 618dffc7-c450-4943-95db-99b4c16a55d4 DEFINE_GUID( FWPM_LAYER_RPC_EP_ADD, 0x618dffc7, 0xc450, 0x4943, 0x95, 0xdb, 0x99, 0xb4, 0xc1, 0x6a, 0x55, 0xd4 ); // 94a4b50b-ba5c-4f27-907a-229fac0c2a7a DEFINE_GUID( FWPM_LAYER_RPC_PROXY_CONN, 0x94a4b50b, 0xba5c, 0x4f27, 0x90, 0x7a, 0x22, 0x9f, 0xac, 0x0c, 0x2a, 0x7a ); // f8a38615-e12c-41ac-98df-121ad981aade DEFINE_GUID( FWPM_LAYER_RPC_PROXY_IF, 0xf8a38615, 0xe12c, 0x41ac, 0x98, 0xdf, 0x12, 0x1a, 0xd9, 0x81, 0xaa, 0xde ); #if (NTDDI_VERSION >= NTDDI_WIN7) // 4aa226e9-9020-45fb-956a-c0249d841195 DEFINE_GUID( FWPM_LAYER_KM_AUTHORIZATION, 0x4aa226e9, 0x9020, 0x45fb, 0x95,0x6a, 0xc0, 0x24, 0x9d, 0x84, 0x11, 0x95 ); // 0c2aa681-905b-4ccd-a467-4dd811d07b7b DEFINE_GUID( FWPM_LAYER_NAME_RESOLUTION_CACHE_V4, 0x0c2aa681, 0x905b, 0x4ccd, 0xa4, 0x67, 0x4d, 0xd8, 0x11, 0xd0, 0x7b, 0x7b ); // 92d592fa-6b01-434a-9dea-d1e96ea97da9 DEFINE_GUID( FWPM_LAYER_NAME_RESOLUTION_CACHE_V6, 0x92d592fa, 0x6b01, 0x434a, 0x9d, 0xea, 0xd1, 0xe9, 0x6e, 0xa9, 0x7d, 0xa9 ); // 74365cce-ccb0-401a-bfc1-b89934ad7e15 DEFINE_GUID( FWPM_LAYER_ALE_RESOURCE_RELEASE_V4, 0x74365cce, 0xccb0, 0x401a, 0xbf, 0xc1, 0xb8, 0x99, 0x34, 0xad, 0x7e, 0x15 ); // f4e5ce80-edcc-4e13-8a2f-b91454bb057b DEFINE_GUID( FWPM_LAYER_ALE_RESOURCE_RELEASE_V6, 0xf4e5ce80, 0xedcc, 0x4e13, 0x8a, 0x2f, 0xb9, 0x14, 0x54, 0xbb, 0x05, 0x7b ); // b4766427-e2a2-467a-bd7e-dbcd1bd85a09 DEFINE_GUID( FWPM_LAYER_ALE_ENDPOINT_CLOSURE_V4, 0xb4766427, 0xe2a2, 0x467a, 0xbd, 0x7e, 0xdb, 0xcd, 0x1b, 0xd8, 0x5a, 0x09 ); // bb536ccd-4755-4ba9-9ff7-f9edf8699c7b DEFINE_GUID( FWPM_LAYER_ALE_ENDPOINT_CLOSURE_V6, 0xbb536ccd, 0x4755, 0x4ba9, 0x9f, 0xf7, 0xf9, 0xed, 0xf8, 0x69, 0x9c, 0x7b ); // c6e63c8c-b784-4562-aa7d-0a67cfcaf9a3 DEFINE_GUID( FWPM_LAYER_ALE_CONNECT_REDIRECT_V4, 0xc6e63c8c, 0xb784, 0x4562, 0xaa, 0x7d, 0x0a, 0x67, 0xcf, 0xca, 0xf9, 0xa3 ); // 587e54a7-8046-42ba-a0aa-b716250fc7fd DEFINE_GUID( FWPM_LAYER_ALE_CONNECT_REDIRECT_V6, 0x587e54a7, 0x8046, 0x42ba, 0xa0, 0xaa, 0xb7, 0x16, 0x25, 0x0f, 0xc7, 0xfd ); // 66978cad-c704-42ac-86ac-7c1a231bd253 DEFINE_GUID( FWPM_LAYER_ALE_BIND_REDIRECT_V4, 0x66978cad, 0xc704, 0x42ac, 0x86, 0xac, 0x7c, 0x1a, 0x23, 0x1b, 0xd2, 0x53 ); // bef02c9c-606b-4536-8c26-1c2fc7b631d4 DEFINE_GUID( FWPM_LAYER_ALE_BIND_REDIRECT_V6, 0xbef02c9c, 0x606b, 0x4536, 0x8c, 0x26, 0x1c, 0x2f, 0xc7, 0xb6, 0x31, 0xd4 ); // af52d8ec-cb2d-44e5-ad92-f8dc38d2eb29 DEFINE_GUID( FWPM_LAYER_STREAM_PACKET_V4, 0xaf52d8ec, 0xcb2d, 0x44e5, 0xad, 0x92, 0xf8, 0xdc, 0x38, 0xd2, 0xeb, 0x29 ); // 779a8ca3-f099-468f-b5d4-83535c461c02 DEFINE_GUID( FWPM_LAYER_STREAM_PACKET_V6, 0x779a8ca3, 0xf099, 0x468f, 0xb5, 0xd4, 0x83, 0x53, 0x5c, 0x46, 0x1c, 0x02 ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) /////////////////////////////////////////////////////////////////////////////// // // GUIDs for built-in sublayers. // /////////////////////////////////////////////////////////////////////////////// // 758c84f4-fb48-4de9-9aeb-3ed9551ab1fd DEFINE_GUID( FWPM_SUBLAYER_RPC_AUDIT, 0x758c84f4, 0xfb48, 0x4de9, 0x9a, 0xeb, 0x3e, 0xd9, 0x55, 0x1a, 0xb1, 0xfd ); // 83f299ed-9ff4-4967-aff4-c309f4dab827 DEFINE_GUID( FWPM_SUBLAYER_IPSEC_TUNNEL, 0x83f299ed, 0x9ff4, 0x4967, 0xaf, 0xf4, 0xc3, 0x09, 0xf4, 0xda, 0xb8, 0x27 ); // eebecc03-ced4-4380-819a-2734397b2b74 DEFINE_GUID( FWPM_SUBLAYER_UNIVERSAL, 0xeebecc03, 0xced4, 0x4380, 0x81, 0x9a, 0x27, 0x34, 0x39, 0x7b, 0x2b, 0x74 ); // 1b75c0ce-ff60-4711-a70f-b4958cc3b2d0 DEFINE_GUID( FWPM_SUBLAYER_LIPS, 0x1b75c0ce, 0xff60, 0x4711, 0xa7, 0x0f, 0xb4, 0x95, 0x8c, 0xc3, 0xb2, 0xd0 ); // 15a66e17-3f3c-4f7b-aa6c-812aa613dd82 DEFINE_GUID( FWPM_SUBLAYER_SECURE_SOCKET, 0x15a66e17, 0x3f3c, 0x4f7b, 0xaa, 0x6c, 0x81, 0x2a, 0xa6, 0x13, 0xdd, 0x82 ); // 337608b9-b7d5-4d5f-82f9-3618618bc058 DEFINE_GUID( FWPM_SUBLAYER_TCP_CHIMNEY_OFFLOAD, 0x337608b9, 0xb7d5, 0x4d5f, 0x82, 0xf9, 0x36, 0x18, 0x61, 0x8b, 0xc0, 0x58 ); // 877519e1-e6a9-41a5-81b4-8c4f118e4a60 DEFINE_GUID( FWPM_SUBLAYER_INSPECTION, 0x877519e1, 0xe6a9, 0x41a5, 0x81, 0xb4, 0x8c, 0x4f, 0x11, 0x8e, 0x4a, 0x60 ); // ba69dc66-5176-4979-9c89-26a7b46a8327 DEFINE_GUID( FWPM_SUBLAYER_TEREDO, 0xba69dc66, 0x5176, 0x4979, 0x9c, 0x89, 0x26, 0xa7, 0xb4, 0x6a, 0x83, 0x27 ); #define FWPM_SUBLAYER_EDGE_TRAVERSAL FWPM_SUBLAYER_TEREDO #if (NTDDI_VERSION >= NTDDI_WIN6SP1) // a5082e73-8f71-4559-8a9a-101cea04ef87 DEFINE_GUID( FWPM_SUBLAYER_IPSEC_FORWARD_OUTBOUND_TUNNEL, 0xa5082e73, 0x8f71, 0x4559, 0x8a, 0x9a, 0x10, 0x1c, 0xea, 0x04, 0xef, 0x87 ); #endif // (NTDDI_VERSION >= NTDDI_WIN6SP1) #if (NTDDI_VERSION >= NTDDI_WIN7) // e076d572-5d3d-48ef-802b-909eddb098bd DEFINE_GUID( FWPM_SUBLAYER_IPSEC_DOSP, 0xe076d572, 0x5d3d, 0x48ef, 0x80, 0x2b, 0x90, 0x9e, 0xdd, 0xb0, 0x98, 0xbd ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) /////////////////////////////////////////////////////////////////////////////// // // GUIDs for built-in conditions. // /////////////////////////////////////////////////////////////////////////////// #if (NTDDI_VERSION >= NTDDI_WIN7) // d999e981-7948-4c8e-b742-c84e3b678f8f DEFINE_GUID( FWPM_CONDITION_ETHER_DESTINATION_ADDRESS, 0xd999e981, 0x7948, 0x4c83, 0xb7, 0x42, 0xc8, 0x4e, 0x3b, 0x67, 0x8f, 0x8f ); // 408f2ed4-3a70-4b4d-92a6-415ac20e2f12 DEFINE_GUID( FWPM_CONDITION_ETHER_SOURCE_ADDRESS, 0x408f2ed4, 0x3a70, 0x4b4d, 0x92, 0xa6, 0x41, 0x5a, 0xc2, 0x0e, 0x2f, 0x12 ); // ad2a4e10-e9e9-4e27-9cfa-fd3e5d184c11 DEFINE_GUID( FWPM_CONDITION_ETHER_ADDRESS_TYPE, 0xad2a4e10, 0xe9e9, 0x4e27, 0x9c, 0xfa, 0xfd, 0x3e, 0x5d, 0x18, 0x4c, 0x11 ); // a38e51e9-0ac5-44eb-9387-a1c75b576e82 DEFINE_GUID( FWPM_CONDITION_ETHER_ENCAP_METHOD, 0xa38e51e9, 0x0ac5, 0x44eb, 0x93, 0x87, 0xa1, 0xc7, 0x5b, 0x57, 0x6e, 0x82 ); // fd08948d-a219-4d52-bb98-1a5540ee7b4e DEFINE_GUID( FWPM_CONDITION_ETHER_TYPE, 0xfd08948d, 0xa219, 0x4d52, 0xbb, 0x98, 0x1a, 0x55, 0x40, 0xee, 0x7b, 0x4e ); // c45f5381-0caf-47d0-b96c-238acb17806b DEFINE_GUID( FWPM_CONDITION_ETHER_SNAP_CONTROL, 0xc45f5381, 0x0caf, 0x47d0, 0xb9, 0x6c, 0x23, 0x8a, 0xcb, 0x17, 0x80, 0x6b ); // af37332e-d7dc-4a69-9f4e-3d683ab7365b DEFINE_GUID( FWPM_CONDITION_ETHER_SNAP_OUI, 0xaf37332e, 0xd7dc, 0x4a69, 0x9f, 0x4e, 0x3d, 0x68, 0x3a, 0xb7, 0x36, 0x5b ); // 938eab21-3618-4e64-9ca5-2141ebda1ca2 DEFINE_GUID( FWPM_CONDITION_ETHER_VLAN_TAG, 0x938eab21, 0x3618, 0x4e64, 0x9c, 0xa5, 0x21, 0x41, 0xeb, 0xda, 0x1c, 0xa2 ); #endif #define FWPM_CONDITION_INTERFACE_LUID FWPM_CONDITION_IP_LOCAL_INTERFACE // d9ee00de-c1ef-4617-bfe3-ffd8f5a08957 DEFINE_GUID( FWPM_CONDITION_IP_LOCAL_ADDRESS, 0xd9ee00de, 0xc1ef, 0x4617, 0xbf, 0xe3, 0xff, 0xd8, 0xf5, 0xa0, 0x89, 0x57 ); // b235ae9a-1d64-49b8-a44c-5ff3d9095045 DEFINE_GUID( FWPM_CONDITION_IP_REMOTE_ADDRESS, 0xb235ae9a, 0x1d64, 0x49b8, 0xa4, 0x4c, 0x5f, 0xf3, 0xd9, 0x09, 0x50, 0x45 ); // ae96897e-2e94-4bc9-b313-b27ee80e574d DEFINE_GUID( FWPM_CONDITION_IP_SOURCE_ADDRESS, 0xae96897e, 0x2e94, 0x4bc9, 0xb3, 0x13, 0xb2, 0x7e, 0xe8, 0x0e, 0x57, 0x4d ); // 2d79133b-b390-45c6-8699-acaceaafed33 DEFINE_GUID( FWPM_CONDITION_IP_DESTINATION_ADDRESS, 0x2d79133b, 0xb390, 0x45c6, 0x86, 0x99, 0xac, 0xac, 0xea, 0xaf, 0xed, 0x33 ); // 6ec7f6c4-376b-45d7-9e9c-d337cedcd237 DEFINE_GUID( FWPM_CONDITION_IP_LOCAL_ADDRESS_TYPE, 0x6ec7f6c4, 0x376b, 0x45d7, 0x9e, 0x9c, 0xd3, 0x37, 0xce, 0xdc, 0xd2, 0x37 ); // 1ec1b7c9-4eea-4f5e-b9ef-76beaaaf17ee DEFINE_GUID( FWPM_CONDITION_IP_DESTINATION_ADDRESS_TYPE, 0x1ec1b7c9, 0x4eea, 0x4f5e, 0xb9, 0xef, 0x76, 0xbe, 0xaa, 0xaf, 0x17, 0xee ); #if (NTDDI_VERSION >= NTDDI_WIN7) // eabe448a-a711-4d64-85b7-3f76b65299c7 DEFINE_GUID( FWPM_CONDITION_IP_NEXTHOP_ADDRESS, 0xeabe448a, 0xa711, 0x4d64, 0x85, 0xb7, 0x3f, 0x76, 0xb6, 0x52, 0x99, 0xc7 ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) // 4cd62a49-59c3-4969-b7f3-bda5d32890a4 DEFINE_GUID( FWPM_CONDITION_IP_LOCAL_INTERFACE, 0x4cd62a49, 0x59c3, 0x4969, 0xb7, 0xf3, 0xbd, 0xa5, 0xd3, 0x28, 0x90, 0xa4 ); #if (NTDDI_VERSION >= NTDDI_WIN6SP1) // 618a9b6d-386b-4136-ad6e-b51587cfb1cd DEFINE_GUID( FWPM_CONDITION_IP_ARRIVAL_INTERFACE, 0x618a9b6d, 0x386b, 0x4136, 0xad, 0x6e, 0xb5, 0x15, 0x87, 0xcf, 0xb1, 0xcd ); // 89f990de-e798-4e6d-ab76-7c9558292e6f DEFINE_GUID( FWPM_CONDITION_ARRIVAL_INTERFACE_TYPE, 0x89f990de, 0xe798, 0x4e6d, 0xab, 0x76, 0x7c, 0x95, 0x58, 0x29, 0x2e, 0x6f ); // 511166dc-7a8c-4aa7-b533-95ab59fb0340 DEFINE_GUID( FWPM_CONDITION_ARRIVAL_TUNNEL_TYPE, 0x511166dc, 0x7a8c, 0x4aa7, 0xb5, 0x33, 0x95, 0xab, 0x59, 0xfb, 0x03, 0x40 ); // cc088db3-1792-4a71-b0f9-037d21cd828b DEFINE_GUID( FWPM_CONDITION_ARRIVAL_INTERFACE_INDEX, 0xcc088db3, 0x1792, 0x4a71, 0xb0, 0xf9, 0x03, 0x7d, 0x21, 0xcd, 0x82, 0x8b ); #if (NTDDI_VERSION >= NTDDI_WIN7) // ef8a6122-0577-45a7-9aaf-825fbeb4fb95 DEFINE_GUID( FWPM_CONDITION_NEXTHOP_SUB_INTERFACE_INDEX, 0xef8a6122, 0x0577, 0x45a7, 0x9a, 0xaf, 0x82, 0x5f, 0xbe, 0xb4, 0xfb, 0x95 ); // 93ae8f5b-7f6f-4719-98c8-14e97429ef04 DEFINE_GUID( FWPM_CONDITION_IP_NEXTHOP_INTERFACE, 0x93ae8f5b, 0x7f6f, 0x4719, 0x98, 0xc8, 0x14, 0xe9, 0x74, 0x29, 0xef, 0x04 ); // 97537c6c-d9a3-4767-a381-e942675cd920 DEFINE_GUID( FWPM_CONDITION_NEXTHOP_INTERFACE_TYPE, 0x97537c6c, 0xd9a3, 0x4767, 0xa3, 0x81, 0xe9, 0x42, 0x67, 0x5c, 0xd9, 0x20 ); // 72b1a111-987b-4720-99dd-c7c576fa2d4c DEFINE_GUID( FWPM_CONDITION_NEXTHOP_TUNNEL_TYPE, 0x72b1a111, 0x987b, 0x4720, 0x99, 0xdd, 0xc7, 0xc5, 0x76, 0xfa, 0x2d, 0x4c ); // 138e6888-7ab8-4d65-9ee8-0591bcf6a494 DEFINE_GUID( FWPM_CONDITION_NEXTHOP_INTERFACE_INDEX, 0x138e6888, 0x7ab8, 0x4d65, 0x9e, 0xe8, 0x05, 0x91, 0xbc, 0xf6, 0xa4, 0x94 ); // 46ea1551-2255-492b-8019-aabeee349f40 DEFINE_GUID( FWPM_CONDITION_ORIGINAL_PROFILE_ID, 0x46ea1551, 0x2255, 0x492b, 0x80, 0x19, 0xaa, 0xbe, 0xee, 0x34, 0x9f, 0x40 ); // ab3033c9-c0e3-4759-937d-5758c65d4ae3 DEFINE_GUID( FWPM_CONDITION_CURRENT_PROFILE_ID, 0xab3033c9, 0xc0e3, 0x4759, 0x93, 0x7d, 0x57, 0x58, 0xc6, 0x5d, 0x4a, 0xe3 ); // 4ebf7562-9f18-4d06-9941-a7a625744d71 DEFINE_GUID( FWPM_CONDITION_LOCAL_INTERFACE_PROFILE_ID, 0x4ebf7562, 0x9f18, 0x4d06, 0x99, 0x41, 0xa7, 0xa6, 0x25, 0x74, 0x4d, 0x71 ); // cdfe6aab-c083-4142-8679-c08f95329c61 DEFINE_GUID( FWPM_CONDITION_ARRIVAL_INTERFACE_PROFILE_ID, 0xcdfe6aab, 0xc083, 0x4142, 0x86, 0x79, 0xc0, 0x8f, 0x95, 0x32, 0x9c, 0x61 ); // d7ff9a56-cdaa-472b-84db-d23963c1d1bf DEFINE_GUID( FWPM_CONDITION_NEXTHOP_INTERFACE_PROFILE_ID, 0xd7ff9a56, 0xcdaa, 0x472b, 0x84, 0xdb, 0xd2, 0x39, 0x63, 0xc1, 0xd1, 0xbf ); // 11205e8c-11ae-457a-8a44-477026dd764a DEFINE_GUID( FWPM_CONDITION_REAUTHORIZE_REASON, 0x11205e8c, 0x11ae, 0x457a, 0x8a, 0x44, 0x47, 0x70, 0x26, 0xdd, 0x76, 0x4a ); // 076dfdbe-c56c-4f72-ae8a-2cfe7e5c8286 DEFINE_GUID( FWPM_CONDITION_ORIGINAL_ICMP_TYPE, 0x076dfdbe, 0xc56c, 0x4f72, 0xae, 0x8a, 0x2c, 0xfe, 0x7e, 0x5c, 0x82, 0x86 ); // da50d5c8-fa0d-4c89-b032-6e62136d1e96 DEFINE_GUID( FWPM_CONDITION_IP_PHYSICAL_ARRIVAL_INTERFACE, 0xda50d5c8, 0xfa0d, 0x4c89, 0xb0, 0x32, 0x6e, 0x62, 0x13, 0x6d, 0x1e, 0x96 ); // f09bd5ce-5150-48be-b098-c25152fb1f92 DEFINE_GUID( FWPM_CONDITION_IP_PHYSICAL_NEXTHOP_INTERFACE, 0xf09bd5ce, 0x5150, 0x48be, 0xb0, 0x98, 0xc2, 0x51, 0x52, 0xfb, 0x1f, 0x92 ); // cce68d5e-053b-43a8-9a6f-33384c28e4f6 DEFINE_GUID( FWPM_CONDITION_INTERFACE_QUARANTINE_EPOCH, 0xcce68d5e, 0x053b, 0x43a8, 0x9a, 0x6f, 0x33, 0x38, 0x4c, 0x28, 0xe4, 0xf6 ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) #endif // (NTDDI_VERSION >= NTDDI_WIN6SP1) // daf8cd14-e09e-4c93-a5ae-c5c13b73ffca DEFINE_GUID( FWPM_CONDITION_INTERFACE_TYPE, 0xdaf8cd14, 0xe09e, 0x4c93, 0xa5, 0xae, 0xc5, 0xc1, 0x3b, 0x73, 0xff, 0xca ); #if (NTDDI_VERSION >= NTDDI_WIN6SP1) #define FWPM_CONDITION_LOCAL_INTERFACE_TYPE FWPM_CONDITION_INTERFACE_TYPE #endif // (NTDDI_VERSION >= NTDDI_WIN6SP1) // 77a40437-8779-4868-a261-f5a902f1c0cd DEFINE_GUID( FWPM_CONDITION_TUNNEL_TYPE, 0x77a40437, 0x8779, 0x4868, 0xa2, 0x61, 0xf5, 0xa9, 0x02, 0xf1, 0xc0, 0xcd ); #if (NTDDI_VERSION >= NTDDI_WIN6SP1) #define FWPM_CONDITION_LOCAL_TUNNEL_TYPE FWPM_CONDITION_TUNNEL_TYPE #endif // (NTDDI_VERSION >= NTDDI_WIN6SP1) // 1076b8a5-6323-4c5e-9810-e8d3fc9e6136 DEFINE_GUID( FWPM_CONDITION_IP_FORWARD_INTERFACE, 0x1076b8a5, 0x6323, 0x4c5e, 0x98, 0x10, 0xe8, 0xd3, 0xfc, 0x9e, 0x61, 0x36 ); // 3971ef2b-623e-4f9a-8cb1-6e79b806b9a7 DEFINE_GUID( FWPM_CONDITION_IP_PROTOCOL, 0x3971ef2b, 0x623e, 0x4f9a, 0x8c, 0xb1, 0x6e, 0x79, 0xb8, 0x06, 0xb9, 0xa7 ); // 0c1ba1af-5765-453f-af22-a8f791ac775b DEFINE_GUID( FWPM_CONDITION_IP_LOCAL_PORT, 0x0c1ba1af, 0x5765, 0x453f, 0xaf, 0x22, 0xa8, 0xf7, 0x91, 0xac, 0x77, 0x5b ); #define FWPM_CONDITION_ICMP_TYPE FWPM_CONDITION_IP_LOCAL_PORT // c35a604d-d22b-4e1a-91b4-68f674ee674b DEFINE_GUID( FWPM_CONDITION_IP_REMOTE_PORT, 0xc35a604d, 0xd22b, 0x4e1a, 0x91, 0xb4, 0x68, 0xf6, 0x74, 0xee, 0x67, 0x4b ); #define FWPM_CONDITION_ICMP_CODE FWPM_CONDITION_IP_REMOTE_PORT // 4672a468-8a0a-4202-abb4-849e92e66809 DEFINE_GUID( FWPM_CONDITION_EMBEDDED_LOCAL_ADDRESS_TYPE, 0x4672a468, 0x8a0a, 0x4202, 0xab, 0xb4, 0x84, 0x9e, 0x92, 0xe6, 0x68, 0x09 ); // 77ee4b39-3273-4671-b63b-ab6feb66eeb6 DEFINE_GUID( FWPM_CONDITION_EMBEDDED_REMOTE_ADDRESS, 0x77ee4b39, 0x3273, 0x4671, 0xb6, 0x3b, 0xab, 0x6f, 0xeb, 0x66, 0xee, 0xb6 ); // 07784107-a29e-4c7b-9ec7-29c44afafdbc DEFINE_GUID( FWPM_CONDITION_EMBEDDED_PROTOCOL, 0x07784107, 0xa29e, 0x4c7b, 0x9e, 0xc7, 0x29, 0xc4, 0x4a, 0xfa, 0xfd, 0xbc ); // bfca394d-acdb-484e-b8e6-2aff79757345 DEFINE_GUID( FWPM_CONDITION_EMBEDDED_LOCAL_PORT, 0xbfca394d, 0xacdb, 0x484e, 0xb8, 0xe6, 0x2a, 0xff, 0x79, 0x75, 0x73, 0x45 ); // cae4d6a1-2968-40ed-a4ce-547160dda88d DEFINE_GUID( FWPM_CONDITION_EMBEDDED_REMOTE_PORT, 0xcae4d6a1, 0x2968, 0x40ed, 0xa4, 0xce, 0x54, 0x71, 0x60, 0xdd, 0xa8, 0x8d ); // 632ce23b-5167-435c-86d7-e903684aa80c DEFINE_GUID( FWPM_CONDITION_FLAGS, 0x632ce23b, 0x5167, 0x435c, 0x86, 0xd7, 0xe9, 0x03, 0x68, 0x4a, 0xa8, 0x0c ); // 8784c146-ca97-44d6-9fd1-19fb1840cbf7 DEFINE_GUID( FWPM_CONDITION_DIRECTION, 0x8784c146, 0xca97, 0x44d6, 0x9f, 0xd1, 0x19, 0xfb, 0x18, 0x40, 0xcb, 0xf7 ); // 667fd755-d695-434a-8af5-d3835a1259bc DEFINE_GUID( FWPM_CONDITION_INTERFACE_INDEX, 0x667fd755, 0xd695, 0x434a, 0x8a, 0xf5, 0xd3, 0x83, 0x5a, 0x12, 0x59, 0xbc ); #if (NTDDI_VERSION >= NTDDI_WIN6SP1) #define FWPM_CONDITION_LOCAL_INTERFACE_INDEX FWPM_CONDITION_INTERFACE_INDEX #endif // (NTDDI_VERSION >= NTDDI_WIN6SP1) // 0cd42473-d621-4be3-ae8c-72a348d283e1 DEFINE_GUID( FWPM_CONDITION_SUB_INTERFACE_INDEX, 0x0cd42473, 0xd621, 0x4be3, 0xae, 0x8c, 0x72, 0xa3, 0x48, 0xd2, 0x83, 0xe1 ); #if (NTDDI_VERSION >= NTDDI_WIN6SP1) #define FWPM_CONDITION_ARRIVAL_SUB_INTERFACE_INDEX \ FWPM_CONDITION_SUB_INTERFACE_INDEX #endif // (NTDDI_VERSION >= NTDDI_WIN6SP1) // 2311334d-c92d-45bf-9496-edf447820e2d DEFINE_GUID( FWPM_CONDITION_SOURCE_INTERFACE_INDEX, 0x2311334d, 0xc92d, 0x45bf, 0x94, 0x96, 0xed, 0xf4, 0x47, 0x82, 0x0e, 0x2d ); // 055edd9d-acd2-4361-8dab-f9525d97662f DEFINE_GUID( FWPM_CONDITION_SOURCE_SUB_INTERFACE_INDEX, 0x055edd9d, 0xacd2, 0x4361, 0x8d, 0xab, 0xf9, 0x52, 0x5d, 0x97, 0x66, 0x2f ); // 35cf6522-4139-45ee-a0d5-67b80949d879 DEFINE_GUID( FWPM_CONDITION_DESTINATION_INTERFACE_INDEX, 0x35cf6522, 0x4139, 0x45ee, 0xa0, 0xd5, 0x67, 0xb8, 0x09, 0x49, 0xd8, 0x79 ); // 2b7d4399-d4c7-4738-a2f5-e994b43da388 DEFINE_GUID( FWPM_CONDITION_DESTINATION_SUB_INTERFACE_INDEX, 0x2b7d4399, 0xd4c7, 0x4738, 0xa2, 0xf5, 0xe9, 0x94, 0xb4, 0x3d, 0xa3, 0x88 ); // d78e1e87-8644-4ea5-9437-d809ecefc971 DEFINE_GUID( FWPM_CONDITION_ALE_APP_ID, 0xd78e1e87, 0x8644, 0x4ea5, 0x94, 0x37, 0xd8, 0x09, 0xec, 0xef, 0xc9, 0x71 ); // af043a0a-b34d-4f86-979c-c90371af6e66 DEFINE_GUID( FWPM_CONDITION_ALE_USER_ID, 0xaf043a0a, 0xb34d, 0x4f86, 0x97, 0x9c, 0xc9, 0x03, 0x71, 0xaf, 0x6e, 0x66 ); // f63073b7-0189-4ab0-95a4-6123cbfab862 DEFINE_GUID( FWPM_CONDITION_ALE_REMOTE_USER_ID, 0xf63073b7, 0x0189, 0x4ab0, 0x95, 0xa4, 0x61, 0x23, 0xcb, 0xfa, 0xb8, 0x62 ); // 1aa47f51-7f93-4508-a271-81abb00c9cab DEFINE_GUID( FWPM_CONDITION_ALE_REMOTE_MACHINE_ID, 0x1aa47f51, 0x7f93, 0x4508, 0xa2, 0x71, 0x81, 0xab, 0xb0, 0x0c, 0x9c, 0xab ); // 1c974776-7182-46e9-afd3-b02910e30334 DEFINE_GUID( FWPM_CONDITION_ALE_PROMISCUOUS_MODE, 0x1c974776, 0x7182, 0x46e9, 0xaf, 0xd3, 0xb0, 0x29, 0x10, 0xe3, 0x03, 0x34 ); // b9f4e088-cb98-4efb-a2c7-ad07332643db DEFINE_GUID( FWPM_CONDITION_ALE_SIO_FIREWALL_SYSTEM_PORT, 0xb9f4e088, 0xcb98, 0x4efb, 0xa2, 0xc7, 0xad, 0x07, 0x33, 0x26, 0x43, 0xdb ); #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPM_CONDITION_ALE_SIO_FIREWALL_SOCKET_PROPERTY \ FWPM_CONDITION_ALE_SIO_FIREWALL_SYSTEM_PORT // b482d227-1979-4a98-8044-18bbe6237542 DEFINE_GUID( FWPM_CONDITION_ALE_REAUTH_REASON, 0xb482d227, 0x1979, 0x4a98, 0x80, 0x44, 0x18, 0xbb, 0xe6, 0x23, 0x75, 0x42 ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) // 46275a9d-c03f-4d77-b784-1c57f4d02753 DEFINE_GUID( FWPM_CONDITION_ALE_NAP_CONTEXT, 0x46275a9d, 0xc03f, 0x4d77, 0xb7, 0x84, 0x1c, 0x57, 0xf4, 0xd0, 0x27, 0x53 ); #if (NTDDI_VERSION >= NTDDI_WIN7) // 35d0ea0e-15ca-492b-900e-97fd46352cce DEFINE_GUID( FWPM_CONDITION_KM_AUTH_NAP_CONTEXT, 0x35d0ea0e, 0x15ca, 0x492b, 0x90, 0x0e, 0x97, 0xfd, 0x46, 0x35, 0x2c, 0xce ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) // 9bf0ee66-06c9-41b9-84da-288cb43af51f DEFINE_GUID( FWPM_CONDITION_REMOTE_USER_TOKEN, 0x9bf0ee66, 0x06c9, 0x41b9, 0x84, 0xda, 0x28, 0x8c, 0xb4, 0x3a, 0xf5, 0x1f ); // 7c9c7d9f-0075-4d35-a0d1-8311c4cf6af1 DEFINE_GUID( FWPM_CONDITION_RPC_IF_UUID, 0x7c9c7d9f, 0x0075, 0x4d35, 0xa0, 0xd1, 0x83, 0x11, 0xc4, 0xcf, 0x6a, 0xf1 ); // eabfd9b7-1262-4a2e-adaa-5f96f6fe326d DEFINE_GUID( FWPM_CONDITION_RPC_IF_VERSION, 0xeabfd9b7, 0x1262, 0x4a2e, 0xad, 0xaa, 0x5f, 0x96, 0xf6, 0xfe, 0x32, 0x6d ); // 238a8a32-3199-467d-871c-272621ab3896 DEFINE_GUID( FWPM_CONDITION_RPC_IF_FLAG, 0x238a8a32, 0x3199, 0x467d, 0x87, 0x1c, 0x27, 0x26, 0x21, 0xab, 0x38, 0x96 ); // ff2e7b4d-3112-4770-b636-4d24ae3a6af2 DEFINE_GUID( FWPM_CONDITION_DCOM_APP_ID, 0xff2e7b4d, 0x3112, 0x4770, 0xb6, 0x36, 0x4d, 0x24, 0xae, 0x3a, 0x6a, 0xf2 ); // d024de4d-deaa-4317-9c85-e40ef6e140c3 DEFINE_GUID( FWPM_CONDITION_IMAGE_NAME, 0xd024de4d, 0xdeaa, 0x4317, 0x9c, 0x85, 0xe4, 0x0e, 0xf6, 0xe1, 0x40, 0xc3 ); // 2717bc74-3a35-4ce7-b7ef-c838fabdec45 DEFINE_GUID( FWPM_CONDITION_RPC_PROTOCOL, 0x2717bc74, 0x3a35, 0x4ce7, 0xb7, 0xef, 0xc8, 0x38, 0xfa, 0xbd, 0xec, 0x45 ); // daba74ab-0d67-43e7-986e-75b84f82f594 DEFINE_GUID( FWPM_CONDITION_RPC_AUTH_TYPE, 0xdaba74ab, 0x0d67, 0x43e7, 0x98, 0x6e, 0x75, 0xb8, 0x4f, 0x82, 0xf5, 0x94 ); // e5a0aed5-59ac-46ea-be05-a5f05ecf446e DEFINE_GUID( FWPM_CONDITION_RPC_AUTH_LEVEL, 0xe5a0aed5, 0x59ac, 0x46ea, 0xbe, 0x05, 0xa5, 0xf0, 0x5e, 0xcf, 0x44, 0x6e ); // 0d306ef0-e974-4f74-b5c7-591b0da7d562 DEFINE_GUID( FWPM_CONDITION_SEC_ENCRYPT_ALGORITHM, 0x0d306ef0, 0xe974, 0x4f74, 0xb5, 0xc7, 0x59, 0x1b, 0x0d, 0xa7, 0xd5, 0x62 ); // 4772183b-ccf8-4aeb-bce1-c6c6161c8fe4 DEFINE_GUID( FWPM_CONDITION_SEC_KEY_SIZE, 0x4772183b, 0xccf8, 0x4aeb, 0xbc, 0xe1, 0xc6, 0xc6, 0x16, 0x1c, 0x8f, 0xe4 ); // 03a629cb-6e52-49f8-9c41-5709633c09cf DEFINE_GUID( FWPM_CONDITION_IP_LOCAL_ADDRESS_V4, 0x03a629cb, 0x6e52, 0x49f8, 0x9c, 0x41, 0x57, 0x09, 0x63, 0x3c, 0x09, 0xcf ); // 2381be84-7524-45b3-a05b-1e637d9c7a6a DEFINE_GUID( FWPM_CONDITION_IP_LOCAL_ADDRESS_V6, 0x2381be84, 0x7524, 0x45b3, 0xa0, 0x5b, 0x1e, 0x63, 0x7d, 0x9c, 0x7a, 0x6a ); // 1bd0741d-e3df-4e24-8634-762046eef6eb DEFINE_GUID( FWPM_CONDITION_PIPE, 0x1bd0741d, 0xe3df, 0x4e24, 0x86, 0x34, 0x76, 0x20, 0x46, 0xee, 0xf6, 0xeb ); // 1febb610-3bcc-45e1-bc36-2e067e2cb186 DEFINE_GUID( FWPM_CONDITION_IP_REMOTE_ADDRESS_V4, 0x1febb610, 0x3bcc, 0x45e1, 0xbc, 0x36, 0x2e, 0x06, 0x7e, 0x2c, 0xb1, 0x86 ); // 246e1d8c-8bee-4018-9b98-31d4582f3361 DEFINE_GUID( FWPM_CONDITION_IP_REMOTE_ADDRESS_V6, 0x246e1d8c, 0x8bee, 0x4018, 0x9b, 0x98, 0x31, 0xd4, 0x58, 0x2f, 0x33, 0x61 ); // e31180a8-bbbd-4d14-a65e-7157b06233bb DEFINE_GUID( FWPM_CONDITION_PROCESS_WITH_RPC_IF_UUID, 0xe31180a8, 0xbbbd, 0x4d14, 0xa6, 0x5e, 0x71, 0x57, 0xb0, 0x62, 0x33, 0xbb ); // dccea0b9-0886-4360-9c6a-ab043a24fba9 DEFINE_GUID( FWPM_CONDITION_RPC_EP_VALUE, 0xdccea0b9, 0x0886, 0x4360, 0x9c, 0x6a, 0xab, 0x04, 0x3a, 0x24, 0xfb, 0xa9 ); // 218b814a-0a39-49b8-8e71-c20c39c7dd2e DEFINE_GUID( FWPM_CONDITION_RPC_EP_FLAGS, 0x218b814a, 0x0a39, 0x49b8, 0x8e, 0x71, 0xc2, 0x0c, 0x39, 0xc7, 0xdd, 0x2e ); // c228fc1e-403a-4478-be05-c9baa4c05ace DEFINE_GUID( FWPM_CONDITION_CLIENT_TOKEN, 0xc228fc1e, 0x403a, 0x4478, 0xbe, 0x05, 0xc9, 0xba, 0xa4, 0xc0, 0x5a, 0xce ); // b605a225-c3b3-48c7-9833-7aefa9527546 DEFINE_GUID( FWPM_CONDITION_RPC_SERVER_NAME, 0xb605a225, 0xc3b3, 0x48c7, 0x98, 0x33, 0x7a, 0xef, 0xa9, 0x52, 0x75, 0x46 ); // 8090f645-9ad5-4e3b-9f9f-8023ca097909 DEFINE_GUID( FWPM_CONDITION_RPC_SERVER_PORT, 0x8090f645, 0x9ad5, 0x4e3b, 0x9f, 0x9f, 0x80, 0x23, 0xca, 0x09, 0x79, 0x09 ); // 40953fe2-8565-4759-8488-1771b4b4b5db DEFINE_GUID( FWPM_CONDITION_RPC_PROXY_AUTH_TYPE, 0x40953fe2, 0x8565, 0x4759, 0x84, 0x88, 0x17, 0x71, 0xb4, 0xb4, 0xb5, 0xdb ); // a3ec00c7-05f4-4df7-91f2-5f60d91ff443 DEFINE_GUID( FWPM_CONDITION_CLIENT_CERT_KEY_LENGTH, 0xa3ec00c7, 0x05f4, 0x4df7, 0x91, 0xf2, 0x5f, 0x60, 0xd9, 0x1f, 0xf4, 0x43 ); // c491ad5e-f882-4283-b916-436b103ff4ad DEFINE_GUID( FWPM_CONDITION_CLIENT_CERT_OID, 0xc491ad5e, 0xf882, 0x4283, 0xb9, 0x16, 0x43, 0x6b, 0x10, 0x3f, 0xf4, 0xad ); // 206e9996-490e-40cf-b831-b38641eb6fcb DEFINE_GUID( FWPM_CONDITION_NET_EVENT_TYPE, 0x206e9996, 0x490e, 0x40cf, 0xb8, 0x31, 0xb3, 0x86, 0x41, 0xeb, 0x6f, 0xcb ); #if (NTDDI_VERSION >= NTDDI_WIN7) // 9b539082-eb90-4186-a6cc-de5b63235016 DEFINE_GUID( FWPM_CONDITION_PEER_NAME, 0x9b539082, 0xeb90, 0x4186, 0xa6, 0xcc, 0xde, 0x5b, 0x63, 0x23, 0x50, 0x16 ); //f68166fd-0682-4c89-b8f5-86436c7ef9b7 DEFINE_GUID( FWPM_CONDITION_REMOTE_ID, 0xf68166fd, 0x0682, 0x4c89, 0xb8, 0xf5, 0x86, 0x43, 0x6c, 0x7e, 0xf9, 0xb7 ); //eb458cd5-da7b-4ef9-8d43-7b0a840332f2 DEFINE_GUID( FWPM_CONDITION_AUTHENTICATION_TYPE, 0xeb458cd5, 0xda7b, 0x4ef9, 0x8d, 0x43, 0x7b, 0x0a, 0x84, 0x03, 0x32, 0xf2 ); //ff0f5f49-0ceb-481b-8638-1479791f3f2c DEFINE_GUID( FWPM_CONDITION_KM_TYPE, 0xff0f5f49, 0x0ceb, 0x481b, 0x86, 0x38, 0x14, 0x79, 0x79, 0x1f, 0x3f, 0x2c ); //feef4582-ef8f-4f7b-858b-9077d122de47 DEFINE_GUID( FWPM_CONDITION_KM_MODE, 0xfeef4582, 0xef8f, 0x4f7b, 0x85, 0x8b, 0x90, 0x77, 0xd1, 0x22, 0xde, 0x47 ); //ad37dee3-722f-45cc-a4e3-068048124452 DEFINE_GUID( FWPM_CONDITION_IPSEC_POLICY_KEY, 0xad37dee3, 0x722f, 0x45cc, 0xa4, 0xe3, 0x06, 0x80, 0x48, 0x12, 0x44, 0x52 ); #endif /////////////////////////////////////////////////////////////////////////////// // // GUIDs for built-in providers. // /////////////////////////////////////////////////////////////////////////////// // 10ad9216-ccde-456c-8b16-e9f04e60a90b DEFINE_GUID( FWPM_PROVIDER_IKEEXT, 0x10ad9216, 0xccde, 0x456c, 0x8b, 0x16, 0xe9, 0xf0, 0x4e, 0x60, 0xa9, 0x0b ); #if (NTDDI_VERSION >= NTDDI_WIN7) // 3c6c05a9-c05c-4bb9-8338-2327814ce8bf DEFINE_GUID( FWPM_PROVIDER_IPSEC_DOSP_CONFIG, 0x3c6c05a9, 0xc05c, 0x4bb9, 0x83, 0x38, 0x23, 0x27, 0x81, 0x4c, 0xe8, 0xbf ); #endif // 896aa19e-9a34-4bcb-ae79-beb9127c84b9 DEFINE_GUID( FWPM_PROVIDER_TCP_CHIMNEY_OFFLOAD, 0x896aa19e, 0x9a34, 0x4bcb, 0xae, 0x79, 0xbe, 0xb9, 0x12, 0x7c, 0x84, 0xb9 ); /////////////////////////////////////////////////////////////////////////////// // // GUIDs for built-in callouts. // /////////////////////////////////////////////////////////////////////////////// // 5132900d-5e84-4b5f-80e4-01741e81ff10 DEFINE_GUID( FWPM_CALLOUT_IPSEC_INBOUND_TRANSPORT_V4, 0x5132900d, 0x5e84, 0x4b5f, 0x80, 0xe4, 0x01, 0x74, 0x1e, 0x81, 0xff, 0x10 ); // 49d3ac92-2a6c-4dcf-955f-1c3be009dd99 DEFINE_GUID( FWPM_CALLOUT_IPSEC_INBOUND_TRANSPORT_V6, 0x49d3ac92, 0x2a6c, 0x4dcf, 0x95, 0x5f, 0x1c, 0x3b, 0xe0, 0x09, 0xdd, 0x99 ); // 4b46bf0a-4523-4e57-aa38-a87987c910d9 DEFINE_GUID( FWPM_CALLOUT_IPSEC_OUTBOUND_TRANSPORT_V4, 0x4b46bf0a, 0x4523, 0x4e57, 0xaa, 0x38, 0xa8, 0x79, 0x87, 0xc9, 0x10, 0xd9 ); // 38d87722-ad83-4f11-a91f-df0fb077225b DEFINE_GUID( FWPM_CALLOUT_IPSEC_OUTBOUND_TRANSPORT_V6, 0x38d87722, 0xad83, 0x4f11, 0xa9, 0x1f, 0xdf, 0x0f, 0xb0, 0x77, 0x22, 0x5b ); // 191a8a46-0bf8-46cf-b045-4b45dfa6a324 DEFINE_GUID( FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_V4, 0x191a8a46, 0x0bf8, 0x46cf, 0xb0, 0x45, 0x4b, 0x45, 0xdf, 0xa6, 0xa3, 0x24 ); // 80c342e3-1e53-4d6f-9b44-03df5aeee154 DEFINE_GUID( FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_V6, 0x80c342e3, 0x1e53, 0x4d6f, 0x9b, 0x44, 0x03, 0xdf, 0x5a, 0xee, 0xe1, 0x54 ); // 70a4196c-835b-4fb0-98e8-075f4d977d46 DEFINE_GUID( FWPM_CALLOUT_IPSEC_OUTBOUND_TUNNEL_V4, 0x70a4196c, 0x835b, 0x4fb0, 0x98, 0xe8, 0x07, 0x5f, 0x4d, 0x97, 0x7d, 0x46 ); // f1835363-a6a5-4e62-b180-23db789d8da6 DEFINE_GUID( FWPM_CALLOUT_IPSEC_OUTBOUND_TUNNEL_V6, 0xf1835363, 0xa6a5, 0x4e62, 0xb1, 0x80, 0x23, 0xdb, 0x78, 0x9d, 0x8d, 0xa6 ); // 28829633-c4f0-4e66-873f-844db2a899c7 DEFINE_GUID( FWPM_CALLOUT_IPSEC_FORWARD_INBOUND_TUNNEL_V4, 0x28829633, 0xc4f0, 0x4e66, 0x87, 0x3f, 0x84, 0x4d, 0xb2, 0xa8, 0x99, 0xc7 ); // af50bec2-c686-429a-884d-b74443e7b0b4 DEFINE_GUID( FWPM_CALLOUT_IPSEC_FORWARD_INBOUND_TUNNEL_V6, 0xaf50bec2, 0xc686, 0x429a, 0x88, 0x4d, 0xb7, 0x44, 0x43, 0xe7, 0xb0, 0xb4 ); // fb532136-15cb-440b-937c-1717ca320c40 DEFINE_GUID( FWPM_CALLOUT_IPSEC_FORWARD_OUTBOUND_TUNNEL_V4, 0xfb532136, 0x15cb, 0x440b, 0x93, 0x7c, 0x17, 0x17, 0xca, 0x32, 0x0c, 0x40 ); // dae640cc-e021-4bee-9eb6-a48b275c8c1d DEFINE_GUID( FWPM_CALLOUT_IPSEC_FORWARD_OUTBOUND_TUNNEL_V6, 0xdae640cc, 0xe021, 0x4bee, 0x9e, 0xb6, 0xa4, 0x8b, 0x27, 0x5c, 0x8c, 0x1d ); // 7dff309b-ba7d-4aba-91aa-ae5c6640c944 DEFINE_GUID( FWPM_CALLOUT_IPSEC_INBOUND_INITIATE_SECURE_V4, 0x7dff309b, 0xba7d, 0x4aba, 0x91, 0xaa, 0xae, 0x5c, 0x66, 0x40, 0xc9, 0x44 ); // a9a0d6d9-c58c-474e-8aeb-3cfe99d6d53d DEFINE_GUID( FWPM_CALLOUT_IPSEC_INBOUND_INITIATE_SECURE_V6, 0xa9a0d6d9, 0xc58c, 0x474e, 0x8a, 0xeb, 0x3c, 0xfe, 0x99, 0xd6, 0xd5, 0x3d ); // 3df6e7de-fd20-48f2-9f26-f854444cba79 DEFINE_GUID( FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_ALE_ACCEPT_V4, 0x3df6e7de, 0xfd20, 0x48f2, 0x9f, 0x26, 0xf8, 0x54, 0x44, 0x4c, 0xba, 0x79 ); // a1e392d3-72ac-47bb-87a7-0122c69434ab DEFINE_GUID( FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_ALE_ACCEPT_V6, 0xa1e392d3, 0x72ac, 0x47bb, 0x87, 0xa7, 0x01, 0x22, 0xc6, 0x94, 0x34, 0xab ); // 6ac141fc-f75d-4203-b9c8-48e6149c2712 DEFINE_GUID( FWPM_CALLOUT_IPSEC_ALE_CONNECT_V4, 0x6ac141fc, 0xf75d, 0x4203, 0xb9,0xc8,0x48, 0xe6, 0x14, 0x9c, 0x27, 0x12 ); // 4c0dda05-e31f-4666-90b0-b3dfad34129a DEFINE_GUID( FWPM_CALLOUT_IPSEC_ALE_CONNECT_V6, 0x4c0dda05, 0xe31f, 0x4666, 0x90, 0xb0, 0xb3, 0xdf, 0xad, 0x34, 0x12, 0x9a ); #if (NTDDI_VERSION >= NTDDI_WIN7) // 6d08a342-db9e-4fbe-9ed2-57374ce89f79 DEFINE_GUID( FWPM_CALLOUT_IPSEC_DOSP_FORWARD_V6, 0x6d08a342, 0xdb9e, 0x4fbe, 0x9e, 0xd2, 0x57, 0x37, 0x4c, 0xe8, 0x9f, 0x79 ); // 2fcb56ec-cd37-4b4f-b108-62c2b1850a0c DEFINE_GUID( FWPM_CALLOUT_IPSEC_DOSP_FORWARD_V4, 0x2fcb56ec, 0xcd37, 0x4b4f, 0xb1, 0x08, 0x62, 0xc2, 0xb1, 0x85, 0x0a, 0x0c ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) // eda08606-2494-4d78-89bc-67837c03b969 DEFINE_GUID( FWPM_CALLOUT_WFP_TRANSPORT_LAYER_V4_SILENT_DROP, 0xeda08606, 0x2494, 0x4d78, 0x89, 0xbc, 0x67, 0x83, 0x7c, 0x03, 0xb9, 0x69 ); // 8693cc74-a075-4156-b476-9286eece814e DEFINE_GUID( FWPM_CALLOUT_WFP_TRANSPORT_LAYER_V6_SILENT_DROP, 0x8693cc74, 0xa075, 0x4156, 0xb4, 0x76, 0x92, 0x86, 0xee, 0xce, 0x81, 0x4e ); // f3e10ab3-2c25-4279-ac36-c30fc181bec4 DEFINE_GUID( FWPM_CALLOUT_TCP_CHIMNEY_CONNECT_LAYER_V4, 0xf3e10ab3, 0x2c25, 0x4279, 0xac, 0x36, 0xc3, 0x0f, 0xc1, 0x81, 0xbe, 0xc4 ); // 39e22085-a341-42fc-a279-aec94e689c56 DEFINE_GUID( FWPM_CALLOUT_TCP_CHIMNEY_CONNECT_LAYER_V6, 0x39e22085, 0xa341, 0x42fc, 0xa2, 0x79, 0xae, 0xc9, 0x4e, 0x68, 0x9c, 0x56 ); // e183ecb2-3a7f-4b54-8ad9-76050ed880ca DEFINE_GUID( FWPM_CALLOUT_TCP_CHIMNEY_ACCEPT_LAYER_V4, 0xe183ecb2, 0x3a7f, 0x4b54, 0x8a, 0xd9, 0x76, 0x05, 0x0e, 0xd8, 0x80, 0xca ); // 0378cf41-bf98-4603-81f2-7f12586079f6 DEFINE_GUID( FWPM_CALLOUT_TCP_CHIMNEY_ACCEPT_LAYER_V6, 0x0378cf41, 0xbf98, 0x4603, 0x81, 0xf2, 0x7f, 0x12, 0x58, 0x60, 0x79, 0xf6 ); // bc582280-1677-41e9-94ab-c2fcb15c2eeb DEFINE_GUID( FWPM_CALLOUT_SET_OPTIONS_AUTH_CONNECT_LAYER_V4, 0xbc582280, 0x1677, 0x41e9, 0x94, 0xab, 0xc2, 0xfc, 0xb1, 0x5c, 0x2e, 0xeb ); // 98e5373c-b884-490f-b65f-2f6a4a575195 DEFINE_GUID( FWPM_CALLOUT_SET_OPTIONS_AUTH_CONNECT_LAYER_V6, 0x98e5373c, 0xb884, 0x490f, 0xb6, 0x5f, 0x2f, 0x6a, 0x4a, 0x57, 0x51, 0x95 ); // 31b95392-066e-42a2-b7db-92f8acdd56f9 DEFINE_GUID( FWPM_CALLOUT_TEREDO_ALE_RESOURCE_ASSIGNMENT_V6, 0x31b95392, 0x066e, 0x42a2, 0xb7, 0xdb, 0x92, 0xf8, 0xac, 0xdd, 0x56, 0xf9 ); #define FWPM_CALLOUT_EDGE_TRAVERSAL_ALE_RESOURCE_ASSIGNMENT_V6 \ FWPM_CALLOUT_TEREDO_ALE_RESOURCE_ASSIGNMENT_V6 // 079b1010-f1c5-4fcd-ae05-da41107abd0b DEFINE_GUID( FWPM_CALLOUT_EDGE_TRAVERSAL_ALE_RESOURCE_ASSIGNMENT_V4, 0x079b1010, 0xf1c5, 0x4fcd, 0xae, 0x05, 0xda, 0x41, 0x10, 0x7a, 0xbd, 0x0b ); // 81a434e7-f60c-4378-bab8-c625a30f0197 DEFINE_GUID( FWPM_CALLOUT_TEREDO_ALE_LISTEN_V6, 0x81a434e7, 0xf60c, 0x4378, 0xba, 0xb8, 0xc6, 0x25, 0xa3, 0x0f, 0x01, 0x97 ); #define FWPM_CALLOUT_EDGE_TRAVERSAL_ALE_LISTEN_V6 \ FWPM_CALLOUT_TEREDO_ALE_LISTEN_V6 // 33486ab5-6d5e-4e65-a00b-a7afed0ba9a1 DEFINE_GUID( FWPM_CALLOUT_EDGE_TRAVERSAL_ALE_LISTEN_V4, 0x33486ab5, 0x6d5e, 0x4e65, 0xa0, 0x0b, 0xa7, 0xaf, 0xed, 0x0b, 0xa9, 0xa1 ); /////////////////////////////////////////////////////////////////////////////// // // GUIDs for built-in provider contexts. // /////////////////////////////////////////////////////////////////////////////// // b25ea800-0d02-46ed-92bd-7fa84bb73e9d DEFINE_GUID( FWPM_PROVIDER_CONTEXT_SECURE_SOCKET_AUTHIP, 0xb25ea800, 0x0d02, 0x46ed, 0x92, 0xbd, 0x7f, 0xa8, 0x4b, 0xb7, 0x3e, 0x9d ); // 8c2d4144-f8e0-42c0-94ce-7ccfc63b2f9b DEFINE_GUID( FWPM_PROVIDER_CONTEXT_SECURE_SOCKET_IPSEC, 0x8c2d4144, 0xf8e0, 0x42c0, 0x94, 0xce, 0x7c, 0xcf, 0xc6, 0x3b, 0x2f, 0x9b ); /////////////////////////////////////////////////////////////////////////////// // // GUIDs for built-in keying modules. // /////////////////////////////////////////////////////////////////////////////// // a9bbf787-82a8-45bb-a400-5d7e5952c7a9 DEFINE_GUID( FWPM_KEYING_MODULE_IKE, 0xa9bbf787, 0x82a8, 0x45bb, 0xa4, 0x00, 0x5d, 0x7e, 0x59, 0x52, 0xc7, 0xa9 ); // 11e3dae0-dd26-4590-857d-ab4b28d1a095 DEFINE_GUID( FWPM_KEYING_MODULE_AUTHIP, 0x11e3dae0, 0xdd26, 0x4590, 0x85, 0x7d, 0xab, 0x4b, 0x28, 0xd1, 0xa0, 0x95 ); // 041792cc-8f07-419d-a394-716968cb1647 DEFINE_GUID( FWPM_KEYING_MODULE_IKEV2, 0x041792cc, 0x8f07, 0x419d, 0xa3, 0x94, 0x71, 0x69, 0x68, 0xcb, 0x16, 0x47 ); #ifndef GUID_DEFS_ONLY #ifndef FWPMX_H #define FWPMX_H #include "fwpmtypes.h" #include "fwpvi.h" #ifdef __cplusplus extern "C" { #endif /////////////////////////////////////////////////////////////////////////////// // // Well-known filter weight ranges. // /////////////////////////////////////////////////////////////////////////////// // Number of bits used for auto-generated weights. #define FWPM_AUTO_WEIGHT_BITS (60) // Maximum auto-generated weight. #define FWPM_AUTO_WEIGHT_MAX (MAXUINT64 >> (64 - FWPM_AUTO_WEIGHT_BITS)) // Maximum allowed weight range. #define FWPM_WEIGHT_RANGE_MAX (MAXUINT64 >> FWPM_AUTO_WEIGHT_BITS) // IPsec policy #define FWPM_WEIGHT_RANGE_IPSEC (0x0) // Filters to exempt IKE traffic from IPsec. #define FWPM_WEIGHT_RANGE_IKE_EXEMPTIONS (0xc) /////////////////////////////////////////////////////////////////////////////// // // IPsec transform constants. // /////////////////////////////////////////////////////////////////////////////// ////////// // Authentication transform constants ////////// static const IPSEC_AUTH_TRANSFORM_ID0 IPSEC_AUTH_TRANSFORM_ID_HMAC_MD5_96 = { IPSEC_AUTH_MD5, IPSEC_AUTH_CONFIG_HMAC_MD5_96 }; static const IPSEC_AUTH_TRANSFORM_ID0 IPSEC_AUTH_TRANSFORM_ID_HMAC_SHA_1_96 = { IPSEC_AUTH_SHA_1, IPSEC_AUTH_CONFIG_HMAC_SHA_1_96 }; #if (NTDDI_VERSION >= NTDDI_WIN6SP1) static const IPSEC_AUTH_TRANSFORM_ID0 IPSEC_AUTH_TRANSFORM_ID_HMAC_SHA_256_128 = { IPSEC_AUTH_SHA_256, IPSEC_AUTH_CONFIG_HMAC_SHA_256_128 }; static const IPSEC_AUTH_TRANSFORM_ID0 IPSEC_AUTH_TRANSFORM_ID_GCM_AES_128 = { IPSEC_AUTH_AES_128, IPSEC_AUTH_CONFIG_GCM_AES_128 }; static const IPSEC_AUTH_TRANSFORM_ID0 IPSEC_AUTH_TRANSFORM_ID_GCM_AES_192 = { IPSEC_AUTH_AES_192, IPSEC_AUTH_CONFIG_GCM_AES_192 }; static const IPSEC_AUTH_TRANSFORM_ID0 IPSEC_AUTH_TRANSFORM_ID_GCM_AES_256 = { IPSEC_AUTH_AES_256, IPSEC_AUTH_CONFIG_GCM_AES_256 }; #endif // (NTDDI_VERSION >= NTDDI_WIN6SP1) ////////// // Cipher transform constants ////////// static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_CBC_DES = { IPSEC_CIPHER_TYPE_DES, IPSEC_CIPHER_CONFIG_CBC_DES }; static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_CBC_3DES = { IPSEC_CIPHER_TYPE_3DES, IPSEC_CIPHER_CONFIG_CBC_3DES }; static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_AES_128 = { IPSEC_CIPHER_TYPE_AES_128, IPSEC_CIPHER_CONFIG_CBC_AES_128 }; static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_AES_192 = { IPSEC_CIPHER_TYPE_AES_192, IPSEC_CIPHER_CONFIG_CBC_AES_192 }; static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_AES_256 = { IPSEC_CIPHER_TYPE_AES_256, IPSEC_CIPHER_CONFIG_CBC_AES_256 }; #if (NTDDI_VERSION >= NTDDI_WIN6SP1) static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_GCM_AES_128 = { IPSEC_CIPHER_TYPE_AES_128, IPSEC_CIPHER_CONFIG_GCM_AES_128 }; static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_GCM_AES_192 = { IPSEC_CIPHER_TYPE_AES_192, IPSEC_CIPHER_CONFIG_GCM_AES_192 }; static const IPSEC_CIPHER_TRANSFORM_ID0 IPSEC_CIPHER_TRANSFORM_ID_GCM_AES_256 = { IPSEC_CIPHER_TYPE_AES_256, IPSEC_CIPHER_CONFIG_GCM_AES_256 }; #endif // (NTDDI_VERSION >= NTDDI_WIN6SP1) /////////////////////////////////////////////////////////////////////////////// // // Well-known filter contexts. // /////////////////////////////////////////////////////////////////////////////// // IPSec transport filter contexts in inbound layer #define FWPM_CONTEXT_IPSEC_INBOUND_PASSTHRU (0x1ui64) #define FWPM_CONTEXT_IPSEC_INBOUND_PERSIST_CONNECTION_SECURITY (0x2ui64) #define FWPM_CONTEXT_IPSEC_INBOUND_RESERVED (0xff00000000000000ui64) // IPSec transport filter contexts in outbound layer #define FWPM_CONTEXT_IPSEC_OUTBOUND_NEGOTIATE_DISCOVER (0x1ui64) #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPM_CONTEXT_IPSEC_OUTBOUND_SUPPRESS_NEGOTIATION (0x2ui64) #endif // Filter contexts used in the ALE connect layer #define FWPM_CONTEXT_ALE_SET_CONNECTION_REQUIRE_IPSEC_SECURITY (0x2ui64) #define FWPM_CONTEXT_ALE_SET_CONNECTION_LAZY_SD_EVALUATION (0x4ui64) // Filter contexts used in the ALE connect or accept layer #define FWPM_CONTEXT_ALE_SET_CONNECTION_REQUIRE_IPSEC_ENCRYPTION (0x8ui64) #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPM_CONTEXT_ALE_SET_CONNECTION_ALLOW_FIRST_INBOUND_PKT_UNENCRYPTED (0x10ui64) // FWPM_CONTEXT_ALE_ALLOW_AUTH_FW modifies configurations that require ipsec security // Hence, at connect, this is only valid in combination with FWPM_CONTEXT_ALE_SET_CONNECTION_REQUIRE_IPSEC_SECURITY. #define FWPM_CONTEXT_ALE_ALLOW_AUTH_FW (0x20ui64) #endif // (NTDDI_VERSION >= NTDDI_WIN7) // Contexts used by the TCP Chimney Offload callouts. #define FWPM_CONTEXT_TCP_CHIMNEY_OFFLOAD_ENABLE (0x1ui64) #define FWPM_CONTEXT_TCP_CHIMNEY_OFFLOAD_DISABLE (0x2ui64) // Contexts used in the RPC audit sublayer #define FWPM_CONTEXT_RPC_AUDIT_ENABLED (0x1ui64) /////////////////////////////////////////////////////////////////////////////// // // Access rights // /////////////////////////////////////////////////////////////////////////////// // Specific access rights. #define FWPM_ACTRL_ADD (0x00000001) #define FWPM_ACTRL_ADD_LINK (0x00000002) #define FWPM_ACTRL_BEGIN_READ_TXN (0x00000004) #define FWPM_ACTRL_BEGIN_WRITE_TXN (0x00000008) #define FWPM_ACTRL_CLASSIFY (0x00000010) #define FWPM_ACTRL_ENUM (0x00000020) #define FWPM_ACTRL_OPEN (0x00000040) #define FWPM_ACTRL_READ (0x00000080) #define FWPM_ACTRL_READ_STATS (0x00000100) #define FWPM_ACTRL_SUBSCRIBE (0x00000200) #define FWPM_ACTRL_WRITE (0x00000400) // Generic access rights. #define FWPM_GENERIC_READ \ ( STANDARD_RIGHTS_READ | \ FWPM_ACTRL_BEGIN_READ_TXN | \ FWPM_ACTRL_CLASSIFY | \ FWPM_ACTRL_OPEN | \ FWPM_ACTRL_READ | \ FWPM_ACTRL_READ_STATS ) #define FWPM_GENERIC_EXECUTE \ ( STANDARD_RIGHTS_EXECUTE | \ FWPM_ACTRL_ENUM | \ FWPM_ACTRL_SUBSCRIBE ) #define FWPM_GENERIC_WRITE \ ( STANDARD_RIGHTS_WRITE | \ DELETE | \ FWPM_ACTRL_ADD | \ FWPM_ACTRL_ADD_LINK | \ FWPM_ACTRL_BEGIN_WRITE_TXN | \ FWPM_ACTRL_WRITE ) #define FWPM_GENERIC_ALL \ ( STANDARD_RIGHTS_REQUIRED | \ FWPM_ACTRL_ADD | \ FWPM_ACTRL_ADD_LINK | \ FWPM_ACTRL_BEGIN_READ_TXN | \ FWPM_ACTRL_BEGIN_WRITE_TXN | \ FWPM_ACTRL_CLASSIFY | \ FWPM_ACTRL_ENUM | \ FWPM_ACTRL_OPEN | \ FWPM_ACTRL_READ | \ FWPM_ACTRL_READ_STATS | \ FWPM_ACTRL_SUBSCRIBE | \ FWPM_ACTRL_WRITE ) /////////////////////////////////////////////////////////////////////////////// // // Common utility functions. // /////////////////////////////////////////////////////////////////////////////// void WINAPI FwpmFreeMemory0(__inout void** p); /////////////////////////////////////////////////////////////////////////////// // // Functions for managing the engine. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI FwpmEngineOpen0( __in_opt const wchar_t* serverName, __in UINT32 authnService, __in_opt SEC_WINNT_AUTH_IDENTITY_W* authIdentity, __in_opt const FWPM_SESSION0* session, __out HANDLE* engineHandle ); DWORD WINAPI FwpmEngineClose0(__inout HANDLE engineHandle); DWORD WINAPI FwpmEngineGetOption0( __in HANDLE engineHandle, __in FWPM_ENGINE_OPTION option, __deref_out FWP_VALUE0** value ); DWORD WINAPI FwpmEngineSetOption0( __in HANDLE engineHandle, __in FWPM_ENGINE_OPTION option, __in const FWP_VALUE0* newValue ); DWORD WINAPI FwpmEngineGetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI FwpmEngineSetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); DWORD WINAPI FwpmSessionCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const FWPM_SESSION_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI FwpmSessionEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_SESSION0*** entries, __out UINT32* numEntriesReturned ); DWORD WINAPI FwpmSessionDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); /////////////////////////////////////////////////////////////////////////////// // // Functions for explicit transactions. // /////////////////////////////////////////////////////////////////////////////// #define FWPM_TXN_READ_ONLY (0x00000001) DWORD WINAPI FwpmTransactionBegin0( __in HANDLE engineHandle, __in UINT32 flags ); DWORD WINAPI FwpmTransactionCommit0(__in HANDLE engineHandle); DWORD WINAPI FwpmTransactionAbort0(__in HANDLE engineHandle); /////////////////////////////////////////////////////////////////////////////// // // Functions for managing providers. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI FwpmProviderAdd0( __in HANDLE engineHandle, __in const FWPM_PROVIDER0* provider, __in_opt PSECURITY_DESCRIPTOR sd ); DWORD WINAPI FwpmProviderDeleteByKey0( __in HANDLE engineHandle, __in const GUID* key ); DWORD WINAPI FwpmProviderGetByKey0( __in HANDLE engineHandle, __in const GUID* key, __deref_out FWPM_PROVIDER0** provider ); DWORD WINAPI FwpmProviderCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const FWPM_PROVIDER_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI FwpmProviderEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_PROVIDER0*** entries, __out UINT32* numEntriesReturned ); DWORD WINAPI FwpmProviderDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI FwpmProviderGetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI FwpmProviderSetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); typedef void (CALLBACK *FWPM_PROVIDER_CHANGE_CALLBACK0)( __inout void* context, __in const FWPM_PROVIDER_CHANGE0* change ); DWORD WINAPI FwpmProviderSubscribeChanges0( __in HANDLE engineHandle, __in const FWPM_PROVIDER_SUBSCRIPTION0* subscription, __in FWPM_PROVIDER_CHANGE_CALLBACK0 callback, __in_opt void* context, __out HANDLE* changeHandle ); DWORD WINAPI FwpmProviderUnsubscribeChanges0( __in HANDLE engineHandle, __inout HANDLE changeHandle ); DWORD WINAPI FwpmProviderSubscriptionsGet0( __in HANDLE engineHandle, __deref_out_ecount(*numEntries) FWPM_PROVIDER_SUBSCRIPTION0*** entries, __out UINT32* numEntries ); /////////////////////////////////////////////////////////////////////////////// // // Functions for managing provider contexts. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI FwpmProviderContextAdd0( __in HANDLE engineHandle, __in const FWPM_PROVIDER_CONTEXT0* providerContext, __in_opt PSECURITY_DESCRIPTOR sd, __out_opt UINT64* id ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmProviderContextAdd1( __in HANDLE engineHandle, __in const FWPM_PROVIDER_CONTEXT1* providerContext, __in_opt PSECURITY_DESCRIPTOR sd, __out_opt UINT64* id ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmProviderContextDeleteById0( __in HANDLE engineHandle, __in UINT64 id ); DWORD WINAPI FwpmProviderContextDeleteByKey0( __in HANDLE engineHandle, __in const GUID* key ); DWORD WINAPI FwpmProviderContextGetById0( __in HANDLE engineHandle, __in UINT64 id, __deref_out FWPM_PROVIDER_CONTEXT0** providerContext ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmProviderContextGetById1( __in HANDLE engineHandle, __in UINT64 id, __deref_out FWPM_PROVIDER_CONTEXT1** providerContext ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmProviderContextGetByKey0( __in HANDLE engineHandle, __in const GUID* key, __deref_out FWPM_PROVIDER_CONTEXT0** providerContext ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmProviderContextGetByKey1( __in HANDLE engineHandle, __in const GUID* key, __deref_out FWPM_PROVIDER_CONTEXT1** providerContext ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmProviderContextCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const FWPM_PROVIDER_CONTEXT_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI FwpmProviderContextEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_PROVIDER_CONTEXT0*** entries, __out UINT32* numEntriesReturned ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmProviderContextEnum1( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_PROVIDER_CONTEXT1*** entries, __out UINT32* numEntriesReturned ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmProviderContextDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI FwpmProviderContextGetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI FwpmProviderContextSetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); typedef void (CALLBACK *FWPM_PROVIDER_CONTEXT_CHANGE_CALLBACK0)( __inout void* context, __in const FWPM_PROVIDER_CONTEXT_CHANGE0* change ); DWORD WINAPI FwpmProviderContextSubscribeChanges0( __in HANDLE engineHandle, __in const FWPM_PROVIDER_CONTEXT_SUBSCRIPTION0* subscription, __in FWPM_PROVIDER_CONTEXT_CHANGE_CALLBACK0 callback, __in_opt void* context, __out HANDLE* changeHandle ); DWORD WINAPI FwpmProviderContextUnsubscribeChanges0( __in HANDLE engineHandle, __inout HANDLE changeHandle ); DWORD WINAPI FwpmProviderContextSubscriptionsGet0( __in HANDLE engineHandle, __deref_out_ecount(*numEntries) FWPM_PROVIDER_CONTEXT_SUBSCRIPTION0*** entries, __out UINT32* numEntries ); /////////////////////////////////////////////////////////////////////////////// // // Functions for managing sub-layers. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI FwpmSubLayerAdd0( __in HANDLE engineHandle, __in const FWPM_SUBLAYER0* subLayer, __in_opt PSECURITY_DESCRIPTOR sd ); DWORD WINAPI FwpmSubLayerDeleteByKey0( __in HANDLE engineHandle, __in const GUID* key ); DWORD WINAPI FwpmSubLayerGetByKey0( __in HANDLE engineHandle, __in const GUID* key, __deref_out FWPM_SUBLAYER0** subLayer ); DWORD WINAPI FwpmSubLayerCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const FWPM_SUBLAYER_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI FwpmSubLayerEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_SUBLAYER0*** entries, __out UINT32* numEntriesReturned ); DWORD WINAPI FwpmSubLayerDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI FwpmSubLayerGetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI FwpmSubLayerSetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); typedef void (CALLBACK *FWPM_SUBLAYER_CHANGE_CALLBACK0)( __inout void* context, __in const FWPM_SUBLAYER_CHANGE0* change ); DWORD WINAPI FwpmSubLayerSubscribeChanges0( __in HANDLE engineHandle, __in const FWPM_SUBLAYER_SUBSCRIPTION0* subscription, __in FWPM_SUBLAYER_CHANGE_CALLBACK0 callback, __in_opt void* context, __out HANDLE* changeHandle ); DWORD WINAPI FwpmSubLayerUnsubscribeChanges0( __in HANDLE engineHandle, __inout HANDLE changeHandle ); DWORD WINAPI FwpmSubLayerSubscriptionsGet0( __in HANDLE engineHandle, __deref_out_ecount(*numEntries) FWPM_SUBLAYER_SUBSCRIPTION0*** entries, __out UINT32* numEntries ); /////////////////////////////////////////////////////////////////////////////// // // Functions for managing layers. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI FwpmLayerGetById0( __in HANDLE engineHandle, __in UINT16 id, __deref_out FWPM_LAYER0** layer ); DWORD WINAPI FwpmLayerGetByKey0( __in HANDLE engineHandle, __in const GUID* key, __deref_out FWPM_LAYER0** layer ); DWORD WINAPI FwpmLayerCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const FWPM_LAYER_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI FwpmLayerEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_LAYER0*** entries, __out UINT32* numEntriesReturned ); DWORD WINAPI FwpmLayerDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI FwpmLayerGetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI FwpmLayerSetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); /////////////////////////////////////////////////////////////////////////////// // // Functions for managing callouts. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI FwpmCalloutAdd0( __in HANDLE engineHandle, __in const FWPM_CALLOUT0* callout, __in_opt PSECURITY_DESCRIPTOR sd, __out_opt UINT32* id ); DWORD WINAPI FwpmCalloutDeleteById0( __in HANDLE engineHandle, __in UINT32 id ); DWORD WINAPI FwpmCalloutDeleteByKey0( __in HANDLE engineHandle, __in const GUID* key ); DWORD WINAPI FwpmCalloutGetById0( __in HANDLE engineHandle, __in UINT32 id, __deref_out FWPM_CALLOUT0** callout ); DWORD WINAPI FwpmCalloutGetByKey0( __in HANDLE engineHandle, __in const GUID* key, __deref_out FWPM_CALLOUT0** callout ); DWORD WINAPI FwpmCalloutCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const FWPM_CALLOUT_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI FwpmCalloutEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_CALLOUT0*** entries, __out UINT32* numEntriesReturned ); DWORD WINAPI FwpmCalloutDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI FwpmCalloutGetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI FwpmCalloutSetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); typedef void (CALLBACK *FWPM_CALLOUT_CHANGE_CALLBACK0)( __inout void* context, __in const FWPM_CALLOUT_CHANGE0* change ); DWORD WINAPI FwpmCalloutSubscribeChanges0( __in HANDLE engineHandle, __in const FWPM_CALLOUT_SUBSCRIPTION0* subscription, __in FWPM_CALLOUT_CHANGE_CALLBACK0 callback, __in_opt void* context, __out HANDLE* changeHandle ); DWORD WINAPI FwpmCalloutUnsubscribeChanges0( __in HANDLE engineHandle, __inout HANDLE changeHandle ); DWORD WINAPI FwpmCalloutSubscriptionsGet0( __in HANDLE engineHandle, __deref_out_ecount(*numEntries) FWPM_CALLOUT_SUBSCRIPTION0*** entries, __out UINT32* numEntries ); /////////////////////////////////////////////////////////////////////////////// // // Functions for managing filters. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI FwpmFilterAdd0( __in HANDLE engineHandle, __in const FWPM_FILTER0* filter, __in_opt PSECURITY_DESCRIPTOR sd, __out_opt UINT64* id ); DWORD WINAPI FwpmFilterDeleteById0( __in HANDLE engineHandle, __in UINT64 id ); DWORD WINAPI FwpmFilterDeleteByKey0( __in HANDLE engineHandle, __in const GUID* key ); DWORD WINAPI FwpmFilterGetById0( __in HANDLE engineHandle, __in UINT64 id, __deref_out FWPM_FILTER0** filter ); DWORD WINAPI FwpmFilterGetByKey0( __in HANDLE engineHandle, __in const GUID* key, __deref_out FWPM_FILTER0** filter ); DWORD WINAPI FwpmFilterCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const FWPM_FILTER_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI FwpmFilterEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_FILTER0*** entries, __out UINT32* numEntriesReturned ); DWORD WINAPI FwpmFilterDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI FwpmFilterGetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI FwpmFilterSetSecurityInfoByKey0( __in HANDLE engineHandle, __in_opt const GUID* key, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); typedef void (CALLBACK *FWPM_FILTER_CHANGE_CALLBACK0)( __inout void* context, __in const FWPM_FILTER_CHANGE0* change ); DWORD WINAPI FwpmFilterSubscribeChanges0( __in HANDLE engineHandle, __in const FWPM_FILTER_SUBSCRIPTION0* subscription, __in FWPM_FILTER_CHANGE_CALLBACK0 callback, __in_opt void* context, __out HANDLE* changeHandle ); DWORD WINAPI FwpmFilterUnsubscribeChanges0( __in HANDLE engineHandle, __inout HANDLE changeHandle ); DWORD WINAPI FwpmFilterSubscriptionsGet0( __in HANDLE engineHandle, __deref_out_ecount(*numEntries) FWPM_FILTER_SUBSCRIPTION0*** entries, __out UINT32* numEntries ); DWORD WINAPI FwpmGetAppIdFromFileName0( __in PCWSTR fileName, __deref_out FWP_BYTE_BLOB** appId ); /////////////////////////////////////////////////////////////////////////////// // // Helper functions for configuring an IPsec tunnel. // /////////////////////////////////////////////////////////////////////////////// // Create a point-to-point tunnel. #define FWPM_TUNNEL_FLAG_POINT_TO_POINT (0x00000001) #if (NTDDI_VERSION >= NTDDI_WIN7) // Enable Virtual interface based IPsec tunnel mode. #define FWPM_TUNNEL_FLAG_ENABLE_VIRTUAL_IF_TUNNELING (0x00000002) #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmIPsecTunnelAdd0( __in HANDLE engineHandle, __in UINT32 flags, __in_opt const FWPM_PROVIDER_CONTEXT0* mainModePolicy, __in const FWPM_PROVIDER_CONTEXT0* tunnelPolicy, __in UINT32 numFilterConditions, __in const FWPM_FILTER_CONDITION0* filterConditions, __in_opt PSECURITY_DESCRIPTOR sd ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmIPsecTunnelAdd1( __in HANDLE engineHandle, __in UINT32 flags, __in_opt const FWPM_PROVIDER_CONTEXT1* mainModePolicy, __in const FWPM_PROVIDER_CONTEXT1* tunnelPolicy, __in UINT32 numFilterConditions, __in const FWPM_FILTER_CONDITION0* filterConditions, __in_opt const GUID* keyModKey, __in_opt PSECURITY_DESCRIPTOR sd ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmIPsecTunnelDeleteByKey0( __in HANDLE engineHandle, __in const GUID* key ); /////////////////////////////////////////////////////////////////////////////// // // Functions for managing IPsec. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI IPsecGetStatistics0( __in HANDLE engineHandle, __out IPSEC_STATISTICS0* ipsecStatistics ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecGetStatistics1( __in HANDLE engineHandle, __out IPSEC_STATISTICS1* ipsecStatistics ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextCreate0( __in HANDLE engineHandle, __in const IPSEC_TRAFFIC0* outboundTraffic, __out_opt UINT64* inboundFilterId, __out UINT64* id ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextCreate1( __in HANDLE engineHandle, __in const IPSEC_TRAFFIC1* outboundTraffic, __in_opt const IPSEC_VIRTUAL_IF_TUNNEL_INFO0* virtualIfTunnelInfo, __out_opt UINT64* inboundFilterId, __out UINT64* id ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextDeleteById0( __in HANDLE engineHandle, __in UINT64 id ); DWORD WINAPI IPsecSaContextGetById0( __in HANDLE engineHandle, __in UINT64 id, __deref_out IPSEC_SA_CONTEXT0** saContext ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextGetById1( __in HANDLE engineHandle, __in UINT64 id, __deref_out IPSEC_SA_CONTEXT1** saContext ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextGetSpi0( __in HANDLE engineHandle, __in UINT64 id, __in const IPSEC_GETSPI0* getSpi, __out IPSEC_SA_SPI* inboundSpi ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextGetSpi1( __in HANDLE engineHandle, __in UINT64 id, __in const IPSEC_GETSPI1* getSpi, __out IPSEC_SA_SPI* inboundSpi ); DWORD WINAPI IPsecSaContextSetSpi0( __in HANDLE engineHandle, __in UINT64 id, __in const IPSEC_GETSPI1* getSpi, __in IPSEC_SA_SPI inboundSpi ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextAddInbound0( __in HANDLE engineHandle, __in UINT64 id, __in const IPSEC_SA_BUNDLE0* inboundBundle ); DWORD WINAPI IPsecSaContextAddOutbound0( __in HANDLE engineHandle, __in UINT64 id, __in const IPSEC_SA_BUNDLE0* outboundBundle ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextAddInbound1( __in HANDLE engineHandle, __in UINT64 id, __in const IPSEC_SA_BUNDLE1* inboundBundle ); DWORD WINAPI IPsecSaContextAddOutbound1( __in HANDLE engineHandle, __in UINT64 id, __in const IPSEC_SA_BUNDLE1* outboundBundle ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextExpire0( __in HANDLE engineHandle, __in UINT64 id ); #if (NTDDI_VERSION >= NTDDI_WIN7) // Flags indicating the specific field in the IPSEC_SA_CONTEXT data type that is // being updated. // #define IPSEC_SA_DETAILS_UPDATE_TRAFFIC (0x01ui64) #define IPSEC_SA_DETAILS_UPDATE_UDP_ENCAPSULATION (0x02ui64) #define IPSEC_SA_BUNDLE_UPDATE_FLAGS (0x04ui64) #define IPSEC_SA_BUNDLE_UPDATE_NAP_CONTEXT (0x08ui64) #define IPSEC_SA_BUNDLE_UPDATE_KEY_MODULE_STATE (0x10ui64) #define IPSEC_SA_BUNDLE_UPDATE_PEER_V4_PRIVATE_ADDRESS (0x20ui64) #define IPSEC_SA_BUNDLE_UPDATE_MM_SA_ID (0x40ui64) DWORD WINAPI IPsecSaContextUpdate0( __in HANDLE engineHandle, __in UINT64 flags, __in const IPSEC_SA_CONTEXT1* newValues ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const IPSEC_SA_CONTEXT_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI IPsecSaContextEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) IPSEC_SA_CONTEXT0*** entries, __out UINT32* numEntriesReturned ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextEnum1( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) IPSEC_SA_CONTEXT1*** entries, __out UINT32* numEntriesReturned ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaContextDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI IPsecSaCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const IPSEC_SA_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI IPsecSaEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) IPSEC_SA_DETAILS0*** entries, __out UINT32* numEntriesReturned ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaEnum1( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) IPSEC_SA_DETAILS1*** entries, __out UINT32* numEntriesReturned ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IPsecSaDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI IPsecSaDbGetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI IPsecSaDbSetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); #if (NTDDI_VERSION >= NTDDI_WIN7) /////////////////////////////////////////////////////////////////////////////// // // Functions for managing IPsec DoS Protection. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI IPsecDospGetStatistics0( __in HANDLE engineHandle, __out IPSEC_DOSP_STATISTICS0* idpStatistics ); DWORD WINAPI IPsecDospStateCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const IPSEC_DOSP_STATE_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI IPsecDospStateEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntries) IPSEC_DOSP_STATE0*** entries, __out UINT32* numEntries ); DWORD WINAPI IPsecDospStateDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI IPsecDospGetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI IPsecDospSetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) /////////////////////////////////////////////////////////////////////////////// // // Functions for managing IKE, Authip. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI IkeextGetStatistics0( __in HANDLE engineHandle, __out IKEEXT_STATISTICS0* ikeextStatistics ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IkeextGetStatistics1( __in HANDLE engineHandle, __out IKEEXT_STATISTICS1* ikeextStatistics ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IkeextSaDeleteById0( __in HANDLE engineHandle, __in UINT64 id ); DWORD WINAPI IkeextSaGetById0( __in HANDLE engineHandle, __in UINT64 id, __deref_out IKEEXT_SA_DETAILS0** sa ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IkeextSaGetById1( __in HANDLE engineHandle, __in UINT64 id, __in_opt GUID* saLookupContext, __deref_out IKEEXT_SA_DETAILS1** sa ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IkeextSaCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const IKEEXT_SA_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI IkeextSaEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) IKEEXT_SA_DETAILS0*** entries, __out UINT32* numEntriesReturned ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IkeextSaEnum1( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) IKEEXT_SA_DETAILS1*** entries, __out UINT32* numEntriesReturned ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI IkeextSaDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI IkeextSaDbGetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI IkeextSaDbSetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); /////////////////////////////////////////////////////////////////////////////// // // Functions for diagnostics. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI FwpmNetEventCreateEnumHandle0( __in HANDLE engineHandle, __in_opt const FWPM_NET_EVENT_ENUM_TEMPLATE0* enumTemplate, __out HANDLE* enumHandle ); DWORD WINAPI FwpmNetEventEnum0( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_NET_EVENT0*** entries, __out UINT32* numEntriesReturned ); #if (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmNetEventEnum1( __in HANDLE engineHandle, __in HANDLE enumHandle, __in UINT32 numEntriesRequested, __deref_out_ecount(*numEntriesReturned) FWPM_NET_EVENT1*** entries, __out UINT32* numEntriesReturned ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) DWORD WINAPI FwpmNetEventDestroyEnumHandle0( __in HANDLE engineHandle, __inout HANDLE enumHandle ); DWORD WINAPI FwpmNetEventsGetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __deref_out_opt PSID* sidOwner, __deref_out_opt PSID* sidGroup, __deref_out_opt PACL* dacl, __deref_out_opt PACL* sacl, __deref_out PSECURITY_DESCRIPTOR* securityDescriptor ); DWORD WINAPI FwpmNetEventsSetSecurityInfo0( __in HANDLE engineHandle, __in SECURITY_INFORMATION securityInfo, __in_opt const SID* sidOwner, __in_opt const SID* sidGroup, __in_opt const ACL* dacl, __in_opt const ACL* sacl ); #if (NTDDI_VERSION >= NTDDI_WIN7) typedef void (CALLBACK *FWPM_NET_EVENT_CALLBACK0)( __inout void* context, __in const FWPM_NET_EVENT1* event ); DWORD WINAPI FwpmNetEventSubscribe0( __in HANDLE engineHandle, __in const FWPM_NET_EVENT_SUBSCRIPTION0* subscription, __in FWPM_NET_EVENT_CALLBACK0 callback, __in_opt void* context, __out HANDLE* eventsHandle ); DWORD WINAPI FwpmNetEventUnsubscribe0( __in HANDLE engineHandle, __inout HANDLE eventsHandle ); DWORD WINAPI FwpmNetEventSubscriptionsGet0( __in HANDLE engineHandle, __deref_out_ecount(*numEntries) FWPM_NET_EVENT_SUBSCRIPTION0*** entries, __out UINT32* numEntries ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) #if (NTDDI_VERSION >= NTDDI_WIN7) /////////////////////////////////////////////////////////////////////////////// // // Functions for tracking system ports. // /////////////////////////////////////////////////////////////////////////////// DWORD WINAPI FwpmSystemPortsGet0( __in_opt HANDLE engineHandle, __deref_out FWPM_SYSTEM_PORTS0** sysPorts ); typedef void (CALLBACK *FWPM_SYSTEM_PORTS_CALLBACK0)( __inout void* context, __in const FWPM_SYSTEM_PORTS0* sysPorts ); DWORD WINAPI FwpmSystemPortsSubscribe0( __in_opt HANDLE engineHandle, __reserved void* reserved, __in FWPM_SYSTEM_PORTS_CALLBACK0 callback, __in_opt void* context, __out HANDLE* sysPortsHandle ); DWORD WINAPI FwpmSystemPortsUnsubscribe0( __in_opt HANDLE engineHandle, __inout HANDLE sysPortsHandle ); #endif // (NTDDI_VERSION >= NTDDI_WIN7) #ifdef __cplusplus } #endif #endif // FWPMX_H #endif // GUID_DEFS_ONLY #endif // (NTDDI_VERSION >= NTDDI_WIN6)
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/network/include/fwptypes.h
C/C++ Header
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 7.00.0555 */ /* Compiler settings for fwptypes.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ /* @@MIDL_FILE_HEADING( ) */ #pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 500 #endif /* verify that the <rpcsal.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCSAL_H_VERSION__ #define __REQUIRED_RPCSAL_H_VERSION__ 100 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif // __RPCNDR_H_VERSION__ #ifndef __fwptypes_h__ #define __fwptypes_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ /* header files for imported files */ #include "wtypes.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_fwptypes_0000_0000 */ /* [local] */ #if _MSC_VER >= 800 #if _MSC_VER >= 1200 #pragma warning(push) #endif #pragma warning(disable:4201) #endif #ifdef __midl typedef struct _LUID { DWORD LowPart; LONG HighPart; } LUID; typedef struct _LUID *PLUID; #endif typedef /* [v1_enum] */ enum FWP_DIRECTION_ { FWP_DIRECTION_OUTBOUND = 0, FWP_DIRECTION_INBOUND = ( FWP_DIRECTION_OUTBOUND + 1 ) , FWP_DIRECTION_MAX = ( FWP_DIRECTION_INBOUND + 1 ) } FWP_DIRECTION; typedef /* [v1_enum] */ enum FWP_IP_VERSION_ { FWP_IP_VERSION_V4 = 0, FWP_IP_VERSION_V6 = ( FWP_IP_VERSION_V4 + 1 ) , FWP_IP_VERSION_NONE = ( FWP_IP_VERSION_V6 + 1 ) , FWP_IP_VERSION_MAX = ( FWP_IP_VERSION_NONE + 1 ) } FWP_IP_VERSION; typedef /* [v1_enum] */ enum FWP_NE_FAMILY_ { FWP_AF_INET = FWP_IP_VERSION_V4, FWP_AF_INET6 = FWP_IP_VERSION_V6, FWP_AF_ETHER = FWP_IP_VERSION_NONE, FWP_AF_NONE = ( FWP_AF_ETHER + 1 ) } FWP_AF; typedef /* [v1_enum] */ enum FWP_ETHER_ENCAP_METHOD_ { FWP_ETHER_ENCAP_METHOD_ETHER_V2 = 0, FWP_ETHER_ENCAP_METHOD_SNAP = 1, FWP_ETHER_ENCAP_METHOD_SNAP_W_OUI_ZERO = 3 } FWP_ETHER_ENCAP_METHOD; typedef /* [v1_enum] */ enum FWP_DATA_TYPE_ { FWP_EMPTY = 0, FWP_UINT8 = ( FWP_EMPTY + 1 ) , FWP_UINT16 = ( FWP_UINT8 + 1 ) , FWP_UINT32 = ( FWP_UINT16 + 1 ) , FWP_UINT64 = ( FWP_UINT32 + 1 ) , FWP_INT8 = ( FWP_UINT64 + 1 ) , FWP_INT16 = ( FWP_INT8 + 1 ) , FWP_INT32 = ( FWP_INT16 + 1 ) , FWP_INT64 = ( FWP_INT32 + 1 ) , FWP_FLOAT = ( FWP_INT64 + 1 ) , FWP_DOUBLE = ( FWP_FLOAT + 1 ) , FWP_BYTE_ARRAY16_TYPE = ( FWP_DOUBLE + 1 ) , FWP_BYTE_BLOB_TYPE = ( FWP_BYTE_ARRAY16_TYPE + 1 ) , FWP_SID = ( FWP_BYTE_BLOB_TYPE + 1 ) , FWP_SECURITY_DESCRIPTOR_TYPE = ( FWP_SID + 1 ) , FWP_TOKEN_INFORMATION_TYPE = ( FWP_SECURITY_DESCRIPTOR_TYPE + 1 ) , FWP_TOKEN_ACCESS_INFORMATION_TYPE = ( FWP_TOKEN_INFORMATION_TYPE + 1 ) , FWP_UNICODE_STRING_TYPE = ( FWP_TOKEN_ACCESS_INFORMATION_TYPE + 1 ) , FWP_BYTE_ARRAY6_TYPE = ( FWP_UNICODE_STRING_TYPE + 1 ) , FWP_SINGLE_DATA_TYPE_MAX = 0xff, FWP_V4_ADDR_MASK = ( FWP_SINGLE_DATA_TYPE_MAX + 1 ) , FWP_V6_ADDR_MASK = ( FWP_V4_ADDR_MASK + 1 ) , FWP_RANGE_TYPE = ( FWP_V6_ADDR_MASK + 1 ) , FWP_DATA_TYPE_MAX = ( FWP_RANGE_TYPE + 1 ) } FWP_DATA_TYPE; typedef struct FWP_BYTE_ARRAY6_ { UINT8 byteArray6[ 6 ]; } FWP_BYTE_ARRAY6; #define FWP_BYTE_ARRAY6_SIZE 6 typedef struct FWP_BYTE_ARRAY16_ { UINT8 byteArray16[ 16 ]; } FWP_BYTE_ARRAY16; typedef struct FWP_BYTE_BLOB_ { UINT32 size; UINT8 *data; } FWP_BYTE_BLOB; typedef struct FWP_TOKEN_INFORMATION_ { ULONG sidCount; PSID_AND_ATTRIBUTES sids; ULONG restrictedSidCount; PSID_AND_ATTRIBUTES restrictedSids; } FWP_TOKEN_INFORMATION; typedef struct FWP_VALUE0_ { FWP_DATA_TYPE type; union { /* Empty union arm */ UINT8 uint8; UINT16 uint16; UINT32 uint32; UINT64 *uint64; INT8 int8; INT16 int16; INT32 int32; INT64 *int64; float float32; double *double64; FWP_BYTE_ARRAY16 *byteArray16; FWP_BYTE_BLOB *byteBlob; SID *sid; FWP_BYTE_BLOB *sd; FWP_TOKEN_INFORMATION *tokenInformation; FWP_BYTE_BLOB *tokenAccessInformation; LPWSTR unicodeString; FWP_BYTE_ARRAY6 *byteArray6; } ; } FWP_VALUE0; typedef /* [v1_enum] */ enum FWP_MATCH_TYPE_ { FWP_MATCH_EQUAL = 0, FWP_MATCH_GREATER = ( FWP_MATCH_EQUAL + 1 ) , FWP_MATCH_LESS = ( FWP_MATCH_GREATER + 1 ) , FWP_MATCH_GREATER_OR_EQUAL = ( FWP_MATCH_LESS + 1 ) , FWP_MATCH_LESS_OR_EQUAL = ( FWP_MATCH_GREATER_OR_EQUAL + 1 ) , FWP_MATCH_RANGE = ( FWP_MATCH_LESS_OR_EQUAL + 1 ) , FWP_MATCH_FLAGS_ALL_SET = ( FWP_MATCH_RANGE + 1 ) , FWP_MATCH_FLAGS_ANY_SET = ( FWP_MATCH_FLAGS_ALL_SET + 1 ) , FWP_MATCH_FLAGS_NONE_SET = ( FWP_MATCH_FLAGS_ANY_SET + 1 ) , FWP_MATCH_EQUAL_CASE_INSENSITIVE = ( FWP_MATCH_FLAGS_NONE_SET + 1 ) , FWP_MATCH_NOT_EQUAL = ( FWP_MATCH_EQUAL_CASE_INSENSITIVE + 1 ) , FWP_MATCH_TYPE_MAX = ( FWP_MATCH_NOT_EQUAL + 1 ) } FWP_MATCH_TYPE; typedef struct FWP_V4_ADDR_AND_MASK_ { UINT32 addr; UINT32 mask; } FWP_V4_ADDR_AND_MASK; #define FWP_V6_ADDR_SIZE (16) typedef struct FWP_V6_ADDR_AND_MASK_ { UINT8 addr[ 16 ]; UINT8 prefixLength; } FWP_V6_ADDR_AND_MASK; typedef struct FWP_RANGE0_ { FWP_VALUE0 valueLow; FWP_VALUE0 valueHigh; } FWP_RANGE0; #define FWP_ACTRL_MATCH_FILTER (0x00000001) typedef struct FWP_CONDITION_VALUE0_ { FWP_DATA_TYPE type; union { /* Empty union arm */ UINT8 uint8; UINT16 uint16; UINT32 uint32; UINT64 *uint64; INT8 int8; INT16 int16; INT32 int32; INT64 *int64; float float32; double *double64; FWP_BYTE_ARRAY16 *byteArray16; FWP_BYTE_BLOB *byteBlob; SID *sid; FWP_BYTE_BLOB *sd; FWP_TOKEN_INFORMATION *tokenInformation; FWP_BYTE_BLOB *tokenAccessInformation; LPWSTR unicodeString; FWP_BYTE_ARRAY6 *byteArray6; FWP_V4_ADDR_AND_MASK *v4AddrMask; FWP_V6_ADDR_AND_MASK *v6AddrMask; FWP_RANGE0 *rangeValue; } ; } FWP_CONDITION_VALUE0; typedef /* [v1_enum] */ enum FWP_CLASSIFY_OPTION_TYPE_ { FWP_CLASSIFY_OPTION_MULTICAST_STATE = 0, FWP_CLASSIFY_OPTION_LOOSE_SOURCE_MAPPING = ( FWP_CLASSIFY_OPTION_MULTICAST_STATE + 1 ) , FWP_CLASSIFY_OPTION_UNICAST_LIFETIME = ( FWP_CLASSIFY_OPTION_LOOSE_SOURCE_MAPPING + 1 ) , FWP_CLASSIFY_OPTION_MCAST_BCAST_LIFETIME = ( FWP_CLASSIFY_OPTION_UNICAST_LIFETIME + 1 ) , FWP_CLASSIFY_OPTION_SECURE_SOCKET_SECURITY_FLAGS = ( FWP_CLASSIFY_OPTION_MCAST_BCAST_LIFETIME + 1 ) , FWP_CLASSIFY_OPTION_SECURE_SOCKET_AUTHIP_MM_POLICY_KEY = ( FWP_CLASSIFY_OPTION_SECURE_SOCKET_SECURITY_FLAGS + 1 ) , FWP_CLASSIFY_OPTION_SECURE_SOCKET_AUTHIP_QM_POLICY_KEY = ( FWP_CLASSIFY_OPTION_SECURE_SOCKET_AUTHIP_MM_POLICY_KEY + 1 ) , FWP_CLASSIFY_OPTION_MAX = ( FWP_CLASSIFY_OPTION_SECURE_SOCKET_AUTHIP_QM_POLICY_KEY + 1 ) } FWP_CLASSIFY_OPTION_TYPE; #define FWP_OPTION_VALUE_ALLOW_MULTICAST_STATE (0x00000000) #define FWP_OPTION_VALUE_DENY_MULTICAST_STATE (0x00000001) #define FWP_OPTION_VALUE_ALLOW_GLOBAL_MULTICAST_STATE (0x00000002) #define FWP_OPTION_VALUE_DISABLE_LOOSE_SOURCE (0x00000000) #define FWP_OPTION_VALUE_ENABLE_LOOSE_SOURCE (0x00000001) #define FWP_ACTION_FLAG_TERMINATING (0x00001000) #define FWP_ACTION_FLAG_NON_TERMINATING (0x00002000) #define FWP_ACTION_FLAG_CALLOUT (0x00004000) typedef UINT32 FWP_ACTION_TYPE; #define FWP_ACTION_BLOCK (0x00000001 | FWP_ACTION_FLAG_TERMINATING) #define FWP_ACTION_PERMIT (0x00000002 | FWP_ACTION_FLAG_TERMINATING) #define FWP_ACTION_CALLOUT_TERMINATING (0x00000003 | FWP_ACTION_FLAG_CALLOUT | FWP_ACTION_FLAG_TERMINATING) #define FWP_ACTION_CALLOUT_INSPECTION (0x00000004 | FWP_ACTION_FLAG_CALLOUT | FWP_ACTION_FLAG_NON_TERMINATING) #define FWP_ACTION_CALLOUT_UNKNOWN (0x00000005 | FWP_ACTION_FLAG_CALLOUT) #define FWP_ACTION_CONTINUE (0x00000006 | FWP_ACTION_FLAG_NON_TERMINATING) #define FWP_ACTION_NONE (0x00000007) #define FWP_ACTION_NONE_NO_MATCH (0x00000008) #define FWP_CONDITION_FLAG_IS_LOOPBACK (0x00000001) #define FWP_CONDITION_FLAG_IS_IPSEC_SECURED (0x00000002) #define FWP_CONDITION_FLAG_IS_REAUTHORIZE (0x00000004) #define FWP_CONDITION_FLAG_IS_WILDCARD_BIND (0x00000008) #define FWP_CONDITION_FLAG_IS_RAW_ENDPOINT (0x00000010) #define FWP_CONDITION_FLAG_IS_FRAGMENT (0x00000020) #define FWP_CONDITION_FLAG_IS_FRAGMENT_GROUP (0x00000040) #define FWP_CONDITION_FLAG_IS_IPSEC_NATT_RECLASSIFY (0x00000080) #define FWP_CONDITION_FLAG_REQUIRES_ALE_CLASSIFY (0x00000100) #define FWP_CONDITION_FLAG_IS_IMPLICIT_BIND (0x00000200) #if (NTDDI_VERSION >= NTDDI_WIN6SP1) #define FWP_CONDITION_FLAG_IS_REASSEMBLED (0x00000400) #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWP_CONDITION_FLAG_IS_NAME_APP_SPECIFIED (0x00004000) #define FWP_CONDITION_FLAG_IS_PROMISCUOUS (0x00008000) #define FWP_CONDITION_FLAG_IS_AUTH_FW (0x00010000) #define FWP_CONDITION_FLAG_IS_RECLASSIFY (0x00020000) #define FWP_CONDITION_FLAG_IS_OUTBOUND_PASS_THRU (0x00040000) #define FWP_CONDITION_FLAG_IS_INBOUND_PASS_THRU (0x00080000) #define FWP_CONDITION_FLAG_IS_CONNECTION_REDIRECTED (0x00100000) #define FWP_CONDITION_REAUTHORIZE_REASON_POLICY_CHANGE (0x00000001) #define FWP_CONDITION_REAUTHORIZE_REASON_NEW_ARRIVAL_INTERFACE (0x00000002) #define FWP_CONDITION_REAUTHORIZE_REASON_NEW_NEXTHOP_INTERFACE (0x00000004) #define FWP_CONDITION_REAUTHORIZE_REASON_PROFILE_CROSSING (0x00000008) #define FWP_CONDITION_REAUTHORIZE_REASON_CLASSIFY_COMPLETION (0x00000010) #define FWP_CONDITION_REAUTHORIZE_REASON_IPSEC_PROPERTIES_CHANGED (0x00000020) #define FWP_CONDITION_REAUTHORIZE_REASON_MID_STREAM_INSPECTION (0x00000040) #define FWP_CONDITION_REAUTHORIZE_REASON_SOCKET_PROPERTY_CHANGED (0x00000080) #define FWP_CONDITION_REAUTHORIZE_REASON_NEW_INBOUND_MCAST_BCAST_PACKET (0x00000100) #define FWP_CONDITION_SOCKET_PROPERTY_FLAG_IS_SYSTEM_PORT_RPC (0x00000001) #define FWP_CONDITION_SOCKET_PROPERTY_FLAG_ALLOW_EDGE_TRAFFIC (0x00000002) #define FWP_CONDITION_SOCKET_PROPERTY_FLAG_DENY_EDGE_TRAFFIC (0x00000004) #endif #endif typedef /* [v1_enum] */ enum FWP_FILTER_ENUM_TYPE_ { FWP_FILTER_ENUM_FULLY_CONTAINED = 0, FWP_FILTER_ENUM_OVERLAPPING = ( FWP_FILTER_ENUM_FULLY_CONTAINED + 1 ) , FWP_FILTER_ENUM_TYPE_MAX = ( FWP_FILTER_ENUM_OVERLAPPING + 1 ) } FWP_FILTER_ENUM_TYPE; #define FWP_FILTER_ENUM_FLAG_BEST_TERMINATING_MATCH (0x00000001) #define FWP_FILTER_ENUM_FLAG_SORTED (0x00000002) #define FWP_FILTER_ENUM_FLAG_BOOTTIME_ONLY (0x00000004) #define FWP_FILTER_ENUM_FLAG_INCLUDE_BOOTTIME (0x00000008) #define FWP_FILTER_ENUM_FLAG_INCLUDE_DISABLED (0x00000010) #define FWP_FILTER_ENUM_VALID_FLAGS (FWP_FILTER_ENUM_FLAG_BEST_TERMINATING_MATCH | FWP_FILTER_ENUM_FLAG_SORTED) #define FWP_CALLOUT_FLAG_CONDITIONAL_ON_FLOW (0x00000001) #define FWP_CALLOUT_FLAG_ALLOW_OFFLOAD (0x00000002) #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWP_CALLOUT_FLAG_ENABLE_COMMIT_ADD_NOTIFY (0x00000004) #define FWP_CALLOUT_FLAG_ALLOW_MID_STREAM_INSPECTION (0x00000008) #define FWP_CALLOUT_FLAG_ALLOW_RECLASSIFY (0x00000010) #endif #if _MSC_VER >= 800 #if _MSC_VER >= 1200 #pragma warning(pop) #else #pragma warning(default:4201) #endif #endif extern RPC_IF_HANDLE __MIDL_itf_fwptypes_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_fwptypes_0000_0000_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/network/include/fwpvi.h
C/C++ Header
/* Copyright (c) Microsoft Corporation SYNOPSIS Declares version independent definitions for the FWP API. */ #include "sdkddkver.h" #if (NTDDI_VERSION >= NTDDI_WIN6) #ifndef FWPVI_H #define FWPVI_H /////////////////////////////////////////////////////////////////////////////// // // Version independent definitions for Fwpmtypes. // /////////////////////////////////////////////////////////////////////////////// #define FWPM_DISPLAY_DATA FWPM_DISPLAY_DATA0 #define FWPM_SESSION FWPM_SESSION0 #define FWPM_SESSION_ENUM_TEMPLATE FWPM_SESSION_ENUM_TEMPLATE0 #define FWPM_PROVIDER FWPM_PROVIDER0 #define FWPM_PROVIDER_ENUM_TEMPLATE FWPM_PROVIDER_ENUM_TEMPLATE0 #define FWPM_PROVIDER_CHANGE FWPM_PROVIDER_CHANGE0 #define FWPM_PROVIDER_SUBSCRIPTION FWPM_PROVIDER_SUBSCRIPTION0 #define FWPM_CLASSIFY_OPTION FWPM_CLASSIFY_OPTION0 #define FWPM_CLASSIFY_OPTIONS FWPM_CLASSIFY_OPTIONS0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPM_PROVIDER_CONTEXT FWPM_PROVIDER_CONTEXT1 #else #define FWPM_PROVIDER_CONTEXT FWPM_PROVIDER_CONTEXT0 #endif #define FWPM_PROVIDER_CONTEXT_ENUM_TEMPLATE FWPM_PROVIDER_CONTEXT_ENUM_TEMPLATE0 #define FWPM_PROVIDER_CONTEXT_CHANGE FWPM_PROVIDER_CONTEXT_CHANGE0 #define FWPM_PROVIDER_CONTEXT_SUBSCRIPTION FWPM_PROVIDER_CONTEXT_SUBSCRIPTION0 #define FWPM_SUBLAYER FWPM_SUBLAYER0 #define FWPM_SUBLAYER_ENUM_TEMPLATE FWPM_SUBLAYER_ENUM_TEMPLATE0 #define FWPM_SUBLAYER_CHANGE FWPM_SUBLAYER_CHANGE0 #define FWPM_SUBLAYER_SUBSCRIPTION FWPM_SUBLAYER_SUBSCRIPTION0 #define FWPM_FIELD FWPM_FIELD0 #define FWPM_LAYER FWPM_LAYER0 #define FWPM_LAYER_ENUM_TEMPLATE FWPM_LAYER_ENUM_TEMPLATE0 #define FWPM_CALLOUT FWPM_CALLOUT0 #define FWPM_CALLOUT_ENUM_TEMPLATE FWPM_CALLOUT_ENUM_TEMPLATE0 #define FWPM_CALLOUT_CHANGE FWPM_CALLOUT_CHANGE0 #define FWPM_CALLOUT_SUBSCRIPTION FWPM_CALLOUT_SUBSCRIPTION0 #define FWPM_ACTION FWPM_ACTION0 #define FWPM_FILTER_CONDITION FWPM_FILTER_CONDITION0 #define FWPM_FILTER FWPM_FILTER0 #define FWPM_FILTER_ENUM_TEMPLATE FWPM_FILTER_ENUM_TEMPLATE0 #define FWPM_FILTER_CHANGE FWPM_FILTER_CHANGE0 #define FWPM_FILTER_SUBSCRIPTION FWPM_FILTER_SUBSCRIPTION0 #define FWPM_LAYER_STATISTICS FWPM_LAYER_STATISTICS0 #define FWPM_STATISTICS FWPM_STATISTICS0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPM_NET_EVENT_HEADER FWPM_NET_EVENT_HEADER1 #define FWPM_NET_EVENT_IKEEXT_MM_FAILURE FWPM_NET_EVENT_IKEEXT_MM_FAILURE1 #define FWPM_NET_EVENT_IKEEXT_EM_FAILURE FWPM_NET_EVENT_IKEEXT_EM_FAILURE1 #else #define FWPM_NET_EVENT_HEADER FWPM_NET_EVENT_HEADER0 #define FWPM_NET_EVENT_IKEEXT_MM_FAILURE FWPM_NET_EVENT_IKEEXT_MM_FAILURE0 #define FWPM_NET_EVENT_IKEEXT_EM_FAILURE FWPM_NET_EVENT_IKEEXT_EM_FAILURE0 #endif #define FWPM_NET_EVENT_IKEEXT_QM_FAILURE FWPM_NET_EVENT_IKEEXT_QM_FAILURE0 #define FWPM_NET_EVENT_IPSEC_KERNEL_DROP FWPM_NET_EVENT_IPSEC_KERNEL_DROP0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPM_NET_EVENT_CLASSIFY_DROP FWPM_NET_EVENT_CLASSIFY_DROP1 #define FWPM_NET_EVENT_IPSEC_DOSP_DROP FWPM_NET_EVENT_IPSEC_DOSP_DROP0 #define FWPM_NET_EVENT FWPM_NET_EVENT1 #else #define FWPM_NET_EVENT_CLASSIFY_DROP FWPM_NET_EVENT_CLASSIFY_DROP0 #define FWPM_NET_EVENT FWPM_NET_EVENT0 #endif #define FWPM_NET_EVENT_ENUM_TEMPLATE FWPM_NET_EVENT_ENUM_TEMPLATE0 #define FWPM_NET_EVENT_SUBSCRIPTION FWPM_NET_EVENT_SUBSCRIPTION0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPM_SYSTEM_PORTS_BY_TYPE FWPM_SYSTEM_PORTS_BY_TYPE0 #define FWPM_SYSTEM_PORTS FWPM_SYSTEM_PORTS0 #endif /////////////////////////////////////////////////////////////////////////////// // // Version independent definitions for Fwpstypes. // /////////////////////////////////////////////////////////////////////////////// #define FWPS_FILTER_CONDITION FWPS_FILTER_CONDITION0 #define FWPS_ACTION FWPS_ACTION0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPS_FILTER FWPS_FILTER1 #else #define FWPS_FILTER FWPS_FILTER0 #endif #define FWPS_INCOMING_VALUE FWPS_INCOMING_VALUE0 #define FWPS_INCOMING_VALUES FWPS_INCOMING_VALUES0 #define FWPS_DISCARD_METADATA FWPS_DISCARD_METADATA0 #define FWPS_INBOUND_FRAGMENT_METADATA FWPS_INBOUND_FRAGMENT_METADATA0 #define FWPS_CLASSIFY_OUT FWPS_CLASSIFY_OUT0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPS_ALE_ENDPOINT_PROPERTIES FWPS_ALE_ENDPOINT_PROPERTIES0 #define FWPS_ALE_ENDPOINT_ENUM_TEMPLATE FWPS_ALE_ENDPOINT_ENUM_TEMPLATE0 #endif /////////////////////////////////////////////////////////////////////////////// // // Version independent definitions for Fwptypes. // /////////////////////////////////////////////////////////////////////////////// #define FWP_VALUE FWP_VALUE0 #define FWP_RANGE FWP_RANGE0 #define FWP_CONDITION_VALUE FWP_CONDITION_VALUE0 /////////////////////////////////////////////////////////////////////////////// // // Version independent definitions for Iketypes. // /////////////////////////////////////////////////////////////////////////////// #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_PRESHARED_KEY_AUTHENTICATION IKEEXT_PRESHARED_KEY_AUTHENTICATION1 #else #define IKEEXT_PRESHARED_KEY_AUTHENTICATION IKEEXT_PRESHARED_KEY_AUTHENTICATION0 #endif #define IKEEXT_CERT_ROOT_CONFIG IKEEXT_CERT_ROOT_CONFIG0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_CERTIFICATE_AUTHENTICATION IKEEXT_CERTIFICATE_AUTHENTICATION1 #else #define IKEEXT_CERTIFICATE_AUTHENTICATION IKEEXT_CERTIFICATE_AUTHENTICATION0 #endif #define IKEEXT_IPV6_CGA_AUTHENTICATION IKEEXT_IPV6_CGA_AUTHENTICATION0 #define IKEEXT_KERBEROS_AUTHENTICATION IKEEXT_KERBEROS_AUTHENTICATION0 #define IKEEXT_NTLM_V2_AUTHENTICATION IKEEXT_NTLM_V2_AUTHENTICATION0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_EAP_AUTHENTICATION IKEEXT_EAP_AUTHENTICATION0 #endif #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_AUTHENTICATION_METHOD IKEEXT_AUTHENTICATION_METHOD1 #else #define IKEEXT_AUTHENTICATION_METHOD IKEEXT_AUTHENTICATION_METHOD0 #endif #define IKEEXT_CIPHER_ALGORITHM IKEEXT_CIPHER_ALGORITHM0 #define IKEEXT_INTEGRITY_ALGORITHM IKEEXT_INTEGRITY_ALGORITHM0 #define IKEEXT_PROPOSAL IKEEXT_PROPOSAL0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_POLICY IKEEXT_POLICY1 #else #define IKEEXT_POLICY IKEEXT_POLICY0 #endif #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_EM_POLICY IKEEXT_EM_POLICY1 #else #define IKEEXT_EM_POLICY IKEEXT_EM_POLICY0 #endif #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS1 #else #define IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS0 #endif #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_KEYMODULE_STATISTICS IKEEXT_KEYMODULE_STATISTICS1 #else #define IKEEXT_KEYMODULE_STATISTICS IKEEXT_KEYMODULE_STATISTICS0 #endif #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS1 #else #define IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS0 #endif #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_COMMON_STATISTICS IKEEXT_COMMON_STATISTICS1 #else #define IKEEXT_COMMON_STATISTICS IKEEXT_COMMON_STATISTICS0 #endif #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_STATISTICS IKEEXT_STATISTICS1 #else #define IKEEXT_STATISTICS IKEEXT_STATISTICS0 #endif #define IKEEXT_TRAFFIC IKEEXT_TRAFFIC0 #define IKEEXT_COOKIE_PAIR IKEEXT_COOKIE_PAIR0 #define IKEEXT_NAME_CREDENTIAL IKEEXT_NAME_CREDENTIAL0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_CERTIFICATE_CREDENTIAL IKEEXT_CERTIFICATE_CREDENTIAL1 #define IKEEXT_CREDENTIAL IKEEXT_CREDENTIAL1 #define IKEEXT_CREDENTIAL_PAIR IKEEXT_CREDENTIAL_PAIR1 #define IKEEXT_CREDENTIALS IKEEXT_CREDENTIALS1 #else #define IKEEXT_CERTIFICATE_CREDENTIAL IKEEXT_CERTIFICATE_CREDENTIAL0 #define IKEEXT_CREDENTIAL IKEEXT_CREDENTIAL0 #define IKEEXT_CREDENTIAL_PAIR IKEEXT_CREDENTIAL_PAIR0 #define IKEEXT_CREDENTIALS IKEEXT_CREDENTIALS0 #endif #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_SA_DETAILS IKEEXT_SA_DETAILS1 #else #define IKEEXT_SA_DETAILS IKEEXT_SA_DETAILS0 #endif #define IKEEXT_SA_ENUM_TEMPLATE IKEEXT_SA_ENUM_TEMPLATE0 /////////////////////////////////////////////////////////////////////////////// // // Version independent definitions for Ipsectypes. // /////////////////////////////////////////////////////////////////////////////// #define IPSEC_SA_LIFETIME IPSEC_SA_LIFETIME0 #define IPSEC_AUTH_TRANSFORM_ID IPSEC_AUTH_TRANSFORM_ID0 #define IPSEC_AUTH_TRANSFORM IPSEC_AUTH_TRANSFORM0 #define IPSEC_CIPHER_TRANSFORM_ID IPSEC_CIPHER_TRANSFORM_ID0 #define IPSEC_CIPHER_TRANSFORM IPSEC_CIPHER_TRANSFORM0 #define IPSEC_AUTH_AND_CIPHER_TRANSFORM IPSEC_AUTH_AND_CIPHER_TRANSFORM0 #define IPSEC_SA_TRANSFORM IPSEC_SA_TRANSFORM0 #define IPSEC_PROPOSAL IPSEC_PROPOSAL0 #define IPSEC_SA_IDLE_TIMEOUT IPSEC_SA_IDLE_TIMEOUT0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPSEC_TRANSPORT_POLICY IPSEC_TRANSPORT_POLICY1 #define IPSEC_TUNNEL_ENDPOINTS IPSEC_TUNNEL_ENDPOINTS1 #define IPSEC_TUNNEL_POLICY IPSEC_TUNNEL_POLICY1 #else #define IPSEC_TRANSPORT_POLICY IPSEC_TRANSPORT_POLICY0 #define IPSEC_TUNNEL_ENDPOINTS IPSEC_TUNNEL_ENDPOINTS0 #define IPSEC_TUNNEL_POLICY IPSEC_TUNNEL_POLICY0 #endif #define IPSEC_KEYING_POLICY IPSEC_KEYING_POLICY0 #define IPSEC_AGGREGATE_SA_STATISTICS IPSEC_AGGREGATE_SA_STATISTICS0 #define IPSEC_ESP_DROP_PACKET_STATISTICS IPSEC_ESP_DROP_PACKET_STATISTICS0 #define IPSEC_AH_DROP_PACKET_STATISTICS IPSEC_AH_DROP_PACKET_STATISTICS0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPSEC_AGGREGATE_DROP_PACKET_STATISTICS IPSEC_AGGREGATE_DROP_PACKET_STATISTICS1 #define IPSEC_TRAFFIC_STATISTICS IPSEC_TRAFFIC_STATISTICS1 #define IPSEC_STATISTICS IPSEC_STATISTICS1 #else #define IPSEC_AGGREGATE_DROP_PACKET_STATISTICS IPSEC_AGGREGATE_DROP_PACKET_STATISTICS0 #define IPSEC_TRAFFIC_STATISTICS IPSEC_TRAFFIC_STATISTICS0 #define IPSEC_STATISTICS IPSEC_STATISTICS0 #endif #define IPSEC_SA_AUTH_INFORMATION IPSEC_SA_AUTH_INFORMATION0 #define IPSEC_SA_CIPHER_INFORMATION IPSEC_SA_CIPHER_INFORMATION0 #define IPSEC_SA_AUTH_AND_CIPHER_INFORMATION IPSEC_SA_AUTH_AND_CIPHER_INFORMATION0 #define IPSEC_SA IPSEC_SA0 #define IPSEC_KEYMODULE_STATE IPSEC_KEYMODULE_STATE0 #define IPSEC_TOKEN IPSEC_TOKEN0 #define IPSEC_ID IPSEC_ID0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPSEC_TRAFFIC IPSEC_TRAFFIC1 #define IPSEC_SA_BUNDLE IPSEC_SA_BUNDLE1 #else #define IPSEC_TRAFFIC IPSEC_TRAFFIC0 #define IPSEC_SA_BUNDLE IPSEC_SA_BUNDLE0 #endif #define IPSEC_V4_UDP_ENCAPSULATION IPSEC_V4_UDP_ENCAPSULATION0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPSEC_GETSPI IPSEC_GETSPI1 #define IPSEC_SA_DETAILS IPSEC_SA_DETAILS1 #define IPSEC_SA_CONTEXT IPSEC_SA_CONTEXT1 #else #define IPSEC_GETSPI IPSEC_GETSPI0 #define IPSEC_SA_DETAILS IPSEC_SA_DETAILS0 #define IPSEC_SA_CONTEXT IPSEC_SA_CONTEXT0 #endif #define IPSEC_SA_CONTEXT_ENUM_TEMPLATE IPSEC_SA_CONTEXT_ENUM_TEMPLATE0 #define IPSEC_SA_ENUM_TEMPLATE IPSEC_SA_ENUM_TEMPLATE0 #define IPSEC_ADDRESS_INFO IPSEC_ADDRESS_INFO0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPSEC_VIRTUAL_IF_TUNNEL_INFO IPSEC_VIRTUAL_IF_TUNNEL_INFO0 #define IPSEC_DOSP_OPTIONS IPSEC_DOSP_OPTIONS0 #define IPSEC_DOSP_STATISTICS IPSEC_DOSP_STATISTICS0 #define IPSEC_DOSP_STATE IPSEC_DOSP_STATE0 #define IPSEC_DOSP_STATE_ENUM_TEMPLATE IPSEC_DOSP_STATE_ENUM_TEMPLATE0 #endif // (NTDDI_VERSION >= NTDDI_WIN7) /////////////////////////////////////////////////////////////////////////////// // // Version independent definitions for Fwpmu / Fwpmk // /////////////////////////////////////////////////////////////////////////////// #define FWPM_SERVICE_STATE_CHANGE_CALLBACK FWPM_SERVICE_STATE_CHANGE_CALLBACK0 #define FwpmFreeMemory FwpmFreeMemory0 #define FwpmBfeStateGet FwpmBfeStateGet0 #define FwpmBfeStateSubscribeChanges FwpmBfeStateSubscribeChanges0 #define FwpmBfeStateUnsubscribeChanges FwpmBfeStateUnsubscribeChanges0 #define FwpmEngineOpen FwpmEngineOpen0 #define FwpmEngineClose FwpmEngineClose0 #define FwpmEngineGetOption FwpmEngineGetOption0 #define FwpmEngineSetOption FwpmEngineSetOption0 #define FwpmEngineGetSecurityInfo FwpmEngineGetSecurityInfo0 #define FwpmEngineSetSecurityInfo FwpmEngineSetSecurityInfo0 #define FwpmSessionCreateEnumHandle FwpmSessionCreateEnumHandle0 #define FwpmSessionEnum FwpmSessionEnum0 #define FwpmSessionDestroyEnumHandle FwpmSessionDestroyEnumHandle0 #define FwpmTransactionBegin FwpmTransactionBegin0 #define FwpmTransactionCommit FwpmTransactionCommit0 #define FwpmTransactionAbort FwpmTransactionAbort0 #define FwpmProviderAdd FwpmProviderAdd0 #define FwpmProviderDeleteByKey FwpmProviderDeleteByKey0 #define FwpmProviderGetByKey FwpmProviderGetByKey0 #define FwpmProviderCreateEnumHandle FwpmProviderCreateEnumHandle0 #define FwpmProviderEnum FwpmProviderEnum0 #define FwpmProviderDestroyEnumHandle FwpmProviderDestroyEnumHandle0 #define FwpmProviderGetSecurityInfoByKey FwpmProviderGetSecurityInfoByKey0 #define FwpmProviderSetSecurityInfoByKey FwpmProviderSetSecurityInfoByKey0 #define FWPM_PROVIDER_CHANGE_CALLBACK FWPM_PROVIDER_CHANGE_CALLBACK0 #define FwpmProviderSubscribeChanges FwpmProviderSubscribeChanges0 #define FwpmProviderUnsubscribeChanges FwpmProviderUnsubscribeChanges0 #define FwpmProviderSubscriptionsGet FwpmProviderSubscriptionsGet0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FwpmProviderContextAdd FwpmProviderContextAdd1 #define FwpmProviderContextGetById FwpmProviderContextGetById1 #define FwpmProviderContextGetByKey FwpmProviderContextGetByKey1 #define FwpmProviderContextEnum FwpmProviderContextEnum1 #else #define FwpmProviderContextAdd FwpmProviderContextAdd0 #define FwpmProviderContextGetById FwpmProviderContextGetById0 #define FwpmProviderContextGetByKey FwpmProviderContextGetByKey0 #define FwpmProviderContextEnum FwpmProviderContextEnum0 #endif #define FwpmProviderContextDeleteById FwpmProviderContextDeleteById0 #define FwpmProviderContextDeleteByKey FwpmProviderContextDeleteByKey0 #define FwpmProviderContextCreateEnumHandle FwpmProviderContextCreateEnumHandle0 #define FwpmProviderContextDestroyEnumHandle FwpmProviderContextDestroyEnumHandle0 #define FwpmProviderContextGetSecurityInfoByKey FwpmProviderContextGetSecurityInfoByKey0 #define FwpmProviderContextSetSecurityInfoByKey FwpmProviderContextSetSecurityInfoByKey0 #define FWPM_PROVIDER_CONTEXT_CHANGE_CALLBACK FWPM_PROVIDER_CONTEXT_CHANGE_CALLBACK0 #define FwpmProviderContextSubscribeChanges FwpmProviderContextSubscribeChanges0 #define FwpmProviderContextUnsubscribeChanges FwpmProviderContextUnsubscribeChanges0 #define FwpmProviderContextSubscriptionsGet FwpmProviderContextSubscriptionsGet0 #define FwpmSubLayerAdd FwpmSubLayerAdd0 #define FwpmSubLayerDeleteByKey FwpmSubLayerDeleteByKey0 #define FwpmSubLayerGetByKey FwpmSubLayerGetByKey0 #define FwpmSubLayerCreateEnumHandle FwpmSubLayerCreateEnumHandle0 #define FwpmSubLayerEnum FwpmSubLayerEnum0 #define FwpmSubLayerDestroyEnumHandle FwpmSubLayerDestroyEnumHandle0 #define FwpmSubLayerGetSecurityInfoByKey FwpmSubLayerGetSecurityInfoByKey0 #define FwpmSubLayerSetSecurityInfoByKey FwpmSubLayerSetSecurityInfoByKey0 #define FWPM_SUBLAYER_CHANGE_CALLBACK FWPM_SUBLAYER_CHANGE_CALLBACK0 #define FwpmSubLayerSubscribeChanges FwpmSubLayerSubscribeChanges0 #define FwpmSubLayerUnsubscribeChanges FwpmSubLayerUnsubscribeChanges0 #define FwpmSubLayerSubscriptionsGet FwpmSubLayerSubscriptionsGet0 #define FwpmLayerGetById FwpmLayerGetById0 #define FwpmLayerGetByKey FwpmLayerGetByKey0 #define FwpmLayerCreateEnumHandle FwpmLayerCreateEnumHandle0 #define FwpmLayerEnum FwpmLayerEnum0 #define FwpmLayerDestroyEnumHandle FwpmLayerDestroyEnumHandle0 #define FwpmLayerGetSecurityInfoByKey FwpmLayerGetSecurityInfoByKey0 #define FwpmLayerSetSecurityInfoByKey FwpmLayerSetSecurityInfoByKey0 #define FwpmCalloutAdd FwpmCalloutAdd0 #define FwpmCalloutDeleteById FwpmCalloutDeleteById0 #define FwpmCalloutDeleteByKey FwpmCalloutDeleteByKey0 #define FwpmCalloutGetById FwpmCalloutGetById0 #define FwpmCalloutGetByKey FwpmCalloutGetByKey0 #define FwpmCalloutCreateEnumHandle FwpmCalloutCreateEnumHandle0 #define FwpmCalloutEnum FwpmCalloutEnum0 #define FwpmCalloutDestroyEnumHandle FwpmCalloutDestroyEnumHandle0 #define FwpmCalloutGetSecurityInfoByKey FwpmCalloutGetSecurityInfoByKey0 #define FwpmCalloutSetSecurityInfoByKey FwpmCalloutSetSecurityInfoByKey0 #define FWPM_CALLOUT_CHANGE_CALLBACK FWPM_CALLOUT_CHANGE_CALLBACK0 #define FwpmCalloutSubscribeChanges FwpmCalloutSubscribeChanges0 #define FwpmCalloutUnsubscribeChanges FwpmCalloutUnsubscribeChanges0 #define FwpmCalloutSubscriptionsGet FwpmCalloutSubscriptionsGet0 #define FwpmFilterAdd FwpmFilterAdd0 #define FwpmFilterDeleteById FwpmFilterDeleteById0 #define FwpmFilterDeleteByKey FwpmFilterDeleteByKey0 #define FwpmFilterGetById FwpmFilterGetById0 #define FwpmFilterGetByKey FwpmFilterGetByKey0 #define FwpmFilterCreateEnumHandle FwpmFilterCreateEnumHandle0 #define FwpmFilterEnum FwpmFilterEnum0 #define FwpmFilterDestroyEnumHandle FwpmFilterDestroyEnumHandle0 #define FwpmFilterGetSecurityInfoByKey FwpmFilterGetSecurityInfoByKey0 #define FwpmFilterSetSecurityInfoByKey FwpmFilterSetSecurityInfoByKey0 #define FWPM_FILTER_CHANGE_CALLBACK FWPM_FILTER_CHANGE_CALLBACK0 #define FwpmFilterSubscribeChanges FwpmFilterSubscribeChanges0 #define FwpmFilterUnsubscribeChanges FwpmFilterUnsubscribeChanges0 #define FwpmFilterSubscriptionsGet FwpmFilterSubscriptionsGet0 #define FwpmGetAppIdFromFileName FwpmGetAppIdFromFileName0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FwpmIPsecTunnelAdd FwpmIPsecTunnelAdd1 #else #define FwpmIPsecTunnelAdd FwpmIPsecTunnelAdd0 #endif #define FwpmIPsecTunnelDeleteByKey FwpmIPsecTunnelDeleteByKey0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPsecGetStatistics IPsecGetStatistics1 #define IPsecSaContextCreate IPsecSaContextCreate1 #else #define IPsecGetStatistics IPsecGetStatistics0 #define IPsecSaContextCreate IPsecSaContextCreate0 #endif #define IPsecSaContextDeleteById IPsecSaContextDeleteById0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPsecSaContextGetById IPsecSaContextGetById1 #define IPsecSaContextGetSpi IPsecSaContextGetSpi1 #define IPsecSaContextSetSpi IPsecSaContextSetSpi0 #define IPsecSaContextAddInbound IPsecSaContextAddInbound1 #define IPsecSaContextAddOutbound IPsecSaContextAddOutbound1 #else #define IPsecSaContextGetById IPsecSaContextGetById0 #define IPsecSaContextGetSpi IPsecSaContextGetSpi0 #define IPsecSaContextAddInbound IPsecSaContextAddInbound0 #define IPsecSaContextAddOutbound IPsecSaContextAddOutbound0 #endif #define IPsecSaContextExpire IPsecSaContextExpire0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPsecSaContextUpdate IPsecSaContextUpdate0 #endif #define IPsecSaContextCreateEnumHandle IPsecSaContextCreateEnumHandle0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPsecSaContextEnum IPsecSaContextEnum1 #else #define IPsecSaContextEnum IPsecSaContextEnum0 #endif #define IPsecSaContextDestroyEnumHandle IPsecSaContextDestroyEnumHandle0 #define IPsecSaCreateEnumHandle IPsecSaCreateEnumHandle0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPsecSaEnum IPsecSaEnum1 #else #define IPsecSaEnum IPsecSaEnum0 #endif #define IPsecSaDestroyEnumHandle IPsecSaDestroyEnumHandle0 #define IPsecSaDbGetSecurityInfo IPsecSaDbGetSecurityInfo0 #define IPsecSaDbSetSecurityInfo IPsecSaDbSetSecurityInfo0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IPsecDospGetStatistics IPsecDospGetStatistics0 #define IPsecDospStateCreateEnumHandle IPsecDospStateCreateEnumHandle0 #define IPsecDospStateEnum IPsecDospStateEnum0 #define IPsecDospStateDestroyEnumHandle IPsecDospStateDestroyEnumHandle0 #define IPsecDospGetSecurityInfo IPsecDospGetSecurityInfo0 #define IPsecDospSetSecurityInfo IPsecDospSetSecurityInfo0 #endif #if (NTDDI_VERSION >= NTDDI_WIN7) #define IkeextGetStatistics IkeextGetStatistics1 #else #define IkeextGetStatistics IkeextGetStatistics0 #endif #define IkeextSaDeleteById IkeextSaDeleteById0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IkeextSaGetById IkeextSaGetById1 #else #define IkeextSaGetById IkeextSaGetById0 #endif #define IkeextSaCreateEnumHandle IkeextSaCreateEnumHandle0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define IkeextSaEnum IkeextSaEnum1 #else #define IkeextSaEnum IkeextSaEnum0 #endif #define IkeextSaDestroyEnumHandle IkeextSaDestroyEnumHandle0 #define IkeextSaDbGetSecurityInfo IkeextSaDbGetSecurityInfo0 #define IkeextSaDbSetSecurityInfo IkeextSaDbSetSecurityInfo0 #define FwpmNetEventCreateEnumHandle FwpmNetEventCreateEnumHandle0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FwpmNetEventEnum FwpmNetEventEnum1 #else #define FwpmNetEventEnum FwpmNetEventEnum0 #endif #define FwpmNetEventDestroyEnumHandle FwpmNetEventDestroyEnumHandle0 #define FwpmNetEventsGetSecurityInfo FwpmNetEventsGetSecurityInfo0 #define FwpmNetEventsSetSecurityInfo FwpmNetEventsSetSecurityInfo0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPM_NET_EVENT_CALLBACK FWPM_NET_EVENT_CALLBACK0 #define FwpmNetEventSubscribe FwpmNetEventSubscribe0 #define FwpmNetEventUnsubscribe FwpmNetEventUnsubscribe0 #define FwpmNetEventSubscriptionsGet FwpmNetEventSubscriptionsGet0 #define FwpmSystemPortsGet FwpmSystemPortsGet0 #define FWPM_SYSTEM_PORTS_CALLBACK FWPM_SYSTEM_PORTS_CALLBACK0 #define FwpmSystemPortsSubscribe FwpmSystemPortsSubscribe0 #define FwpmSystemPortsUnsubscribe FwpmSystemPortsUnsubscribe0 #endif /////////////////////////////////////////////////////////////////////////////// // // Version independent definitions for Fwpsu / Fwpsk // /////////////////////////////////////////////////////////////////////////////// #define FWPS_INCOMING_METADATA_VALUES FWPS_INCOMING_METADATA_VALUES0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPS_CALLOUT_CLASSIFY_FN FWPS_CALLOUT_CLASSIFY_FN1 #else #define FWPS_CALLOUT_CLASSIFY_FN FWPS_CALLOUT_CLASSIFY_FN0 #endif // (NTDDI_VERSION >= NTDDI_WIN7) #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPS_CALLOUT_NOTIFY_FN FWPS_CALLOUT_NOTIFY_FN1 #else #define FWPS_CALLOUT_NOTIFY_FN FWPS_CALLOUT_NOTIFY_FN0 #endif // (NTDDI_VERSION >= NTDDI_WIN7) #define FWPS_CALLOUT_FLOW_DELETE_NOTIFY_FN FWPS_CALLOUT_FLOW_DELETE_NOTIFY_FN0 #define FWPS_CALLOUT_BOOTTIME_CALLOUT_DELETE_NOTIFY_FN FWPS_CALLOUT_BOOTTIME_CALLOUT_DELETE_NOTIFY_FN0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPS_CALLOUT FWPS_CALLOUT1 #else #define FWPS_CALLOUT FWPS_CALLOUT0 #endif // (NTDDI_VERSION >= NTDDI_WIN7) #if (NTDDI_VERSION >= NTDDI_WIN7) #define FwpsCalloutRegister FwpsCalloutRegister1 #else #define FwpsCalloutRegister FwpsCalloutRegister0 #endif // (NTDDI_VERSION >= NTDDI_WIN7) #define FwpsCalloutUnregisterById FwpsCalloutUnregisterById0 #define FwpsCalloutUnregisterByKey FwpsCalloutUnregisterByKey0 #define FwpsFlowAssociateContext FwpsFlowAssociateContext0 #define FwpsFlowRemoveContext FwpsFlowRemoveContext0 #define FWPS_PACKET_LIST_INBOUND_IPSEC_INFORMATION FWPS_PACKET_LIST_INBOUND_IPSEC_INFORMATION0 #define FWPS_PACKET_LIST_OUTBOUND_IPSEC_INFORMATION FWPS_PACKET_LIST_OUTBOUND_IPSEC_INFORMATION0 #define FWPS_PACKET_LIST_IPSEC_INFORMATION FWPS_PACKET_LIST_IPSEC_INFORMATION0 #define FWPS_PACKET_LIST_FWP_INFORMATION FWPS_PACKET_LIST_FWP_INFORMATION0 #define FWPS_PACKET_LIST_INFORMATION FWPS_PACKET_LIST_INFORMATION0 #define FwpsGetPacketListSecurityInformation FwpsGetPacketListSecurityInformation0 #define FwpsPendOperation FwpsPendOperation0 #define FwpsCompleteOperation FwpsCompleteOperation0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FwpsAcquireClassifyHandle FwpsAcquireClassifyHandle0 #define FwpsReleaseClassifyHandle FwpsReleaseClassifyHandle0 #define FwpsPendClassify FwpsPendClassify0 #define FwpsCompleteClassify FwpsCompleteClassify0 #define FwpsAcquireWritableLayerDataPointer FwpsAcquireWritableLayerDataPointer0 #define FwpsApplyModifiedLayerData FwpsApplyModifiedLayerData0 #define FWPS_CONNECT_REQUEST FWPS_CONNECT_REQUEST0 #define FWPS_BIND_REQUEST FWPS_BIND_REQUEST0 #define FWPS_NET_BUFFER_LIST_EVENT_TYPE FWPS_NET_BUFFER_LIST_EVENT_TYPE0 #define FWPS_NET_BUFFER_LIST_NOTIFY_FN FWPS_NET_BUFFER_LIST_NOTIFY_FN0 #define FwpsNetBufferListGetTagForContext FwpsNetBufferListGetTagForContext0 #define FwpsNetBufferListAssociateContext FwpsNetBufferListAssociateContext0 #define FwpsNetBufferListRetrieveContext FwpsNetBufferListRetrieveContext0 #define FwpsNetBufferListRemoveContext FwpsNetBufferListRemoveContext0 #define FwpsOpenToken FwpsOpenToken0 #define FwpsAleEndpointGetById FwpsAleEndpointGetById0 #define FwpsAleEndpointCreateEnumHandle FwpsAleEndpointCreateEnumHandle0 #define FwpsAleEndpointEnum FwpsAleEndpointEnum0 #define FwpsAleEndpointDestroyEnumHandle FwpsAleEndpointDestroyEnumHandle0 #define FwpsAleEndpointGetSecurityInfo FwpsAleEndpointGetSecurityInfo0 #define FwpsAleEndpointSetSecurityInfo FwpsAleEndpointSetSecurityInfo0 #endif // (NTDDI_VERSION >= NTDDI_WIN7) #define FwpsClassifyOptionSet FwpsClassifyOptionSet0 #define FwpsInjectionHandleCreate FwpsInjectionHandleCreate0 #define FwpsInjectionHandleDestroy FwpsInjectionHandleDestroy0 #define FWPS_INJECT_COMPLETE FWPS_INJECT_COMPLETE0 #define FwpsAllocateNetBufferAndNetBufferList FwpsAllocateNetBufferAndNetBufferList0 #define FwpsFreeNetBufferList FwpsFreeNetBufferList0 #define FwpsAllocateCloneNetBufferList FwpsAllocateCloneNetBufferList0 #define FwpsFreeCloneNetBufferList FwpsFreeCloneNetBufferList0 #define FwpsReassembleForwardFragmentGroup FwpsReassembleForwardFragmentGroup0 #define FwpsInjectNetworkSendAsync FwpsInjectNetworkSendAsync0 #define FwpsInjectForwardAsync FwpsInjectForwardAsync0 #define FwpsConstructIpHeaderForTransportPacket FwpsConstructIpHeaderForTransportPacket0 #if (NTDDI_VERSION >= NTDDI_WIN7) #define FWPS_TRANSPORT_SEND_PARAMS FWPS_TRANSPORT_SEND_PARAMS1 #define FwpsInjectTransportSendAsync FwpsInjectTransportSendAsync1 #else #define FWPS_TRANSPORT_SEND_PARAMS FWPS_TRANSPORT_SEND_PARAMS0 #define FwpsInjectTransportSendAsync FwpsInjectTransportSendAsync0 #endif // (NTDDI_VERSION >= NTDDI_WIN7) #define FwpsInjectTransportReceiveAsync FwpsInjectTransportReceiveAsync0 #define FwpsInjectNetworkReceiveAsync FwpsInjectNetworkReceiveAsync0 #define FwpsReferenceNetBufferList FwpsReferenceNetBufferList0 #define FwpsDereferenceNetBufferList FwpsDereferenceNetBufferList0 #define FwpsQueryPacketInjectionState FwpsQueryPacketInjectionState0 #define FWPS_STREAM_DATA_OFFSET FWPS_STREAM_DATA_OFFSET0 #define FWPS_STREAM_DATA FWPS_STREAM_DATA0 #define FWPS_STREAM_CALLOUT_IO_PACKET FWPS_STREAM_CALLOUT_IO_PACKET0 #define FwpsStreamInjectAsync FwpsStreamInjectAsync0 #define FwpsStreamContinue FwpsStreamContinue0 #define FwpsCopyStreamDataToBuffer FwpsCopyStreamDataToBuffer0 #define FwpsCloneStreamData FwpsCloneStreamData0 #define FwpsDiscardClonedStreamData FwpsDiscardClonedStreamData0 #endif // FWPVI_H #endif // (NTDDI_VERSION >= NTDDI_WIN6)
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/network/include/iketypes.h
C/C++ Header
/* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 7.00.0555 */ /* Compiler settings for iketypes.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ /* @@MIDL_FILE_HEADING( ) */ #pragma warning( disable: 4049 ) /* more than 64k source lines */ /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 500 #endif /* verify that the <rpcsal.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCSAL_H_VERSION__ #define __REQUIRED_RPCSAL_H_VERSION__ 100 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif // __RPCNDR_H_VERSION__ #ifndef __iketypes_h__ #define __iketypes_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ /* header files for imported files */ #include "fwptypes.h" #ifdef __cplusplus extern "C"{ #endif /* interface __MIDL_itf_iketypes_0000_0000 */ /* [local] */ #pragma once #pragma once #pragma once #pragma once #if _MSC_VER >= 800 #if _MSC_VER >= 1200 #pragma warning(push) #endif #pragma warning(disable:4201) #endif typedef struct IPSEC_V4_UDP_ENCAPSULATION0_ IPSEC_V4_UDP_ENCAPSULATION0; typedef /* [v1_enum] */ enum IKEEXT_KEY_MODULE_TYPE_ { IKEEXT_KEY_MODULE_IKE = 0, IKEEXT_KEY_MODULE_AUTHIP = ( IKEEXT_KEY_MODULE_IKE + 1 ) , IKEEXT_KEY_MODULE_IKEV2 = ( IKEEXT_KEY_MODULE_AUTHIP + 1 ) , IKEEXT_KEY_MODULE_MAX = ( IKEEXT_KEY_MODULE_IKEV2 + 1 ) } IKEEXT_KEY_MODULE_TYPE; typedef /* [v1_enum] */ enum IKEEXT_AUTHENTICATION_METHOD_TYPE_ { IKEEXT_PRESHARED_KEY = 0, IKEEXT_CERTIFICATE = ( IKEEXT_PRESHARED_KEY + 1 ) , IKEEXT_KERBEROS = ( IKEEXT_CERTIFICATE + 1 ) , IKEEXT_ANONYMOUS = ( IKEEXT_KERBEROS + 1 ) , IKEEXT_SSL = ( IKEEXT_ANONYMOUS + 1 ) , IKEEXT_NTLM_V2 = ( IKEEXT_SSL + 1 ) , IKEEXT_IPV6_CGA = ( IKEEXT_NTLM_V2 + 1 ) , IKEEXT_CERTIFICATE_ECDSA_P256 = ( IKEEXT_IPV6_CGA + 1 ) , IKEEXT_CERTIFICATE_ECDSA_P384 = ( IKEEXT_CERTIFICATE_ECDSA_P256 + 1 ) , IKEEXT_SSL_ECDSA_P256 = ( IKEEXT_CERTIFICATE_ECDSA_P384 + 1 ) , IKEEXT_SSL_ECDSA_P384 = ( IKEEXT_SSL_ECDSA_P256 + 1 ) , IKEEXT_EAP = ( IKEEXT_SSL_ECDSA_P384 + 1 ) , IKEEXT_AUTHENTICATION_METHOD_TYPE_MAX = ( IKEEXT_EAP + 1 ) } IKEEXT_AUTHENTICATION_METHOD_TYPE; typedef /* [v1_enum] */ enum IKEEXT_AUTHENTICATION_IMPERSONATION_TYPE_ { IKEEXT_IMPERSONATION_NONE = 0, IKEEXT_IMPERSONATION_SOCKET_PRINCIPAL = ( IKEEXT_IMPERSONATION_NONE + 1 ) , IKEEXT_IMPERSONATION_MAX = ( IKEEXT_IMPERSONATION_SOCKET_PRINCIPAL + 1 ) } IKEEXT_AUTHENTICATION_IMPERSONATION_TYPE; typedef struct IKEEXT_PRESHARED_KEY_AUTHENTICATION0__ { FWP_BYTE_BLOB presharedKey; } IKEEXT_PRESHARED_KEY_AUTHENTICATION0; #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_PSK_FLAG_LOCAL_AUTH_ONLY (0x00000001) #define IKEEXT_PSK_FLAG_REMOTE_AUTH_ONLY (0x00000002) typedef struct IKEEXT_PRESHARED_KEY_AUTHENTICATION1__ { FWP_BYTE_BLOB presharedKey; UINT32 flags; } IKEEXT_PRESHARED_KEY_AUTHENTICATION1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_CERT_FLAG_ENABLE_ACCOUNT_MAPPING (0x00000001) #define IKEEXT_CERT_FLAG_DISABLE_REQUEST_PAYLOAD (0x00000002) #define IKEEXT_CERT_FLAG_USE_NAP_CERTIFICATE (0x00000004) #define IKEEXT_CERT_FLAG_INTERMEDIATE_CA (0x00000008) #define IKEEXT_CERT_FLAG_IGNORE_INIT_CERT_MAP_FAILURE (0x00000010) #define IKEEXT_CERT_FLAG_PREFER_NAP_CERTIFICATE_OUTBOUND (0x00000020) typedef struct IKEEXT_CERT_ROOT_CONFIG0_ { FWP_BYTE_BLOB certData; UINT32 flags; } IKEEXT_CERT_ROOT_CONFIG0; #define IKEEXT_CERT_AUTH_FLAG_SSL_ONE_WAY (0x00000001) #define IKEEXT_CERT_AUTH_FLAG_DISABLE_CRL_CHECK (0x00000002) #define IKEEXT_CERT_AUTH_ENABLE_CRL_CHECK_STRONG (0x00000004) #define IKEEXT_CERT_AUTH_DISABLE_SSL_CERT_VALIDATION (0x00000008) #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_CERT_AUTH_ALLOW_HTTP_CERT_LOOKUP (0x00000010) #define IKEEXT_CERT_AUTH_URL_CONTAINS_BUNDLE (0x00000020) #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef /* [v1_enum] */ enum IKEEXT_CERT_CONFIG_TYPE_ { IKEEXT_CERT_CONFIG_EXPLICIT_TRUST_LIST = 0, IKEEXT_CERT_CONFIG_ENTERPRISE_STORE = ( IKEEXT_CERT_CONFIG_EXPLICIT_TRUST_LIST + 1 ) , IKEEXT_CERT_CONFIG_TRUSTED_ROOT_STORE = ( IKEEXT_CERT_CONFIG_ENTERPRISE_STORE + 1 ) , IKEEXT_CERT_CONFIG_UNSPECIFIED = ( IKEEXT_CERT_CONFIG_TRUSTED_ROOT_STORE + 1 ) , IKEEXT_CERT_CONFIG_TYPE_MAX = ( IKEEXT_CERT_CONFIG_UNSPECIFIED + 1 ) } IKEEXT_CERT_CONFIG_TYPE; typedef struct IKEEXT_CERTIFICATE_AUTHENTICATION0_ { IKEEXT_CERT_CONFIG_TYPE inboundConfigType; union { struct { UINT32 inboundRootArraySize; IKEEXT_CERT_ROOT_CONFIG0 *inboundRootArray; } ; IKEEXT_CERT_ROOT_CONFIG0 *inboundEnterpriseStoreConfig; IKEEXT_CERT_ROOT_CONFIG0 *inboundTrustedRootStoreConfig; } ; IKEEXT_CERT_CONFIG_TYPE outboundConfigType; union { struct { UINT32 outboundRootArraySize; IKEEXT_CERT_ROOT_CONFIG0 *outboundRootArray; } ; IKEEXT_CERT_ROOT_CONFIG0 *outboundEnterpriseStoreConfig; IKEEXT_CERT_ROOT_CONFIG0 *outboundTrustedRootStoreConfig; } ; UINT32 flags; } IKEEXT_CERTIFICATE_AUTHENTICATION0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_CERTIFICATE_AUTHENTICATION1_ { IKEEXT_CERT_CONFIG_TYPE inboundConfigType; union { struct { UINT32 inboundRootArraySize; IKEEXT_CERT_ROOT_CONFIG0 *inboundRootArray; } ; IKEEXT_CERT_ROOT_CONFIG0 *inboundEnterpriseStoreConfig; IKEEXT_CERT_ROOT_CONFIG0 *inboundTrustedRootStoreConfig; /* Empty union arm */ } ; IKEEXT_CERT_CONFIG_TYPE outboundConfigType; union { struct { UINT32 outboundRootArraySize; IKEEXT_CERT_ROOT_CONFIG0 *outboundRootArray; } ; IKEEXT_CERT_ROOT_CONFIG0 *outboundEnterpriseStoreConfig; IKEEXT_CERT_ROOT_CONFIG0 *outboundTrustedRootStoreConfig; /* Empty union arm */ } ; UINT32 flags; FWP_BYTE_BLOB localCertLocationUrl; } IKEEXT_CERTIFICATE_AUTHENTICATION1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_IPV6_CGA_AUTHENTICATION0_ { wchar_t *keyContainerName; wchar_t *cspName; UINT32 cspType; FWP_BYTE_ARRAY16 cgaModifier; BYTE cgaCollisionCount; } IKEEXT_IPV6_CGA_AUTHENTICATION0; #define IKEEXT_KERB_AUTH_DISABLE_INITIATOR_TOKEN_GENERATION (0x00000001) #define IKEEXT_KERB_AUTH_DONT_ACCEPT_EXPLICIT_CREDENTIALS (0x00000002) typedef struct IKEEXT_KERBEROS_AUTHENTICATION0__ { UINT32 flags; } IKEEXT_KERBEROS_AUTHENTICATION0; #define IKEEXT_NTLM_V2_AUTH_DONT_ACCEPT_EXPLICIT_CREDENTIALS (0x00000001) typedef struct IKEEXT_NTLM_V2_AUTHENTICATION0__ { UINT32 flags; } IKEEXT_NTLM_V2_AUTHENTICATION0; #if (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_EAP_FLAG_LOCAL_AUTH_ONLY (0x00000001) #define IKEEXT_EAP_FLAG_REMOTE_AUTH_ONLY (0x00000002) typedef struct IKEEXT_EAP_AUTHENTICATION0__ { UINT32 flags; } IKEEXT_EAP_AUTHENTICATION0; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_AUTHENTICATION_METHOD0_ { IKEEXT_AUTHENTICATION_METHOD_TYPE authenticationMethodType; union { IKEEXT_PRESHARED_KEY_AUTHENTICATION0 presharedKeyAuthentication; IKEEXT_CERTIFICATE_AUTHENTICATION0 certificateAuthentication; IKEEXT_KERBEROS_AUTHENTICATION0 kerberosAuthentication; IKEEXT_NTLM_V2_AUTHENTICATION0 ntlmV2Authentication; /* Empty union arm */ IKEEXT_CERTIFICATE_AUTHENTICATION0 sslAuthentication; IKEEXT_IPV6_CGA_AUTHENTICATION0 cgaAuthentication; } ; } IKEEXT_AUTHENTICATION_METHOD0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_AUTHENTICATION_METHOD1_ { IKEEXT_AUTHENTICATION_METHOD_TYPE authenticationMethodType; union { IKEEXT_PRESHARED_KEY_AUTHENTICATION1 presharedKeyAuthentication; IKEEXT_CERTIFICATE_AUTHENTICATION1 certificateAuthentication; IKEEXT_KERBEROS_AUTHENTICATION0 kerberosAuthentication; IKEEXT_NTLM_V2_AUTHENTICATION0 ntlmV2Authentication; /* Empty union arm */ IKEEXT_CERTIFICATE_AUTHENTICATION1 sslAuthentication; IKEEXT_IPV6_CGA_AUTHENTICATION0 cgaAuthentication; IKEEXT_EAP_AUTHENTICATION0 eapAuthentication; } ; } IKEEXT_AUTHENTICATION_METHOD1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef /* [v1_enum] */ enum IKEEXT_CIPHER_TYPE_ { IKEEXT_CIPHER_DES = 0, IKEEXT_CIPHER_3DES = ( IKEEXT_CIPHER_DES + 1 ) , IKEEXT_CIPHER_AES_128 = ( IKEEXT_CIPHER_3DES + 1 ) , IKEEXT_CIPHER_AES_192 = ( IKEEXT_CIPHER_AES_128 + 1 ) , IKEEXT_CIPHER_AES_256 = ( IKEEXT_CIPHER_AES_192 + 1 ) , IKEEXT_CIPHER_TYPE_MAX = ( IKEEXT_CIPHER_AES_256 + 1 ) } IKEEXT_CIPHER_TYPE; typedef struct IKEEXT_CIPHER_ALGORITHM0_ { IKEEXT_CIPHER_TYPE algoIdentifier; UINT32 keyLen; UINT32 rounds; } IKEEXT_CIPHER_ALGORITHM0; typedef /* [v1_enum] */ enum IKEEXT_INTEGRITY_TYPE_ { IKEEXT_INTEGRITY_MD5 = 0, IKEEXT_INTEGRITY_SHA1 = ( IKEEXT_INTEGRITY_MD5 + 1 ) , IKEEXT_INTEGRITY_SHA_256 = ( IKEEXT_INTEGRITY_SHA1 + 1 ) , IKEEXT_INTEGRITY_SHA_384 = ( IKEEXT_INTEGRITY_SHA_256 + 1 ) , IKEEXT_INTEGRITY_TYPE_MAX = ( IKEEXT_INTEGRITY_SHA_384 + 1 ) } IKEEXT_INTEGRITY_TYPE; typedef struct IKEEXT_INTEGRITY_ALGORITHM0_ { IKEEXT_INTEGRITY_TYPE algoIdentifier; } IKEEXT_INTEGRITY_ALGORITHM0; typedef /* [v1_enum] */ enum IKEEXT_DH_GROUP_ { IKEEXT_DH_GROUP_NONE = 0, IKEEXT_DH_GROUP_1 = ( IKEEXT_DH_GROUP_NONE + 1 ) , IKEEXT_DH_GROUP_2 = ( IKEEXT_DH_GROUP_1 + 1 ) , IKEEXT_DH_GROUP_2048 = ( IKEEXT_DH_GROUP_2 + 1 ) , IKEEXT_DH_ECP_256 = ( IKEEXT_DH_GROUP_2048 + 1 ) , IKEEXT_DH_ECP_384 = ( IKEEXT_DH_ECP_256 + 1 ) , IKEEXT_DH_GROUP_MAX = ( IKEEXT_DH_ECP_384 + 1 ) } IKEEXT_DH_GROUP; typedef struct IKEEXT_PROPOSAL0_ { IKEEXT_CIPHER_ALGORITHM0 cipherAlgorithm; IKEEXT_INTEGRITY_ALGORITHM0 integrityAlgorithm; UINT32 maxLifetimeSeconds; IKEEXT_DH_GROUP dhGroup; UINT32 quickModeLimit; } IKEEXT_PROPOSAL0; #define IKEEXT_POLICY_FLAG_DISABLE_DIAGNOSTICS (0x00000001) #define IKEEXT_POLICY_FLAG_NO_MACHINE_LUID_VERIFY (0x00000002) #define IKEEXT_POLICY_FLAG_NO_IMPERSONATION_LUID_VERIFY (0x00000004) #define IKEEXT_POLICY_FLAG_ENABLE_OPTIONAL_DH (0x00000008) typedef struct IKEEXT_POLICY0_ { UINT32 softExpirationTime; UINT32 numAuthenticationMethods; IKEEXT_AUTHENTICATION_METHOD0 *authenticationMethods; IKEEXT_AUTHENTICATION_IMPERSONATION_TYPE initiatorImpersonationType; UINT32 numIkeProposals; IKEEXT_PROPOSAL0 *ikeProposals; UINT32 flags; UINT32 maxDynamicFilters; } IKEEXT_POLICY0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_POLICY1_ { UINT32 softExpirationTime; UINT32 numAuthenticationMethods; IKEEXT_AUTHENTICATION_METHOD1 *authenticationMethods; IKEEXT_AUTHENTICATION_IMPERSONATION_TYPE initiatorImpersonationType; UINT32 numIkeProposals; IKEEXT_PROPOSAL0 *ikeProposals; UINT32 flags; UINT32 maxDynamicFilters; UINT32 retransmitDurationSecs; } IKEEXT_POLICY1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_EM_POLICY0_ { UINT32 numAuthenticationMethods; IKEEXT_AUTHENTICATION_METHOD0 *authenticationMethods; IKEEXT_AUTHENTICATION_IMPERSONATION_TYPE initiatorImpersonationType; } IKEEXT_EM_POLICY0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_EM_POLICY1_ { UINT32 numAuthenticationMethods; IKEEXT_AUTHENTICATION_METHOD1 *authenticationMethods; IKEEXT_AUTHENTICATION_IMPERSONATION_TYPE initiatorImpersonationType; } IKEEXT_EM_POLICY1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) #define IKEEXT_ERROR_CODE_COUNT (ERROR_IPSEC_IKE_NEG_STATUS_END - ERROR_IPSEC_IKE_NEG_STATUS_BEGIN) typedef struct IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS0_ { UINT32 currentActiveMainModes; UINT32 totalMainModesStarted; UINT32 totalSuccessfulMainModes; UINT32 totalFailedMainModes; UINT32 totalResponderMainModes; UINT32 currentNewResponderMainModes; UINT32 currentActiveQuickModes; UINT32 totalQuickModesStarted; UINT32 totalSuccessfulQuickModes; UINT32 totalFailedQuickModes; UINT32 totalAcquires; UINT32 totalReinitAcquires; UINT32 currentActiveExtendedModes; UINT32 totalExtendedModesStarted; UINT32 totalSuccessfulExtendedModes; UINT32 totalFailedExtendedModes; UINT32 totalImpersonationExtendedModes; UINT32 totalImpersonationMainModes; } IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS1_ { UINT32 currentActiveMainModes; UINT32 totalMainModesStarted; UINT32 totalSuccessfulMainModes; UINT32 totalFailedMainModes; UINT32 totalResponderMainModes; UINT32 currentNewResponderMainModes; UINT32 currentActiveQuickModes; UINT32 totalQuickModesStarted; UINT32 totalSuccessfulQuickModes; UINT32 totalFailedQuickModes; UINT32 totalAcquires; UINT32 totalReinitAcquires; UINT32 currentActiveExtendedModes; UINT32 totalExtendedModesStarted; UINT32 totalSuccessfulExtendedModes; UINT32 totalFailedExtendedModes; UINT32 totalImpersonationExtendedModes; UINT32 totalImpersonationMainModes; } IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_KEYMODULE_STATISTICS0_ { IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS0 v4Statistics; IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS0 v6Statistics; UINT32 errorFrequencyTable[ 97 ]; UINT32 mainModeNegotiationTime; UINT32 quickModeNegotiationTime; UINT32 extendedModeNegotiationTime; } IKEEXT_KEYMODULE_STATISTICS0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_KEYMODULE_STATISTICS1_ { IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS1 v4Statistics; IKEEXT_IP_VERSION_SPECIFIC_KEYMODULE_STATISTICS1 v6Statistics; UINT32 errorFrequencyTable[ 97 ]; UINT32 mainModeNegotiationTime; UINT32 quickModeNegotiationTime; UINT32 extendedModeNegotiationTime; } IKEEXT_KEYMODULE_STATISTICS1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS0_ { UINT32 totalSocketReceiveFailures; UINT32 totalSocketSendFailures; } IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS1_ { UINT32 totalSocketReceiveFailures; UINT32 totalSocketSendFailures; } IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_COMMON_STATISTICS0_ { IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS0 v4Statistics; IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS0 v6Statistics; UINT32 totalPacketsReceived; UINT32 totalInvalidPacketsReceived; UINT32 currentQueuedWorkitems; } IKEEXT_COMMON_STATISTICS0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_COMMON_STATISTICS1_ { IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS1 v4Statistics; IKEEXT_IP_VERSION_SPECIFIC_COMMON_STATISTICS1 v6Statistics; UINT32 totalPacketsReceived; UINT32 totalInvalidPacketsReceived; UINT32 currentQueuedWorkitems; } IKEEXT_COMMON_STATISTICS1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_STATISTICS0_ { IKEEXT_KEYMODULE_STATISTICS0 ikeStatistics; IKEEXT_KEYMODULE_STATISTICS0 authipStatistics; IKEEXT_COMMON_STATISTICS0 commonStatistics; } IKEEXT_STATISTICS0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_STATISTICS1_ { IKEEXT_KEYMODULE_STATISTICS1 ikeStatistics; IKEEXT_KEYMODULE_STATISTICS1 authipStatistics; IKEEXT_KEYMODULE_STATISTICS1 ikeV2Statistics; IKEEXT_COMMON_STATISTICS1 commonStatistics; } IKEEXT_STATISTICS1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_TRAFFIC0_ { FWP_IP_VERSION ipVersion; union { UINT32 localV4Address; UINT8 localV6Address[ 16 ]; } ; union { UINT32 remoteV4Address; UINT8 remoteV6Address[ 16 ]; } ; UINT64 authIpFilterId; } IKEEXT_TRAFFIC0; typedef UINT64 IKEEXT_COOKIE; typedef struct IKEEXT_COOKIE_PAIR0_ { IKEEXT_COOKIE initiator; IKEEXT_COOKIE responder; } IKEEXT_COOKIE_PAIR0; #define IKEEXT_CERT_CREDENTIAL_FLAG_NAP_CERT (0x00000001) typedef struct IKEEXT_CERTIFICATE_CREDENTIAL0_ { FWP_BYTE_BLOB subjectName; FWP_BYTE_BLOB certHash; UINT32 flags; } IKEEXT_CERTIFICATE_CREDENTIAL0; typedef struct IKEEXT_NAME_CREDENTIAL0_ { wchar_t *principalName; } IKEEXT_NAME_CREDENTIAL0; typedef struct IKEEXT_CREDENTIAL0_ { IKEEXT_AUTHENTICATION_METHOD_TYPE authenticationMethodType; IKEEXT_AUTHENTICATION_IMPERSONATION_TYPE impersonationType; union { IKEEXT_PRESHARED_KEY_AUTHENTICATION0 *presharedKey; IKEEXT_CERTIFICATE_CREDENTIAL0 *certificate; IKEEXT_NAME_CREDENTIAL0 *name; /* Empty union arm */ } ; } IKEEXT_CREDENTIAL0; typedef struct IKEEXT_CREDENTIAL_PAIR0_ { IKEEXT_CREDENTIAL0 localCredentials; IKEEXT_CREDENTIAL0 peerCredentials; } IKEEXT_CREDENTIAL_PAIR0; typedef struct IKEEXT_CREDENTIALS0_ { UINT32 numCredentials; IKEEXT_CREDENTIAL_PAIR0 *credentials; } IKEEXT_CREDENTIALS0; typedef struct IKEEXT_SA_DETAILS0_ { UINT64 saId; IKEEXT_KEY_MODULE_TYPE keyModuleType; FWP_IP_VERSION ipVersion; union { IPSEC_V4_UDP_ENCAPSULATION0 *v4UdpEncapsulation; /* Empty union arm */ } ; IKEEXT_TRAFFIC0 ikeTraffic; IKEEXT_PROPOSAL0 ikeProposal; IKEEXT_COOKIE_PAIR0 cookiePair; IKEEXT_CREDENTIALS0 ikeCredentials; GUID ikePolicyKey; UINT64 virtualIfTunnelId; } IKEEXT_SA_DETAILS0; #if (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_CERTIFICATE_CREDENTIAL1_ { FWP_BYTE_BLOB subjectName; FWP_BYTE_BLOB certHash; UINT32 flags; FWP_BYTE_BLOB certificate; } IKEEXT_CERTIFICATE_CREDENTIAL1; typedef struct IKEEXT_CREDENTIAL1_ { IKEEXT_AUTHENTICATION_METHOD_TYPE authenticationMethodType; IKEEXT_AUTHENTICATION_IMPERSONATION_TYPE impersonationType; union { IKEEXT_PRESHARED_KEY_AUTHENTICATION1 *presharedKey; IKEEXT_CERTIFICATE_CREDENTIAL1 *certificate; IKEEXT_NAME_CREDENTIAL0 *name; /* Empty union arm */ } ; } IKEEXT_CREDENTIAL1; typedef struct IKEEXT_CREDENTIAL_PAIR1_ { IKEEXT_CREDENTIAL1 localCredentials; IKEEXT_CREDENTIAL1 peerCredentials; } IKEEXT_CREDENTIAL_PAIR1; typedef struct IKEEXT_CREDENTIALS1_ { UINT32 numCredentials; IKEEXT_CREDENTIAL_PAIR1 *credentials; } IKEEXT_CREDENTIALS1; typedef struct IKEEXT_SA_DETAILS1_ { UINT64 saId; IKEEXT_KEY_MODULE_TYPE keyModuleType; FWP_IP_VERSION ipVersion; union { IPSEC_V4_UDP_ENCAPSULATION0 *v4UdpEncapsulation; /* Empty union arm */ } ; IKEEXT_TRAFFIC0 ikeTraffic; IKEEXT_PROPOSAL0 ikeProposal; IKEEXT_COOKIE_PAIR0 cookiePair; IKEEXT_CREDENTIALS1 ikeCredentials; GUID ikePolicyKey; UINT64 virtualIfTunnelId; FWP_BYTE_BLOB correlationKey; } IKEEXT_SA_DETAILS1; #endif // (NTDDI_VERSION >= NTDDI_WIN7) typedef struct IKEEXT_SA_ENUM_TEMPLATE0_ { FWP_CONDITION_VALUE0 localSubNet; FWP_CONDITION_VALUE0 remoteSubNet; FWP_BYTE_BLOB localMainModeCertHash; } IKEEXT_SA_ENUM_TEMPLATE0; typedef /* [v1_enum] */ enum IKEEXT_MM_SA_STATE_ { IKEEXT_MM_SA_STATE_NONE = 0, IKEEXT_MM_SA_STATE_SA_SENT = ( IKEEXT_MM_SA_STATE_NONE + 1 ) , IKEEXT_MM_SA_STATE_SSPI_SENT = ( IKEEXT_MM_SA_STATE_SA_SENT + 1 ) , IKEEXT_MM_SA_STATE_FINAL = ( IKEEXT_MM_SA_STATE_SSPI_SENT + 1 ) , IKEEXT_MM_SA_STATE_FINAL_SENT = ( IKEEXT_MM_SA_STATE_FINAL + 1 ) , IKEEXT_MM_SA_STATE_COMPLETE = ( IKEEXT_MM_SA_STATE_FINAL_SENT + 1 ) , IKEEXT_MM_SA_STATE_MAX = ( IKEEXT_MM_SA_STATE_COMPLETE + 1 ) } IKEEXT_MM_SA_STATE; typedef /* [v1_enum] */ enum IKEEXT_QM_SA_STATE_ { IKEEXT_QM_SA_STATE_NONE = 0, IKEEXT_QM_SA_STATE_INITIAL = ( IKEEXT_QM_SA_STATE_NONE + 1 ) , IKEEXT_QM_SA_STATE_FINAL = ( IKEEXT_QM_SA_STATE_INITIAL + 1 ) , IKEEXT_QM_SA_STATE_COMPLETE = ( IKEEXT_QM_SA_STATE_FINAL + 1 ) , IKEEXT_QM_SA_STATE_MAX = ( IKEEXT_QM_SA_STATE_COMPLETE + 1 ) } IKEEXT_QM_SA_STATE; typedef /* [v1_enum] */ enum IKEEXT_EM_SA_STATE_ { IKEEXT_EM_SA_STATE_NONE = 0, IKEEXT_EM_SA_STATE_SENT_ATTS = ( IKEEXT_EM_SA_STATE_NONE + 1 ) , IKEEXT_EM_SA_STATE_SSPI_SENT = ( IKEEXT_EM_SA_STATE_SENT_ATTS + 1 ) , IKEEXT_EM_SA_STATE_AUTH_COMPLETE = ( IKEEXT_EM_SA_STATE_SSPI_SENT + 1 ) , IKEEXT_EM_SA_STATE_FINAL = ( IKEEXT_EM_SA_STATE_AUTH_COMPLETE + 1 ) , IKEEXT_EM_SA_STATE_COMPLETE = ( IKEEXT_EM_SA_STATE_FINAL + 1 ) , IKEEXT_EM_SA_STATE_MAX = ( IKEEXT_EM_SA_STATE_COMPLETE + 1 ) } IKEEXT_EM_SA_STATE; typedef /* [v1_enum] */ enum IKEEXT_SA_ROLE_ { IKEEXT_SA_ROLE_INITIATOR = 0, IKEEXT_SA_ROLE_RESPONDER = ( IKEEXT_SA_ROLE_INITIATOR + 1 ) , IKEEXT_SA_ROLE_MAX = ( IKEEXT_SA_ROLE_RESPONDER + 1 ) } IKEEXT_SA_ROLE; #if _MSC_VER >= 800 #if _MSC_VER >= 1200 #pragma warning(pop) #else #pragma warning(default:4201) #endif #endif extern RPC_IF_HANDLE __MIDL_itf_iketypes_0000_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf_iketypes_0000_0000_v0_0_s_ifspec; /* Additional Prototypes for ALL interfaces */ /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/network/network.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include <WinSock2.h> #include <arkdrv-api/arkdrv-api.h> #include "network.h" /* //https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/8fd93a3d-a794-4233-9ff7-09b89eed6b1f/compiling-with-wfp?forum=wfp #include "include/fwpmu.h" #pragma comment(lib, "fwpuclnt.lib") #pragma comment(lib, "Rpcrt4.lib") BOOLEAN GuidEqual(_In_ const GUID* pGUIDAlpha, _In_ const GUID* pGUIDOmega) { RPC_STATUS status = RPC_S_OK; UINT32 areEqual = FALSE; do { if (pGUIDAlpha == 0 || pGUIDOmega == 0) { if ((pGUIDAlpha == 0 && pGUIDOmega) || (pGUIDAlpha && pGUIDOmega == 0)) break; } if (pGUIDAlpha == 0 && pGUIDOmega == 0) { areEqual = TRUE; break; } areEqual = UuidEqual((UUID*)pGUIDAlpha, (UUID*)pGUIDOmega, &status); } while (false); return (BOOLEAN)areEqual; } bool EnumWfpCallouts(std::vector<CALLOUT_INFO>& CalloutIDs) { bool Result = false; HANDLE EngineHandle = NULL; UINT32 status = NO_ERROR; FWPM_SESSION session = { 0 }; HANDLE EnumHandle = NULL; FWPM_CALLOUT_ENUM_TEMPLATE* pCalloutEnumTemplate = NULL; session.displayData.name = L"WFPSampler's User Mode Session"; session.flags = 0; do { status = FwpmEngineOpen0(0, RPC_C_AUTHN_WINNT, 0, &session, &EngineHandle); if (status != NO_ERROR) { break; } status = FwpmCalloutCreateEnumHandle(EngineHandle, pCalloutEnumTemplate, &EnumHandle); if (status != NO_ERROR) { break; } UINT32 NumEntries = 0; FWPM_CALLOUT** ppCallouts = 0; status = FwpmCalloutEnum0(EngineHandle, EnumHandle, 0xFFFFFFFF, &ppCallouts, &NumEntries); if (status != NO_ERROR) { break; } if (ppCallouts) { for (DWORD Index = 0; Index < NumEntries; Index++) { CALLOUT_INFO CalloutInfo; CalloutInfo.CalloutId = ppCallouts[Index]->calloutId; RtlCopyMemory(&CalloutInfo.CalloutKey, &ppCallouts[Index]->calloutKey, sizeof(GUID)); CalloutIDs.push_back(CalloutInfo); } Result = true; } } while (false); if (EnumHandle) { FwpmCalloutDestroyEnumHandle(EngineHandle, EnumHandle); } if (EngineHandle) { status = FwpmEngineClose(EngineHandle); } if (pCalloutEnumTemplate) { delete pCalloutEnumTemplate; pCalloutEnumTemplate = NULL; } return Result; } UINT64 GetFilterIDByCalloutKey(const GUID* CalloutKey) { UINT64 Result = 0; HANDLE EngineHandle = NULL; LONG Status = NO_ERROR; FWPM_SESSION Session = { 0 }; HANDLE EnumHandle = 0; FWPM_FILTER_ENUM_TEMPLATE* pFilterEnumTemplate = NULL; Session.displayData.name = L"WFPSampler's User Mode Session"; Session.flags = 0; do { Status = FwpmEngineOpen(0, RPC_C_AUTHN_WINNT, 0, &Session, &EngineHandle); if (Status != NO_ERROR) { break; } UINT32 NumEntries = 0; FWPM_FILTER** ppFilters = 0; Status = FwpmFilterCreateEnumHandle0(EngineHandle, pFilterEnumTemplate, &EnumHandle); if (Status != NO_ERROR) { break; } Status = FwpmFilterEnum0(EngineHandle, EnumHandle, 0xFFFFFFFF, &ppFilters, &NumEntries); if (Status != NO_ERROR) { break; } if (Status == NO_ERROR && ppFilters && NumEntries) { for (UINT32 Index = 0; Index < NumEntries; Index++) { if (GuidEqual(&ppFilters[Index]->action.calloutKey, CalloutKey)) { Result = ppFilters[Index]->filterId; break; } } } } while (false); if (EngineHandle) { Status = FwpmEngineClose(EngineHandle); } if (pFilterEnumTemplate) { delete pFilterEnumTemplate; pFilterEnumTemplate = NULL; } return Result; } bool DeleteFilterById(UINT64 FilterId) { bool Result = false; HANDLE EngineHandle = NULL; LONG Status = NO_ERROR; FWPM_SESSION Session = { 0 }; Session.displayData.name = L"WFPSampler's User Mode Session"; Session.flags = 0; do { Status = FwpmEngineOpen(0, RPC_C_AUTHN_WINNT, 0, &Session, &EngineHandle); if (Status != NO_ERROR) { break; } Status = FwpmFilterDeleteById(EngineHandle, FilterId); if (Status != NO_ERROR) { break; } Result = true; } while (false); if (EngineHandle) { Status = FwpmEngineClose(EngineHandle); } return Result; } */ bool WfpSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } #define QVariantHex(s1) s1.toString().toULongLong(nullptr, 16) #define QVariantStrcmp(s1, s2) QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) bool PortSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); auto column = left.column(); if ((column == 1 || column == 2)) { auto list1 = s1.toString().split(":"); auto list2 = s2.toString().split(":"); auto ip1 = list1[0]; auto ip2 = list2[0]; if (ip1 != ip2) return ip1 < ip2; return QHexToDWord(list1[1]) < QHexToDWord(list2[1]); } if ((column == 4)) return QVariantHex(s1) < QVariantHex(s2); return QVariantStrcmp(s1, s2) < 0; } KernelNetwork::KernelNetwork() { } KernelNetwork::~KernelNetwork() { } void KernelNetwork::onTabChanged(int index) { switch (index) { //case TAB_KERNEL_NETWORK_WFP: ShowWfpInfo(); break; case TAB_KERNEL_NETWORK_PORT: onShowPortInfo(); break; default: break; } CommonTabObject::onTabChanged(index); } bool KernelNetwork::eventFilter(QObject *obj, QEvent *e) { if (e->type() == QEvent::ContextMenu) { QMenu *menu = nullptr; if (obj == ui_->hostsFileListWidget) menu = hosts_menu_; if (obj == ui_->portView) menu = port_menu_; QContextMenuEvent *ctxevt = dynamic_cast<QContextMenuEvent*>(e); if (ctxevt && menu) { menu->move(ctxevt->globalPos()); menu->show(); } } if (e->type() == QEvent::KeyPress) { QKeyEvent *keyevt = dynamic_cast<QKeyEvent*>(e); if (keyevt->matches(QKeySequence::Delete)) { for (auto &action : hosts_menu_->actions()) { if (action->text() == tr("Delete")) emit action->trigger(); } } if (keyevt->matches(QKeySequence::Refresh)) { onShowPortInfo(); } } return QWidget::eventFilter(obj, e); } void KernelNetwork::ModuleInit(Ui::Kernel *ui, Kernel *kernel) { this->ui_ = ui; this->kernel_ = kernel; Init(ui->tabNetwork, TAB_KERNEL, TAB_KERNEL_NETWORK); //InitWfpView(); InitHostsView(); InitPortView(); //onTabChanged(ui_->tabNetwork->currentIndex()); } void KernelNetwork::InitWfpView() { /* wfp_model_ = new QStandardItemModel; QTreeView *view = ui_->wfpView; proxy_wfp_ = new WfpSortFilterProxyModel(view); proxy_wfp_->setSourceModel(wfp_model_); proxy_wfp_->setDynamicSortFilter(true); proxy_wfp_->setFilterKeyColumn(1); view->setModel(proxy_wfp_); view->selectionModel()->setModel(proxy_wfp_); view->header()->setSortIndicator(-1, Qt::AscendingOrder); view->setSortingEnabled(true); view->viewport()->installEventFilter(kernel_); view->installEventFilter(kernel_); std::pair<int, QString> colum_layout[] = { { 130, tr("ID") }, { 100, tr("Key") }, { 200, tr("Name") }, }; QStringList name_list; for (auto p : colum_layout) { name_list << p.second; } wfp_model_->setHorizontalHeaderLabels(name_list); for (int i = 0; i < _countof(colum_layout); i++) { view->setColumnWidth(i, colum_layout[i].first); } view->setEditTriggers(QAbstractItemView::NoEditTriggers); */ } void KernelNetwork::InitHostsView() { hosts_dir_ = UNONE::OsSystem32DirW() + L"\\drivers\\etc"; hosts_file_ = hosts_dir_ + L"\\hosts"; auto GetCurrentHostsName = [=]()->std::wstring { std::wstring hosts; auto cur = ui_->hostsFileListWidget->currentItem(); if (cur) { hosts = cur->text().toStdWString(); } return std::move(hosts); }; auto GetCurrentHostsPath = [=]()->std::wstring { std::wstring hosts = GetCurrentHostsName(); if (!hosts.empty()) hosts = hosts_dir_ + L"\\" + hosts; return std::move(hosts); }; auto RefreshHostsData = [=]() { std::string data; auto &&hosts = GetCurrentHostsPath(); UNONE::FsReadFileDataW(hosts, data); ui_->hostsDataEdit->setText(StrToQ(data)); }; auto WriteHostsData = [=](std::wstring path = L"") { std::string data = ui_->hostsDataEdit->toPlainText().toStdString(); std::wstring hosts; if (path.empty()) hosts = GetCurrentHostsPath(); else hosts = path; UNONE::StrReplaceA(data, "\n", "\r\n"); UNONE::FsWriteFileDataW(hosts, data); }; auto RefreshHostsList = [=]() { auto row = ui_->hostsFileListWidget->currentRow(); ui_->hostsFileListWidget->clear(); std::vector<std::wstring> names; UNONE::DirEnumCallbackW fcb = [&](wchar_t* path, wchar_t* name, void* param)->bool { if (UNONE::FsIsDirW(path)) return true; size_t yy=UNONE::StrIndexIW(std::wstring(name), std::wstring(L"hosts")); if (UNONE::StrIndexIW(std::wstring(name), std::wstring(L"hosts")) != 0) return true; names.push_back(name); return true; }; UNONE::FsEnumDirectoryW(hosts_dir_, fcb); for (auto &n : names) { ui_->hostsFileListWidget->addItem(WStrToQ(n)); } ui_->hostsFileListWidget->setCurrentRow(row); }; connect(ui_->hostsFileListWidget, &QListWidget::itemSelectionChanged, [=] { RefreshHostsData(); }); connect(ui_->hostsRefreshBtn, &QPushButton::clicked, [=] { RefreshHostsData(); RefreshHostsList(); }); connect(ui_->hostsSaveBtn, &QPushButton::clicked, [=] { WriteHostsData(); }); connect(ui_->hostsBackupBtn, &QPushButton::clicked, [=] { bool ok; SYSTEMTIME systime; GetSystemTime(&systime); QString def = WStrToQ(UNONE::TmFormatSystemTimeW(systime, L"YMD-HWS")); QString text = QInputDialog::getText(this, tr("Hosts Backup"), tr("Please input file name: (hosts-***)"), QLineEdit::Normal, def, &ok); if (ok && !text.isEmpty()) { auto &&hosts = hosts_dir_ + L"\\hosts-" + text.toStdWString(); WriteHostsData(hosts); RefreshHostsList(); } }); connect(ui_->hostsClearBtn, &QPushButton::clicked, [=] { ui_->hostsDataEdit->clear(); }); connect(ui_->hostsDirBtn, &QPushButton::clicked, [&] { ShellRun(WStrToQ(hosts_dir_), ""); }); if (!UNONE::FsIsExistedW(hosts_file_)) UNONE::FsWriteFileDataW(hosts_file_, "# 127.0.0.1 localhost\n# ::1 localhost"); RefreshHostsList(); ui_->hostsFileListWidget->setCurrentRow(0); ui_->hostsFileListWidget->installEventFilter(this); hosts_menu_ = new QMenu(); hosts_menu_->addAction(tr("Mark as Main"), kernel_, [=] { WriteHostsData(hosts_file_); RefreshHostsList(); ui_->hostsFileListWidget->setCurrentRow(0); }); hosts_menu_->addAction(tr("Rename"), kernel_, [=] { bool ok; std::wstring &&old = GetCurrentHostsPath(); auto && name = UNONE::FsPathToNameW(old); UNONE::StrReplaceIW(name, L"hosts-"); QString text = QInputDialog::getText(this, tr("Hosts Rename"), tr("Please input file name: (hosts-***)"), QLineEdit::Normal, WStrToQ(name), &ok); if (ok) { DeleteFileW(old.c_str()); std::wstring hosts; if (!text.isEmpty()) { hosts = hosts_dir_ + L"\\hosts-" + text.toStdWString(); } else { hosts = hosts_dir_ + L"\\hosts"; } WriteHostsData(hosts); RefreshHostsList(); } }); hosts_menu_->addAction(tr("Backup"), kernel_, [=] { emit ui_->hostsBackupBtn->click(); }); auto copy_menu = new QMenu(); copy_menu->addAction(tr("File Name"))->setData(0); copy_menu->addAction(tr("File Path"))->setData(1); copy_menu->setTitle(tr("Copy")); connect(copy_menu, &QMenu::triggered, [=](QAction* action) { auto idx = action->data().toInt(); std::wstring data; switch (idx) { case 0: data = GetCurrentHostsName(); break; case 1: data = GetCurrentHostsPath(); break; } ClipboardCopyData(UNONE::StrToA(data)); }); hosts_menu_->addAction(tr("Refresh"), kernel_, [=] { emit ui_->hostsRefreshBtn->click(); }); hosts_menu_->addAction(copy_menu->menuAction()); hosts_menu_->addSeparator(); hosts_menu_->addAction(tr("Delete"), kernel_, [=] { DeleteFileW(GetCurrentHostsPath().c_str()); emit ui_->hostsRefreshBtn->click(); }, QKeySequence::Delete); hosts_menu_->addAction(tr("Delete Non-Main"), kernel_, [=] { if (QMessageBox::warning(this, tr("Warning"), tr("Are you sure to delete all hosts file(include backups)?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { return; } for (int i = 0; i < ui_->hostsFileListWidget->count(); i++) { auto name = ui_->hostsFileListWidget->item(i)->text(); if (!name.compare("hosts", Qt::CaseInsensitive)) continue; auto path = hosts_dir_ + L"\\" + QToWStr(name); DeleteFileW(path.c_str()); } emit ui_->hostsRefreshBtn->click(); }); } void KernelNetwork::InitPortView() { QTreeView *view = ui_->portView; port_model_ = new QStandardItemModel; proxy_port_ = new PortSortFilterProxyModel(view); std::vector<std::pair<int, QString>> layout = { { 50, tr("Protocol") }, { 135, tr("Local address") }, { 145, tr("Foreign address") }, { 100, tr("State") }, { 50, tr("PID") }, { 530, tr("Process Path") }, }; SetDefaultTreeViewStyle(view, port_model_, proxy_port_, layout); view->viewport()->installEventFilter(this); view->installEventFilter(this); port_menu_ = new QMenu(); port_menu_->addAction(tr("Refresh"), this, [&] { onShowPortInfo(); }, QKeySequence::Refresh); port_menu_->addAction(tr("Copy"), this, [&] { auto view = ui_->portView; ClipboardCopyData(GetCurItemViewData(view, GetCurViewColumn(view)).toStdString()); }); port_menu_->addSeparator(); port_menu_->addAction(tr("Kill Process"), this, [&] { auto pid = GetCurItemViewData(ui_->portView, 4).toInt(); PsKillProcess(pid); onShowPortInfo(); }); port_menu_->addSeparator(); port_menu_->addAction(tr("Sendto Scanner"), this, [&] { kernel_->GetParent()->SetActiveTab(TAB_SCANNER); emit kernel_->signalOpen(GetCurItemViewData(ui_->portView, 5)); }); port_menu_->addAction(tr("Explore File"), this, [&] { ExploreFile(GetCurItemViewData(ui_->portView, 5)); }); port_menu_->addAction(tr("Properties..."), this, [&]() { WinShowProperties(GetCurItemViewData(ui_->portView, 5).toStdWString()); }); connect(ui_->locaIPv4Btn, &QPushButton::clicked, [] {ShellRun("cmd.exe", "/k ipconfig|findstr /i ipv4"); }); connect(ui_->locaIPv6Btn, &QPushButton::clicked, [] {ShellRun("cmd.exe", "/k ipconfig|findstr /i ipv6"); }); connect(ui_->ipv4CheckBox, SIGNAL(clicked()), this, SLOT(onShowPortInfo())); connect(ui_->ipv6CheckBox, SIGNAL(clicked()), this, SLOT(onShowPortInfo())); connect(ui_->tcpListenCheckBox, SIGNAL(clicked()), this, SLOT(onShowPortInfo())); connect(ui_->tcpConnCheckBox, SIGNAL(clicked()), this, SLOT(onShowPortInfo())); connect(ui_->udpListenCheckBox, SIGNAL(clicked()), this, SLOT(onShowPortInfo())); connect(ui_->portFilterEdit, &QLineEdit::textChanged, [&](QString str) {onShowPortInfo(); }); ui_->ipv4CheckBox->setChecked(true); ui_->tcpListenCheckBox->setChecked(true); } void KernelNetwork::ShowWfpInfo() { DISABLE_RECOVER(); ClearItemModelData(wfp_model_, 0); std::vector<CALLOUT_INFO> infos; //EnumWfpCallouts(infos); for (auto item : infos) { auto id_item = new QStandardItem(DWordToHexQ(item.CalloutId)); auto key_item = new QStandardItem(DWordToHexQ(item.CalloutKey)); auto name_item = new QStandardItem(item.ModuleName); auto count = wfp_model_->rowCount(); wfp_model_->setItem(count, 0, id_item); wfp_model_->setItem(count, 1, key_item); wfp_model_->setItem(count, 2, name_item); } } void KernelNetwork::onShowPortInfo() { DISABLE_RECOVER(); ClearItemModelData(port_model_, 0); auto ipv4 = ui_->ipv4CheckBox->isChecked(); auto ipv6 = ui_->ipv6CheckBox->isChecked(); auto tcpls = ui_->tcpListenCheckBox->isChecked(); auto tcpconn = ui_->tcpConnCheckBox->isChecked(); auto udpls = ui_->udpListenCheckBox->isChecked(); std::vector<ARK_NETWORK_ENDPOINT_ITEM> items; std::vector<ARK_NETWORK_ENDPOINT_ITEM> newers; if (tcpls || tcpconn) { if (ipv4) ArkDrvApi::Network::EnumTcp4Endpoints(items); if (ipv6) ArkDrvApi::Network::EnumTcp6Endpoints(items); for (auto &item : items) { if (tcpls && item.state == 2) newers.push_back(item); if (tcpconn && item.state != 2) newers.push_back(item); } } if (udpls) { items.clear(); if (ipv4) ArkDrvApi::Network::EnumUdp4Endpoints(items); if (ipv6) ArkDrvApi::Network::EnumUdp6Endpoints(items); newers.insert(newers.end(), items.begin(), items.end()); } auto flt = ui_->portFilterEdit->text(); for (auto &item : newers) { auto protocol = CharsToQ(item.protocol); auto local = CharsToQ(item.local); auto remote = CharsToQ(item.remote); auto readable_state = (item.tran_ver == ARK_NETWORK_TCP) ? CharsToQ(item.readable_state) : ""; auto pidstr = WStrToQ(UNONE::StrFormatW(L"%d", item.pid)); ProcInfo pi; CacheGetProcInfo(item.pid, pi); if (!flt.isEmpty()) { if (!protocol.contains(flt, Qt::CaseInsensitive) && !local.contains(flt, Qt::CaseInsensitive) && !remote.contains(flt, Qt::CaseInsensitive) && !readable_state.contains(flt, Qt::CaseInsensitive) && !pidstr.contains(flt, Qt::CaseInsensitive) && !pi.path.contains(flt, Qt::CaseInsensitive) ) continue; } auto item_0 = new QStandardItem(protocol); auto item_1 = new QStandardItem(local); auto item_2 = new QStandardItem(remote); auto item_3 = new QStandardItem(readable_state); auto item_4 = new QStandardItem(pidstr); auto item_5 = new QStandardItem(LoadIcon(pi.path), pi.path); auto count = port_model_->rowCount(); port_model_->setItem(count, 0, item_0); port_model_->setItem(count, 1, item_1); port_model_->setItem(count, 2, item_2); port_model_->setItem(count, 3, item_3); port_model_->setItem(count, 4, item_4); port_model_->setItem(count, 5, item_5); } }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/network/network.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <windows.h> #include <vector> #include "ui_kernel.h" #include "../kernel.h" #include "../common/common.h" #include "../common/ui-wrapper/ui-wrapper.h" class Ui::Kernel; class Kernel; enum { //TAB_KERNEL_NETWORK_WFP, //TAB_KERNEL_NETWORK_TDI, TAB_KERNEL_NETWORK_PORT, TAB_KERNEL_NETWORK_HOSTS, }; typedef struct _CALLOUT_INFO { ULONG CalloutId; GUID CalloutKey; CHAR ModuleName[MAX_PATH]; }CALLOUT_INFO; bool EnumWfpCallouts(std::vector<CALLOUT_INFO>& CalloutIDs); PROXY_FILTER(WfpSortFilterProxyModel); PROXY_FILTER(PortSortFilterProxyModel); class KernelNetwork : public CommonTabObject { Q_OBJECT public: KernelNetwork(); ~KernelNetwork(); public: bool eventFilter(QObject *obj, QEvent *e); void ModuleInit(Ui::Kernel *ui, Kernel *kernel); private slots: void onTabChanged(int index); void onShowPortInfo(); private: void InitWfpView(); void InitHostsView(); void InitPortView(); void ShowWfpInfo(); private: Ui::Kernel *ui_; Kernel *kernel_; std::wstring hosts_dir_; std::wstring hosts_file_; QMenu *hosts_menu_; QMenu *port_menu_; QStandardItemModel *wfp_model_; QStandardItemModel *port_model_; WfpSortFilterProxyModel *proxy_wfp_; PortSortFilterProxyModel *proxy_port_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/notify/notify.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/notify/notify.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/object/object.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "object.h" #include <arkdrv-api/arkdrv-api.h> bool ObjectTypesSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); auto column = left.column(); if ((column == 1 || column == 3 || column == 4)) return s1.toString().toULongLong(nullptr, 16) < s2.toString().toULongLong(nullptr, 16); return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } bool ObjectSectionsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); auto column = left.column(); if ((column == 2 || column == 3)) return s1.toString().toULongLong(nullptr, 16) < s2.toString().toULongLong(nullptr, 16); return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } KernelObject::KernelObject() { } KernelObject::~KernelObject() { } void KernelObject::onTabChanged(int index) { switch (index) { case TAB_KERNEL_OBJECT_TYPES: ShowObjectTypes(); break; case TAB_KERNEL_OBJECT_SECTIONS: ShowObjectSections(); break; default: break; } CommonTabObject::onTabChanged(index); } bool KernelObject::eventFilter(QObject *obj, QEvent *e) { if (e->type() == QEvent::ContextMenu) { QMenu *menu = nullptr; if (obj == ui_->objectTypesView->viewport()) menu = objtypes_menu_; if (obj == ui_->objectSectionsView->viewport()) menu = objsections_menu_; QContextMenuEvent *ctxevt = dynamic_cast<QContextMenuEvent*>(e); if (ctxevt && menu) { menu->move(ctxevt->globalPos()); menu->show(); } } if (e->type() == QEvent::KeyPress) { QKeyEvent *keyevt = dynamic_cast<QKeyEvent*>(e); if (keyevt->matches(QKeySequence::Refresh)) { ShowObjectTypes(); } } return QWidget::eventFilter(obj, e); } void KernelObject::ModuleInit(Ui::Kernel *ui, Kernel *kernel) { this->ui_ = ui; Init(ui->tabObject, TAB_KERNEL, TAB_KERNEL_OBJECT); InitObjectTypesView(); InitObjectSectionsView(); } void KernelObject::InitObjectTypesView() { QTreeView *view = ui_->objectTypesView; objtypes_model_ = new QStandardItemModel; proxy_objtypes_ = new ObjectTypesSortFilterProxyModel(view); std::vector<std::pair<int, QString>> layout = { { 170, tr("TypeObject") }, { 80, tr("TypeIndex") }, { 227, tr("TypeName") }, { 110, tr("TotalObjectsNum") }, { 110, tr("TotalHandlesNum") }, }; SetDefaultTreeViewStyle(view, objtypes_model_, proxy_objtypes_, layout); view->viewport()->installEventFilter(this); view->installEventFilter(this); objtypes_menu_ = new QMenu(); objtypes_menu_->addAction(tr("Refresh"), this, [&] { ShowObjectTypes(); }, QKeySequence::Refresh); objtypes_menu_->addAction(tr("Copy"), this, [&] { auto view = ui_->objectTypesView; ClipboardCopyData(GetCurItemViewData(view, GetCurViewColumn(view)).toStdString()); }); } void KernelObject::InitObjectSectionsView() { QTreeView *view = ui_->objectSectionsView; objsections_model_ = new QStandardItemModel; proxy_objsections_ = new ObjectSectionsSortFilterProxyModel(view); std::vector<std::pair<int, QString>> layout = { { 220, tr("SectionDirectory") }, { 350, tr("SectionName") }, { 90, tr("SectionSize") }, { 80, tr("SessionID") }, { 80, tr("SessionName") }, }; SetDefaultTreeViewStyle(view, objsections_model_, proxy_objsections_, layout); view->viewport()->installEventFilter(this); view->installEventFilter(this); objsections_menu_ = new QMenu(); objsections_menu_->addAction(tr("Refresh"), this, [&] { ShowObjectSections(); }); objsections_menu_->addAction(tr("Copy"), this, [&] { auto view = ui_->objectSectionsView; ClipboardCopyData(GetCurItemViewData(view, GetCurViewColumn(view)).toStdString()); }); auto GetSectionData = [&](QTreeView *view, ULONG64 &map_addr, ULONG &map_size, HANDLE &map_hd){ map_size = map_addr = 0; std::string section_data; auto name = GetCurItemViewData(view, 1); auto size = VariantInt(GetCurItemViewData(view, 2).toStdString(), 16); auto session = GetCurItemViewData(view, 3); std::wstring prefix, section_name; std::wstring map_name; section_name = name.toStdWString(); if (session.isEmpty()) { prefix = L"Global"; map_name = UNONE::StrFormatW(L"%s\\%s", prefix.c_str(), section_name.c_str()); } else { prefix = L""; map_name = section_name; } map_hd = OpenFileMappingW(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, map_name.c_str()); if (!map_hd) { auto msg = UNONE::StrFormatW(L"OpenFileMappingW %s err:%d", map_name.c_str(), GetLastError()); ERR(msg.c_str()); QMessageBox::critical(NULL, tr("Error"), WStrToQ(msg)); return; } map_addr = (ULONG64)MapViewOfFileEx(map_hd, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0, NULL); if (!map_addr) map_addr = (ULONG64)MapViewOfFileEx(map_hd, FILE_MAP_READ, 0, 0, 0, NULL); if (!map_addr) { auto msg = UNONE::StrFormatW(L"MapViewOfFileEx %s err:%d", map_name.c_str(), GetLastError()); CloseHandle(map_hd); ERR(msg.c_str()); QMessageBox::critical(NULL, tr("Error"), WStrToQ(msg)); return; } map_size = size; }; objsections_menu_->addAction(tr("Dump to File"), this, [&] { ULONG64 map_addr; ULONG map_size; HANDLE map_hd; GetSectionData(ui_->objectSectionsView, map_addr, map_size, map_hd); if (!map_addr) return; std::string data((char*)map_addr, map_size); QString filename = WStrToQ(UNONE::StrFormatW(L"%X_%X", map_addr, map_size)); QString dumpmem = QFileDialog::getSaveFileName(this, tr("Save to"), filename, tr("DumpMemory(*)")); if (!dumpmem.isEmpty()) { UNONE::FsWriteFileDataW(dumpmem.toStdWString(), data) ? MsgBoxInfo(tr("Dump memory to file ok")) : MsgBoxError(tr("Dump memory to file error")); } }); objsections_menu_->addAction(tr("Memory Edit"), this, [&] { ULONG64 map_addr; ULONG map_size; HANDLE map_hd; GetSectionData(ui_->objectSectionsView, map_addr, map_size, map_hd); if (!map_addr) return; auto memrw = new KernelMemoryRW(); QList<QVariant> vars{ map_addr, (uint)map_hd}; memrw->RegFreeCallback([&](QList<QVariant> vars) { PVOID addr = (PVOID)vars[0].toLongLong(); HANDLE hd = (HANDLE)vars[1].toUInt(); UnmapViewOfFile(addr); CloseHandle(hd); }, vars); memrw->SetMaxSize(map_size); map_size = MIN(map_size, PAGE_SIZE); memrw->ViewMemory(GetCurrentProcessId(), map_addr, map_size); memrw->OpenNewWindow(qobject_cast<QWidget*>(this->parent()), map_addr, map_size); }); } void KernelObject::ShowObjectTypes() { DISABLE_RECOVER(); ClearItemModelData(objtypes_model_, 0); std::vector<ARK_OBJECT_TYPE_ITEM> items; ArkDrvApi::Object::ObjectTypeEnum(items); for (auto item : items) { auto item_0 = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%p", item.type_object))); auto item_1 = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%d", item.type_index))); auto item_2 = new QStandardItem(WStrToQ(item.type_name)); auto item_3 = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%d", item.total_objects))); auto item_4 = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%d", item.total_handles))); auto count = objtypes_model_->rowCount(); objtypes_model_->setItem(count, 0, item_0); objtypes_model_->setItem(count, 1, item_1); objtypes_model_->setItem(count, 2, item_2); objtypes_model_->setItem(count, 3, item_3); objtypes_model_->setItem(count, 4, item_4); } } void KernelObject::ShowObjectSections() { DISABLE_RECOVER(); ClearItemModelData(objsections_model_, 0); std::vector<ARK_OBJECT_SECTION_ITEM> items; ArkDrvApi::Object::ObjectSectionEnum(items); for (auto item : items) { auto item_0 = new QStandardItem(WStrToQ(item.section_dir)); auto item_1 = new QStandardItem(WStrToQ(item.section_name)); auto item_2 = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%x", item.section_size))); QString idx; if (item.session_id != ARK_SESSION_GLOBAL) idx = WStrToQ(UNONE::StrFormatW(L"%d", item.session_id)); auto item_3 = new QStandardItem(idx); auto item_4 = new QStandardItem(WStrToQ(item.session_name)); auto count = objsections_model_->rowCount(); objsections_model_->setItem(count, 0, item_0); objsections_model_->setItem(count, 1, item_1); objsections_model_->setItem(count, 2, item_2); objsections_model_->setItem(count, 3, item_3); objsections_model_->setItem(count, 4, item_4); } }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/object/object.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <windows.h> #include <vector> #include "ui_kernel.h" #include "../kernel.h" #include "../common/common.h" class Ui::Kernel; class Kernel; enum { TAB_KERNEL_OBJECT_TYPES, TAB_KERNEL_OBJECT_SECTIONS, }; PROXY_FILTER(ObjectTypesSortFilterProxyModel); PROXY_FILTER(ObjectSectionsSortFilterProxyModel); class KernelObject : public CommonTabObject { Q_OBJECT public: KernelObject(); ~KernelObject(); public: bool eventFilter(QObject *obj, QEvent *e); void ModuleInit(Ui::Kernel *ui, Kernel *kernel); private slots: void onTabChanged(int index); private: void ShowObjectTypes(); void ShowObjectSections(); void InitObjectTypesView(); void InitObjectSectionsView(); private: Ui::Kernel *ui_; QMenu *objtypes_menu_; QMenu *objsections_menu_; QStandardItemModel *objtypes_model_; QStandardItemModel *objsections_model_; ObjectTypesSortFilterProxyModel *proxy_objtypes_; ObjectSectionsSortFilterProxyModel *proxy_objsections_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/storage/storage.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "storage.h" #include "../../../OpenArkDrv/arkdrv-api/arkdrv-api.h" bool UnlockFileSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } KernelStorage::KernelStorage() { } KernelStorage::~KernelStorage() { } void KernelStorage::onTabChanged(int index) { CommonTabObject::onTabChanged(index); } bool KernelStorage::eventFilter(QObject *obj, QEvent *e) { if (e->type() == QEvent::ContextMenu) { QMenu *menu = nullptr; if (obj == ui_->unlockView->viewport()) menu = unlock_menu_; //if (obj == ui_->fsfltView->viewport()) menu = fsflt_menu_; QContextMenuEvent *ctxevt = dynamic_cast<QContextMenuEvent*>(e); if (ctxevt && menu) { menu->move(ctxevt->globalPos()); menu->show(); } } else if (e->type() == QEvent::MouseMove) { QMouseEvent *mouse = static_cast<QMouseEvent *>(e); if (obj == ui_->inputPathEdit) { if (ui_->inputPathEdit->text().isEmpty()) { QString tips(tr("Tips: \n1. You can copy file or directory and paste to here(Enter key to ShowHold).\n" "2. You need enter kernel mode to view FileHold.\n" "3. Path is case insensitive.")); QToolTip::showText(mouse->globalPos(), tips); return true; } } } else if (e->type() == QEvent::KeyPress) { QKeyEvent *keyevt = dynamic_cast<QKeyEvent*>(e); if ((keyevt->key() == Qt::Key_Enter) || (keyevt->key() == Qt::Key_Return)) { ui_->showHoldBtn->click(); } } return QWidget::eventFilter(obj, e); } void KernelStorage::ModuleInit(Ui::Kernel *ui, Kernel *kernel) { this->ui_ = ui; this->kernel_ = kernel; Init(ui->tabStorage, TAB_KERNEL, TAB_KERNEL_STORAGE); InitFileUnlockView(); //InitFileFilterView(); } void KernelStorage::InitFileUnlockView() { unlock_model_ = new QStandardItemModel; QTreeView *view = ui_->unlockView; proxy_unlock_ = new UnlockFileSortFilterProxyModel(view); std::vector<std::pair<int, QString>> layout = { { 150, tr("ProcessName") }, { 50, tr("PID") }, { 340, tr("FilePath") }, { 250, tr("ProcessPath") }, { 50, tr("Type") }, { 150, tr("FileObject/DllBase") }, { 70, tr("FileHandle") }, }; SetDefaultTreeViewStyle(view, unlock_model_, proxy_unlock_, layout); view->viewport()->installEventFilter(this); view->installEventFilter(this); ui_->inputPathEdit->installEventFilter(this); ui_->inputPathEdit->setMouseTracking(true); unlock_menu_ = new QMenu(); unlock_menu_->addAction(tr("Refresh"), this, [&] { ui_->showHoldBtn->click(); }); unlock_menu_->addAction(tr("Copy"), this, [&] { auto view = ui_->unlockView; ClipboardCopyData(GetCurItemViewData(view, GetCurViewColumn(view)).toStdString()); }); unlock_menu_->addSeparator(); unlock_menu_->addAction(tr("Unlock"), this, [&] { ui_->unlockFileBtn->click(); }); unlock_menu_->addAction(tr("Unlock All"), this, [&] { ui_->unlockFileAllBtn->click(); }); unlock_menu_->addAction(tr("Kill Process"), this, [&] { ui_->killProcessBtn->click(); }); unlock_menu_->addSeparator(); unlock_menu_->addAction(tr("Scan Selected"), this, [&] { kernel_->GetParent()->SetActiveTab(TAB_SCANNER); auto column = GetCurViewColumn(ui_->unlockView); if (column == 0) column = 3; emit kernel_->signalOpen(GetCurItemViewData(ui_->unlockView, column)); }); unlock_menu_->addAction(tr("Explore Selected"), this, [&] { auto column = GetCurViewColumn(ui_->unlockView); if (column == 0) column = 3; ExploreFile(GetCurItemViewData(ui_->unlockView, column)); }); unlock_menu_->addAction(tr("Properties Selected..."), this, [&]() { auto column = GetCurViewColumn(ui_->unlockView); if (column == 0) column = 3; WinShowProperties(GetCurItemViewData(ui_->unlockView, column).toStdWString()); }); connect(ui_->inputPathEdit, &QLineEdit::textChanged, [&](QString str) { if (str.contains("file:///")) { ui_->inputPathEdit->setText(str.replace("file:///", "")); ui_->inputPathEdit->setText(str.replace("/", "\\")); } }); connect(ui_->showHoldBtn, &QPushButton::clicked, [&] { DISABLE_RECOVER(); ClearItemModelData(unlock_model_, 0); QString file = ui_->inputPathEdit->text(); if (file.isEmpty()) { ERR(L"Please input the file path..."); return; } std::wstring origin, path; std::vector<HANDLE_ITEM> items; origin = UNONE::FsPathStandardW(file.toStdWString()); UNONE::ObParseToNtPathW(origin, path); UNONE::StrLowerW(path); ArkDrvApi::Storage::UnlockEnum(path, items); for (auto item : items) { auto pid = (DWORD)item.pid; ProcInfo info; CacheGetProcInfo(pid, info); auto &&ppath = info.path; auto &&pname = info.name; std::wstring fpath; UNONE::ObParseToDosPathW(item.name, fpath); auto item_pname = new QStandardItem(LoadIcon(ppath), pname); auto item_pid = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%d", pid))); auto item_fpath = new QStandardItem(WStrToQ(fpath)); auto item_ftype = new QStandardItem("FILE"); auto item_fobj = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%p", item.object))); auto item_ppath = new QStandardItem(ppath); auto item_fhandle = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%X", (DWORD)item.handle))); auto count = unlock_model_->rowCount(); unlock_model_->setItem(count, 0, item_pname); unlock_model_->setItem(count, 1, item_pid); unlock_model_->setItem(count, 2, item_fpath); unlock_model_->setItem(count, 3, item_ppath); unlock_model_->setItem(count, 4, item_ftype); unlock_model_->setItem(count, 5, item_fobj); unlock_model_->setItem(count, 6, item_fhandle); } // Add process dll path std::vector<DWORD> pids; UNONE::PsGetAllProcess(pids); for (auto pid : pids) { UNONE::PsEnumModule(pid, [&](MODULEENTRY32W& entry)->bool { if (UNONE::StrContainIW(entry.szExePath, origin)) { QString modname = WCharsToQ(entry.szModule); QString modpath = WCharsToQ(entry.szExePath); HANDLE hmodule = entry.hModule; ProcInfo info; CacheGetProcInfo(pid, info); auto &&ppath = info.path; auto &&pname = info.name; auto item_pname = new QStandardItem(LoadIcon(ppath), pname); auto item_pid = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%d", pid))); auto item_fpath = new QStandardItem(modpath); auto item_ppath = new QStandardItem(ppath); auto item_ftype = new QStandardItem("DLL"); auto item_fobj = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%p", hmodule))); auto item_fhandle = new QStandardItem("0"); auto count = unlock_model_->rowCount(); unlock_model_->setItem(count, 0, item_pname); unlock_model_->setItem(count, 1, item_pid); unlock_model_->setItem(count, 2, item_fpath); unlock_model_->setItem(count, 3, item_ppath); unlock_model_->setItem(count, 4, item_ftype); unlock_model_->setItem(count, 5, item_fobj); unlock_model_->setItem(count, 6, item_fhandle); } return true; }); } }); auto CommonUnlock = [&](QString type, DWORD pid, QString fobj, QString fhandle, QString fpath="") { if (type == "DLL") { // Close by kill process if (fpath.compare(CacheGetProcInfo(pid).path, Qt::CaseInsensitive)) { PsKillProcess(pid); return; } // Close by free library ULONG64 remote_routine = GetFreeLibraryAddress(pid); if (remote_routine) { ULONG64 pararm = QHexToQWord(fobj); for (int i = 0; i < 10; i++) { UNONE::PsCreateRemoteThread((DWORD)pid, remote_routine, pararm, 0); INFO("%d %lld %lld", pid, remote_routine, pararm); } } } else { // Close by driver HANDLE_ITEM handle_item = { 0 }; handle_item.pid = HANDLE(pid); handle_item.handle = HANDLE(QHexToDWord(fhandle)); ArkDrvApi::Storage::UnlockClose(handle_item); } }; connect(ui_->unlockFileBtn, &QPushButton::clicked, [&]{ DISABLE_RECOVER(); auto selected = ui_->unlockView->selectionModel()->selectedIndexes(); if (selected.empty()) return; int count = unlock_model_->columnCount(); for (int i = 0; i < selected.size() / count; i++) { auto pid = ui_->unlockView->model()->itemData(selected[i * count + 1]).values()[0].toUInt(); auto fpath = ui_->unlockView->model()->itemData(selected[i * count + 2]).values()[0].toString(); auto type = ui_->unlockView->model()->itemData(selected[i * count + 4]).values()[0].toString(); auto fobj = ui_->unlockView->model()->itemData(selected[i * count + 5]).values()[0].toString(); auto fhandle = ui_->unlockView->model()->itemData(selected[i * count + 6]).values()[0].toString(); CommonUnlock(type, pid, fobj, fhandle, fpath); } ui_->showHoldBtn->click(); }); connect(ui_->unlockFileAllBtn, &QPushButton::clicked, [&] { DISABLE_RECOVER(); for (int i = 0; i < unlock_model_->rowCount(); i++) { QStandardItem *item = unlock_model_->item(i, 1); //pid auto pid = item->text().toUInt(); auto type = unlock_model_->item(i, 4)->text(); auto fobj = unlock_model_->item(i, 5)->text(); auto fhandle = unlock_model_->item(i, 6)->text(); CommonUnlock(type, pid, fobj, fhandle); } ui_->showHoldBtn->click(); }); connect(ui_->killProcessBtn, &QPushButton::clicked, [&] { DISABLE_RECOVER(); auto selected = ui_->unlockView->selectionModel()->selectedIndexes(); if (selected.empty()) return; int count = unlock_model_->columnCount(); for (int i = 0; i < selected.size() / count; i++) { auto pid = ui_->unlockView->model()->itemData(selected[i * count + 1]).values()[0].toUInt(); PsKillProcess(pid); } ui_->showHoldBtn->click(); }); } void KernelStorage::InitFileFilterView() { /* fsflt_model_ = new QStandardItemModel; fsflt_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Value")); SetDefaultTreeViewStyle(ui_->fsfltView, fsflt_model_); ui_->fsfltView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); ui_->fsfltView->viewport()->installEventFilter(this); ui_->fsfltView->installEventFilter(this); fsflt_menu_ = new QMenu(); fsflt_menu_->addAction(tr("ExpandAll"), this, SLOT(onExpandAll()));*/ } void KernelStorage::ShowUnlockFiles() { }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/storage/storage.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <windows.h> #include <vector> #include "ui_kernel.h" #include "../kernel.h" #include "../common/common.h" class Ui::Kernel; class Kernel; PROXY_FILTER(UnlockFileSortFilterProxyModel); class KernelStorage : public CommonTabObject { Q_OBJECT public: KernelStorage(); ~KernelStorage(); public: bool eventFilter(QObject *obj, QEvent *e); void ModuleInit(Ui::Kernel *ui, Kernel *kernel); private slots: void onTabChanged(int index); private: void ShowUnlockFiles(); void InitFileUnlockView(); void InitFileFilterView(); private: Ui::Kernel *ui_; Kernel *kernel_; QMenu *unlock_menu_; QMenu *fsflt_menu_; QStandardItemModel *fsflt_model_; QStandardItemModel *unlock_model_; UnlockFileSortFilterProxyModel *proxy_unlock_; UnlockFileSortFilterProxyModel *proxy_fsflt_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/wingui/wingui.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "wingui.h" #include <unone.h> struct { std::string vk_str; UINT32 vk; } VkStrTables[] = { { "LBUTTON",0x01 }, { "RBUTTON",0x02 }, { "CANCEL",0x03 }, { "MBUTTON",0x04 }, { "XBUTTON1",0x05 }, { "XBUTTON2",0x06 }, { "BACK",0x08 }, { "TAB",0x09 }, { "CLEAR",0x0C }, { "RETURN",0x0D }, { "SHIFT",0x10 }, { "CONTROL",0x11 }, { "MENU",0x12 }, { "PAUSE",0x13 }, { "CAPITAL",0x14 }, { "KANA",0x15 }, { "HANGEUL",0x15 }, { "HANGUL",0x15 }, { "JUNJA",0x17 }, { "FINAL",0x18 }, { "HANJA",0x19 }, { "KANJI",0x19 }, { "ESCAPE",0x1B }, { "CONVERT",0x1C }, { "NONCONVERT",0x1D }, { "ACCEPT",0x1E }, { "MODECHANGE",0x1F }, { "SPACE",0x20 }, { "PRIOR",0x21 }, { "NEXT",0x22 }, { "END",0x23 }, { "HOME",0x24 }, { "LEFT",0x25 }, { "UP",0x26 }, { "RIGHT",0x27 }, { "DOWN",0x28 }, { "SELECT",0x29 }, { "PRINT",0x2A }, { "EXECUTE",0x2B }, { "SNAPSHOT",0x2C }, { "INSERT",0x2D }, { "DELETE",0x2E }, { "HELP",0x2F }, { "LWIN",0x5B }, { "RWIN",0x5C }, { "APPS",0x5D }, { "SLEEP",0x5F }, { "NUMPAD0",0x60 }, { "NUMPAD1",0x61 }, { "NUMPAD2",0x62 }, { "NUMPAD3",0x63 }, { "NUMPAD4",0x64 }, { "NUMPAD5",0x65 }, { "NUMPAD6",0x66 }, { "NUMPAD7",0x67 }, { "NUMPAD8",0x68 }, { "NUMPAD9",0x69 }, { "MULTIPLY",0x6A }, { "ADD",0x6B }, { "SEPARATOR",0x6C }, { "SUBTRACT",0x6D }, { "DECIMAL",0x6E }, { "DIVIDE",0x6F }, { "F1",0x70 }, { "F2",0x71 }, { "F3",0x72 }, { "F4",0x73 }, { "F5",0x74 }, { "F6",0x75 }, { "F7",0x76 }, { "F8",0x77 }, { "F9",0x78 }, { "F10",0x79 }, { "F11",0x7A }, { "F12",0x7B }, { "F13",0x7C }, { "F14",0x7D }, { "F15",0x7E }, { "F16",0x7F }, { "F17",0x80 }, { "F18",0x81 }, { "F19",0x82 }, { "F20",0x83 }, { "F21",0x84 }, { "F22",0x85 }, { "F23",0x86 }, { "F24",0x87 }, { "NUMLOCK",0x90 }, { "SCROLL",0x91 }, { "OEM_NEC_EQUAL",0x92 }, { "OEM_FJ_JISHO",0x92 }, { "OEM_FJ_MASSHOU",0x93 }, { "OEM_FJ_TOUROKU",0x94 }, { "OEM_FJ_LOYA",0x95 }, { "OEM_FJ_ROYA",0x96 }, { "LSHIFT",0xA0 }, { "RSHIFT",0xA1 }, { "LCONTROL",0xA2 }, { "RCONTROL",0xA3 }, { "LMENU",0xA4 }, { "RMENU",0xA5 }, { "BROWSER_BACK",0xA6 }, { "BROWSER_FORWARD",0xA7 }, { "BROWSER_REFRESH",0xA8 }, { "BROWSER_STOP",0xA9 }, { "BROWSER_SEARCH",0xAA }, { "BROWSER_FAVORITES",0xAB }, { "BROWSER_HOME",0xAC }, { "VOLUME_MUTE",0xAD }, { "VOLUME_DOWN",0xAE }, { "VOLUME_UP",0xAF }, { "MEDIA_NEXT_TRACK",0xB0 }, { "MEDIA_PREV_TRACK",0xB1 }, { "MEDIA_STOP",0xB2 }, { "MEDIA_PLAY_PAUSE",0xB3 }, { "LAUNCH_MAIL",0xB4 }, { "LAUNCH_MEDIA_SELECT",0xB5 }, { "LAUNCH_APP1",0xB6 }, { "LAUNCH_APP2",0xB7 }, { "OEM_1",0xBA }, { "OEM_PLUS",0xBB }, { "OEM_COMMA",0xBC }, { "OEM_MINUS",0xBD }, { "OEM_PERIOD",0xBE }, { "OEM_2",0xBF }, { "OEM_3",0xC0 }, { "OEM_4",0xDB }, { "OEM_5",0xDC }, { "OEM_6",0xDD }, { "OEM_7",0xDE }, { "OEM_8",0xDF }, { "OEM_AX",0xE1 }, { "OEM_102",0xE2 }, { "ICO_HELP",0xE3 }, { "ICO_00",0xE4 }, { "PROCESSKEY",0xE5 }, { "ICO_CLEAR",0xE6 }, { "PACKET",0xE7 }, { "OEM_RESET",0xE9 }, { "OEM_JUMP",0xEA }, { "OEM_PA1",0xEB }, { "OEM_PA2",0xEC }, { "OEM_PA3",0xED }, { "OEM_WSCTRL",0xEE }, { "OEM_CUSEL",0xEF }, { "OEM_ATTN",0xF0 }, { "OEM_FINISH",0xF1 }, { "OEM_COPY",0xF2 }, { "OEM_AUTO",0xF3 }, { "OEM_ENLW",0xF4 }, { "OEM_BACKTAB",0xF5 }, { "ATTN",0xF6 }, { "CRSEL",0xF7 }, { "EXSEL",0xF8 }, { "EREOF",0xF9 }, { "PLAY",0xFA }, { "ZOOM",0xFB }, { "NONAME",0xFC }, { "PA1",0xFD }, { "OEM_CLEAR",0xFE } }; std::string HotkeyVkToString(UINT32 vk, UINT16 mod1, UINT16 mod2) { std::string vks; if (mod1 & MOD_WIN) vks.append("+Win"); if (mod1 & MOD_CONTROL) vks.append("+Ctrl"); if (mod1 & MOD_ALT) vks.append("+Alt"); if (mod1 & MOD_SHIFT) vks.append("+Shift"); //if (mod2 & MOD_NOREPEAT) vks.append("[NoRepeat]"); if (vk >= 0x30 && vk <= 0x5A) { vks.append("+"); vks.push_back((char)vk); } else { if (vk) { std::string cap; for (auto t : VkStrTables) { if (t.vk == vk) { cap = UNONE::StrToLowerA(t.vk_str); cap[0] -= 32; vks.append("+" + cap); break; } } if (cap.empty()) vks.append(UNONE::StrFormatA("+(Unknown VK:%d)", vk)); } } vks = UNONE::StrTrimA(vks, "+"); return std::move(vks); }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/kernel/wingui/wingui.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <windows.h> #include <string> std::string HotkeyVkToString(UINT32 vk, UINT16 mod1, UINT16 mod2);
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/main.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "../openark/openark.h" #include "common/common.h" //for qt static link #include <QtWidgets/QApplication> #include <QtPlugin> Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) Q_IMPORT_PLUGIN(QICOPlugin) int OpenArkInit(int argc, char *argv[]) { UNONE::SeEnableDebugPrivilege(); bool is_ark64 = UNONE::PeX64((CHAR*)GetModuleHandleW(NULL)); if (!is_ark64 && UNONE::OsIs64()) { auto &&path = UNONE::PsGetProcessDirW() + L"\\OpenArk64.exe"; if (UNONE::FsIsExistedW(path)) { UNONE::PsCreateProcessW(path); exit(0); } } app = new QApplication(argc, argv); app->setWindowIcon(QIcon(":/OpenArk/OpenArk.ico")); app_tr = new QTranslator(); QFont font = qApp->font(); font.setPixelSize(12); font.setFamily("Microsoft YaHei"); qApp->setFont(font); OpenArkConfig::Instance()->Init(); OpenArkLanguage::Instance()->ChangeLanguage(OpenArkConfig::Instance()->GetLang(CONF_GET)); return 0; } int OpenArkUninit(int argc, char *argv[]) { delete app_tr; delete app; app_tr = nullptr; app = nullptr; return 0; } int main(int argc, char *argv[]) { OpenArkInit(argc, argv); auto w = new OpenArk; w->show(); auto err = app->exec(); delete w; OpenArkUninit(argc, argv); return err; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/openark/openark.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "openark.h" #include "common/common.h" #include "process-mgr/process-mgr.h" #include "scanner/scanner.h" #include "coderkit/coderkit.h" #include "bundler/bundler.h" #include "settings/settings.h" #include "about/about.h" #include "cmds/cmds.h" #include "kernel/kernel.h" #include "reverse/reverse.h" #include "utilities/utilities.h" #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkReply> #define APP_CHKUPT_SERVER "http://upt.blackint3.com/openark/version.txt" #define APP_MESSAGE_PATTERN \ "%{if-debug}<font color=#E0E2E4>%{endif}"\ "%{if-info}<font color=#E0E2E4>%{endif}"\ "%{if-warning}<font color=red>%{endif}"\ "%{if-critical}<font color=red>%{endif}"\ "[%{function}:%{line}]"\ "%{if-debug}[DBG]%{endif}%{if-info}[INFO]%{endif}%{if-warning}[WARN]%{endif}%{if-critical}[ERR]%{endif}"\ "%{message}</font>" void QtMessageHandlerCallback(QtMsgType type, const QMessageLogContext &context, const QString &msg) { QString fmt = msg; if (!msg.isEmpty()) { fmt = qFormatLogMessage(type, context, msg); } openark->onLogOutput(fmt); } OpenArk::OpenArk(QWidget *parent) : QMainWindow(parent) { openark = this; qSetMessagePattern(APP_MESSAGE_PATTERN); qInstallMessageHandler(QtMessageHandlerCallback); UNONE::InterRegisterLogger([&](const std::wstring &log) { onLogOutput(WStrToQ(log)); }); ui.setupUi(this); int x, y, w, h; OpenArkConfig::Instance()->GetMainGeometry(x, y, w, h); move(x, y); resize(w, h); bool maxed = false; OpenArkConfig::Instance()->GetMainMaxed(maxed); if (maxed) showMaximized(); ui.splitter->setStretchFactor(0, 1); ui.splitter->setStretchFactor(1, 5); QString title = QString(tr("OpenArk v%1 ").arg(AppVersion())); title.append(tr(" [build:%1] ").arg(AppBuildTime())); UNONE::PeX64((CHAR*)GetModuleHandleW(NULL)) ? title.append(tr("64-Bit")) : title.append(tr("32-Bit")); setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint); setWindowTitle(title); QWidget *widget = new QWidget(); QLabel *link = new QLabel(widget); link->setText("<a style='color:blue;a{text-decoration: none}' href=\"https://github.com/BlackINT3/OpenArk\">"+ tr("Project on Github")+"</a>&nbsp;"); link->setOpenExternalLinks(true); stool_ = new QToolBar(widget); stool_->setObjectName(QStringLiteral("statusToolBar")); stool_->setIconSize(QSize(16, 16)); stool_->addAction(ui.actionConsole); stool_->addSeparator(); stool_->addAction(ui.actionModule); stool_->addAction(ui.actionHandle); stool_->addAction(ui.actionMemory); ui.actionModule->setChecked(false); ui.actionHandle->setChecked(false); ui.actionMemory->setChecked(false); connect(ui.actionModule, SIGNAL(triggered(bool)), this, SLOT(onActionPtool(bool))); connect(ui.actionHandle, SIGNAL(triggered(bool)), this, SLOT(onActionPtool(bool))); connect(ui.actionMemory, SIGNAL(triggered(bool)), this, SLOT(onActionPtool(bool))); //stool_->setStyleSheet("background-color:red"); QGridLayout *layout = new QGridLayout(widget); layout->setMargin(0); layout->addWidget(stool_, 0, 0, 1, 1, Qt::AlignVCenter | Qt::AlignLeft); layout->addWidget(link, 0, 1, 1, 1, Qt::AlignVCenter | Qt::AlignRight); //ui.statusBar->setStyleSheet("QToolButton: {background-color: red; }"); ui.statusBar->setSizeGripEnabled(false); ui.statusBar->setFixedHeight(28); ui.statusBar->addWidget(widget, 1); connect(ui.actionConsole, SIGNAL(triggered(bool)), this, SLOT(onActionConsole(bool))); ui.consoleWidget->hide(); ui.actionOnTop->setCheckable(true); ui.actionExit->setShortcut(QKeySequence(Qt::ALT + Qt::Key_F4)); // Language QActionGroup *langs = new QActionGroup(this); langs->setExclusive(true); langs->addAction(ui.actionEnglish); langs->addAction(ui.actionZhcn); int lang = OpenArkLanguage::Instance()->GetLanguage(); if (lang == 0) { ui.actionEnglish->setChecked(true); } else if (lang == 1) { ui.actionZhcn->setChecked(true); } connect(langs, SIGNAL(triggered(QAction*)), this, SLOT(onActionLanguage(QAction*))); connect(ui.actionRun, &QAction::triggered, this, [=]() { UNONE::PsCreateProcessW(L"rundll32.exe shell32.dll,#61"); }); connect(ui.actionExit, &QAction::triggered, this, [=]() { QApplication::quit(); }); connect(ui.actionAbout, SIGNAL(triggered(bool)), this, SLOT(onActionAbout(bool))); connect(ui.actionSettings, SIGNAL(triggered(bool)), this, SLOT(onActionSettings(bool))); connect(ui.actionOpen, SIGNAL(triggered(bool)), this, SLOT(onActionOpen(bool))); connect(ui.actionRefresh, SIGNAL(triggered(bool)), this, SLOT(onActionRefresh(bool))); connect(ui.actionReset, SIGNAL(triggered(bool)), this, SLOT(onActionReset(bool))); connect(ui.actionOnTop, SIGNAL(triggered(bool)), this, SLOT(onActionOnTop(bool))); connect(ui.actionGithub, SIGNAL(triggered(bool)), this, SLOT(onActionGithub(bool))); connect(ui.actionManuals, SIGNAL(triggered(bool)), this, SLOT(onActionManuals(bool))); connect(ui.actionCheckUpdate, SIGNAL(triggered(bool)), this, SLOT(onActionCheckUpdate(bool))); connect(ui.actionCoderKit, SIGNAL(triggered(bool)), this, SLOT(onActionCoderKit(bool))); connect(ui.actionScanner, SIGNAL(triggered(bool)), this, SLOT(onActionScanner(bool))); connect(ui.actionBundler, SIGNAL(triggered(bool)), this, SLOT(onActionBundler(bool))); cmds_ = new Cmds(ui.cmdOutWindow); cmds_->hide(); cmds_->setParent(ui.cmdOutWindow); ui.cmdInput->installEventFilter(this); ui.cmdOutWindow->installEventFilter(this); ui.cmdOutWindow->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui.cmdInput, SIGNAL(returnPressed()), this, SLOT(onCmdInput())); connect(ui.cmdButton, SIGNAL(clicked()), this, SLOT(onCmdHelp())); connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int))); connect(ui.cmdOutWindow, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onShowConsoleMenu(const QPoint &))); int main_idx = 1; QVector<int> level2_idx; QVector<QVector<int>> idxs; OpenArkConfig::Instance()->GetPrefMainTab(main_idx); OpenArkConfig::Instance()->GetMainTabAllMap(idxs); auto CreateTabPage = [&](QWidget *widget, QWidget *origin) { int idx = ui.tabWidget->indexOf(origin); QString text = ui.tabWidget->tabText(idx); ui.tabWidget->removeTab(idx); ui.tabWidget->insertTab(idx, widget, text); }; auto processmgr = new ProcessMgr(this); CreateTabPage(processmgr, ui.tabProcessMgr); auto scanner = new Scanner(this, TAB_SCANNER); CreateTabPage(scanner, ui.tabScanner); auto coderkit = new CoderKit(this, TAB_CODERKIT); CreateTabPage(coderkit, ui.tabCoderKit); auto bundler = new Bundler(this); CreateTabPage(bundler, ui.tabBundler); auto kernel = new Kernel(this, TAB_KERNEL); CreateTabPage(kernel, ui.tabKernel); auto utilities = new Utilities(this, TAB_UTILITIES); CreateTabPage(utilities, ui.tabUtilities); auto reverse = new Reverse(this, TAB_REVERSE); CreateTabPage(reverse, ui.tabReverse); for (int tab = 0; tab < TAB_MAX; tab++) { level2_idx = idxs[tab]; switch (tab) { case TAB_KERNEL: kernel->SetActiveTab(level2_idx); break; case TAB_CODERKIT: coderkit->SetActiveTab(level2_idx); break; case TAB_SCANNER: scanner->SetActiveTab(level2_idx); break; case TAB_UTILITIES: utilities->SetActiveTab(level2_idx); break; case TAB_REVERSE: reverse->SetActiveTab(level2_idx); break; } } SetActiveTab(main_idx); chkupt_timer_ = new QTimer(); chkupt_timer_->setInterval(1000); chkupt_timer_->start(); connect(chkupt_timer_, &QTimer::timeout, this, [&]() { onActionCheckUpdate(false); chkupt_timer_->stop(); }); connect(OpenArkLanguage::Instance(), &OpenArkLanguage::languageChaned, this, [this]() {ui.retranslateUi(this); }); this->installEventFilter(this); } bool OpenArk::eventFilter(QObject *obj, QEvent *e) { bool filtered = false; if (obj == ui.cmdInput) { if (e->type() == QEvent::KeyPress) { filtered = true; QKeyEvent* keyevt = dynamic_cast<QKeyEvent*>(e); if (keyevt->key() == Qt::Key_Up) { ui.cmdInput->setText(cmds_->CmdGetLast()); } else if (keyevt->key() == Qt::Key_Down) { ui.cmdInput->setText(cmds_->CmdGetNext()); } else if (keyevt->key() == Qt::Key_Tab) { ui.cmdOutWindow->setFocus(); } else { filtered = false; } } } else if (obj == ui.cmdOutWindow) { if (e->type() == QEvent::KeyPress) { filtered = true; QKeyEvent* keyevt = dynamic_cast<QKeyEvent*>(e); if (keyevt->key() == Qt::Key_Tab) { ui.cmdInput->setFocus(); } else { filtered = false; } } } else if (obj == this) { if (e->type() == QEvent::Resize) { auto evt = dynamic_cast<QResizeEvent*>(e); old_window_size_ = evt->oldSize(); OpenArkConfig::Instance()->SetMainGeometry(-1, -1, evt->size().width(), evt->size().height()); } else if (e->type() == QEvent::Move) { auto evt = dynamic_cast<QMoveEvent*>(e); old_window_pos_ = evt->oldPos(); OpenArkConfig::Instance()->SetMainGeometry(evt->pos().x() - 8, evt->pos().y() - 31, -1, -1); } } if (filtered) { QKeyEvent* keyevt = dynamic_cast<QKeyEvent*>(e); keyevt->ignore(); return true; } return QWidget::eventFilter(obj, e); } void OpenArk::changeEvent(QEvent *e) { if (e->type() != QEvent::WindowStateChange) return; if (windowState() == Qt::WindowMaximized) { OpenArkConfig::Instance()->SetMainGeometry(old_window_pos_.x(), old_window_pos_.y(), old_window_size_.width(), old_window_size_.height()); OpenArkConfig::Instance()->SetMainMaxed(true); } else if (windowState() != Qt::WindowMinimized) { OpenArkConfig::Instance()->SetMainMaxed(false); } } void OpenArk::onActionOpen(bool checked) { QString file = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("All Files (*.*)")); if (file.isEmpty()) return; QMetaObject::invokeMethod(ui.tabWidget->currentWidget(), "onOpenFile", Qt::QueuedConnection, Q_ARG(QString, file)); } void OpenArk::onActionRefresh(bool checked) { QMetaObject::invokeMethod(ui.tabWidget->currentWidget(), "onRefresh", Qt::QueuedConnection); } void OpenArk::onActionReset(bool checked) { QMetaObject::invokeMethod(ui.tabWidget->currentWidget(), "onReset", Qt::QueuedConnection); } void OpenArk::onActionOnTop(bool checked) { HWND wnd = (HWND)winId(); if (checked) { SetWindowOnTop(wnd, true); } else { SetWindowOnTop(wnd, false); } } void OpenArk::onActionAbout(bool checked) { auto about = new About(this); about->raise(); about->show(); } void OpenArk::onActionSettings(bool checked) { auto about = new Settings(this); about->raise(); about->show(); } void OpenArk::onActionConsole(bool checked) { QAction* sender = qobject_cast<QAction*>(QObject::sender()); if (sender->isChecked()) { ui.consoleWidget->show(); ui.cmdInput->setFocus(); } else { ui.consoleWidget->hide(); } } void OpenArk::onActionPtool(bool checked) { QAction* sender = qobject_cast<QAction*>(QObject::sender()); if (!sender->isChecked()) { emit signalShowPtool(-1); return; } if (sender == ui.actionModule) { emit signalShowPtool(0); ui.actionHandle->setChecked(false); ui.actionMemory->setChecked(false); return; } if (sender == ui.actionHandle) { emit signalShowPtool(1); ui.actionModule->setChecked(false); ui.actionMemory->setChecked(false); return; } if (sender == ui.actionMemory) { emit signalShowPtool(2); ui.actionModule->setChecked(false); ui.actionHandle->setChecked(false); return; } } void OpenArk::onActionManuals(bool checked) { ShellOpenUrl("https://openark.blackint3.com/manuals/"); } void OpenArk::onActionGithub(bool checked) { ShellOpenUrl("https://github.com/BlackINT3/OpenArk/"); } void OpenArk::onActionCheckUpdate(bool checked) { QString url = APP_CHKUPT_SERVER; QNetworkRequest req; req.setUrl(QUrl(url)); QNetworkAccessManager *mgr = new QNetworkAccessManager(this); QNetworkReply *reply = mgr->get(req); INFO(L"requset server:%s", url.toStdWString().c_str()); connect(reply, &QNetworkReply::finished, [this, reply, checked]() { if (reply->error() != QNetworkReply::NoError) { auto err = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); ERR(L"request http.err:%d, net.err:%d", err.toInt(), (int)reply->error()); return; } QByteArray data = reply->readAll(); QJsonValue val; QJsonObject obj; INFO("server responsed:%s", data.toStdString().c_str()); if (!JsonParse(data, obj) || !JsonGetValue(obj, "err", val)) { ERR(L"request app-err: json invalid"); return; } if (val.toInt() != 0) { ERR(L"request app-err: %d", val.toInt()); return; } QJsonValue appver, appbd, appurl, appfsurl; if (!JsonGetValue(obj, "appver", appver) || !JsonGetValue(obj, "appbd", appbd) || !JsonGetValue(obj, "appurl", appurl)) { ERR(L"request json err: %d", val.toInt()); return; } if (JsonGetValue(obj, "appfsurl", appfsurl)) { AppFsUrl(appfsurl.toString()); } auto local_ver = AppVersion(); auto local_bd = AppBuildTime(); INFO(L"local appver:%s, build:%s", local_ver.toStdWString().c_str(), local_bd.toStdWString().c_str()); if (local_ver.isEmpty() || local_bd.isEmpty()) { return; } if (local_ver < appver.toString() || local_bd < appbd.toString()) { QString tips = QString(tr("Found new version, app should be updated.\nappver: %1\nappbd: %2\nappurl: %3") .arg(appver.toString()) .arg(appbd.toString()) .arg(appurl.toString())); QMessageBox::StandardButton reply; reply = QMessageBox::question(this, tr("App Updates"), tips, QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { ShellOpenUrl(appurl.toString()); } return; } if (checked) MsgBoxInfo(tr("OpenArk is latest.")); INFO(L"OpenArk is latest."); reply->deleteLater(); }); } void OpenArk::onActionLanguage(QAction *act) { auto lang = OpenArkLanguage::Instance()->GetLanguage(); auto text = act->text(); if (act == ui.actionEnglish) { if (lang == 0) return; lang = 0; } else if (act == ui.actionZhcn) { if (lang == 1) return; lang = 1; } else { return; } QString tips = tr("Language changed ok, did you restart application now?"); OpenArkConfig::Instance()->GetLang(CONF_SET, lang); QMessageBox::StandardButton reply; reply = QMessageBox::information(this, tr("Information"), tips, QMessageBox::Yes | QMessageBox::No); if (reply == QMessageBox::Yes) { onExecCmd(L".restart"); } } void OpenArk::onActionCoderKit(bool checked) { SetActiveTab(TAB_CODERKIT); } void OpenArk::onActionScanner(bool checked) { SetActiveTab(TAB_SCANNER); } void OpenArk::onActionBundler(bool checked) { SetActiveTab(TAB_BUNDLER); } void OpenArk::onLogOutput(QString log) { log.replace("\n", "<br/>"); log.replace("err", "<font color=red>err</font>"); log.replace("error", "<font color=red>error</font>"); log.replace("ERR", "<font color=red>ERR</font>"); log.replace("ERROR", "<font color=red>ERROR</font>"); log = QString("<font color=#E0E2E4>%1</font>").arg(log); ui.cmdOutWindow->append(log); } void OpenArk::onExecCmd(const std::wstring &cmdline) { cmds_->CmdDispatcher(cmdline); } void OpenArk::onOpen(QString path) { QMetaObject::invokeMethod(ui.tabWidget->currentWidget(), "onOpenFile", Qt::QueuedConnection, Q_ARG(QString, path)); } void OpenArk::onCmdHelp() { onExecCmd(L".help"); } void OpenArk::onShowConsoleMenu(const QPoint &pt) { QMenu *menu = ui.cmdOutWindow->createStandardContextMenu(); menu->addSeparator(); menu->addAction(tr("History"), this, SLOT(onConsoleHistory())); menu->addAction(tr("Helps"), this, SLOT(onConsoleHelps())); menu->addAction(tr("Clear"), this, SLOT(onConsoleClear())); menu->exec(ui.cmdOutWindow->mapToGlobal(pt)); delete menu; } void OpenArk::onConsoleHistory() { onExecCmd(L".history"); } void OpenArk::onConsoleClear() { onExecCmd(L".cls"); } void OpenArk::onConsoleHelps() { onExecCmd(L".help"); } void OpenArk::onCmdInput() { QLineEdit* sender = qobject_cast<QLineEdit*>(QObject::sender()); std::wstring input = sender->text().toStdWString(); if (input.empty()) input = cmds_->CmdGetLast().toStdWString(); onExecCmd(input); auto scroll = ui.cmdOutWindow->verticalScrollBar(); scroll->setSliderPosition(scroll->maximum()); sender->clear(); } void OpenArk::onTabChanged(int idx) { if (idx == TAB_PROCESS) onActionRefresh(true); OpenArkConfig::Instance()->SetPrefMainTab(idx); switch (idx) { case TAB_KERNEL: case TAB_CODERKIT: case TAB_SCANNER: case TAB_UTILITIES: case TAB_REVERSE: auto obj = ui.tabWidget->currentWidget(); auto xxx = obj->objectName(); if (obj->objectName().contains("tab")) break; qint32 l2; qRegisterMetaType<qint32>("qint32"); QMetaObject::invokeMethod(obj, "GetActiveTab", Qt::DirectConnection, Q_RETURN_ARG(qint32, l2)); OpenArkConfig::Instance()->SetPrefLevel2Tab(l2); QMetaObject::invokeMethod(obj, "RefreshTab", Qt::DirectConnection); break; } } void OpenArk::StatusBarClear() { } void OpenArk::StatusBarAdd(QWidget *label) { stool_->addSeparator(); stool_->addWidget(label); }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/openark/openark.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <QtWidgets/QMainWindow> #include "ui_openark.h" #include "common/config/config.h" class Cmds; class OpenArk : public QMainWindow { Q_OBJECT public: OpenArk(QWidget *parent = Q_NULLPTR); protected: bool eventFilter(QObject *obj, QEvent *e); void changeEvent(QEvent *e); signals: void signalRefresh(); void signalShowPtool(int); public slots: void onLogOutput(QString log); void onExecCmd(const std::wstring &cmdline); void onOpen(QString path); private slots: void onActionOpen(bool checked); void onActionRefresh(bool checked); void onActionReset(bool checked); void onActionOnTop(bool checked); void onActionAbout(bool checked); void onActionSettings(bool checked); void onActionConsole(bool checked); void onActionPtool(bool checked); void onActionManuals(bool checked); void onActionGithub(bool checked); void onActionCoderKit(bool checked); void onActionScanner(bool checked); void onActionBundler(bool checked); void onActionCheckUpdate(bool checked); void onActionLanguage(QAction *act); void onCmdHelp(); void onShowConsoleMenu(const QPoint &pt); void onConsoleClear(); void onConsoleHelps(); void onConsoleHistory(); void onCmdInput(); void onTabChanged(int); public: void StatusBarClear(); void StatusBarAdd(QWidget *label); void SetActiveTab(int idx) const { ui.tabWidget->setCurrentIndex(idx); }; int GetActiveTab() const { return ui.tabWidget->currentIndex(); }; private: Cmds *cmds_; QSize old_window_size_; QPoint old_window_pos_; QTimer *chkupt_timer_; QToolBar *stool_; Ui::OpenArkWindow ui; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/openark_zh.ts
TypeScript
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.1" language="zh_CN"> <context> <name>About</name> <message> <location filename="ui/about.ui" line="14"/> <source>About...</source> <translation>关于...</translation> </message> <message> <location filename="ui/about.ui" line="58"/> <source>OpenArk - Open Anti Rootkit</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/about.ui" line="71"/> <source>Open source and free, for reverse enginerring, programming, anti-malware...</source> <oldsource>Open source and free, for reverse enginerring 、programming、anti-malware...</oldsource> <translation type="unfinished">自由、开源,适用于逆向分析人员、程序员和反病毒人员...</translation> </message> <message> <location filename="ui/about.ui" line="84"/> <source>Support: Windows XP/7/8/8.1/10/11 32/64bit</source> <oldsource>Support: Windows XP/7/8/8.1/10 32/64bit</oldsource> <translation type="unfinished">系统支持:Windows XP/7/8/8.1/10/11 32/64bit</translation> </message> <message> <location filename="ui/about.ui" line="97"/> <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Copyright (C) 2019 BlackINT3 &lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://github.com/BlackINT3/OpenArk&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/BlackINT3/OpenArk&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/about.ui" line="113"/> <source>License: LGPL</source> <translation type="unfinished">许可:LGPL</translation> </message> <message> <location filename="ui/about.ui" line="127"/> <source>OK</source> <translation type="unfinished">确定</translation> </message> </context> <context> <name>Bundler</name> <message> <location filename="ui/bundler.ui" line="20"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/bundler.ui" line="34"/> <source>Folder:</source> <translation type="unfinished">文件夹路径:</translation> </message> <message> <location filename="ui/bundler.ui" line="57"/> <source>Open Folde&amp;r</source> <translation type="unfinished">&amp;打开文件夹</translation> </message> <message> <location filename="ui/bundler.ui" line="92"/> <source>Launch Script:</source> <translation type="unfinished">启动脚本:</translation> </message> <message> <location filename="ui/bundler.ui" line="99"/> <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; p, li { white-space: pre-wrap; } &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;SimSun&apos;; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;; font-weight:600; color:#00aa00;&quot;&gt;Bundler script manual&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;; font-weight:600; color:#aa0000;&quot;&gt;start&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt; file param - aysnc execute file&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;; font-weight:600; color:#aa0000;&quot;&gt;call&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt; file param - sync execute file until exited&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;; font-weight:600; color:#aa0000;&quot;&gt;cmd&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt; param - execute cmd&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;; font-weight:600; color:#aa0000;&quot;&gt;clean&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt; - remove extracted files&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt;;--------------------------------------------------------------------------------------&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt;call %root%\OpenArk32.exe&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;;&quot;&gt;clean&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/bundler.ui" line="135"/> <source>S&amp;elect ICON</source> <translation type="unfinished">选择图标(&amp;E)</translation> </message> <message> <location filename="ui/bundler.ui" line="161"/> <source>&amp;Save to..</source> <translation type="unfinished">&amp;生成..</translation> </message> <message> <location filename="bundler/bundler.cpp" line="22"/> <source>Name</source> <translation type="unfinished">名称</translation> </message> <message> <location filename="bundler/bundler.cpp" line="22"/> <source>Size(KB)</source> <translation type="unfinished">大小(KB)</translation> </message> <message> <location filename="bundler/bundler.cpp" line="22"/> <source>Path</source> <translation type="unfinished">路径</translation> </message> <message> <location filename="bundler/bundler.cpp" line="25"/> <source>Use the ICON</source> <translation type="unfinished">使用这个图标</translation> </message> <message> <location filename="bundler/bundler.cpp" line="77"/> <source>Open Folder</source> <translation type="unfinished">打开文件夹</translation> </message> <message> <location filename="bundler/bundler.cpp" line="84"/> <source>Select ICON</source> <translation type="unfinished">选择图标</translation> </message> <message> <location filename="bundler/bundler.cpp" line="84"/> <source>ico/exe (*.exe;*.ico)</source> <translation type="unfinished">图标/可执行程序 (*.exe;*.ico)</translation> </message> <message> <location filename="bundler/bundler.cpp" line="99"/> <source>Save to</source> <translation type="unfinished">生成程序</translation> </message> <message> <location filename="bundler/bundler.cpp" line="99"/> <source>BundleFile(*.exe)</source> <translation type="unfinished">捆绑文件(*.exe)</translation> </message> <message> <source>Files is empty</source> <translation type="obsolete">文件列表不能为空</translation> </message> <message> <location filename="bundler/bundler.cpp" line="115"/> <source>Build err</source> <translation type="unfinished">生成失败</translation> </message> <message> <location filename="bundler/bundler.cpp" line="116"/> <source>Build bundle file err</source> <translation type="unfinished">打包程序失败</translation> </message> <message> <location filename="bundler/bundler.cpp" line="132"/> <location filename="bundler/bundler.cpp" line="133"/> <source>BeginUpdateResourceW err</source> <translation type="unfinished">BeginUpdateResourceW 失败</translation> </message> <message> <location filename="bundler/bundler.cpp" line="138"/> <location filename="bundler/bundler.cpp" line="139"/> <source>UpdateResourceW err</source> <translation type="unfinished">UpdateResourceW 失败</translation> </message> <message> <location filename="bundler/bundler.cpp" line="144"/> <source>Build %1 ok</source> <translation type="unfinished">生成程序 %1 成功</translation> </message> </context> <context> <name>CoderKit</name> <message> <location filename="ui/coderkit.ui" line="20"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="54"/> <source>CodePoints</source> <translation type="unfinished">文字编码</translation> </message> <message> <location filename="ui/coderkit.ui" line="389"/> <source>Text:</source> <translation type="unfinished">文字:</translation> </message> <message> <location filename="ui/coderkit.ui" line="95"/> <source>Default:</source> <translation type="unfinished">默认编码:</translation> </message> <message> <location filename="ui/coderkit.ui" line="114"/> <source>ASCII:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="133"/> <source>UNICODE:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="152"/> <source>UTF-7:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="171"/> <source>UTF-8:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="190"/> <source>UTF-16:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="209"/> <source>UTF-16BE:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="228"/> <source>UTF-32:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="247"/> <source>UTF-32BE:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="266"/> <source>GBK:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="285"/> <source>BIG5:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="304"/> <source>CP866:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="340"/> <source>assemble</source> <translation type="unfinished">汇编</translation> </message> <message> <location filename="ui/coderkit.ui" line="347"/> <source>1 byte</source> <translation type="unfinished">1字节</translation> </message> <message> <location filename="ui/coderkit.ui" line="400"/> <source>Constants</source> <translation type="unfinished">常量信息</translation> </message> <message> <location filename="ui/coderkit.ui" line="406"/> <source>Windows Error</source> <translation type="unfinished">Windows错误码</translation> </message> <message> <location filename="ui/coderkit.ui" line="438"/> <source>DosError:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="451"/> <source>NTSTATUS:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="474"/> <source>HRESULT:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="497"/> <source>Message:</source> <translation type="unfinished">错误消息:</translation> </message> <message> <location filename="ui/coderkit.ui" line="505"/> <source>Windows GUI</source> <translation type="unfinished">Windows界面</translation> </message> <message> <location filename="ui/coderkit.ui" line="517"/> <source>Message ID</source> <translation type="unfinished">查看消息ID</translation> </message> <message> <location filename="ui/coderkit.ui" line="526"/> <source>Algorithms</source> <translation type="unfinished">加密算法</translation> </message> <message> <location filename="ui/coderkit.ui" line="540"/> <source>Type:</source> <translation type="unfinished">类型:</translation> </message> <message> <location filename="ui/coderkit.ui" line="547"/> <source>Base64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="554"/> <source>CRC32</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="561"/> <source>MD5</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="568"/> <source>SHA1</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="575"/> <source>URL-Encode</source> <oldsource>urlencode</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="582"/> <source>URL-Decode</source> <oldsource>urldecode</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="606"/> <source>PlainText:</source> <translation type="unfinished">明文:</translation> </message> <message> <location filename="ui/coderkit.ui" line="620"/> <source>Key:</source> <translation type="unfinished">密钥:</translation> </message> <message> <location filename="ui/coderkit.ui" line="647"/> <source>CipherText:</source> <translation type="unfinished">密文:</translation> </message> <message> <location filename="ui/coderkit.ui" line="663"/> <source>AsmTools</source> <translation type="unfinished">汇编工具</translation> </message> <message> <location filename="ui/coderkit.ui" line="671"/> <source>Assemble</source> <translation type="unfinished">汇编</translation> </message> <message> <location filename="ui/coderkit.ui" line="678"/> <source>Disassemble</source> <translation type="unfinished">反汇编</translation> </message> <message> <location filename="ui/coderkit.ui" line="685"/> <source>Platform:</source> <translation type="unfinished">平台:</translation> </message> <message> <location filename="ui/coderkit.ui" line="693"/> <source>x64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="698"/> <source>x86</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="708"/> <source>arm64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="713"/> <source>arm32</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="718"/> <source>arm16</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="723"/> <source>mips64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="728"/> <source>mips32</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="733"/> <source>mips16</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="741"/> <source>ByteOrder:</source> <translation type="unfinished">字节序:</translation> </message> <message> <location filename="ui/coderkit.ui" line="749"/> <source>little-endian</source> <oldsource>Little-Endian</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="754"/> <source>big-endian</source> <oldsource>Big-Endian</oldsource> <translation type="unfinished"></translation> </message> <message> <source>64-bit</source> <translation type="obsolete">64位</translation> </message> <message> <source>32-bit</source> <translation type="obsolete">32位</translation> </message> <message> <location filename="ui/coderkit.ui" line="703"/> <source>x86-16</source> <oldsource>16-bit</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/coderkit.ui" line="66"/> <location filename="ui/coderkit.ui" line="762"/> <source>Format:</source> <translation type="unfinished">格式:</translation> </message> <message> <location filename="ui/coderkit.ui" line="319"/> <location filename="ui/coderkit.ui" line="769"/> <source>null</source> <translation type="unfinished">无</translation> </message> <message> <location filename="ui/coderkit.ui" line="354"/> <source>2 bytes</source> <translation type="unfinished">2字节</translation> </message> <message> <location filename="ui/coderkit.ui" line="361"/> <source>4 bytes</source> <translation type="unfinished">4字节</translation> </message> <message> <location filename="ui/coderkit.ui" line="333"/> <location filename="ui/coderkit.ui" line="776"/> <source>space</source> <translation type="unfinished">空格</translation> </message> <message> <location filename="ui/coderkit.ui" line="326"/> <location filename="ui/coderkit.ui" line="783"/> <source>\x</source> <translation type="unfinished"></translation> </message> <message> <location filename="coderkit/coderkit.cpp" line="264"/> <source>Open console to view result</source> <translation type="unfinished">打开控制台查看结果</translation> </message> <message> <location filename="coderkit/coderkit.cpp" line="388"/> <source>Warning</source> <translation type="unfinished">警告</translation> </message> <message> <location filename="coderkit/coderkit.cpp" line="389"/> <source>Your input data so much(suggest less 10 KB), it&apos;ll be very slowly, continue?</source> <translation type="unfinished">你输入的数据太多(建议小于10KB),反汇编会很慢,是否继续?</translation> </message> <message> <location filename="coderkit/coderkit.cpp" line="577"/> <location filename="coderkit/coderkit.cpp" line="638"/> <source>Compile Error: -------------------------------------------------------------- </source> <translation type="unfinished">编译错误: -------------------------------------------------------------- </translation> </message> <message> <location filename="coderkit/coderkit.cpp" line="579"/> <source>run compiler error</source> <translation type="unfinished"></translation> </message> <message> <location filename="coderkit/coderkit.cpp" line="616"/> <source>run disassember error</source> <translation type="unfinished"></translation> </message> <message> <location filename="coderkit/coderkit.cpp" line="640"/> <source>start nasm error</source> <translation type="unfinished">启动nasm错误</translation> </message> <message> <location filename="coderkit/coderkit.cpp" line="662"/> <source>start ndisasm error</source> <translation type="unfinished">启动ndisasm错误</translation> </message> </context> <context> <name>Kernel</name> <message> <location filename="ui/kernel.ui" line="14"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/kernel.ui" line="45"/> <source>Kernel Entry</source> <translation type="unfinished">内核入口</translation> </message> <message> <source>[KernelMode] Connect successfully...</source> <translation type="obsolete">[内核模式] 连接成功...</translation> </message> <message> <location filename="ui/kernel.ui" line="1084"/> <source>[KernelMode] not initialized...</source> <translation type="unfinished">[内核模式] 未初始化...</translation> </message> <message> <location filename="ui/kernel.ui" line="1104"/> <location filename="kernel/kernel.cpp" line="156"/> <location filename="kernel/kernel.cpp" line="175"/> <source>Enter KernelMode</source> <translation type="unfinished">进入内核模式</translation> </message> <message> <location filename="ui/kernel.ui" line="144"/> <source>DriverKit</source> <translation type="unfinished">驱动工具箱</translation> </message> <message> <source>Driver Installer</source> <translation type="obsolete">驱动安装</translation> </message> <message> <location filename="ui/kernel.ui" line="185"/> <source>DriverFile:</source> <translation type="unfinished">驱动文件:</translation> </message> <message> <location filename="ui/kernel.ui" line="195"/> <source>Browse...</source> <translation type="unfinished">浏览...</translation> </message> <message> <source>Install Expired</source> <oldsource>Sign &amp;&amp; Install</oldsource> <translation type="obsolete">过期签名安装</translation> </message> <message> <location filename="ui/kernel.ui" line="218"/> <source>ServiceName:</source> <translation type="unfinished">服务名:</translation> </message> <message> <source>Sign</source> <translation type="obsolete">签名</translation> </message> <message> <source>Install Unsigned</source> <translation type="obsolete">无签名安装</translation> </message> <message> <location filename="ui/kernel.ui" line="315"/> <source>You can drag driver file to here...</source> <translation>可拖动文件到这里...</translation> </message> <message> <location filename="ui/kernel.ui" line="347"/> <source>Uninstall</source> <translation type="unfinished">卸载</translation> </message> <message> <location filename="ui/kernel.ui" line="285"/> <source>Write Registry</source> <translation type="unfinished">写入注册表</translation> </message> <message> <location filename="ui/kernel.ui" line="366"/> <source>Clean Registry</source> <translation type="unfinished">清理注册表</translation> </message> <message> <location filename="ui/kernel.ui" line="399"/> <source>WDF Driver Installer</source> <translation type="unfinished">WDF驱动安装</translation> </message> <message> <location filename="ui/kernel.ui" line="417"/> <source>Wait for sonn...</source> <translation type="unfinished"></translation> </message> <message> <source>System Notify</source> <oldsource>SystemNotify</oldsource> <translation type="obsolete">系统回调</translation> </message> <message> <location filename="ui/kernel.ui" line="476"/> <source>System Hotkey</source> <translation type="unfinished">系统热键</translation> </message> <message> <location filename="kernel/kernel.cpp" line="94"/> <source>Tips:If you not found the hotkeys,please check the shortcut keys of IME software.(eg:Microsoft/Sogou/Google IME, etc.)</source> <translation type="unfinished">温馨提示:如果上面没获取对应的热键,请检查你输入法的快捷键(比如:微软拼音/搜狗/谷歌输入法等)</translation> </message> <message> <location filename="ui/kernel.ui" line="582"/> <source>ObjectTypes</source> <translation type="unfinished">对象类型表</translation> </message> <message> <location filename="ui/kernel.ui" line="614"/> <source>ObjectSections</source> <translation type="unfinished">内存区对象</translation> </message> <message> <location filename="ui/kernel.ui" line="765"/> <source>Path:</source> <oldsource>InputPath:</oldsource> <translation type="unfinished">路径:</translation> </message> <message> <location filename="ui/kernel.ui" line="791"/> <source>&amp;ShowHold</source> <oldsource>ShowHold</oldsource> <translation type="unfinished">查看占用(&amp;S)</translation> </message> <message> <location filename="ui/kernel.ui" line="901"/> <source>Local IPV4</source> <translation type="unfinished">本机 IPV4</translation> </message> <message> <location filename="ui/kernel.ui" line="908"/> <source>Local IPV6</source> <translation type="unfinished">本机 IPV6</translation> </message> <message> <location filename="ui/kernel.ui" line="511"/> <location filename="ui/kernel.ui" line="922"/> <source>Filter:</source> <translation type="unfinished">过滤器:</translation> </message> <message> <source>&lt;a href=&quot;https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes&quot;&gt;Virtual-Key Codes&lt;/a&gt;</source> <oldsource>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Virtual-Key Codes&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</oldsource> <translation type="obsolete">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;虚拟键码对照表&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation> </message> <message> <location filename="ui/kernel.ui" line="644"/> <source>Kernel Memory</source> <translation type="unfinished">内存管理</translation> </message> <message> <location filename="ui/kernel.ui" line="704"/> <source>Kernel Storage</source> <translation type="unfinished">存储管理</translation> </message> <message> <location filename="ui/kernel.ui" line="846"/> <source>Kernel Network</source> <translation type="unfinished">网络管理</translation> </message> <message> <location filename="ui/kernel.ui" line="945"/> <source>IPV4</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/kernel.ui" line="952"/> <source>IPV6</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/kernel.ui" line="966"/> <source>TCP Listen</source> <translation type="unfinished">TCP监听</translation> </message> <message> <location filename="ui/kernel.ui" line="973"/> <source>TCP Connection</source> <translation type="unfinished">TCP连接</translation> </message> <message> <location filename="ui/kernel.ui" line="980"/> <source>UDP Listen</source> <translation type="unfinished">UDP监听</translation> </message> <message> <location filename="ui/kernel.ui" line="990"/> <source>Hosts</source> <translation type="unfinished">Hosts文件</translation> </message> <message> <location filename="ui/kernel.ui" line="1021"/> <source>&amp;HostsDirectory</source> <translation type="unfinished">打开Hosts目录(&amp;H)</translation> </message> <message> <location filename="ui/kernel.ui" line="1041"/> <source>&amp;Save</source> <translation type="unfinished">保存(&amp;S)</translation> </message> <message> <location filename="ui/kernel.ui" line="1048"/> <source>&amp;Clear</source> <translation type="unfinished">清空(&amp;C)</translation> </message> <message> <location filename="ui/kernel.ui" line="1055"/> <source>&amp;Backup</source> <translation type="unfinished">备份(&amp;B)</translation> </message> <message> <location filename="ui/kernel.ui" line="1062"/> <source>&amp;Refresh</source> <translation type="unfinished">刷新(&amp;R)</translation> </message> <message> <source>&amp;Reload</source> <translation type="obsolete">重新加载(&amp;R)</translation> </message> <message> <source>Memory View</source> <translation type="obsolete">内存查看</translation> </message> <message> <source>Address:</source> <translation type="obsolete">地址:</translation> </message> <message> <source>Size:</source> <translation type="obsolete">大小:</translation> </message> <message> <source>DumpMemory</source> <translation type="obsolete">读取内存</translation> </message> <message> <source>Region:</source> <translation type="obsolete">区域:</translation> </message> <message> <source>Unknown...</source> <translation type="obsolete">未知...</translation> </message> <message> <source>Memory</source> <translation type="obsolete">内存管理</translation> </message> <message> <source>MemoryRegion</source> <translation type="obsolete">内存区域</translation> </message> <message> <source>Storage Manager</source> <oldsource>Storage</oldsource> <translation type="obsolete">存储管理</translation> </message> <message> <source>UnlockFile</source> <translation type="obsolete">解锁占用</translation> </message> <message> <source>Network</source> <translation type="obsolete">网络管理</translation> </message> <message> <source>Driver</source> <translation type="obsolete">驱动管理</translation> </message> <message> <location filename="ui/kernel.ui" line="73"/> <source>Kernel Driver</source> <oldsource>Driver Manager</oldsource> <translation type="unfinished">驱动管理</translation> </message> <message> <location filename="ui/kernel.ui" line="165"/> <source>NT Driver Installer</source> <translation type="unfinished">NT驱动安装</translation> </message> <message> <location filename="ui/kernel.ui" line="445"/> <source>SystemNotify</source> <translation type="unfinished">系统回调</translation> </message> <message> <location filename="ui/kernel.ui" line="544"/> <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;Virtual-Key Codes&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/kernel.ui" line="554"/> <source>Kernel Object</source> <oldsource>Object Manager</oldsource> <translation type="unfinished">对象管理</translation> </message> <message> <source>Memory Manager</source> <translation type="obsolete">内存管理</translation> </message> <message> <location filename="ui/kernel.ui" line="675"/> <source>MemoryReadWrite</source> <oldsource>MemoryView</oldsource> <translation type="unfinished">内存读写</translation> </message> <message> <source>FileFilter</source> <translation type="obsolete">文件过滤</translation> </message> <message> <location filename="ui/kernel.ui" line="729"/> <source>FileUnlock</source> <translation type="unfinished">文件解锁</translation> </message> <message> <source>Select File...</source> <translation type="obsolete">选择文件...</translation> </message> <message> <location filename="ui/kernel.ui" line="832"/> <source>&amp;Kill Process</source> <oldsource>KillProcess</oldsource> <translation type="unfinished">结束进程(&amp;K)</translation> </message> <message> <location filename="ui/kernel.ui" line="818"/> <source>&amp;Unlock</source> <oldsource>Unlock</oldsource> <translation type="unfinished">解锁(&amp;U)</translation> </message> <message> <location filename="ui/kernel.ui" line="825"/> <source>Unlock &amp;All</source> <oldsource>Unlock All</oldsource> <translation type="unfinished">解锁全部(&amp;A)</translation> </message> <message> <source>Network Manager</source> <translation type="obsolete">网络管理</translation> </message> <message> <location filename="ui/kernel.ui" line="871"/> <source>Port</source> <translation type="unfinished">端口</translation> </message> <message> <source>Install Normally</source> <translation type="obsolete">正常安装</translation> </message> <message> <location filename="ui/kernel.ui" line="266"/> <source>Install</source> <translation type="unfinished">安装</translation> </message> <message> <location filename="ui/kernel.ui" line="308"/> <source>Information:</source> <translation type="unfinished">信息:</translation> </message> <message> <location filename="ui/kernel.ui" line="98"/> <source>Drivers</source> <translation type="unfinished">驱动列表</translation> </message> <message> <location filename="kernel/kernel.cpp" line="212"/> <location filename="kernel/kernel.cpp" line="329"/> <source>Name</source> <translation type="unfinished">名称</translation> </message> <message> <location filename="kernel/kernel.cpp" line="212"/> <source>Value</source> <translation type="unfinished">值</translation> </message> <message> <location filename="kernel/kernel.cpp" line="234"/> <source>OperateSystem</source> <translation type="unfinished">操作系统</translation> </message> <message> <location filename="kernel/kernel.cpp" line="236"/> <source>MajorVersion</source> <translation type="unfinished">主版本号</translation> </message> <message> <location filename="kernel/kernel.cpp" line="237"/> <source>MiniorVersion</source> <translation type="unfinished">副版本号</translation> </message> <message> <location filename="kernel/kernel.cpp" line="238"/> <location filename="kernel/kernel.cpp" line="254"/> <source>ReleaseNumber</source> <translation type="unfinished">发行编号</translation> </message> <message> <location filename="kernel/kernel.cpp" line="239"/> <location filename="kernel/kernel.cpp" line="254"/> <source>BuildNumber</source> <translation type="unfinished">编译号</translation> </message> <message> <location filename="kernel/kernel.cpp" line="240"/> <source>MajorServicePack</source> <translation type="unfinished">主服务包</translation> </message> <message> <location filename="kernel/kernel.cpp" line="241"/> <source>MiniorServicePack</source> <translation type="unfinished">副服务包</translation> </message> <message> <location filename="kernel/kernel.cpp" line="244"/> <source>R3 AddressRange</source> <translation type="unfinished">R3地址空间</translation> </message> <message> <location filename="kernel/kernel.cpp" line="245"/> <source>R0 AddressRange</source> <translation type="unfinished">R0地址空间</translation> </message> <message> <location filename="kernel/kernel.cpp" line="246"/> <source>Page Size</source> <translation type="unfinished">页面大小</translation> </message> <message> <location filename="kernel/kernel.cpp" line="247"/> <source>Physical Memory</source> <translation type="unfinished">物理内存</translation> </message> <message> <location filename="kernel/kernel.cpp" line="248"/> <source>CPU Count</source> <translation type="unfinished">CPU核数</translation> </message> <message> <location filename="kernel/kernel.cpp" line="249"/> <source>SystemRoot</source> <translation type="unfinished">系统根目录</translation> </message> <message> <source>[KernelMode] Disconnected...</source> <translation type="obsolete">[内核模式] 已断开...</translation> </message> <message> <source>Base</source> <translation type="obsolete">基址</translation> </message> <message> <location filename="kernel/kernel.cpp" line="274"/> <location filename="kernel/kernel.cpp" line="337"/> <source>Path</source> <translation type="unfinished">路径</translation> </message> <message> <source>Number</source> <translation type="obsolete">顺序</translation> </message> <message> <location filename="kernel/kernel.cpp" line="275"/> <location filename="kernel/kernel.cpp" line="338"/> <source>Description</source> <translation type="unfinished">描述</translation> </message> <message> <location filename="kernel/kernel.cpp" line="276"/> <source>Version</source> <translation type="unfinished">版本</translation> </message> <message> <location filename="kernel/kernel.cpp" line="277"/> <source>Company</source> <translation type="unfinished">公司</translation> </message> <message> <location filename="kernel/kernel.cpp" line="283"/> <location filename="kernel/kernel.cpp" line="346"/> <source>Refresh</source> <translation type="unfinished">刷新</translation> </message> <message> <location filename="kernel/kernel.cpp" line="307"/> <source>Copy</source> <translation type="unfinished">复制</translation> </message> <message> <location filename="kernel/kernel.cpp" line="314"/> <location filename="kernel/kernel.cpp" line="371"/> <source>Explore File</source> <translation type="unfinished">定位到文件</translation> </message> <message> <location filename="kernel/kernel.cpp" line="310"/> <location filename="kernel/kernel.cpp" line="367"/> <source>Sendto Scanner</source> <translation type="unfinished">扫描文件</translation> </message> <message> <location filename="kernel/kernel.cpp" line="166"/> <source>[KernelMode] Enter successfully...</source> <translation type="unfinished">[内核模式] 进入内核模式成功...</translation> </message> <message> <location filename="kernel/kernel.cpp" line="173"/> <source>[KernelMode] Exit successfully...</source> <translation type="unfinished">[内核模式] 退出内核模式成功...</translation> </message> <message> <location filename="kernel/kernel.cpp" line="210"/> <source>[KernelMode] Enter kernel mode needed before using the features(Hotkey/Notify/Memory...)</source> <translation>[内核模式] 使用(热键/回调/内存)等功能时需要进入内核模式...</translation> </message> <message> <location filename="kernel/kernel.cpp" line="317"/> <location filename="kernel/kernel.cpp" line="374"/> <source>Properties...</source> <translation type="unfinished">属性...</translation> </message> <message> <source>Open File</source> <translation type="obsolete">打开文件</translation> </message> <message> <source>Driver Files (*.sys);;All Files (*.*)</source> <translation type="obsolete">驱动文件 (*.sys);;所有文件 (*.*)</translation> </message> <message> <location filename="kernel/kernel.cpp" line="290"/> <location filename="kernel/kernel.cpp" line="427"/> <source>CreateProcess</source> <translation type="unfinished"></translation> </message> <message> <location filename="kernel/kernel.cpp" line="291"/> <location filename="kernel/kernel.cpp" line="430"/> <source>CreateThread</source> <translation type="unfinished"></translation> </message> <message> <location filename="kernel/kernel.cpp" line="292"/> <location filename="kernel/kernel.cpp" line="433"/> <source>LoadImage</source> <translation type="unfinished"></translation> </message> <message> <location filename="kernel/kernel.cpp" line="293"/> <location filename="kernel/kernel.cpp" line="436"/> <source>CmpCallback</source> <translation type="unfinished"></translation> </message> <message> <source>Install ok...</source> <translation type="obsolete">安装成功...</translation> </message> <message> <location filename="kernel/kernel.cpp" line="145"/> <location filename="kernel/kernel.cpp" line="168"/> <source>Exit KernelMode</source> <translation type="unfinished">退出内核模式</translation> </message> <message> <source>[KernelMode] Driver load successfully...</source> <translation type="obsolete">[内核模式] 驱动安装成功...</translation> </message> <message> <source>[KernelMode] Driver unloaded...</source> <translation type="obsolete">[内核模式] 驱动已卸载...</translation> </message> <message> <source>Sign failed, open console window to view detail...</source> <translation type="obsolete">签名失败,打开控制台窗口查看详情...</translation> </message> <message> <source>Install failed, open console window to view detail...</source> <translation type="obsolete">安装失败,打开控制台窗口查看详情...</translation> </message> <message> <source>Uninstall ok...</source> <translation type="obsolete">卸载成功...</translation> </message> <message> <source>Uninstall failed, open console window to view detail...</source> <translation type="obsolete">卸载失败,打开控制台窗口查看详情...</translation> </message> <message> <source>[KernelMode] You need enable kernel mode to install driver...</source> <translation type="obsolete">[内核模式] 你需要启用内核模式来安装驱动...</translation> </message> <message> <location filename="kernel/kernel.cpp" line="272"/> <source>Callback Entry</source> <translation type="unfinished">回调入口</translation> </message> <message> <location filename="kernel/kernel.cpp" line="273"/> <source>Type</source> <translation type="unfinished">类型</translation> </message> <message> <location filename="kernel/kernel.cpp" line="285"/> <source>Delete Notify</source> <translation type="unfinished">删除回调</translation> </message> <message> <location filename="kernel/kernel.cpp" line="297"/> <source>Disassemble Notify</source> <translation type="unfinished">反汇编回调入口</translation> </message> <message> <source>Memory Read-Write</source> <translation type="obsolete">内存读写</translation> </message> <message> <location filename="kernel/kernel.cpp" line="330"/> <source>PID.TID</source> <translation type="unfinished">进程ID.线程ID</translation> </message> <message> <location filename="kernel/kernel.cpp" line="331"/> <source>Hotkey</source> <translation type="unfinished">热键</translation> </message> <message> <location filename="kernel/kernel.cpp" line="332"/> <source>HotkeyObject</source> <translation type="unfinished">热键对象地址</translation> </message> <message> <location filename="kernel/kernel.cpp" line="333"/> <source>HotkeyID</source> <translation type="unfinished">热键ID</translation> </message> <message> <location filename="kernel/kernel.cpp" line="334"/> <source>HWND</source> <translation type="unfinished">句柄</translation> </message> <message> <location filename="kernel/kernel.cpp" line="335"/> <source>Title</source> <translation type="unfinished">标题</translation> </message> <message> <location filename="kernel/kernel.cpp" line="336"/> <source>ClassName</source> <translation type="unfinished">类名</translation> </message> <message> <source>Error</source> <translation type="obsolete">错误</translation> </message> <message> <location filename="kernel/kernel.cpp" line="348"/> <source>Delete Hotkey</source> <translation type="unfinished">删除热键</translation> </message> <message> <location filename="kernel/kernel.cpp" line="402"/> <source>[-] Driver file not existed!</source> <translation type="unfinished">[-] 驱动文件不存在!</translation> </message> </context> <context> <name>KernelDriver</name> <message> <location filename="kernel/driver/driver.cpp" line="97"/> <source>Name</source> <translation type="unfinished">名称</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="98"/> <source>Base</source> <translation type="unfinished">基址</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="99"/> <source>Path</source> <translation type="unfinished">路径</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="100"/> <source>Number</source> <translation type="unfinished">顺序</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="101"/> <source>Description</source> <translation type="unfinished">描述</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="102"/> <source>Version</source> <translation type="unfinished">版本</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="103"/> <source>Company</source> <translation type="unfinished">公司</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="109"/> <source>Refresh</source> <translation type="unfinished">刷新</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="110"/> <source>Copy</source> <translation type="unfinished">复制</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="113"/> <source>Sendto Scanner</source> <translation type="unfinished">扫描文件</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="117"/> <source>Explore File</source> <translation type="unfinished">定位到文件</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="120"/> <source>Properties...</source> <translation type="unfinished">属性...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="129"/> <source>Open File</source> <translation type="unfinished">打开文件</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="129"/> <source>Driver Files (*.sys);;All Files (*.*)</source> <translation type="unfinished">驱动文件 (*.sys);;所有文件 (*.*)</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="138"/> <source>Write registry ok...</source> <translation type="unfinished">写入注册表成功...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="139"/> <source>Write registry failed, open console window to view detail...</source> <translation type="unfinished">写入注册表失败,打开控制台窗口查看详情...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="144"/> <source>Clean registry ok...</source> <translation type="unfinished">清理注册表成功...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="145"/> <source>Clean registry failed, open console window to view detail...</source> <translation type="unfinished">删除注册表失败,打开控制台窗口查看详情...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="154"/> <source>Sign ok...</source> <translation type="unfinished">签名成功...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="155"/> <source>Sign failed, open console window to view detail...</source> <translation type="unfinished">签名失败,打开控制台窗口查看详情...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="161"/> <source>Install ok...</source> <translation type="unfinished">安装成功...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="162"/> <source>Install failed, open console window to view detail...</source> <translation type="unfinished">安装失败,打开控制台窗口查看详情...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="181"/> <source>Uninstall ok...</source> <translation type="unfinished">卸载成功...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="182"/> <source>Uninstall failed, open console window to view detail...</source> <translation type="unfinished">卸载失败,打开控制台窗口查看详情...</translation> </message> <message> <location filename="kernel/driver/driver.cpp" line="234"/> <source>[-] Driver file not existed!</source> <translation type="unfinished">[-] 驱动文件不存在!</translation> </message> </context> <context> <name>KernelMemoryRW</name> <message> <location filename="kernel/memory/memory.h" line="81"/> <source>Memory Read-Write</source> <translation type="unfinished">内存读写</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="102"/> <location filename="kernel/memory/memory.cpp" line="212"/> <source>Read Memory error, addr:0x%1 size:0x%2</source> <oldsource>Read Memory error, addr:%1 size:%2</oldsource> <translation type="unfinished">读取内存错误,地址:0x%1 大小:0x%2</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="107"/> <source>Save to</source> <translation type="unfinished">生成程序</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="107"/> <source>DumpMemory(*)</source> <translation type="unfinished">转储文件</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="110"/> <source>Dump memory to file ok</source> <translation type="unfinished">读取内存到文件成功</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="111"/> <source>Dump memory to file error</source> <translation type="unfinished">读取内存到文件失败</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="211"/> <source>Read Memory successfully, addr:0x%1 size:0x%2</source> <oldsource>Read Memory successfully, addr:%1 size:%2</oldsource> <translation type="unfinished">读取内存成功,地址:0x%1 大小:0x%2</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="84"/> <location filename="kernel/memory/memory.cpp" line="229"/> <source>Warning</source> <translation type="unfinished">警告</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="84"/> <source>Read size too big, UI maybe no responsible.</source> <translation type="unfinished">读取的数据太长,可能导致界面未响应。</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="229"/> <source>Write kernel memory maybe cause BSOD, are you sure to write?</source> <translation type="unfinished">修改内核空间内存可能会导致蓝屏,是否继续?</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="236"/> <source>Write Memory successfully, addr:0x%1</source> <translation type="unfinished">修改内存成功,地址:%1</translation> </message> <message> <location filename="kernel/memory/memory.cpp" line="237"/> <source>Write Memory error, addr:0x%1</source> <translation type="unfinished">修改内存失败,地址:%1</translation> </message> </context> <context> <name>KernelNetwork</name> <message> <source>Name</source> <translation type="obsolete">名称</translation> </message> <message> <location filename="kernel/network/network.cpp" line="422"/> <source>Hosts Backup</source> <translation type="unfinished">Hosts备份</translation> </message> <message> <location filename="kernel/network/network.cpp" line="422"/> <location filename="kernel/network/network.cpp" line="454"/> <source>Please input file name: (hosts-***)</source> <translation type="unfinished">请输入新的文件名:(hosts-***)</translation> </message> <message> <location filename="kernel/network/network.cpp" line="444"/> <source>Mark as Main</source> <translation type="unfinished">设为主文件</translation> </message> <message> <location filename="kernel/network/network.cpp" line="449"/> <source>Rename</source> <translation type="unfinished">重命名</translation> </message> <message> <location filename="kernel/network/network.cpp" line="454"/> <source>Hosts Rename</source> <translation type="unfinished">Hosts重命名</translation> </message> <message> <location filename="kernel/network/network.cpp" line="467"/> <source>Backup</source> <translation type="unfinished">备份</translation> </message> <message> <location filename="kernel/network/network.cpp" line="483"/> <location filename="kernel/network/network.cpp" line="527"/> <source>Refresh</source> <oldsource>Reload</oldsource> <translation type="unfinished">刷新</translation> </message> <message> <location filename="kernel/network/network.cpp" line="535"/> <source>Kill Process</source> <translation type="unfinished">结束进程</translation> </message> <message> <location filename="kernel/network/network.cpp" line="541"/> <source>Sendto Scanner</source> <translation type="unfinished">扫描文件</translation> </message> <message> <location filename="kernel/network/network.cpp" line="545"/> <source>Explore File</source> <translation type="unfinished">定位到文件</translation> </message> <message> <location filename="kernel/network/network.cpp" line="548"/> <source>Properties...</source> <translation type="unfinished">属性...</translation> </message> <message> <location filename="kernel/network/network.cpp" line="471"/> <source>File Name</source> <translation type="unfinished">文件名</translation> </message> <message> <location filename="kernel/network/network.cpp" line="472"/> <source>File Path</source> <translation type="unfinished">文件路径</translation> </message> <message> <location filename="kernel/network/network.cpp" line="473"/> <location filename="kernel/network/network.cpp" line="530"/> <source>Copy</source> <translation type="unfinished">复制</translation> </message> <message> <location filename="kernel/network/network.cpp" line="294"/> <location filename="kernel/network/network.cpp" line="489"/> <source>Delete</source> <translation type="unfinished">删除</translation> </message> <message> <location filename="kernel/network/network.cpp" line="493"/> <source>Delete Non-Main</source> <translation type="unfinished">删除所有(主文件除外)</translation> </message> <message> <source>Delete All</source> <translation type="obsolete">删除全部</translation> </message> <message> <location filename="kernel/network/network.cpp" line="494"/> <source>Warning</source> <translation type="unfinished">警告</translation> </message> <message> <location filename="kernel/network/network.cpp" line="494"/> <source>Are you sure to delete all hosts file(include backups)?</source> <translation type="unfinished">你确定要删除所有hosts文件吗(包括备份的)?</translation> </message> <message> <location filename="kernel/network/network.cpp" line="514"/> <source>Protocol</source> <translation type="unfinished">协议</translation> </message> <message> <location filename="kernel/network/network.cpp" line="515"/> <source>Local address</source> <translation type="unfinished">本地地址</translation> </message> <message> <location filename="kernel/network/network.cpp" line="516"/> <source>Foreign address</source> <translation type="unfinished">外部地址</translation> </message> <message> <location filename="kernel/network/network.cpp" line="517"/> <source>State</source> <translation type="unfinished">状态</translation> </message> <message> <location filename="kernel/network/network.cpp" line="518"/> <source>PID</source> <translation type="unfinished">进程ID</translation> </message> <message> <source>Process Name</source> <translation type="obsolete">进程名</translation> </message> <message> <location filename="kernel/network/network.cpp" line="519"/> <source>Process Path</source> <translation type="unfinished">进程路径</translation> </message> </context> <context> <name>KernelObject</name> <message> <location filename="kernel/object/object.cpp" line="90"/> <source>TypeObject</source> <translation type="unfinished">类型对象</translation> </message> <message> <location filename="kernel/object/object.cpp" line="91"/> <source>TypeIndex</source> <translation type="unfinished">类型索引</translation> </message> <message> <location filename="kernel/object/object.cpp" line="92"/> <source>TypeName</source> <translation type="unfinished">类型名称</translation> </message> <message> <location filename="kernel/object/object.cpp" line="93"/> <source>TotalObjectsNum</source> <translation type="unfinished">关联对象数</translation> </message> <message> <location filename="kernel/object/object.cpp" line="94"/> <source>TotalHandlesNum</source> <translation type="unfinished">关联句柄数</translation> </message> <message> <location filename="kernel/object/object.cpp" line="102"/> <location filename="kernel/object/object.cpp" line="128"/> <source>Refresh</source> <translation type="unfinished">刷新</translation> </message> <message> <location filename="kernel/object/object.cpp" line="105"/> <location filename="kernel/object/object.cpp" line="131"/> <source>Copy</source> <translation type="unfinished">复制</translation> </message> <message> <location filename="kernel/object/object.cpp" line="117"/> <source>SectionDirectory</source> <translation type="unfinished">内存区目录</translation> </message> <message> <location filename="kernel/object/object.cpp" line="118"/> <source>SectionName</source> <translation type="unfinished">内存区名</translation> </message> <message> <location filename="kernel/object/object.cpp" line="119"/> <source>SectionSize</source> <translation type="unfinished">内存区大小</translation> </message> <message> <location filename="kernel/object/object.cpp" line="120"/> <source>SessionID</source> <translation type="unfinished">会话ID</translation> </message> <message> <location filename="kernel/object/object.cpp" line="121"/> <source>SessionName</source> <translation type="unfinished">会话名</translation> </message> <message> <location filename="kernel/object/object.cpp" line="156"/> <location filename="kernel/object/object.cpp" line="165"/> <source>Error</source> <translation type="unfinished">错误</translation> </message> <message> <location filename="kernel/object/object.cpp" line="171"/> <source>Dump to File</source> <translation type="unfinished">转存到文件</translation> </message> <message> <location filename="kernel/object/object.cpp" line="177"/> <source>Save to</source> <translation type="unfinished">生成程序</translation> </message> <message> <location filename="kernel/object/object.cpp" line="177"/> <source>DumpMemory(*)</source> <translation type="unfinished">转储文件</translation> </message> <message> <location filename="kernel/object/object.cpp" line="180"/> <source>Dump memory to file ok</source> <translation type="unfinished">转存到文件成功</translation> </message> <message> <location filename="kernel/object/object.cpp" line="181"/> <source>Dump memory to file error</source> <translation type="unfinished">转存到文件失败</translation> </message> <message> <location filename="kernel/object/object.cpp" line="185"/> <source>Memory Edit</source> <translation type="unfinished">内存编辑</translation> </message> </context> <context> <name>KernelStorage</name> <message> <source>FileObject</source> <translation type="obsolete">文件对象</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="89"/> <source>FilePath</source> <translation type="unfinished">文件路径</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="88"/> <source>PID</source> <translation type="unfinished">进程ID</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="54"/> <source>Tips: 1. You can copy file or directory and paste to here(Enter key to ShowHold). 2. You need enter kernel mode to view FileHold. 3. Path is case insensitive.</source> <oldsource>Tips: 1. You can copy file or directory and paste to here(Enter key to ShowHold). 2. You need enter kernel mode to view FileHold. 3. Path is case insensitive</oldsource> <translation type="unfinished">提示: 1、你可以直接复制文件或文件夹,然后粘贴到这里(回车查看占用)。 2、你需要进入内核模式查看文件占用。 3、路径不区分大小写。</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="87"/> <source>ProcessName</source> <translation type="unfinished">进程名</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="90"/> <source>ProcessPath</source> <translation type="unfinished">进程路径</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="91"/> <source>Type</source> <translation type="unfinished">类型</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="92"/> <source>FileObject/DllBase</source> <translation type="unfinished">文件对象/模块基址</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="93"/> <source>FileHandle</source> <translation type="unfinished">文件句柄</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="105"/> <source>Copy</source> <translation type="unfinished">复制</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="111"/> <source>Unlock</source> <translation type="unfinished">解锁</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="115"/> <source>Unlock All</source> <translation type="unfinished">解锁全部</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="119"/> <source>Kill Process</source> <translation type="unfinished">结束进程</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="124"/> <source>Scan Selected</source> <translation type="unfinished">扫描该项</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="130"/> <source>Explore Selected</source> <translation type="unfinished">定位到该项</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="135"/> <source>Properties Selected...</source> <translation type="unfinished">属性...</translation> </message> <message> <source>Sendto Scanner</source> <translation type="obsolete">扫描文件</translation> </message> <message> <source>Explore File</source> <translation type="obsolete">定位到文件</translation> </message> <message> <source>Properties...</source> <translation type="obsolete">属性...</translation> </message> <message> <source>KillProcess</source> <translation type="obsolete">结束进程</translation> </message> <message> <source>Name</source> <translation type="obsolete">名称</translation> </message> <message> <source>Value</source> <translation type="obsolete">值</translation> </message> <message> <source>ExpandAll</source> <translation type="obsolete">全部展开</translation> </message> <message> <location filename="kernel/storage/storage.cpp" line="101"/> <source>Refresh</source> <translation type="unfinished">刷新</translation> </message> </context> <context> <name>MemoryRW</name> <message> <location filename="res/ui/memory-rw.ui" line="20"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="28"/> <location filename="res/ui/memory-rw.ui" line="95"/> <source>Address:</source> <translation type="unfinished">地址:</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="47"/> <location filename="res/ui/memory-rw.ui" line="114"/> <source>0xFFFFF78000000000</source> <oldsource>0xfffff780`00000000</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="54"/> <source>Data:</source> <translation type="unfinished">数据:</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="67"/> <source>90 90 90 90 90</source> <translation type="unfinished"></translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="74"/> <source>WriteMemory</source> <translation type="unfinished">写入内存</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="81"/> <source>WriteString</source> <translation type="unfinished">字符串写入</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="121"/> <source>Size:</source> <translation type="unfinished">大小:</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="134"/> <source>0x200</source> <translation type="unfinished"></translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="147"/> <source>Region:</source> <translation type="unfinished">区域:</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="163"/> <source>Unknown...</source> <translation type="unfinished">未知...</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="183"/> <source>ReadMemory</source> <translation type="unfinished">读取内存</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="190"/> <source>DumpToFile</source> <translation type="unfinished">转存到文件</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="252"/> <source>PID:</source> <translation type="unfinished">进程ID:</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="280"/> <source>4</source> <translation type="unfinished"></translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="294"/> <source>ProcessName:</source> <translation type="unfinished">进程名:</translation> </message> <message> <location filename="res/ui/memory-rw.ui" line="326"/> <source>SYSTEM</source> <translation type="unfinished"></translation> </message> </context> <context> <name>OpenArk</name> <message> <location filename="openark/openark.cpp" line="71"/> <source>OpenArk v%1 </source> <translation type="unfinished"></translation> </message> <message> <location filename="openark/openark.cpp" line="72"/> <source> [build:%1] </source> <translation type="unfinished"> [构建:%1] </translation> </message> <message> <location filename="openark/openark.cpp" line="74"/> <source>64-Bit</source> <translation type="unfinished">64位</translation> </message> <message> <location filename="openark/openark.cpp" line="74"/> <source>32-Bit</source> <translation type="unfinished">32位</translation> </message> <message> <location filename="openark/openark.cpp" line="81"/> <source>Project on Github</source> <translation type="unfinished">Github开源项目</translation> </message> <message> <location filename="openark/openark.cpp" line="275"/> <source>Open File</source> <translation type="unfinished">打开文件</translation> </message> <message> <location filename="openark/openark.cpp" line="275"/> <source>All Files (*.*)</source> <translation type="unfinished">所有文件 (*.*)</translation> </message> <message> <location filename="openark/openark.cpp" line="411"/> <source>Found new version, app should be updated. appver: %1 appbd: %2 appurl: %3</source> <translation type="unfinished">发现新版本,程序需要更新。 版本:%1 构建:%2 下载地址:%3</translation> </message> <message> <location filename="openark/openark.cpp" line="416"/> <source>App Updates</source> <translation type="unfinished">程序更新</translation> </message> <message> <location filename="openark/openark.cpp" line="422"/> <source>OpenArk is latest.</source> <translation type="unfinished">OpenArk是最新版本.</translation> </message> <message> <location filename="openark/openark.cpp" line="441"/> <source>Language changed ok, did you restart application now?</source> <translation type="unfinished">语言设置成功,现在是否重启进程?</translation> </message> <message> <location filename="openark/openark.cpp" line="444"/> <source>Information</source> <translation type="unfinished">信息</translation> </message> <message> <location filename="openark/openark.cpp" line="495"/> <source>History</source> <translation type="unfinished">历史记录</translation> </message> <message> <location filename="openark/openark.cpp" line="496"/> <source>Helps</source> <translation type="unfinished">帮助</translation> </message> <message> <location filename="openark/openark.cpp" line="497"/> <source>Clear</source> <translation type="unfinished">清空</translation> </message> </context> <context> <name>OpenArkWindow</name> <message> <location filename="ui/openark.ui" line="75"/> <source>Process</source> <translation type="unfinished">进程</translation> </message> <message> <location filename="ui/openark.ui" line="85"/> <location filename="ui/openark.ui" line="431"/> <source>CoderKit</source> <translation type="unfinished">编程助手</translation> </message> <message> <location filename="ui/openark.ui" line="90"/> <location filename="ui/openark.ui" line="436"/> <source>Scanner</source> <translation type="unfinished">扫描器</translation> </message> <message> <location filename="ui/openark.ui" line="95"/> <location filename="ui/openark.ui" line="446"/> <source>Bundler</source> <translation type="unfinished">捆绑器</translation> </message> <message> <location filename="ui/openark.ui" line="132"/> <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; p, li { white-space: pre-wrap; } &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;SimSun&apos;; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;; font-weight:600; color:#21daff;&quot;&gt;OpenArk Console&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;; color:#e0e2e4;&quot;&gt;Copyright (C) 2019 BlackINT3 &lt;/span&gt;&lt;a href=&quot;https://github.com/BlackINT3/OpenArk&quot;&gt;&lt;span style=&quot; font-family:&apos;Microsoft YaHei&apos;; text-decoration: underline; color:#8ccf34;&quot;&gt;https://github.com/BlackINT3/OpenArk&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source> <oldsource>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; p, li { white-space: pre-wrap; } &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;SimSun&apos;; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; color:#21daff;&quot;&gt;OpenArk Console&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; color:#e0e2e4;&quot;&gt;Copyright (C) 2019 BlackINT3 &lt;/span&gt;&lt;a href=&quot;https://github.com/BlackINT3/OpenArk&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#8ccf34;&quot;&gt;https://github.com/BlackINT3/OpenArk&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/openark.ui" line="159"/> <source>C:\&gt;</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/openark.ui" line="169"/> <source>Command Help</source> <translation type="unfinished">命令帮助</translation> </message> <message> <location filename="ui/openark.ui" line="192"/> <source>&amp;File</source> <translation type="unfinished">文件(&amp;F)</translation> </message> <message> <location filename="ui/openark.ui" line="202"/> <source>&amp;View</source> <translation type="unfinished">视图(&amp;V)</translation> </message> <message> <location filename="ui/openark.ui" line="211"/> <source>&amp;Options</source> <translation type="unfinished">选项(&amp;O)</translation> </message> <message> <location filename="ui/openark.ui" line="225"/> <source>&amp;Plugins</source> <translation type="unfinished">插件(&amp;P)</translation> </message> <message> <location filename="ui/openark.ui" line="245"/> <source>&amp;Window</source> <oldsource>Window</oldsource> <translation type="unfinished">窗口(&amp;W)</translation> </message> <message> <location filename="ui/openark.ui" line="234"/> <source>&amp;Help</source> <oldsource>Help</oldsource> <translation type="unfinished">帮助(&amp;H)</translation> </message> <message> <location filename="ui/openark.ui" line="80"/> <source>Kernel</source> <translation type="unfinished">内核</translation> </message> <message> <location filename="ui/openark.ui" line="105"/> <source>Reverse</source> <translation type="unfinished">逆向工具</translation> </message> <message> <location filename="ui/openark.ui" line="100"/> <source>Utilities</source> <translation type="unfinished">实用工具</translation> </message> <message> <location filename="ui/openark.ui" line="215"/> <source>&amp;Language</source> <translation type="unfinished">语言(&amp;L)</translation> </message> <message> <location filename="ui/openark.ui" line="257"/> <source>toolBar</source> <translation type="unfinished">工具栏</translation> </message> <message> <location filename="ui/openark.ui" line="300"/> <source>&amp;Console</source> <translation type="unfinished">控制台(&amp;C)</translation> </message> <message> <location filename="ui/openark.ui" line="303"/> <source>Open Console Window</source> <translation type="unfinished">打开控制台窗口</translation> </message> <message> <location filename="ui/openark.ui" line="306"/> <source>Alt+Shift+C</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/openark.ui" line="315"/> <source>&amp;Open</source> <translation type="unfinished">打开(&amp;O)</translation> </message> <message> <location filename="ui/openark.ui" line="318"/> <source>Ctrl+O</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/openark.ui" line="323"/> <source>Ex&amp;port</source> <translation type="unfinished">导出(&amp;P)</translation> </message> <message> <location filename="ui/openark.ui" line="332"/> <source>&amp;Exit</source> <oldsource>Exit</oldsource> <translation type="unfinished">退出(&amp;X)</translation> </message> <message> <location filename="ui/openark.ui" line="337"/> <source>Output</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/openark.ui" line="342"/> <source>HelloCoder</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/openark.ui" line="358"/> <location filename="ui/openark.ui" line="361"/> <location filename="ui/openark.ui" line="384"/> <source>Project on Github</source> <translation type="unfinished">Github开源项目</translation> </message> <message> <location filename="ui/openark.ui" line="370"/> <source>About OpenArk</source> <translation type="unfinished">关于OpenArk</translation> </message> <message> <location filename="ui/openark.ui" line="379"/> <source>Check for Updates...</source> <translation type="unfinished">检查更新...</translation> </message> <message> <location filename="ui/openark.ui" line="393"/> <source>Manuals</source> <translation type="unfinished">文档手册</translation> </message> <message> <location filename="ui/openark.ui" line="402"/> <source>&amp;Refresh</source> <translation type="unfinished">刷新(&amp;R)</translation> </message> <message> <location filename="ui/openark.ui" line="414"/> <source>&amp;Save</source> <translation type="unfinished">保存(&amp;S)</translation> </message> <message> <location filename="ui/openark.ui" line="417"/> <source>Ctrl+S</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/openark.ui" line="426"/> <source>&amp;Settings</source> <translation type="unfinished">设置(&amp;S)</translation> </message> <message> <location filename="ui/openark.ui" line="475"/> <source>&amp;Module</source> <translation type="unfinished">模块(&amp;M)</translation> </message> <message> <location filename="ui/openark.ui" line="478"/> <source>Open Module Window</source> <translation type="unfinished">打开模块列表</translation> </message> <message> <location filename="ui/openark.ui" line="490"/> <source>&amp;Handle</source> <translation type="unfinished">句柄(&amp;H)</translation> </message> <message> <location filename="ui/openark.ui" line="493"/> <source>Open Handle Window</source> <translation type="unfinished">打开句柄列表</translation> </message> <message> <location filename="ui/openark.ui" line="505"/> <source>&amp;Memory</source> <translation type="unfinished">内存(&amp;M)</translation> </message> <message> <location filename="ui/openark.ui" line="508"/> <source>Open Memory Window</source> <translation type="unfinished">打开内存列表</translation> </message> <message> <location filename="ui/openark.ui" line="516"/> <source>English</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/openark.ui" line="524"/> <source>简体中文</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/openark.ui" line="533"/> <source>&amp;Run</source> <translation type="unfinished">运行(&amp;R)</translation> </message> <message> <location filename="ui/openark.ui" line="536"/> <source>Ctrl+R</source> <translation type="unfinished"></translation> </message> <message> <source>&amp;CoderKit</source> <translation type="obsolete">编程助手</translation> </message> <message> <location filename="ui/openark.ui" line="441"/> <source>C&amp;leaner</source> <translation type="unfinished">清理设置(&amp;L)</translation> </message> <message> <location filename="ui/openark.ui" line="455"/> <source>&amp;Allways On Top</source> <translation type="unfinished">置顶(&amp;A)</translation> </message> <message> <location filename="ui/openark.ui" line="460"/> <source>Reset</source> <translation type="unfinished">重置</translation> </message> <message> <location filename="ui/openark.ui" line="463"/> <source>Reset Window</source> <translation type="unfinished">重置窗口</translation> </message> </context> <context> <name>ProcessMgr</name> <message> <location filename="ui/process-mgr.ui" line="20"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/process-mgr.ui" line="69"/> <source>Hide Unnamed Handles</source> <translation type="unfinished">隐藏无名称句柄</translation> </message> <message> <location filename="ui/process-mgr.ui" line="77"/> <source>Hide Uncommited Memory</source> <translation type="unfinished">隐藏未提交内存</translation> </message> <message> <location filename="ui/process-mgr.ui" line="85"/> <source>Hide NonExecute Memory</source> <translation type="unfinished">隐藏非可执行内存</translation> </message> <message> <location filename="ui/process-mgr.ui" line="93"/> <source>Hide Image Memory</source> <translation type="unfinished">隐藏模块内存</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="858"/> <source>Process Name</source> <translation type="unfinished">进程名</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="859"/> <source>Process ID</source> <translation type="unfinished">进程ID</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="860"/> <source>Parent ID</source> <translation type="unfinished">父进程ID</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="861"/> <source>Process Path</source> <translation type="unfinished">进程路径</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="862"/> <source>Created Time</source> <translation type="unfinished">启动时间</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="863"/> <source>Copy</source> <translation type="unfinished">复制</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="867"/> <source>Create Minidump...</source> <translation type="unfinished">创建 MiniDump...</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="868"/> <source>Create Fulldump...</source> <translation type="unfinished">创建 FullDump...</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="869"/> <source>Create Dump</source> <translation type="unfinished">创建Dump文件</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="871"/> <location filename="process-mgr/process-mgr.cpp" line="933"/> <source>Refresh</source> <translation type="unfinished">刷新</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="873"/> <source>Kill Process</source> <translation type="unfinished">结束进程</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="874"/> <source>Kill Process Tree</source> <translation type="unfinished">结束进程树</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="877"/> <source>Select PID</source> <translation type="unfinished">选择进程(PID)</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="878"/> <location filename="process-mgr/process-mgr.cpp" line="934"/> <source>Explore File</source> <translation type="unfinished">定位到文件</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="879"/> <source>Enum Thread</source> <translation type="unfinished">枚举线程</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="880"/> <source>Enum Window</source> <translation type="unfinished">枚举窗口</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="881"/> <source>Inject Dll</source> <translation type="unfinished">注入DLL</translation> </message> <message> <source>Sento Scanner</source> <translation type="obsolete">扫描</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="534"/> <source>Save to</source> <translation type="unfinished">生成程序</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="534"/> <source>DumpMemory(*)</source> <translation type="unfinished">转储文件</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="538"/> <source>Dump memory ok</source> <translation type="unfinished">内存转储成功</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="875"/> <source>Restart Process</source> <translation type="unfinished">重启进程</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="882"/> <location filename="process-mgr/process-mgr.cpp" line="935"/> <source>Sendto Scanner</source> <oldsource>Scanner</oldsource> <translation type="unfinished">扫描文件</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="884"/> <location filename="process-mgr/process-mgr.cpp" line="938"/> <source>Properties...</source> <translation type="unfinished">属性...</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="887"/> <source>Process</source> <translation type="unfinished">进程</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="887"/> <source>PID</source> <translation type="unfinished">进程ID</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="887"/> <source>PPID</source> <translation type="unfinished">父进程ID</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="887"/> <location filename="process-mgr/process-mgr.cpp" line="941"/> <source>Path</source> <translation type="unfinished">路径</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="887"/> <location filename="process-mgr/process-mgr.cpp" line="941"/> <source>Description</source> <translation type="unfinished">描述</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="887"/> <location filename="process-mgr/process-mgr.cpp" line="941"/> <source>Company Name</source> <translation type="unfinished">公司名</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="887"/> <source>CreatedTime</source> <translation type="unfinished">启动时间</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="936"/> <source>Verify Signature</source> <translation type="unfinished">校验签名</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="937"/> <source>Verify All Signature</source> <translation type="unfinished">校验所有签名</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="941"/> <location filename="process-mgr/process-mgr.cpp" line="956"/> <source>Name</source> <translation type="unfinished">名称</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="941"/> <location filename="process-mgr/process-mgr.cpp" line="978"/> <source>Base</source> <translation type="unfinished">基址</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="941"/> <location filename="process-mgr/process-mgr.cpp" line="978"/> <source>Size</source> <translation type="unfinished">大小</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="941"/> <source>Version</source> <translation type="unfinished">版本</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="941"/> <source>Signature</source> <translation type="unfinished">签名校验</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="951"/> <source>Close Handle</source> <translation type="unfinished">关闭句柄</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="956"/> <location filename="process-mgr/process-mgr.cpp" line="978"/> <source>Type</source> <translation type="unfinished">类型</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="956"/> <source>Value</source> <translation type="unfinished">值</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="956"/> <source>Access</source> <translation type="unfinished">访问权限</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="956"/> <source>Object Address</source> <translation type="unfinished">对象地址</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="972"/> <source>Dump Memory</source> <translation type="unfinished">内存转储</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="978"/> <source>Address</source> <translation type="unfinished">地址</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="978"/> <source>Property</source> <translation type="unfinished">属性</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="978"/> <source>State</source> <translation type="unfinished">状态</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="978"/> <source>Module</source> <translation type="unfinished">模块</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="261"/> <source>CPU:</source> <translation type="unfinished">CPU使用:</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="262"/> <source>Memory:</source> <translation type="unfinished">内存使用:</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="263"/> <source>Processes:</source> <translation type="unfinished">进程数:</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="264"/> <source>Threads:</source> <translation type="unfinished">线程数:</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="265"/> <source>Handles:</source> <translation type="unfinished">句柄数:</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="288"/> <source>Do you kill all processes? ------------------- </source> <translation type="unfinished">你确定要结束以下所有进程? ------------------- </translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="294"/> <source>Warning</source> <translation type="unfinished">警告</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="314"/> <source>Select Dll</source> <translation type="unfinished">选择DLL</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="314"/> <source>Dll Files (*.dll);;All Files (*.*)</source> <translation type="unfinished">DLL文件 (*.dll);;所有文件 (*.*)</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="320"/> <source>Dll file invalid.</source> <translation type="unfinished">DLL文件无效.</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="327"/> <source>Can&apos;t inject 32-bit dll to 64-bit process.</source> <translation type="unfinished">32位DLL不能注入到64位进程中.</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="331"/> <source>Inject 64-bit dll to 32-bit process, maybe fail.</source> <translation type="unfinished">64位模块注入到32位进程,可能会失败.</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="335"/> <source>Inject ok.</source> <translation type="unfinished">注入成功.</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="337"/> <source>Inject failed.</source> <translation type="unfinished">注入失败.</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="381"/> <location filename="process-mgr/process-mgr.cpp" line="390"/> <source>Save dump file</source> <translation type="unfinished">保存Dump文件</translation> </message> <message> <location filename="process-mgr/process-mgr.cpp" line="381"/> <location filename="process-mgr/process-mgr.cpp" line="390"/> <source>DumpFile(*.dmp)</source> <translation type="unfinished">Dump文件(*.dmp)</translation> </message> </context> <context> <name>ProcessProperties</name> <message> <location filename="ui/process-properties.ui" line="20"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/process-properties.ui" line="36"/> <source>Image</source> <translation type="unfinished">镜像文件</translation> </message> <message> <location filename="ui/process-properties.ui" line="54"/> <source>Image File</source> <translation type="unfinished">镜像文件</translation> </message> <message> <location filename="ui/process-properties.ui" line="66"/> <source>ICON</source> <translation type="unfinished">图标</translation> </message> <message> <location filename="ui/process-properties.ui" line="82"/> <location filename="ui/process-properties.ui" line="101"/> <location filename="ui/process-properties.ui" line="133"/> <location filename="ui/process-properties.ui" line="165"/> <location filename="ui/process-properties.ui" line="256"/> <location filename="ui/process-properties.ui" line="312"/> <location filename="ui/process-properties.ui" line="344"/> <location filename="ui/process-properties.ui" line="376"/> <location filename="ui/process-properties.ui" line="408"/> <location filename="ui/process-properties.ui" line="439"/> <source>N/A</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/process-properties.ui" line="117"/> <source>File Version:</source> <translation type="unfinished">文件版本:</translation> </message> <message> <location filename="ui/process-properties.ui" line="149"/> <source>Build Time:</source> <translation type="unfinished">编译时间:</translation> </message> <message> <location filename="ui/process-properties.ui" line="181"/> <source>Path:</source> <translation type="unfinished">进程路径:</translation> </message> <message> <location filename="ui/process-properties.ui" line="194"/> <source>Command line:</source> <translation type="unfinished">命令行:</translation> </message> <message> <location filename="ui/process-properties.ui" line="217"/> <source>Current directory:</source> <translation type="unfinished">当前目录:</translation> </message> <message> <location filename="ui/process-properties.ui" line="240"/> <source>Product Version:</source> <translation type="unfinished">产品版本:</translation> </message> <message> <location filename="ui/process-properties.ui" line="272"/> <source>Explore</source> <translation type="unfinished">定位文件</translation> </message> <message> <location filename="ui/process-properties.ui" line="296"/> <source>Parent:</source> <translation type="unfinished">父进程:</translation> </message> <message> <location filename="ui/process-properties.ui" line="328"/> <source>User:</source> <translation type="unfinished">用户:</translation> </message> <message> <location filename="ui/process-properties.ui" line="360"/> <source>Start:</source> <translation type="unfinished">启动时间:</translation> </message> <message> <location filename="ui/process-properties.ui" line="392"/> <source>Image:</source> <translation type="unfinished">镜像:</translation> </message> <message> <location filename="ui/process-properties.ui" line="417"/> <source>Threads</source> <translation type="unfinished">线程列表</translation> </message> <message> <location filename="ui/process-properties.ui" line="432"/> <source>Count:</source> <translation type="unfinished">数量:</translation> </message> <message> <location filename="ui/process-properties.ui" line="462"/> <source>WindowList</source> <translation type="unfinished">窗口列表</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="30"/> <source>%1:%2 Properties</source> <translation type="unfinished">%1:%2 属性</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="36"/> <location filename="process-mgr/process-properties.cpp" line="37"/> <source>TID</source> <translation type="unfinished">线程ID</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="36"/> <source>KernelTime</source> <translation type="unfinished">内核态时间</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="36"/> <source>UserTime</source> <translation type="unfinished">用户态时间</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="36"/> <source>CreateTime</source> <translation type="unfinished">创建时间</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="37"/> <source>HWND</source> <translation type="unfinished">句柄</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="37"/> <source>Title</source> <translation type="unfinished">标题</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="37"/> <source>ClassName</source> <translation type="unfinished">类名</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="37"/> <source>Visible</source> <translation type="unfinished">可见</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="37"/> <source>PID</source> <translation type="unfinished">进程ID</translation> </message> <message> <location filename="process-mgr/process-properties.cpp" line="41"/> <source>Refresh</source> <translation type="unfinished">刷新</translation> </message> </context> <context> <name>ProcessSelection</name> <message> <location filename="ui/process-selection.ui" line="20"/> <source>Dialog</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/process-selection.ui" line="54"/> <source>Process Selection</source> <translation type="unfinished">选择进程</translation> </message> <message> <location filename="ui/process-selection.ui" line="79"/> <source>Decimal</source> <translation type="unfinished">10进制</translation> </message> <message> <location filename="ui/process-selection.ui" line="92"/> <source>Hex</source> <translation type="unfinished">16进制</translation> </message> <message> <location filename="ui/process-selection.ui" line="105"/> <source>PID:</source> <translation type="unfinished">进程ID:</translation> </message> <message> <location filename="ui/process-selection.ui" line="118"/> <source>Name:</source> <translation type="unfinished">名称:</translation> </message> <message> <location filename="ui/process-selection.ui" line="131"/> <source>Path:</source> <translation type="unfinished">路径:</translation> </message> <message> <location filename="process-mgr/process-selection.cpp" line="28"/> <source>Select...</source> <translation type="unfinished">选择...</translation> </message> </context> <context> <name>QObject</name> <message> <location filename="common/win-wrapper/win-wrapper.cpp" line="138"/> <source>Create dump ok.</source> <translation type="unfinished">创建Dump文件成功.</translation> </message> <message> <location filename="common/win-wrapper/win-wrapper.cpp" line="140"/> <source>Create dump failed.</source> <translation type="unfinished">创建Dump文件失败.</translation> </message> <message> <location filename="common/qt-wrapper/qt-wrapper.h" line="101"/> <source>OpenArk Information</source> <translation type="unfinished"></translation> </message> <message> <location filename="common/qt-wrapper/qt-wrapper.h" line="105"/> <source>OpenArk Warning</source> <translation type="unfinished"></translation> </message> <message> <location filename="common/qt-wrapper/qt-wrapper.h" line="109"/> <source>OpenArk Error</source> <translation type="unfinished"></translation> </message> </context> <context> <name>Reverse</name> <message> <location filename="ui/reverse.ui" line="14"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="33"/> <source>WinCommon</source> <oldsource>WinReverse</oldsource> <translation type="unfinished">Win平台</translation> </message> <message> <source>Common</source> <translation type="obsolete">常用</translation> </message> <message> <location filename="ui/reverse.ui" line="110"/> <source>Procexp</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="121"/> <source>Procmon</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="132"/> <source>Winobj</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="143"/> <source>Dbgview</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="580"/> <source>HxD</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="198"/> <source>PCHunter</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="165"/> <source>APIMon32</source> <oldsource>APIMonitor32</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="624"/> <source>Notepad++</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="613"/> <source>010Editor</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="635"/> <source>WinSpy</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="274"/> <source>Windbg *32</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="318"/> <source>IDA *32</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="296"/> <source>x64dbg *32</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="362"/> <source>OllyICE</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="438"/> <source>ExeinfoPe</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="471"/> <source>ResHacker</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="591"/> <source>Winhex</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="285"/> <source>Windbg *64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="307"/> <source>x64dbg *64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="329"/> <source>IDA *64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="373"/> <source>OD 52PJ</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="961"/> <source>Fiddler2</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="994"/> <source>Wireshark1</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1005"/> <source>Wireshark3</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="972"/> <source>Fiddler4</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="340"/> <source>Ghidra</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="983"/> <source>Charles</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="646"/> <source>Window</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="602"/> <source>DiskGenius</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="922"/> <source>cURL</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="950"/> <source>tcpdump</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="220"/> <source>WKE</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="209"/> <source>PCHunter+</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="936"/> <source>Nmap</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="810"/> <source>WinRAR</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="799"/> <source>7-Zip</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="832"/> <source>Chrome85</source> <oldsource>ChromeSetup</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="821"/> <source>Chrome49</source> <oldsource>Chrome</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="843"/> <source>Firefox</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="679"/> <source>Keygener</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="690"/> <source>PYGTools</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="854"/> <source>CPU-Z</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="865"/> <source>AIDA64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="701"/> <source>PoolMonX</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="493"/> <source>PeBear</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="504"/> <source>DnSpy</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="526"/> <source>InstDrv</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1016"/> <source>WizTree</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1027"/> <source>Rapidee</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1046"/> <source>WinDevKits</source> <translation type="unfinished">开发依赖</translation> </message> <message> <location filename="ui/reverse.ui" line="1088"/> <source>vcredist_2005_x86</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1105"/> <source>TortoiseGit</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1122"/> <source>TortoiseSVN</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1139"/> <source>Git</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1156"/> <source>vcredist_2008_x86</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1173"/> <source>vcredist_2010_x86</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1190"/> <source>vcredist_2012_x86</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1207"/> <source>vcredist_2013_x86</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1224"/> <source>vcredist_2015_x86</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1241"/> <source>vcredist_15~19_x86</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1258"/> <source>vcredist_15~19_x64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1275"/> <source>vcredist_2015_x64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1292"/> <source>vcredist_2010_x64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1309"/> <source>vcredist_2012_x64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1326"/> <source>vcredist_2008_x64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1343"/> <source>vcredist_2013_x64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1360"/> <source>vcredist_2005_x64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1377"/> <source>JDK</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1394"/> <source>Python</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1411"/> <source>Golang</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="460"/> <source>HCD</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="515"/> <source>Cheat Engine</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="788"/> <source>Everything</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="657"/> <source>Spy++ *32</source> <oldsource>Spy++</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="755"/> <source>Teamviewer</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="766"/> <source>AnyDesk</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="777"/> <source>Sunlogin</source> <translation type="unfinished">向日葵</translation> </message> <message> <location filename="ui/reverse.ui" line="449"/> <source>PEID</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="187"/> <source>Sysinternals</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="482"/> <source>CFF Explorer</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="154"/> <source>NirSoft</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="384"/> <source>Radare</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="176"/> <source>APIMon64</source> <oldsource>APIMonitor64</oldsource> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="351"/> <source>OllyDBG</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="668"/> <source>Spy++ *64</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/reverse.ui" line="1445"/> <source>ToolsFolder</source> <translation type="unfinished">工具目录</translation> </message> <message> <source>Placeholder</source> <translation type="obsolete">空白占位</translation> </message> <message> <source>It&apos;s a placeholder used for future.</source> <translation type="obsolete">这是一个占位,用于后续功能更新。</translation> </message> <message> <location filename="reverse/reverse.cpp" line="216"/> <location filename="reverse/reverse.cpp" line="236"/> <source>Error</source> <translation type="unfinished">错误</translation> </message> <message> <location filename="reverse/reverse.cpp" line="216"/> <source>Download pending, wait for a while...</source> <translation type="unfinished">下载进行中,等待片刻...</translation> </message> <message> <location filename="reverse/reverse.cpp" line="236"/> <source>Download failed, err:%1</source> <translation type="unfinished">下载失败,错误:%1</translation> </message> </context> <context> <name>Scanner</name> <message> <location filename="ui/scanner.ui" line="14"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/scanner.ui" line="57"/> <source>Summary</source> <translation type="unfinished">基本信息</translation> </message> <message> <location filename="ui/scanner.ui" line="111"/> <source>Headers</source> <translation type="unfinished">PE头</translation> </message> <message> <location filename="ui/scanner.ui" line="137"/> <source>Sections</source> <translation type="unfinished">区段</translation> </message> <message> <location filename="ui/scanner.ui" line="163"/> <source>Import</source> <translation type="unfinished">导入表</translation> </message> <message> <location filename="ui/scanner.ui" line="214"/> <source>Export</source> <translation type="unfinished">导出表</translation> </message> <message> <location filename="ui/scanner.ui" line="265"/> <source>Relocation</source> <translation type="unfinished">重定位表</translation> </message> <message> <location filename="ui/scanner.ui" line="301"/> <source>Debug</source> <translation type="unfinished">调试目录</translation> </message> <message> <location filename="ui/scanner.ui" line="327"/> <source>RVA</source> <translation type="unfinished">地址转换</translation> </message> <message> <location filename="ui/scanner.ui" line="365"/> <source>VA:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/scanner.ui" line="387"/> <source>Base:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/scanner.ui" line="409"/> <source>RVA:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/scanner.ui" line="441"/> <source>Raw:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/scanner.ui" line="483"/> <source>ReBase:</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/scanner.ui" line="505"/> <source>ReVA:</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="35"/> <location filename="scanner/scanner.cpp" line="45"/> <location filename="scanner/scanner.cpp" line="55"/> <location filename="scanner/scanner.cpp" line="61"/> <location filename="scanner/scanner.cpp" line="62"/> <location filename="scanner/scanner.cpp" line="69"/> <location filename="scanner/scanner.cpp" line="70"/> <location filename="scanner/scanner.cpp" line="82"/> <source>Name</source> <translation type="unfinished">名称</translation> </message> <message> <location filename="scanner/scanner.cpp" line="35"/> <location filename="scanner/scanner.cpp" line="45"/> <location filename="scanner/scanner.cpp" line="69"/> <location filename="scanner/scanner.cpp" line="82"/> <source>Value</source> <translation type="unfinished">值</translation> </message> <message> <location filename="scanner/scanner.cpp" line="51"/> <source>ExpandAll</source> <translation type="unfinished">全部展开</translation> </message> <message> <location filename="scanner/scanner.cpp" line="55"/> <source>VirtualSize</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="55"/> <location filename="scanner/scanner.cpp" line="76"/> <source>VirtualAddress</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="55"/> <source>SizeOfRawData</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="55"/> <location filename="scanner/scanner.cpp" line="830"/> <source>PointerToRawData</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="55"/> <source>PointerToRelocations</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="55"/> <source>PointerToLinenumbers</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="55"/> <source>NumberOfRelocations</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="55"/> <source>NumberOfLinenumbers</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="55"/> <location filename="scanner/scanner.cpp" line="823"/> <source>Characteristics</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="61"/> <source>OriginalFirstThunk</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="61"/> <location filename="scanner/scanner.cpp" line="824"/> <source>TimeDateStamp</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="61"/> <source>ForwarderChain</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="61"/> <source>FirstThunk</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="62"/> <source>ForwarderString</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="62"/> <source>Function</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="62"/> <location filename="scanner/scanner.cpp" line="70"/> <source>Ordinal</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="62"/> <source>AddressOfData</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="62"/> <source>Hint</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="70"/> <source>FunctionAddr</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="76"/> <source>SizeOfBlock</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="76"/> <source>ItemCount</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="77"/> <source>Item</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="77"/> <location filename="scanner/scanner.cpp" line="827"/> <source>Type</source> <translation type="unfinished">类型</translation> </message> <message> <location filename="scanner/scanner.cpp" line="77"/> <source>Address</source> <translation type="unfinished">地址</translation> </message> <message> <location filename="scanner/scanner.cpp" line="344"/> <source>file path is empty</source> <translation type="unfinished">文件路径为空</translation> </message> <message> <location filename="scanner/scanner.cpp" line="440"/> <source>File Path</source> <translation type="unfinished">文件路径</translation> </message> <message> <location filename="scanner/scanner.cpp" line="444"/> <source>File Type</source> <translation type="unfinished">文件类型</translation> </message> <message> <location filename="scanner/scanner.cpp" line="445"/> <source>File Size</source> <translation type="unfinished">文件大小</translation> </message> <message> <location filename="scanner/scanner.cpp" line="449"/> <source>Created Time</source> <translation type="unfinished">创建时间</translation> </message> <message> <location filename="scanner/scanner.cpp" line="450"/> <source>Modified Time</source> <translation type="unfinished">修改时间</translation> </message> <message> <location filename="scanner/scanner.cpp" line="451"/> <source>Accessed Time</source> <translation type="unfinished">访问时间</translation> </message> <message> <location filename="scanner/scanner.cpp" line="457"/> <source>CRC32</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="458"/> <source>MD5</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="459"/> <source>SHA1</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="473"/> <source>File Version</source> <translation type="unfinished">文件版本</translation> </message> <message> <location filename="scanner/scanner.cpp" line="474"/> <source>ProductVersion</source> <translation type="unfinished">产品版本</translation> </message> <message> <location filename="scanner/scanner.cpp" line="475"/> <source>ProductName</source> <translation type="unfinished">产品名称</translation> </message> <message> <location filename="scanner/scanner.cpp" line="476"/> <source>LegalCopyright</source> <translation type="unfinished">版权信息</translation> </message> <message> <location filename="scanner/scanner.cpp" line="477"/> <source>OriginalFileName</source> <translation type="unfinished">原始文件名</translation> </message> <message> <location filename="scanner/scanner.cpp" line="478"/> <source>InternalName</source> <translation type="unfinished">内部名称</translation> </message> <message> <location filename="scanner/scanner.cpp" line="479"/> <source>CompanyName</source> <translation type="unfinished">公司名称</translation> </message> <message> <location filename="scanner/scanner.cpp" line="480"/> <source>FileDescription</source> <translation type="unfinished">文件描述</translation> </message> <message> <location filename="scanner/scanner.cpp" line="487"/> <location filename="scanner/scanner.cpp" line="493"/> <source>ImageBase</source> <translation type="unfinished">镜像基址</translation> </message> <message> <location filename="scanner/scanner.cpp" line="488"/> <location filename="scanner/scanner.cpp" line="494"/> <source>ImageSize</source> <translation type="unfinished">镜像大小</translation> </message> <message> <location filename="scanner/scanner.cpp" line="489"/> <location filename="scanner/scanner.cpp" line="495"/> <source>OEP</source> <translation type="unfinished">程序入口</translation> </message> <message> <location filename="scanner/scanner.cpp" line="520"/> <source>Linker</source> <translation type="unfinished">编译器</translation> </message> <message> <location filename="scanner/scanner.cpp" line="521"/> <source>CompileTime</source> <translation type="unfinished">编译时间</translation> </message> <message> <location filename="scanner/scanner.cpp" line="522"/> <source>PDB File</source> <translation type="unfinished">符号文件</translation> </message> <message> <location filename="scanner/scanner.cpp" line="534"/> <source>Cert Owner</source> <translation type="unfinished">证书所有者</translation> </message> <message> <location filename="scanner/scanner.cpp" line="535"/> <source>Cert SN</source> <translation type="unfinished">证书序列号</translation> </message> <message> <location filename="scanner/scanner.cpp" line="825"/> <source>MajorVersion</source> <translation type="unfinished">主版本号</translation> </message> <message> <location filename="scanner/scanner.cpp" line="826"/> <source>MinorVersion</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="828"/> <source>SizeOfData</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="829"/> <source>AddressOfRawData</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="885"/> <source>Signature</source> <translation type="unfinished">签名</translation> </message> <message> <location filename="scanner/scanner.cpp" line="886"/> <source>Age</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="887"/> <source>GUID</source> <translation type="unfinished"></translation> </message> <message> <location filename="scanner/scanner.cpp" line="888"/> <source>ImageID</source> <translation type="unfinished">镜像ID</translation> </message> <message> <location filename="scanner/scanner.cpp" line="889"/> <source>SymbolID</source> <translation type="unfinished">符号ID</translation> </message> <message> <location filename="scanner/scanner.cpp" line="890"/> <source>PDB</source> <translation type="unfinished">符号文件</translation> </message> </context> <context> <name>Settings</name> <message> <location filename="ui/settings.ui" line="14"/> <location filename="settings/settings.cpp" line="108"/> <source>Settings</source> <translation type="unfinished">设置</translation> </message> <message> <location filename="ui/settings.ui" line="24"/> <source>General</source> <translation type="unfinished">常规</translation> </message> <message> <location filename="ui/settings.ui" line="36"/> <source>Core</source> <translation type="unfinished">基础设置</translation> </message> <message> <location filename="ui/settings.ui" line="48"/> <source>Enable Context Menu</source> <translation type="unfinished">启用右键菜单</translation> </message> <message> <location filename="ui/settings.ui" line="55"/> <source>Console</source> <translation type="unfinished">控制台</translation> </message> <message> <source>Custom Clean Setting</source> <translation type="obsolete">自定义清理设置</translation> </message> <message> <source>自定义清理</source> <translation type="obsolete">自定义清理</translation> </message> <message> <location filename="ui/settings.ui" line="83"/> <source>Clean Path</source> <translation type="unfinished">清理路径</translation> </message> <message> <location filename="ui/settings.ui" line="142"/> <source>Add Path</source> <translation type="unfinished">增加路径</translation> </message> <message> <location filename="ui/settings.ui" line="149"/> <source>Del Path</source> <translation type="unfinished">删除路径</translation> </message> <message> <location filename="ui/settings.ui" line="115"/> <source>File Suffx</source> <translation type="unfinished">文件后缀</translation> </message> <message> <location filename="ui/settings.ui" line="65"/> <source>Cleaner</source> <translation type="unfinished">清理设置</translation> </message> <message> <location filename="ui/settings.ui" line="156"/> <source>Save</source> <translation type="unfinished">保存</translation> </message> <message> <location filename="settings/settings.cpp" line="34"/> <source>Name</source> <translation type="unfinished">名称</translation> </message> <message> <location filename="settings/settings.cpp" line="34"/> <source>Value</source> <translation type="unfinished">值</translation> </message> <message> <location filename="settings/settings.cpp" line="53"/> <source>Open Folder</source> <translation type="unfinished">打开文件夹</translation> </message> <message> <location filename="settings/settings.cpp" line="72"/> <source>Save Success</source> <translation type="unfinished">保存成功</translation> </message> <message> <location filename="settings/settings.cpp" line="94"/> <source>Scan</source> <translation type="unfinished">扫描</translation> </message> <message> <location filename="settings/settings.cpp" line="101"/> <source>UnlockFile</source> <translation type="unfinished">解锁占用</translation> </message> </context> <context> <name>Utilities</name> <message> <location filename="ui/utilities.ui" line="14"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/utilities.ui" line="1614"/> <source>Cleaner</source> <translation type="unfinished">垃圾清理</translation> </message> <message> <source>FilesCount:</source> <translation type="obsolete">文件数目:</translation> </message> <message> <source>FilesSize:</source> <translation type="obsolete">文件大小:</translation> </message> <message> <location filename="ui/utilities.ui" line="1640"/> <source>[STATUS] not started...</source> <translation type="unfinished">[状态] 未开始...</translation> </message> <message> <source>Custom Clean</source> <oldsource>custom_clean</oldsource> <translation type="obsolete">自定义清理</translation> </message> <message> <location filename="ui/utilities.ui" line="1673"/> <source>CustomFolder</source> <translation type="unfinished">自定义目录</translation> </message> <message> <location filename="ui/utilities.ui" line="1683"/> <source>Builtins</source> <translation type="unfinished">内置目录</translation> </message> <message> <location filename="ui/utilities.ui" line="1693"/> <source>&amp;Scan</source> <translation type="unfinished">扫描(&amp;S)</translation> </message> <message> <location filename="ui/utilities.ui" line="1700"/> <source>&amp;Clean</source> <translation type="unfinished">清理(&amp;C)</translation> </message> <message> <location filename="ui/utilities.ui" line="33"/> <source>SystemTools</source> <translation type="unfinished">系统工具</translation> </message> <message> <location filename="ui/utilities.ui" line="51"/> <source>Common</source> <translation type="unfinished">常用</translation> </message> <message> <location filename="ui/utilities.ui" line="160"/> <source>Command</source> <translation type="unfinished">命令提示符</translation> </message> <message> <location filename="ui/utilities.ui" line="143"/> <source>PowerShell</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/utilities.ui" line="126"/> <source>LinuxShell</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/utilities.ui" line="337"/> <source>EnvVariable</source> <translation type="unfinished">环境变量</translation> </message> <message> <location filename="ui/utilities.ui" line="537"/> <source>KillExplorer </source> <translation type="unfinished">结束资源管理器</translation> </message> <message> <location filename="ui/utilities.ui" line="520"/> <location filename="ui/utilities.ui" line="554"/> <source>ResetExplorer</source> <translation type="unfinished">重启资源管理器</translation> </message> <message> <location filename="ui/utilities.ui" line="770"/> <source>Diskmgr</source> <translation type="unfinished">磁盘管理</translation> </message> <message> <location filename="ui/utilities.ui" line="827"/> <source>DateTime</source> <translation type="unfinished">时间日期</translation> </message> <message> <location filename="ui/utilities.ui" line="1707"/> <source>&amp;Setting</source> <oldsource>Setting</oldsource> <translation type="unfinished">设置(&amp;T)</translation> </message> <message> <location filename="ui/utilities.ui" line="679"/> <source>DeskIcon</source> <translation type="unfinished">桌面图标</translation> </message> <message> <location filename="ui/utilities.ui" line="662"/> <source>OS Version</source> <translation type="unfinished">系统版本</translation> </message> <message> <location filename="ui/utilities.ui" line="753"/> <source>Devices</source> <translation type="unfinished">设备管理</translation> </message> <message> <location filename="ui/utilities.ui" line="736"/> <source>Tasks</source> <translation type="unfinished">计划任务</translation> </message> <message> <location filename="ui/utilities.ui" line="1137"/> <source>ResourceMon</source> <translation type="unfinished">资源监视</translation> </message> <message> <location filename="ui/utilities.ui" line="1154"/> <source>PerfConfig</source> <translation type="unfinished">性能设置</translation> </message> <message> <location filename="ui/utilities.ui" line="1228"/> <source>Powers</source> <translation type="unfinished">电源设置</translation> </message> <message> <location filename="ui/utilities.ui" line="955"/> <source>UserGroups</source> <translation type="unfinished">用户管理</translation> </message> <message> <location filename="ui/utilities.ui" line="1080"/> <source>Secur Policy</source> <translation type="unfinished">安全策略</translation> </message> <message> <location filename="ui/utilities.ui" line="1370"/> <source>Proxy</source> <translation type="unfinished">代理设置</translation> </message> <message> <location filename="ui/utilities.ui" line="1552"/> <source>NetConnections</source> <translation type="unfinished">网络连接</translation> </message> <message> <location filename="ui/utilities.ui" line="240"/> <source>Regedit</source> <translation type="unfinished">注册表</translation> </message> <message> <location filename="ui/utilities.ui" line="257"/> <source>Services</source> <translation type="unfinished">服务管理</translation> </message> <message> <location filename="ui/utilities.ui" line="354"/> <source>Programs</source> <translation type="unfinished">程序管理</translation> </message> <message> <location filename="ui/utilities.ui" line="223"/> <source>Taskmgr</source> <translation type="unfinished">任务管理器</translation> </message> <message> <location filename="ui/utilities.ui" line="320"/> <source>ComputerName</source> <translation type="unfinished">计算机名</translation> </message> <message> <location filename="ui/utilities.ui" line="417"/> <source>Calculator</source> <translation type="unfinished">计算器</translation> </message> <message> <location filename="ui/utilities.ui" line="451"/> <source>FastReboot</source> <oldsource>FastPoweroff </oldsource> <translation type="unfinished">快速重启</translation> </message> <message> <location filename="ui/utilities.ui" line="434"/> <source>FastPoweroff</source> <oldsource>FastReboot </oldsource> <translation type="unfinished">快速关机</translation> </message> <message> <location filename="ui/utilities.ui" line="585"/> <source>Configuration</source> <translation type="unfinished">配置</translation> </message> <message> <source>Disk Managment</source> <translation type="obsolete">磁盘管理</translation> </message> <message> <source>Date and Time</source> <translation type="obsolete">日期时间</translation> </message> <message> <source>Desktop Icons</source> <translation type="obsolete">桌面图标</translation> </message> <message> <source>Windows Version</source> <translation type="obsolete">系统版本</translation> </message> <message> <location filename="ui/utilities.ui" line="645"/> <source>SystemInfo</source> <translation type="unfinished">系统信息</translation> </message> <message> <location filename="ui/utilities.ui" line="844"/> <location filename="ui/utilities.ui" line="864"/> <source>Wallpaper</source> <translation type="unfinished">墙纸</translation> </message> <message> <source>Device Manager</source> <translation type="obsolete">设备管理</translation> </message> <message> <source>Task Scheduler</source> <translation type="obsolete">计划任务</translation> </message> <message> <location filename="ui/utilities.ui" line="895"/> <source>Performance &amp;&amp; Security</source> <translation type="unfinished">性能和安全</translation> </message> <message> <location filename="ui/utilities.ui" line="1171"/> <source>Performance</source> <translation type="unfinished">性能监视</translation> </message> <message> <source>Resource Monitor</source> <translation type="obsolete">资源监视</translation> </message> <message> <location filename="ui/utilities.ui" line="972"/> <source>UAC Settings</source> <translation type="unfinished">UAC设置</translation> </message> <message> <source>Perf Settings</source> <translation type="obsolete">性能设置</translation> </message> <message> <source>Power Settings</source> <translation type="obsolete">电源设置</translation> </message> <message> <location filename="ui/utilities.ui" line="1063"/> <source>Group Policy</source> <translation type="unfinished">组策略</translation> </message> <message> <source>Users &amp;&amp; Groups</source> <translation type="obsolete">用户和组</translation> </message> <message> <location filename="ui/utilities.ui" line="989"/> <source>Credential</source> <translation type="unfinished">凭据管理</translation> </message> <message> <location filename="ui/utilities.ui" line="1245"/> <location filename="ui/utilities.ui" line="1262"/> <source>Certificate</source> <translation type="unfinished">证书管理</translation> </message> <message> <source>Security Policy</source> <translation type="obsolete">安全策略</translation> </message> <message> <location filename="ui/utilities.ui" line="1046"/> <source>Event Viewer</source> <translation type="unfinished">事件查看</translation> </message> <message> <location filename="ui/utilities.ui" line="1293"/> <source>Network</source> <translation type="unfinished">网络</translation> </message> <message> <location filename="ui/utilities.ui" line="1353"/> <source>Firewall</source> <translation type="unfinished">防火墙</translation> </message> <message> <source>Proxy Settings</source> <translation type="obsolete">代理设置</translation> </message> <message> <source>Network Connections</source> <translation type="obsolete">网络连接</translation> </message> <message> <location filename="ui/utilities.ui" line="1387"/> <source>Hosts</source> <translation type="unfinished">Hosts文件</translation> </message> <message> <location filename="ui/utilities.ui" line="1461"/> <source>IP v4</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/utilities.ui" line="1478"/> <source>IP v6</source> <translation type="unfinished"></translation> </message> <message> <location filename="ui/utilities.ui" line="1444"/> <source>Route</source> <translation type="unfinished">路由表</translation> </message> <message> <location filename="ui/utilities.ui" line="1535"/> <location filename="ui/utilities.ui" line="1569"/> <source>Shared Folders</source> <translation type="unfinished">共享文件夹</translation> </message> <message> <location filename="utilities/utilities.cpp" line="279"/> <source>Directory</source> <translation type="unfinished">文件夹</translation> </message> <message> <location filename="utilities/utilities.cpp" line="279"/> <source>FileCount</source> <translation type="unfinished">文件数</translation> </message> <message> <location filename="utilities/utilities.cpp" line="279"/> <source>SumSize</source> <translation type="unfinished">总大小</translation> </message> <message> <location filename="utilities/utilities.cpp" line="279"/> <source>Detail</source> <translation type="unfinished">详细</translation> </message> <message> <location filename="utilities/utilities.cpp" line="305"/> <source>[STATUS] Scanning...</source> <translation type="unfinished">[状态] 扫描中...</translation> </message> <message> <location filename="utilities/utilities.cpp" line="313"/> <source>[STATUS] Scan completed...</source> <translation type="unfinished">[状态] 扫描完成...</translation> </message> <message> <location filename="utilities/utilities.cpp" line="327"/> <source>[STATUS] Cleaning...</source> <translation type="unfinished">[状态] 清理中...</translation> </message> <message> <location filename="utilities/utilities.cpp" line="336"/> <source>[STATUS] Clean completed...</source> <translation type="unfinished">[状态] 清理完成...</translation> </message> <message> <location filename="utilities/utilities.cpp" line="378"/> <location filename="utilities/utilities.cpp" line="384"/> <source>Warning</source> <translation type="unfinished">警告</translation> </message> <message> <location filename="utilities/utilities.cpp" line="378"/> <source>Are you sure to reboot?</source> <translation type="unfinished">确定要重启电脑吗?</translation> </message> <message> <location filename="utilities/utilities.cpp" line="384"/> <source>Are you sure to poweroff?</source> <translation type="unfinished">确定要关机吗?</translation> </message> </context> </TS>
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/process-mgr/process-mgr.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "process-mgr.h" #include "../common/common.h" #include "../cmds/constants/constants.h" #include "../openark/openark.h" #include "process-properties.h" #include "process-selection.h" #include <arkdrv-api/arkdrv-api.h> // ProcessView's header index struct { int s = 0; int name = s++; int pid = s++; int ppid = s++; int path = s++; int desc = s++; int corp = s++; int ctime = s++; } PS; // ModuleView's header index struct { int s = 0; int name = s++; int base = s++; int size = s++; int path = s++; int desc = s++; int ver = s++; int corp = s++; int sign = s++; } MOD; // HandleView's header index struct { int s = 0; int type = s++; int name = s++; int value = s++; int access = s++; int obj = s++; } HD; // MemoryView's header index struct { int s = 0; int addr = s++; int size = s++; int property = s++; int state = s++; int type = s++; int base = s++; int mod = s++; } MEM; #define BOTTOM_HIDE -1 #define BOTTOM_MOD 0 #define BOTTOM_HD 1 #define BOTTOM_MEM 2 bool ProcSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); auto column = left.column(); if ((column == PS.pid || column == PS.ppid)) return s1.toUInt() < s2.toUInt(); return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } bool ModSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); auto column = left.column(); bool ok; if (bottom_idx_ == BOTTOM_MOD) { if ((column == MOD.base || column == MOD.size)) return s1.toString().toULongLong(&ok, 16) < s2.toString().toULongLong(&ok, 16); } else if (bottom_idx_ == BOTTOM_HD) { if ((column == HD.value || column == HD.access || column == HD.obj)) return s1.toString().toULongLong(&ok, 16) < s2.toString().toULongLong(&ok, 16); } else if (bottom_idx_ == BOTTOM_MEM) { if ((column == MEM.addr || column == MEM.size || column == MEM.base)) return s1.toString().toULongLong(&ok, 16) < s2.toString().toULongLong(&ok, 16); } return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } ProcessMgr::ProcessMgr(QWidget* parent) : parent_((OpenArk*)parent), cntproc_label_(nullptr), proxy_proc_(nullptr), proc_header_idx_(0), bottom_header_idx_(0), bottom_idx_(BOTTOM_HIDE), mod_menu_(nullptr), hd_menu_(nullptr), mem_menu_(nullptr) { unnamed_checked_ = false; uncommed_checked_ = false; nonexec_checked_ = false; imaged_checked_ = false; ui.setupUi(this); connect(OpenArkLanguage::Instance(), &OpenArkLanguage::languageChaned, this, [this]() {ui.retranslateUi(this); }); ui.splitter->setStretchFactor(0, 2); ui.splitter->setStretchFactor(1, 1); InitProcessView(); InitBottomCommon(); InitModuleView(); InitHandleView(); InitMemoryView(); connect(parent_, SIGNAL(signalShowPtool(int)), this, SLOT(onShowBottom(int))); connect(this, SIGNAL(signalOpen(QString)), parent_, SLOT(onOpen(QString))); connect(&timer_, SIGNAL(timeout()), this, SLOT(onTimer())); timer_.setInterval(1000); timer_.start(); } ProcessMgr::~ProcessMgr() { timer_.stop(); } bool ProcessMgr::eventFilter(QObject *obj, QEvent *e) { bool filtered = false; if (obj == ui.processView->viewport()) { if (e->type() == QEvent::ContextMenu) { QContextMenuEvent* ctxevt = dynamic_cast<QContextMenuEvent*>(e); if (ctxevt != nullptr) { proc_menu_->move(ctxevt->globalPos()); proc_menu_->show(); } } else if (e->type() == QEvent::MouseMove) { QMouseEvent *mouse = static_cast<QMouseEvent *>(e); QPoint pt = mouse->pos(); if (pt.rx() <= ui.processView->columnWidth(0)) { DISABLE_RECOVER(); QModelIndex idx = ui.processView->indexAt(pt); const QModelIndex &curidx = idx.sibling(idx.row(), 1); if (!curidx.isValid()) return true; auto pid = curidx.data(Qt::DisplayRole).toInt(); if (pid == 0 || pid == 4) return true; auto info = CacheGetProcessBaseInfo(pid); info.CommandLine = UNONE::StrInsertW(info.CommandLine, 120, L"\n "); info.ImagePathName = UNONE::StrInsertW(info.ImagePathName, 120, L"\n "); QString tips = QString("Command Line:\n %1\nPath:\n %2").arg(WStrToQ(info.CommandLine)).arg(WStrToQ(info.ImagePathName)); QToolTip::showText(mouse->globalPos(), tips); return true; } } } else if (obj == ui.moduleView->viewport()) { if (e->type() == QEvent::ContextMenu) { QContextMenuEvent* ctxevt = dynamic_cast<QContextMenuEvent*>(e); if (ctxevt != nullptr) { QMenu *menu = nullptr; switch (bottom_idx_) { case BOTTOM_MOD: menu = mod_menu_; break; case BOTTOM_HD: menu = hd_menu_; break; case BOTTOM_MEM: menu = mem_menu_; break; } if (menu) { menu->move(ctxevt->globalPos()); menu->show(); } } } } else if (obj == ui.processView) { if (e->type() == QEvent::KeyPress) { filtered = true; QKeyEvent *keyevt = dynamic_cast<QKeyEvent*>(e); if (keyevt->matches(QKeySequence::Refresh)) { onRefresh(); } else if (keyevt->matches(QKeySequence::Delete)) { onKillProcess(); } else if (keyevt->key() == Qt::Key_Delete && keyevt->modifiers() == Qt::ShiftModifier) { onKillProcessTree(); } else if (keyevt->key() == Qt::Key_L && keyevt->modifiers() == Qt::ControlModifier) { onExploreFile(); } else if (keyevt->key() == Qt::Key_J && keyevt->modifiers() == Qt::ControlModifier) { onInjectDll(); } else if (keyevt->key() == Qt::Key_G && keyevt->modifiers() == Qt::ControlModifier) { onSelectPid(); } else if (keyevt->key() == Qt::Key_P && keyevt->modifiers() == Qt::ControlModifier) { onShowProperties(); } else { filtered = false; } } } if (filtered) { dynamic_cast<QKeyEvent*>(e)->ignore(); return true; } return QWidget::eventFilter(obj, e); } void ProcessMgr::onOpenFile(const QString& file) { } void ProcessMgr::onRefresh() { auto sender = QObject::sender(); if (IsContainAction(proc_menu_, sender)) { onShowProcess(); return; } if (IsContainAction(mod_menu_, sender)) { onShowModule(); return; } if (sender == nullptr) { onShowProcess(); return; } } void ProcessMgr::onReset() { //proxy_model_->setSortRole(Qt::InitialSortOrderRole); //proxy_model_->invalidate(); ui.processView->header()->setSortIndicator(-1, Qt::AscendingOrder); ui.moduleView->header()->setSortIndicator(-1, Qt::AscendingOrder); onRefresh(); } void ProcessMgr::onTimer() { //ShowProcessList(); PERFORMANCE_INFORMATION perf = { 0 }; GetPerformanceInfo(&perf, sizeof(perf)); if (cntproc_label_ == nullptr) { cpu_percent_label_ = new QLabel(); parent_->StatusBarAdd(cpu_percent_label_); mm_percent_label_ = new QLabel(); parent_->StatusBarAdd(mm_percent_label_); cntproc_label_ = new QLabel(); parent_->StatusBarAdd(cntproc_label_); cntthread_label_ = new QLabel(); parent_->StatusBarAdd(cntthread_label_); cnthandle_label_ = new QLabel(); parent_->StatusBarAdd(cnthandle_label_); } cpu_percent_label_->setText(tr("CPU:") + WStrToQ(UNONE::StrFormatW(L"%0.2f%%", GetSystemUsageOfCPU()))); mm_percent_label_->setText(tr("Memory:") + WStrToQ(UNONE::StrFormatW(L"%0.2f%%", GetSystemUsageOfMemory()))); cntproc_label_->setText(tr("Processes:") + QString("%1").arg(perf.ProcessCount)); cntthread_label_->setText(tr("Threads:") + QString("%1").arg(perf.ThreadCount)); cnthandle_label_->setText(tr("Handles:") + QString("%1").arg(perf.HandleCount)); } void ProcessMgr::onCopyActionTriggerd(QAction* action) { auto idx = action->data().toInt(); QString data = ProcCurViewItemData(idx); if (idx == 0) data.replace(" *32", ""); ClipboardCopyData(data.toStdString()); } void ProcessMgr::onKillProcess() { PsKillProcess(ProcCurPid()); onRefresh(); } void ProcessMgr::onKillProcessTree() { QString tips; auto pid = ProcCurPid(); auto pids = UNONE::PsGetDescendantPids(pid); pids.push_back(pid); tips.append(tr("Do you kill all processes?\n-------------------\n")); for (auto d : pids) { std::wstring wstr = UNONE::StrFormatW(L"[%d] %s", d, UNONE::PsGetProcessNameW(d).c_str()); tips.append(WStrToQ(wstr)); tips.append("\n"); } auto msbox = QMessageBox::warning(this, tr("Warning"), tips, QMessageBox::Yes | QMessageBox::No); if (msbox == QMessageBox::Yes) { for (auto d : pids) { PsKillProcess(d); }; onRefresh(); } } void ProcessMgr::onRestartProcess() { UNONE::PsRestartProcess(ProcCurPid()); onRefresh(); } void ProcessMgr::onSuspendProcess() { } void ProcessMgr::onInjectDll() { QString file = QFileDialog::getOpenFileName(this, tr("Select Dll"), "", tr("Dll Files (*.dll);;All Files (*.*)")); if (file.isEmpty()) return; std::wstring dll = file.toStdWString(); std::string buf; UNONE::FsReadFileDataW(dll, buf); if (buf.empty() || !UNONE::PeValid((CHAR*)buf.c_str())) { MsgBoxError(tr("Dll file invalid.")); return; } auto pid = ProcCurPid(); bool is_dll64 = UNONE::PeX64((CHAR*)buf.c_str()); bool is_exe64 = UNONE::PsIsX64(pid); if ((!is_dll64 && is_exe64)) { MsgBoxError(tr("Can't inject 32-bit dll to 64-bit process.")); return; } if ((is_dll64 && !is_exe64)) { MsgBoxWarn(tr("Inject 64-bit dll to 32-bit process, maybe fail.")); } auto thd = UNONE::PsInjectByRemoteThreadW(pid, dll); if (thd) { MsgBoxInfo(tr("Inject ok.")); } else { MsgBoxError(tr("Inject failed.")); } CloseHandle(thd); } void ProcessMgr::onSelectPid() { auto dlg = new ProcessSelection(this); dlg->setObjectName("ProcessSelection"); dlg->raise(); dlg->show(); } void ProcessMgr::onExploreFile() { auto sender = QObject::sender(); if (IsContainAction(proc_menu_, sender)) { ExploreFile(ProcCurViewItemData(PS.path)); return; } if (IsContainAction(mod_menu_, sender)) { ExploreFile(BottomCurViewItemData(MOD.path)); return; } if (sender == nullptr) { ExploreFile(ProcCurViewItemData(PS.path)); return; } } void ProcessMgr::onEnumThread() { ShowProperties(ProcCurPid(), 1); } void ProcessMgr::onEnumWindow() { ShowProperties(ProcCurPid(), 2); } void ProcessMgr::onCreateMiniDump() { DWORD pid = ProcCurPid(); QString name = WStrToQ(UNONE::PsGetProcessNameW(pid)).replace(".exe", ".dmp", Qt::CaseInsensitive); QString dmp = QFileDialog::getSaveFileName(this, tr("Save dump file"), name, tr("DumpFile(*.dmp)")); if (dmp.isEmpty()) return; CreateDump(pid, dmp.toStdWString(), true); } void ProcessMgr::onCreateFullDump() { DWORD pid = ProcCurPid(); QString name = WStrToQ(UNONE::PsGetProcessNameW(pid)).replace(".exe", ".dmp", Qt::CaseInsensitive); QString dmp = QFileDialog::getSaveFileName(this, tr("Save dump file"), name, tr("DumpFile(*.dmp)")); if (dmp.isEmpty()) return; CreateDump(pid, dmp.toStdWString(), false); } void ProcessMgr::onSendtoScanner() { QString path; auto action = qobject_cast<QAction*>(QObject::sender()); if (IsContainAction(proc_menu_, action)) { path = ProcCurViewItemData(PS.path); } else if (IsContainAction(mod_menu_, action)) { path = BottomCurViewItemData(MOD.path); } parent_->SetActiveTab(TAB_SCANNER); emit signalOpen(path); } void ProcessMgr::onVerifySignature() { QString path; path = BottomCurViewItemData(MOD.path); auto row = ui.moduleView->currentIndex().row(); QString owner; bool ret = GetCertOwner(path, owner); if (!ret) { auto err = GetLastError(); owner = WStrToQ(UNONE::StrFormatW(L"[-] %X %s", err, UNONE::OsDosErrorMsgW(err).c_str())); SetLineBgColor(bottom_model_, row, Qt::red); } SetCurItemViewData(ui.moduleView, MOD.sign, owner); } void ProcessMgr::onVerifyAllSignature() { for (int i = 0; i < bottom_model_->rowCount(); i++) { auto row = i; QString path = bottom_model_->item(row, MOD.path)->data(Qt::DisplayRole).toString(); QString owner; bool ret = GetCertOwner(path, owner); if (!ret) { auto err = GetLastError(); owner = WStrToQ(UNONE::StrFormatW(L"[-] %X %s", err, UNONE::OsDosErrorMsgW(err).c_str())); SetLineBgColor(bottom_model_, row, Qt::red); } bottom_model_->item(row, MOD.sign)->setData(owner, Qt::DisplayRole); } ui.moduleView->header()->setSortIndicator(MOD.sign, Qt::AscendingOrder); } void ProcessMgr::onShowProperties() { ShowProperties(ProcCurPid(), 0); } void ProcessMgr::onCloseHandle() { auto src_hd = (HANDLE)(UNONE::StrToHex64A(BottomCurViewItemData(HD.value).toStdString())); DWORD pid = ProcCurPid(); HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); if (!phd) { ERR(L"OpenProcess pid:%d err:%d", pid, GetLastError()); return; } HANDLE dup = NULL; if (!DuplicateHandle(phd, (HANDLE)src_hd, GetCurrentProcess(), &dup, 0, FALSE, DUPLICATE_CLOSE_SOURCE)) { ERR(L"DuplicateHandle pid:%d hd:%x err:%d", pid, src_hd, GetLastError()); CloseHandle(phd); return; } INFO(L"DuplicateHandle pid:%d hd:%x ok", pid, src_hd); CloseHandle(dup); CloseHandle(phd); onShowHandle(); } void ProcessMgr::onHideUnnamedHandles(bool checked) { unnamed_checked_ = checked; for (int i = 0; i < bottom_model_->rowCount(); i++) { if (!checked) { SetLineHidden(ui.moduleView, i, false); continue; } if (bottom_model_->item(i, HD.name)->data(Qt::DisplayRole).toString().isEmpty()) { QModelIndex idx = bottom_model_->index(i, HD.name); SetLineHidden(ui.moduleView, proxy_bottom_->mapFromSource(idx).row(), true); } } } void ProcessMgr::onHideMemoryItem(bool checked) { auto sender = QObject::sender(); if (sender == ui.actionHideUncommited) uncommed_checked_ = checked; else if (sender == ui.actionHideNonExecute) nonexec_checked_ = checked; else if (sender == ui.actionHideImage) imaged_checked_ = checked; for (int i = 0; i < bottom_model_->rowCount(); i++) { bool hidden = false; if (uncommed_checked_) { if (bottom_model_->item(i, MEM.state)->data(Qt::DisplayRole).toString() != "MEM_COMMIT") hidden = true; } if (nonexec_checked_) { if (!bottom_model_->item(i, MEM.property)->data(Qt::DisplayRole).toString().contains("EXECUTE")) hidden = true; } if (imaged_checked_) { if (bottom_model_->item(i, MEM.type)->data(Qt::DisplayRole).toString() == "MEM_IMAGE") hidden = true; } QModelIndex idx = bottom_model_->index(i, HD.name); if (hidden) { SetLineHidden(ui.moduleView, proxy_bottom_->mapFromSource(idx).row(), true); } else { SetLineHidden(ui.moduleView, proxy_bottom_->mapFromSource(idx).row(), false); } } } void ProcessMgr::onDumpMemory() { DWORD pid = ProcCurPid(); HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); if (!phd) { ERR(L"OpenProcess pid:%d err:%d", pid, GetLastError()); return; } DWORD size = UNONE::StrToHexA(BottomCurViewItemData(MEM.size).toStdString()); DWORD64 addr = UNONE::StrToHex64A(BottomCurViewItemData(MEM.base).toStdString()); std::string data; data.resize(size); SIZE_T readlen; bool ret = ReadProcessMemory(phd, (LPCVOID)addr, (LPVOID)data.data(), size, &readlen); if (!ret && size != readlen) { ERR(L"ReadProcessMemory pid:%d err:%d, expect:%d readlen:%d", pid, GetLastError(), size, readlen); CloseHandle(phd); return; } QString filename = StrToQ(UNONE::StrFormatA("%X_%X", addr, size)); QString dumpmem = QFileDialog::getSaveFileName(this, tr("Save to"), filename, tr("DumpMemory(*)")); if (!dumpmem.isEmpty()) { ret = UNONE::FsWriteFileDataW(dumpmem.toStdWString(), data); if (ret) { MsgBoxInfo(tr("Dump memory ok")); } } CloseHandle(phd); } void ProcessMgr::onShowBottom(int idx) { ui.moduleView->show(); switch (idx) { case BOTTOM_MOD: onShowModule(); break; case BOTTOM_HD: onShowHandle(); break; case BOTTOM_MEM: onShowMemory(); break; default: ui.moduleView->hide(); break; } bottom_idx_ = idx; proxy_bottom_->bottom_idx_ = idx; } void ProcessMgr::onShowProcess() { DISABLE_RECOVER(); auto view = ui.processView; auto selected = view->selectionModel()->selectedIndexes(); if (!selected.empty()) { QRect rect = view->visualRect(selected[0]); proc_sel_ = rect.center(); } ClearItemModelData(proc_model_); CacheRefreshProcInfo(); if (proc_header_idx_ == 0) ShowProcessTree(); else ShowProcessList(); AjustProcessStyle(); } void ProcessMgr::onShowModule() { DISABLE_RECOVER(); ClearItemModelData(bottom_model_, 0); InitModuleView(); DWORD pid = ProcCurPid(); bool activate = false; auto &&path = UNONE::PsGetProcessPathW(pid); if (path.empty()) { UNONE::InterCreateTlsValue(ArkDrvApi::Process::OpenProcessR0, UNONE::PROCESS_VID); path = UNONE::PsGetProcessPathW(pid); activate = true; } UNONE::PsEnumModule(pid, [&](MODULEENTRY32W& entry)->bool{ QString modname = WCharsToQ(entry.szModule); QString modpath = WCharsToQ(entry.szExePath); ULONG64 modbase = (ULONG64)entry.modBaseAddr; ULONG64 modsize = entry.modBaseSize; auto count = bottom_model_->rowCount(); for (int i = 0; i < count; i++) { auto base = bottom_model_->data(bottom_model_->index(i, MOD.base)).toString().toStdWString(); if (UNONE::StrToHex64W(base) == modbase) { return true; } } auto info = CacheGetFileBaseInfo(modpath); QStandardItem *name_item = new QStandardItem(LoadIcon(modpath), modname); QStandardItem *base_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%llX", modbase))); QStandardItem *size_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%llX", modsize))); QStandardItem *path_item = new QStandardItem(modpath); QStandardItem *desc_item = new QStandardItem(info.desc); QStandardItem *ver_item = new QStandardItem(info.ver); QStandardItem *corp_item = new QStandardItem(info.corp); QStandardItem *sign_item = new QStandardItem(""); bottom_model_->setItem(count, MOD.name, name_item); bottom_model_->setItem(count, MOD.base, base_item); bottom_model_->setItem(count, MOD.size, size_item); bottom_model_->setItem(count, MOD.path, path_item); bottom_model_->setItem(count, MOD.desc, desc_item); bottom_model_->setItem(count, MOD.ver, ver_item); bottom_model_->setItem(count, MOD.corp, corp_item); bottom_model_->setItem(count, MOD.sign, sign_item); return true; }); auto view = ui.moduleView; view->setColumnWidth(MOD.name, 150); view->resizeColumnToContents(MOD.base); view->resizeColumnToContents(MOD.size); view->setColumnWidth(MOD.path, 290); view->setColumnWidth(MOD.desc, 200); view->setColumnWidth(MOD.corp, 150); } void ProcessMgr::onShowHandle() { DISABLE_RECOVER(); ClearItemModelData(bottom_model_, 0); InitHandleView(); InitObjectTypeTable(); DWORD pid = ProcCurPid(); HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); UNONE::PsEnumHandle(pid, [&](SYSTEM_HANDLE_TABLE_ENTRY_INFO &info)->bool { auto count = bottom_model_->rowCount(); auto idx = info.ObjectTypeIndex; QStandardItem *type_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%s",ObjectTypeTable[idx].c_str()))); std::string name; if (phd != NULL) { HANDLE dup = NULL; if (DuplicateHandle(phd, (HANDLE)info.HandleValue, GetCurrentProcess(), &dup, 0, FALSE, DUPLICATE_SAME_ACCESS)) { switch (idx) { case 7: { DWORD pid = GetProcessId(dup); name = UNONE::StrFormatA("%s(%d)", UNONE::PsGetProcessNameA(pid).c_str(), pid); break; } case 8: { typedef DWORD (WINAPI *__GetThreadId)(HANDLE Thread); auto pGetThreadId = (__GetThreadId)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetThreadId"); DWORD tid = 0; if (pGetThreadId) tid = pGetThreadId(dup); DWORD pid = UNONE::PsGetPidByThread(tid); name = UNONE::StrFormatA("%s(%d) %d", UNONE::PsGetProcessNameA(pid).c_str(), pid, tid); } default: ObGetObjectName((HANDLE)dup, name); static int file_idx = GetObjectTypeIndex(L"File"); if (idx == file_idx) UNONE::ObParseToDosPathA(name, name); break; } CloseHandle(dup); } } QStandardItem *name_item = new QStandardItem(StrToQ(name)); QStandardItem *value_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%llX", info.HandleValue))); QStandardItem *access_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%llX", info.GrantedAccess))); QStandardItem *obj_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%llX", info.Object))); bottom_model_->setItem(count, HD.type, type_item); bottom_model_->setItem(count, HD.name, name_item); bottom_model_->setItem(count, HD.value, value_item); bottom_model_->setItem(count, HD.access, access_item); bottom_model_->setItem(count, HD.obj, obj_item); return true; }); CloseHandle(phd); } void ProcessMgr::onShowMemory() { DISABLE_RECOVER(); ClearItemModelData(bottom_model_, 0); InitMemoryView(); DWORD pid = ProcCurPid(); HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); UNONE::PsEnumMemory(pid, [&](MEMORY_BASIC_INFORMATION &mbi)->bool { std::wstring mod_name; WCHAR name[MAX_PATH + 1] = { 0 }; if (mbi.Type & MEM_IMAGE) { GetMappedFileNameW(phd, mbi.BaseAddress, name, MAX_PATH); UNONE::ObParseToDosPathW(name, mod_name); } auto count = bottom_model_->rowCount(); QStandardItem *addr_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%llX", mbi.BaseAddress))); QStandardItem *size_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%X", mbi.RegionSize))); QStandardItem *property_item = new QStandardItem(StrToQ(MbiPageProtectToString(mbi.Protect))); QStandardItem *state_item = new QStandardItem(StrToQ(MbiStateToString(mbi.State))); QStandardItem *type_item = new QStandardItem(StrToQ(MbiTypeToString(mbi.Type))); QStandardItem *base_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"0x%llX", mbi.AllocationBase))); QStandardItem *mod_item = new QStandardItem(WStrToQ(mod_name)); bottom_model_->setItem(count, MEM.addr, addr_item); bottom_model_->setItem(count, MEM.size, size_item); bottom_model_->setItem(count, MEM.property, property_item); bottom_model_->setItem(count, MEM.state, state_item); bottom_model_->setItem(count, MEM.type, type_item); bottom_model_->setItem(count, MEM.base, base_item); bottom_model_->setItem(count, MEM.mod, mod_item); if ((mbi.Protect & PAGE_NOACCESS) || (mbi.State & MEM_RESERVE)) { SetLineBgColor(bottom_model_, count, Qt::gray); } return true; }); } void ProcessMgr::onSectionClicked(int idx) { auto sender = QObject::sender(); if (sender == ui.processView->header()) { if (idx == PS.name) { proc_header_idx_++; switch (proc_header_idx_) { case 3: ui.processView->header()->setSortIndicator(-1, Qt::AscendingOrder); proc_header_idx_ = 0; onShowProcess(); break; case 1: onShowProcess(); } } else { if (proc_header_idx_ == 0) { proc_header_idx_ = 1; onShowProcess(); } } } else if (sender == ui.moduleView->header()) { if (idx == bottom_header_last_) { bottom_header_idx_ = 1; } else { bottom_header_idx_++; } if (bottom_header_idx_ == 3) { bottom_header_idx_ = 0; ui.moduleView->header()->setSortIndicator(-1, Qt::AscendingOrder); } } onProcSelection(DWordToDecQ(cur_pid_)); } void ProcessMgr::onProcDoubleClicked( const QModelIndex &idx ) { onShowProperties(); } void ProcessMgr::onProcChanged(const QModelIndex &current, const QModelIndex &previous) { if (current.isValid()) { //auto row = current.row(); cur_pid_ = current.sibling(current.row(), PS.pid).data().toUInt(); } onShowBottom(bottom_idx_); } void ProcessMgr::onProcSelection(QString pid) { auto view = ui.processView; std::function<bool(QModelIndex idx)> LocateProcess = [&](QModelIndex idx)->bool { int rows = proc_model_->rowCount(idx); for (int i = 0; i < rows; i++) { QString qstr; QModelIndex child_name; QStandardItem *item; if (idx == view->rootIndex()) { child_name = proc_model_->index(i, PS.name); item = proc_model_->itemFromIndex(child_name); qstr = proc_model_->index(i, PS.pid).data(Qt::DisplayRole).toString(); } else { item = proc_model_->itemFromIndex(idx); child_name = item->child(i, PS.name)->index(); qstr = item->child(i, PS.pid)->data(Qt::DisplayRole).toString(); } if (qstr == pid) { auto idx = proxy_proc_->mapFromSource(child_name); view->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); view->scrollTo(idx); return true; } if (proc_model_->itemFromIndex(child_name)->hasChildren()) { if (LocateProcess(child_name)) { return true; } } } return false; }; LocateProcess(view->rootIndex()); } DWORD ProcessMgr::ProcCurPid() { //auto idx = ui.processView->currentIndex(); //DWORD pid = idx.sibling(idx.row(), PS.pid).data().toUInt(); return cur_pid_; } int ProcessMgr::ProcCurRow() { auto idx = ui.processView->currentIndex(); return idx.row(); } int ProcessMgr::ProcCurCol() { auto idx = ui.processView->currentIndex(); return idx.column(); } QString ProcessMgr::ProcCurViewItemData(int column) { return GetCurItemViewData(ui.processView, column); } QString ProcessMgr::ProcViewItemData(int row, int column) { return GetItemViewData(ui.processView, row, column); } QString ProcessMgr::BottomCurViewItemData(int column) { return GetCurItemViewData(ui.moduleView, column); } QString ProcessMgr::ModViewItemData(int row, int column) { return GetItemViewData(ui.moduleView, row, column); } void ProcessMgr::InitProcessView() { //process list auto copy_menu_ = new QMenu(); copy_menu_->addAction(tr("Process Name"))->setData(PS.name); copy_menu_->addAction(tr("Process ID"))->setData(PS.pid); copy_menu_->addAction(tr("Parent ID"))->setData(PS.ppid); copy_menu_->addAction(tr("Process Path"))->setData(PS.path); copy_menu_->addAction(tr("Created Time"))->setData(PS.ctime); copy_menu_->setTitle(tr("Copy")); connect(copy_menu_, SIGNAL(triggered(QAction*)), SLOT(onCopyActionTriggerd(QAction*))); auto dump_menu_ = new QMenu(); dump_menu_->addAction(tr("Create Minidump..."), this, SLOT(onCreateMiniDump())); dump_menu_->addAction(tr("Create Fulldump..."), this, SLOT(onCreateFullDump())); dump_menu_->setTitle(tr("Create Dump")); proc_menu_ = new QMenu(); proc_menu_->addAction(tr("Refresh"), this, SLOT(onRefresh()), QKeySequence::Refresh); proc_menu_->addAction(copy_menu_->menuAction()); proc_menu_->addAction(tr("Kill Process"), this, SLOT(onKillProcess()), QKeySequence::Delete); proc_menu_->addAction(tr("Kill Process Tree"), this, SLOT(onKillProcessTree()), QKeySequence("SHIFT+Delete")); proc_menu_->addAction(tr("Restart Process"), this, SLOT(onRestartProcess())); //proc_menu_->addAction(tr("Suspend"), this, SLOT(onSuspendProcess())); proc_menu_->addAction(tr("Select PID"), this, SLOT(onSelectPid()), QKeySequence("CTRL+G")); proc_menu_->addAction(tr("Explore File"), this, SLOT(onExploreFile()), QKeySequence("CTRL+L")); proc_menu_->addAction(tr("Enum Thread"), this, SLOT(onEnumThread())); proc_menu_->addAction(tr("Enum Window"), this, SLOT(onEnumWindow())); proc_menu_->addAction(tr("Inject Dll"), this, SLOT(onInjectDll()), QKeySequence("CTRL+J")); proc_menu_->addAction(tr("Sendto Scanner"), this, SLOT(onSendtoScanner())); proc_menu_->addAction(dump_menu_->menuAction()); proc_menu_->addAction(tr("Properties..."), this, SLOT(onShowProperties()), QKeySequence("CTRL+P")); proc_model_ = new QStandardItemModel; proc_model_->setHorizontalHeaderLabels(QStringList() << tr("Process") << tr("PID") << tr("PPID") << tr("Path") << tr("Description") << tr("Company Name") << tr("CreatedTime")); QTreeView *pview = ui.processView; proxy_proc_ = new ProcSortFilterProxyModel(pview); proxy_proc_->setSourceModel(proc_model_); proxy_proc_->setDynamicSortFilter(true); proxy_proc_->setFilterKeyColumn(1); pview->setModel(proxy_proc_); pview->selectionModel()->setModel(proxy_proc_); pview->header()->setSortIndicator(-1, Qt::AscendingOrder); pview->setSortingEnabled(true); pview->viewport()->installEventFilter(this); pview->installEventFilter(this); pview->setMouseTracking(true); pview->setEditTriggers(QAbstractItemView::NoEditTriggers); pview->setExpandsOnDoubleClick(false); pview->setColumnWidth(PS.name, 250); pview->setColumnWidth(PS.path, 400); pview->setColumnWidth(PS.desc, 190); pview->setColumnWidth(PS.corp, 155); connect(pview->header(), SIGNAL(sectionClicked(int)), this, SLOT(onSectionClicked(int))); connect(pview, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(onProcDoubleClicked(const QModelIndex&))); connect(pview->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &ProcessMgr::onProcChanged); } void ProcessMgr::InitBottomCommon() { bottom_model_ = new QStandardItemModel; QTreeView *view = ui.moduleView; proxy_bottom_ = new ModSortFilterProxyModel(view); proxy_bottom_->setSourceModel(bottom_model_); proxy_bottom_->setDynamicSortFilter(true); proxy_bottom_->setFilterKeyColumn(1); view->setModel(proxy_bottom_); view->selectionModel()->setModel(proxy_bottom_); view->header()->setSortIndicator(-1, Qt::AscendingOrder); view->setSortingEnabled(true); view->viewport()->installEventFilter(this); view->installEventFilter(this); view->hide(); connect(view->header(), SIGNAL(sectionClicked(int)), this, SLOT(onSectionClicked(int))); } void ProcessMgr::InitModuleView() { if (!mod_menu_) { mod_menu_ = new QMenu(); mod_menu_->addAction(tr("Refresh"), this, SLOT(onRefresh())); mod_menu_->addAction(tr("Explore File"), this, SLOT(onExploreFile())); mod_menu_->addAction(tr("Sendto Scanner"), this, SLOT(onSendtoScanner())); mod_menu_->addAction(tr("Verify Signature"), this, SLOT(onVerifySignature())); mod_menu_->addAction(tr("Verify All Signature"), this, SLOT(onVerifyAllSignature())); mod_menu_->addAction(tr("Properties..."), this, [&]() {WinShowProperties(BottomCurViewItemData(MOD.path).toStdWString()); }); } else { bottom_model_->clear(); bottom_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Base") << tr("Size") << tr("Path") << tr("Description") << tr("Version") << tr("Company Name")<<tr("Signature")); auto bview = ui.moduleView; bview->header()->setSortIndicator(-1, Qt::AscendingOrder); } } void ProcessMgr::InitHandleView() { if (!hd_menu_) { hd_menu_ = new QMenu(); hd_menu_->addAction(tr("Close Handle"), this, SLOT(onCloseHandle())); hd_menu_->addAction(ui.actionHideUnnamed); connect(ui.actionHideUnnamed, SIGNAL(triggered(bool)), this, SLOT(onHideUnnamedHandles(bool))); } else { bottom_model_->clear(); bottom_model_->setHorizontalHeaderLabels(QStringList() << tr("Type") << tr("Name") << tr("Value") << tr("Access") << tr("Object Address")); auto bview = ui.moduleView; bview->setColumnWidth(HD.type, 170); bview->setColumnWidth(HD.name, 700); bview->header()->setSortIndicator(-1, Qt::AscendingOrder); } } void ProcessMgr::InitMemoryView() { if (!mem_menu_) { mem_menu_ = new QMenu(); mem_menu_->addAction(ui.actionHideUncommited); mem_menu_->addAction(ui.actionHideNonExecute); mem_menu_->addAction(ui.actionHideImage); mem_menu_->addSeparator(); mem_menu_->addAction(tr("Dump Memory"), this, SLOT(onDumpMemory())); connect(ui.actionHideUncommited, SIGNAL(triggered(bool)), this, SLOT(onHideMemoryItem(bool))); connect(ui.actionHideNonExecute, SIGNAL(triggered(bool)), this, SLOT(onHideMemoryItem(bool))); connect(ui.actionHideImage, SIGNAL(triggered(bool)), this, SLOT(onHideMemoryItem(bool))); } else { bottom_model_->clear(); bottom_model_->setHorizontalHeaderLabels(QStringList() << tr("Address") << tr("Size") << tr("Property") << tr("State") << tr("Type") << tr("Base") << tr("Module")); auto bview = ui.moduleView; bview->setColumnWidth(MEM.addr, 150); bview->setColumnWidth(MEM.property, 180); bview->setColumnWidth(MEM.state, 180); bview->setColumnWidth(MEM.type, 180); bview->setColumnWidth(MEM.base, 150); bview->header()->setSortIndicator(-1, Qt::AscendingOrder); } } void ProcessMgr::ShowProperties(DWORD pid, int tab) { auto properties = new ProcessProperties(this->parent_, pid, tab); properties->setObjectName("ProcessProperties"); properties->raise(); properties->show(); } void ProcessMgr::ShowProcessList() { DISABLE_RECOVER(); std::vector<ProcInfo> pis; UNONE::PsEnumProcess([&pis](PROCESSENTRY32W& entry)->bool { ProcInfo info; auto pid = info.pid = entry.th32ProcessID; auto ppid = info.ppid = entry.th32ParentProcessID; info.name = WCharsToQ(entry.szExeFile); CacheGetProcInfo(pid, info); pis.push_back(info); return true; }); for (const auto& pi : pis) { QStandardItem *name_item = new QStandardItem(pi.name); name_item->setBackground(QColor(240, 240, 240)); AppendProcessItem(nullptr, name_item, pi, proc_model_->rowCount()); } } void ProcessMgr::ShowProcessTree() { DISABLE_RECOVER(); std::function<void(QStandardItem *parent, ProcInfo pi, int seq)> AppendProcessTree = [&](QStandardItem *parent, ProcInfo pi, int seq) { QStandardItem *name_item = new QStandardItem(pi.name); name_item->setBackground(QColor(240, 240, 240)); AppendProcessItem(parent, name_item, pi, seq); QVector<ProcInfo> childs; CacheGetProcChilds(pi.pid, childs); for (size_t i = 0; i < childs.size(); i++) { AppendProcessTree(name_item, childs[i], i); } }; std::vector<ProcInfo> pis; UNONE::PsEnumProcess([&](PROCESSENTRY32W& entry)->bool { ProcInfo info; auto pid = info.pid = entry.th32ProcessID; auto ppid = info.ppid = entry.th32ParentProcessID; info.name = WCharsToQ(entry.szExeFile); CacheGetProcInfo(pid, info); if (ppid == 0 || !info.parent_existed) { pis.push_back(info); } return true; }); for (const auto& pi : pis) { AppendProcessTree(nullptr, pi, proc_model_->rowCount()); } ui.processView->expandAll(); } void ProcessMgr::AppendProcessItem(QStandardItem *parent, QStandardItem *name_item, ProcInfo info, int seq) { name_item->setIcon(LoadIcon(info.path)); QStandardItem *pid_item = new QStandardItem(PidFormat(info.pid)); QStandardItem *ppid_item = new QStandardItem(PidFormat(info.ppid)); QStandardItem *desc_item = new QStandardItem(info.desc); QStandardItem *corp_item = new QStandardItem(info.corp); QStandardItem *ctime_item = new QStandardItem(info.ctime); QStandardItem *path_item = new QStandardItem(info.path); if (parent == nullptr) { proc_model_->setItem(seq, PS.name, name_item); proc_model_->setItem(seq, PS.pid, pid_item); proc_model_->setItem(seq, PS.ppid, ppid_item); proc_model_->setItem(seq, PS.path, path_item); proc_model_->setItem(seq, PS.desc, desc_item); proc_model_->setItem(seq, PS.corp, corp_item); proc_model_->setItem(seq, PS.ctime, ctime_item); return; } parent->appendRow(name_item); parent->setChild(seq, PS.pid, pid_item); parent->setChild(seq, PS.ppid, ppid_item); parent->setChild(seq, PS.path, path_item); parent->setChild(seq, PS.desc, desc_item); parent->setChild(seq, PS.corp, corp_item); parent->setChild(seq, PS.ctime, ctime_item); } void ProcessMgr::AjustProcessStyle() { auto view = ui.processView; view->resizeColumnToContents(1); view->resizeColumnToContents(2); QModelIndex idx = view->indexAt(proc_sel_); view->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); view->scrollTo(idx); }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/process-mgr/process-mgr.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <QtGui> #include <QtCore> #include <QtWidgets> #include <QMutex> #include <Windows.h> #include "ui_process-mgr.h" #include "../common/common.h" namespace Ui { class ProcessMgr; class OpenArkWindow; } class OpenArk; PROXY_FILTER(ProcSortFilterProxyModel); class ModSortFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT public: ModSortFilterProxyModel(QWidget *parent) {}; ~ModSortFilterProxyModel() {}; int bottom_idx_; protected: bool lessThan(const QModelIndex &left, const QModelIndex &right) const; }; class ProcessMgr : public QWidget { Q_OBJECT public: ProcessMgr(QWidget* parent); ~ProcessMgr(); signals: void signalOpen(QString); protected: bool eventFilter(QObject *obj, QEvent *e); public slots : void onOpenFile(const QString& file); void onRefresh(); void onReset(); void onProcSelection(QString pid); private slots: void onTimer(); void onCopyActionTriggerd(QAction* action); void onKillProcess(); void onKillProcessTree(); void onRestartProcess(); void onSuspendProcess(); void onInjectDll(); void onSelectPid(); void onExploreFile(); void onCreateMiniDump(); void onCreateFullDump(); void onEnumThread(); void onEnumWindow(); void onSendtoScanner(); void onVerifySignature(); void onVerifyAllSignature(); void onShowProperties(); void onCloseHandle(); void onHideUnnamedHandles(bool checked); void onHideMemoryItem(bool checked); void onDumpMemory(); void onShowBottom(int idx); void onShowProcess(); void onShowModule(); void onShowHandle(); void onShowMemory(); void onSectionClicked(int idx); void onProcDoubleClicked(const QModelIndex &idx); void onProcChanged(const QModelIndex &current, const QModelIndex &previous); private: void InitProcessView(); void InitBottomCommon(); void InitModuleView(); void InitHandleView(); void InitMemoryView(); void ShowProperties(DWORD pid, int tab); void ShowProcessList(); void ShowProcessTree(); void AppendProcessItem(QStandardItem *parent, QStandardItem *name_item, ProcInfo info, int seq); void AjustProcessStyle(); int ProcCurRow(); int ProcCurCol(); DWORD ProcCurPid(); QString ProcCurViewItemData(int column); QString ProcViewItemData(int row, int column); QString BottomCurViewItemData(int column); QString ModViewItemData(int row, int column); private: int proc_header_idx_; int bottom_header_idx_; int bottom_header_last_; int bottom_idx_; bool unnamed_checked_; bool uncommed_checked_; bool nonexec_checked_; bool imaged_checked_; DWORD cur_pid_; private: Ui::ProcessMgr ui; OpenArk *parent_; QLabel *cpu_percent_label_; QLabel *mm_percent_label_; QLabel *cntproc_label_; QLabel *cntthread_label_; QLabel *cnthandle_label_; QMenu *proc_menu_; QMenu *mod_menu_; QMenu *hd_menu_; QMenu *mem_menu_; QTimer timer_; QPoint proc_sel_; QStandardItemModel *proc_model_; QStandardItemModel *bottom_model_; QStandardItemModel *hd_model_; QStandardItemModel *mem_model_; ProcSortFilterProxyModel *proxy_proc_; ModSortFilterProxyModel *proxy_bottom_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/process-mgr/process-properties.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "process-properties.h" #include "../common/common.h" #include "../common/cache/cache.h" ProcessProperties::ProcessProperties(QWidget* parent, DWORD pid, int tab) : pid_(pid) { setAttribute(Qt::WA_ShowModal, true); setAttribute(Qt::WA_DeleteOnClose); setWindowFlags(windowFlags()& ~Qt::WindowMaximizeButtonHint); ui.setupUi(this); connect(OpenArkLanguage::Instance(), &OpenArkLanguage::languageChaned, this, [this]() {ui.retranslateUi(this); }); CacheGetProcInfo(pid_, pinfo_); QString title = QString(tr("%1:%2 Properties")).arg(pinfo_.name).arg(pid_); setWindowTitle(title); setWindowIcon(LoadIcon(pinfo_.path)); threads_model_ = new QStandardItemModel; wnds_model_ = new QStandardItemModel; threads_model_->setHorizontalHeaderLabels(QStringList() << tr("TID") << tr("KernelTime") << tr("UserTime") << tr("CreateTime")); wnds_model_->setHorizontalHeaderLabels(QStringList() << tr("HWND") << tr("Title") << tr("ClassName") << tr("Visible") << tr("TID") << tr("PID")); SetDefaultTreeViewStyle(ui.threadView, threads_model_); SetDefaultTreeViewStyle(ui.wndsView, wnds_model_); menu_ = new QMenu(); menu_->addAction(tr("Refresh"), this, SLOT(onRefresh())); ui.threadView->installEventFilter(this); ui.wndsView->installEventFilter(this); connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged())); connect(ui.exploreButton, SIGNAL(clicked()), this, SLOT(onExploreFile())); ui.tabWidget->setCurrentIndex(tab); if (tab == 0) ShowImageDetail(); else if (tab == 1) ShowThreads(); else if (tab == 2) ShowWindowList(); this->installEventFilter(this); // timer_.setInterval(2000); // timer_.start(); // connect(&timer_, SIGNAL(timeout()), this, SLOT(onTimer())); } ProcessProperties::~ProcessProperties() { // timer_.stop(); } bool ProcessProperties::eventFilter(QObject *obj, QEvent *e) { if (obj == this) { if (e->type() == QEvent::KeyPress) { QKeyEvent* keyevt = dynamic_cast<QKeyEvent*>(e); if (keyevt->key() == Qt::Key_Escape) { this->close(); return true; } } } else if (obj == ui.threadView || obj == ui.wndsView) { if (e->type() == QEvent::ContextMenu) { QContextMenuEvent* ctxevt = dynamic_cast<QContextMenuEvent*>(e); if (ctxevt != nullptr) { menu_->move(ctxevt->globalPos()); menu_->show(); } } } return QWidget::eventFilter(obj, e); } void ProcessProperties::onRefresh() { onTabChanged(); } void ProcessProperties::onTimer() { onTabChanged(); } void ProcessProperties::onTabChanged() { auto curidx = ui.tabWidget->currentIndex(); switch (curidx) { case 0: ShowImageDetail(); break; case 1: ShowThreads(); break; case 2: ShowWindowList(); break; } } void ProcessProperties::onExploreFile() { ExploreFile(pinfo_.path); } void ProcessProperties::ShowImageDetail() { ui.pathEdit->setText(pinfo_.path); ui.iconLabel->setPixmap(LoadIcon(pinfo_.path).pixmap(QSize(48, 48))); std::wstring prod_ver, file_ver, descript, copyright; std::wstring path = pinfo_.path.toStdWString(); UNONE::FsGetFileInfoW(path, L"ProductVersion", prod_ver); UNONE::FsGetFileVersionW(path, file_ver); UNONE::FsGetFileInfoW(path, L"FileDescription", descript); UNONE::FsGetFileInfoW(path, L"LegalCopyright", copyright); ui.prodVerLabel->setText(WStrToQ(prod_ver)); ui.fileVerLabel->setText(WStrToQ(file_ver)); ui.descLabel->setText(WStrToQ(descript)); ui.copyrightLabel->setText(WStrToQ(copyright)); ui.bitsLabel->setText(UNONE::PsIsX64(pid_) ? WCharsToQ(L"64-bits") : WCharsToQ(L"32-bits")); auto image = UNONE::PeMapImageByPathW(path); if (image) { std::string cptime; auto stamp = UNONE::PeGetTimeStamp(image); if (stamp) cptime = UNONE::TmFormatUnixTimeA(stamp, "Y-M-D H:W:S"); ui.buildLabel->setText(StrToQ(cptime)); UNONE::PeUnmapImage(image); } auto info = CacheGetProcessBaseInfo(pid_); ui.cmdlineEdit->setText(WStrToQ(info.CommandLine)); ui.curdirEdit->setText(WStrToQ(info.CurrentDirectory)); ui.parentLabel->setText(WStrToQ(UNONE::StrFormatW(L"%s(%d)", QToWChars(pinfo_.name), pinfo_.ppid)));; ui.userLabel->setText(WStrToQ(UNONE::OsHostNameW() + L"\\" + UNONE::OsUserNameW())); ui.startLabel->setText(WStrToQ(ProcessCreateTime(pid_))); } void ProcessProperties::ShowThreads() { ClearItemModelData(threads_model_); std::vector<DWORD> tids; UNONE::PsGetAllThread(pid_, tids); for (auto tid : tids) { auto tid_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%04X(%d)", tid, tid))); std::wstring ct, kt, ut; RetrieveThreadTimes(tid, ct, kt, ut); auto ct_item = new QStandardItem(WStrToQ(ct)); auto kt_item = new QStandardItem(WStrToQ(kt)); auto ut_item = new QStandardItem(WStrToQ(ut)); auto count = threads_model_->rowCount(); threads_model_->setItem(count, 0, tid_item); threads_model_->setItem(count, 1, kt_item); threads_model_->setItem(count, 2, ut_item); threads_model_->setItem(count, 3, ct_item); } QString qstr = WStrToQ(UNONE::StrFormatW(L"%d", tids.size())); ui.threadCountLabel->setText(qstr); } void ProcessProperties::ShowWindowList() { ClearItemModelData(wnds_model_); std::vector<HWND> wnds; wnds = UNONE::PsGetWnds(pid_); for (auto wnd : wnds) { DWORD tid, pid; tid = GetWindowThreadProcessId(wnd, &pid); auto hwnd_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%08X", wnd))); auto title_item = new QStandardItem(WStrToQ(UNONE::PsGetWndTextW(wnd))); auto class_item = new QStandardItem(WStrToQ(UNONE::PsGetWndClassNameW(wnd))); auto visible_item = new QStandardItem(WStrToQ(IsWindowVisible(wnd) ? L"+":L"-")); auto tid_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%04X(%d)", tid, tid))); auto pid_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%04X(%d)", pid, pid))); auto count = wnds_model_->rowCount(); wnds_model_->setItem(count, 0, hwnd_item); wnds_model_->setItem(count, 1, title_item); wnds_model_->setItem(count, 2, class_item); wnds_model_->setItem(count, 3, visible_item); wnds_model_->setItem(count, 4, tid_item); wnds_model_->setItem(count, 5, pid_item); } }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/process-mgr/process-properties.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <QtCore> #include <QtWidgets> #include <Windows.h> #include "ui_process-properties.h" #include "../common/cache/cache.h" namespace Ui { class ProcessProperties; } class ProcessProperties : public QWidget { Q_OBJECT public: ProcessProperties(QWidget* parent, DWORD pid, int tab); ~ProcessProperties(); protected: bool eventFilter(QObject *obj, QEvent *e); public slots: void onRefresh(); private slots: void onTimer(); void onTabChanged(); void onExploreFile(); private: void ShowImageDetail(); void ShowThreads(); void ShowWindowList(); private: Ui::ProcessProperties ui; QStandardItemModel *threads_model_; QStandardItemModel *wnds_model_; DWORD pid_; ProcInfo pinfo_; QMenu *menu_; QTimer timer_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/process-mgr/process-selection.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "../common/common.h" #include "process-selection.h" ProcessSelection::ProcessSelection(QWidget *parent) : parent_((ProcessMgr*)parent) { ui.setupUi(this); connect(OpenArkLanguage::Instance(), &OpenArkLanguage::languageChaned, this, [this]() {ui.retranslateUi(this); }); setAttribute(Qt::WA_ShowModal, true); setAttribute(Qt::WA_DeleteOnClose); setWindowFlags(windowFlags()& ~Qt::WindowMaximizeButtonHint); setWindowTitle(tr("Select...")); ui.decRadio->setChecked(true); ui.pidEdit->setFocus(); connect(ui.okBtn, SIGNAL(accepted()), this, SLOT(onLocateProcess())); connect(this, SIGNAL(procSelection(QString)), parent_, SLOT(onProcSelection(QString))); connect(ui.pidEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onPidChanged(const QString&))); connect(ui.decRadio, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool))); connect(ui.hexRadio, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool))); } ProcessSelection::~ProcessSelection() { } void ProcessSelection::onLocateProcess() { QString dec = WStrToQ(UNONE::StrFormatW(L"%d", GetInputPid())); emit procSelection(dec); } void ProcessSelection::onPidChanged(const QString &text) { DWORD pid = GetInputPid(); ui.nameEdit->setText(WStrToQ(UNONE::PsGetProcessNameW(pid))); ui.pathEdit->setText(WStrToQ(UNONE::PsGetProcessPathW(pid))); } void ProcessSelection::onToggled(bool checked) { auto sender = qobject_cast<QRadioButton*>(QObject::sender()); if (!sender->isChecked()) return; DWORD pid = 0; if (sender == ui.decRadio) { pid = UNONE::StrToHexA(ui.pidEdit->text().toStdString()); ui.pidEdit->setText(WStrToQ(UNONE::StrFormatW(L"%d", pid))); return; } if (sender == ui.hexRadio) { pid = UNONE::StrToIntegerA(ui.pidEdit->text().toStdString()); ui.pidEdit->setText(WStrToQ(UNONE::StrFormatW(L"%X", pid))); return; } } DWORD ProcessSelection::GetInputPid() { DWORD pid; bool hexed = true; if (ui.decRadio->isChecked()) hexed = false; if (hexed) { pid = UNONE::StrToHexA(ui.pidEdit->text().toStdString()); } else { pid = UNONE::StrToIntegerA(ui.pidEdit->text().toStdString()); } return pid; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/process-mgr/process-selection.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <QtCore> #include <QtWidgets> #include <Windows.h> #include "process-mgr.h" #include "ui_process-selection.h" namespace Ui { class ProcessSelection; } class ProcessSelection : public QDialog { Q_OBJECT public: ProcessSelection(QWidget* parent); ~ProcessSelection(); signals: void procSelection(QString); private slots: void onLocateProcess(); void onPidChanged(const QString &text); void onToggled(bool checked); private: DWORD GetInputPid(); Ui::ProcessSelection ui; ProcessMgr *parent_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/reverse/reverse.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "reverse.h" #include "../common/common.h" #include "../common/utils/compress/zip_utils.h" #include "../openark/openark.h" using namespace Plugin::Compressor; enum { RUN_EXE, RUN_EXE_HIDE, RUN_EXE_BY_CMD, RUN_DIR, RUN_CMD_DIR, RUN_OPEN_URL, }; WINTOOL_ITEM WinAllTools[] = { { RUN_EXE, "procexp", "procexp/procexp.exe", "procexp.zip" }, { RUN_EXE, "procmon", "Procmon/Procmon.exe", "Procmon.zip" }, { RUN_EXE, "pchunter32", "PCHunter/PCHunter32.exe", "PCHunter32.zip" }, { RUN_EXE, "pchunter64", "PCHunter/PCHunter64.exe", "PCHunter64.zip" }, { RUN_EXE, "winobj", "Winobj/Winobj.exe", "Winobj.zip" }, { RUN_EXE, "dbgview", "Dbgview/Dbgview.exe", "Dbgview.zip" }, { RUN_EXE, "apimonitor32", "API Monitor/apimonitor-x86.exe", "API Monitor.zip" }, { RUN_EXE, "apimonitor64", "API Monitor/apimonitor-x64.exe", "API Monitor.zip" }, { RUN_CMD_DIR, "sysinternals", "SysinternalsSuite/", "SysinternalsSuite.zip" }, { RUN_EXE, "nirsoft", "nirsoft_package/NirLauncher.exe", "nirsoft_package.zip" }, { RUN_EXE, "windbg32", "Windbg/x86/windbg.exe", "Windbg32.zip" }, { RUN_EXE, "windbg64", "Windbg/x64/windbg.exe", "Windbg64.zip" }, { RUN_EXE, "x64dbg32", "x64dbg/x32/x32dbg.exe", "x64dbg.zip" }, { RUN_EXE, "x64dbg64", "x64dbg/x64/x64dbg.exe", "x64dbg.zip" }, { RUN_EXE, "ida32", "IDA/ida.exe", "IDA.zip" }, { RUN_EXE, "ida64", "IDA/ida64.exe", "IDA.zip" }, { RUN_EXE, "ollydbg", "OllyDBG/OllyDBG.exe", "OllyDBG.zip" }, { RUN_EXE, "ollyice", "OllyICE/OllyICE.exe", "OllyICE.zip" }, { RUN_EXE, "od52pj", "OD 52pj/OD.exe", "OD 52pj.zip" }, { RUN_EXE, "exeinfope", "ExeinfoPe/exeinfope.exe", "ExeinfoPe.zip" }, { RUN_EXE, "reshacker", "ResourceHacker/ResourceHacker.exe", "ResourceHacker.zip" }, { RUN_EXE, "cffexplorer", "CFF Explorer/CFF Explorer.exe", "CFF Explorer.zip" }, { RUN_EXE, "cheatengine", "Cheat Engine/Cheat Engine.exe", "Cheat Engine.zip" }, { RUN_EXE, "peid", "PEID/PEID.exe", "PEID.zip" }, { RUN_EXE, "hcd", "HCD/HCD.exe", "HCD.zip" }, { RUN_CMD_DIR, "radare", "radare2/bin/", "radare2.zip" }, { RUN_EXE, "notepadxx", "Notepad++/notepad++.exe", "Notepadxx.zip" }, { RUN_EXE, "editor010", "010Editor/010Editor.exe", "010Editor.zip" }, { RUN_EXE, "winhex", "Winhex/winhex.exe", "Winhex.zip" }, { RUN_EXE, "hxd", "HxD/HxD.exe", "HxD.zip" }, { RUN_EXE, "winspy", "WinSpy/WinSpy.exe", "WinSpy.zip" }, { RUN_EXE, "spyxx32", "Spy++/spyxx.exe", "Spyxx32.zip" }, { RUN_EXE, "spyxx64", "Spy++/spyxx_amd64.exe", "Spyxx64.zip" }, { RUN_EXE, "fiddler2", "Fiddler2/Fiddler.exe", "Fiddler2.zip" }, { RUN_EXE, "fiddler4", "Fiddler4/Fiddler.exe", "Fiddler4.zip" }, { RUN_EXE, "wiresharkv1", "Wireshark/Wireshark-win32-1.10.14.exe", "Wireshark-v1.zip" }, { RUN_EXE, "wiresharkv3", "Wireshark/Wireshark-win32-3.2.3.exe", "Wireshark-v3.zip" }, { RUN_EXE, "everything", "Everything/Everything.exe", "Everything.zip" }, { RUN_EXE, "teamviewer", "misc/remote/Teamviewer.exe", "misc/remote/Teamviewer.exe" }, { RUN_EXE, "anydesk", "misc/remote/AnyDesk.exe", "misc/remote/AnyDesk.exe" }, { RUN_EXE, "sunlogin", "misc/remote/SunloginClient.exe", "misc/remote/SunloginClient.exe" }, //2020.09.02 add { RUN_EXE, "pchunternew32", "PCHunterNew/PCHunter32.exe", "PCHunterNew32.zip" }, { RUN_EXE, "pchunternew64", "PCHunterNew/PCHunter64.exe", "PCHunterNew64.zip" }, { RUN_EXE, "wke32", "WKE32.exe", "WKE32.exe" }, { RUN_EXE, "wke64", "WKE64.exe", "WKE64.exe" }, { RUN_EXE, "ghidra", "Ghidra/ghidraRun.bat", "Ghidra.zip" }, { RUN_EXE, "keygener", "Keygener.exe", "Keygener.exe" }, { RUN_EXE, "pygtools", "PYGTools/PYG_TOOLS_VER5.exe", "PYGTools.zip" }, { RUN_EXE, "poolmonx", "PoolMonX/PoolMonX.exe", "PoolMonX.zip" }, { RUN_EXE_BY_CMD, "diskgenius", "DiskGenius/DiskGenius.exe", "DiskGenius.zip" }, //cannot shell open diskgenius directly, WTF { RUN_EXE, "window", "Window.exe", "Window.exe" }, { RUN_CMD_DIR, "curl", "network/curl/", "network/curl.zip" }, { RUN_EXE, "nmap", "network/nmap-setup.exe", "network/nmap-setup.exe" }, { RUN_EXE, "charles", "charles-win64.msi", "charles-win64.msi" }, { RUN_CMD_DIR, "tcpdump", "network/tcpdump/", "network/tcpdump.zip" }, { RUN_EXE, "x7z", "compressor/7z.exe", "compressor/7z.exe" }, { RUN_EXE, "winrar", "compressor/winrar.exe", "compressor/winrar.exe" }, { RUN_EXE, "chrome49", "browser/ChromeStandalone49.exe", "browser/ChromeStandalone49.exe" }, { RUN_EXE, "chrome85", "browser/ChromeStandalone85.exe", "browser/ChromeStandalone85.exe" }, { RUN_EXE, "firefox", "browser/FirefoxSetup.exe", "browser/FirefoxSetup.exe" }, { RUN_EXE, "cpuz", "cpuz/cpuz_x32.exe", "cpuz.zip" }, { RUN_EXE, "aida64", "aida64/aida64.exe", "aida64.zip" }, //2021.11.01 add { RUN_EXE, "dnspy", "reverse/dnSpy/dnSpy.exe", "reverse/dnSpy.zip" }, { RUN_EXE, "die", "reverse/die_win32_portable/die.exe", "reverse/die_win32.zip" }, { RUN_EXE, "pebear", "reverse/PE-bear/PE-bear.exe", "reverse/PE-bear.zip" }, { RUN_EXE, "instdrv", "reverse/InstDrv.exe", "reverse/InstDrv.exe" }, { RUN_EXE, "pdbripper", "reverse/pdbripper/pdbripper.exe", "reverse/pdbripper.zip" }, { RUN_EXE, "instdrv", "reverse/InstDrv.exe", "reverse/InstDrv.exe" }, { RUN_EXE, "loadtest", "reverse/LoadTest.exe", "reverse/LoadTest.exe" }, { RUN_EXE, "notepad2", "misc/Notepad2.exe", "misc/Notepad2.exe" }, { RUN_EXE, "vscode", "misc/VSCodeSetup.exe", "misc/VSCodeSetup.exe" }, { RUN_EXE, "calc", "reverse/Calc.exe", "reverse/Calc.exe" }, { RUN_EXE, "calcfpu", "reverse/CalcFPU.exe", "reverse/CalcFPU.exe" }, { RUN_EXE, "wiztree", "misc/WizTree.exe", "misc/WizTree.zip" }, { RUN_EXE, "rapidee", "misc/rapidee.exe", "misc/rapidee.zip" }, { RUN_EXE, "as_ssd", "misc/AS_SSD/AS_SSD.exe", "misc/AS_SSD.zip" }, { RUN_EXE, "hddog", "misc/HDDog.exe", "misc/HDDog.exe" }, //Linux { RUN_EXE, "cygwin64", "linux/cygwin64/Cygwin.bat", "linux/cygwin64.zip" }, { RUN_EXE, "mobaxterm", "linux/MobaXterm/MobaXterm.exe", "linux/MobaXterm.zip" }, { RUN_EXE, "putty", "linux/putty.exe", "linux/putty.zip" }, { RUN_CMD_DIR, "ssh_win", "linux/ssh-win/", "linux/ssh-win.zip" }, { RUN_EXE, "robo3t", "linux/robo3t-x86_64.exe", "linux/robo3t-x86_64.exe" }, { RUN_EXE, "redistool", "linux/redis-desktop-manager.exe", "linux/redis-desktop-manager.exe" }, { RUN_EXE, "sqlitestudio", "linux/SQLiteStudio/SQLiteStudio.exe", "linux/sqlitestudio.zip" }, //Android { RUN_CMD_DIR, "adb", "android/adb/", "android/adb.zip" }, { RUN_CMD_DIR, "aapt", "android/adb/", "android/adb.zip" }, { RUN_EXE, "jadx", "android/jadx.exe", "android/jadx.exe" }, { RUN_EXE, "jeb", "android/jeb/bin/jeb.exe", "android/jeb.zip" }, { RUN_EXE, "gda", "android/GDA.exe", "android/GDA.exe" }, { RUN_EXE, "jd_gui", "android/jd-gui.exe", "android/jd-gui.exe" }, { RUN_EXE_BY_CMD, "scrcpy", "android/scrcpy-win64/scrcpy.exe", "android/scrcpy-win64.zip" }, { RUN_EXE, "xelfviewer", "android/xelfviewer/xelfviewer.exe", "android/xelfviewer.zip" }, { RUN_EXE, "uleb128", "android/ULEB128.exe", "android/ULEB128.exe" }, { RUN_EXE, "apkstudio", "android/ApkStudio-x64/ApkStudio.exe", "android/ApkStudio-x64.zip" }, { RUN_EXE, "androidkiller", "android/AndroidKiller/AndroidKiller.exe", "android/AndroidKiller.zip" }, { RUN_EXE, "jdk8", "android/jdk8.exe", "android/jdk8.exe" }, //WinDevKits { RUN_OPEN_URL, "jdk", "https://mirrors.huaweicloud.com/java/jdk/", "" }, { RUN_EXE, "jdk11", "android/jdk11.exe", "android/jdk11.exe" }, { RUN_OPEN_URL, "python", "https://www.python.org/downloads/", "" }, { RUN_OPEN_URL, "golang", "https://studygolang.com/dl", "" }, { RUN_OPEN_URL, "visualstudio", "https://visualstudio.microsoft.com/downloads/", "" }, { RUN_OPEN_URL, "androidstudio", "https://developer.android.google.cn/studio/", "" }, { RUN_EXE, "git32", "dev/Git-32bit.exe", "dev/Git-32bit.exe" }, { RUN_EXE, "torgit32", "dev/TortoiseGit-32bit.msi", "dev/TortoiseGit-32bit.msi" }, { RUN_EXE, "torsvn32", "dev/TortoiseSVN-32bit.msi", "dev/TortoiseSVN-32bit.msi" }, { RUN_EXE, "git64", "dev/Git-64bit.exe", "dev/Git-64bit.exe" }, { RUN_EXE, "torgit64", "dev/TortoiseGit-64bit.msi", "dev/TortoiseGit-64bit.msi" }, { RUN_EXE, "torsvn64", "dev/TortoiseSVN-64bit.msi", "dev/TortoiseSVN-64bit.msi" }, { RUN_EXE, "vc2005x64", "dev/vcredist_2005_x64", "" }, { RUN_EXE, "vc2005x86", "dev/vcredist/vcredist_2005_x86.exe", "dev/vcredist/vcredist_2005_x86.exe" }, { RUN_EXE, "vc2008x64", "dev/vcredist/vcredist_2008_x64.exe", "dev/vcredist/vcredist_2008_x64.exe" }, { RUN_EXE, "vc2008x86", "dev/vcredist/vcredist_2008_x86.exe", "dev/vcredist/vcredist_2008_x86.exe" }, { RUN_EXE, "vc2010x64", "dev/vcredist/vcredist_2010_x64.exe", "dev/vcredist/vcredist_2010_x64.exe" }, { RUN_EXE, "vc2010x86", "dev/vcredist/vcredist_2010_x86.exe", "dev/vcredist/vcredist_2010_x86.exe" }, { RUN_EXE, "vc2012x64", "dev/vcredist/vcredist_2012_x64.exe", "dev/vcredist/vcredist_2012_x64.exe" }, { RUN_EXE, "vc2012x86", "dev/vcredist/vcredist_2012_x86.exe", "dev/vcredist/vcredist_2012_x86.exe" }, { RUN_EXE, "vc2013x64", "dev/vcredist/vcredist_2013_x64.exe", "dev/vcredist/vcredist_2013_x64.exe" }, { RUN_EXE, "vc2013x86", "dev/vcredist/vcredist_2013_x86.exe", "dev/vcredist/vcredist_2013_x86.exe" }, { RUN_EXE, "vc2015x64", "dev/vcredist/vcredist_2015_x64.exe", "dev/vcredist/vcredist_2015_x64.exe" }, { RUN_EXE, "vc2015x86", "dev/vcredist/vcredist_2015_x86.exe", "dev/vcredist/vcredist_2015_x86.exe" }, { RUN_EXE, "vc1519x64", "dev/vcredist/vcredist_2015~2019_x64.exe", "dev/vcredist/vcredist_2015~2019_x64.exe" }, { RUN_EXE, "vc1519x86", "dev/vcredist/vcredist_2015~2019_x86.exe", "dev/vcredist/vcredist_2015~2019_x86.exe" }, { RUN_EXE, "dotnet4", "dev/dotnet/dotNetFx40_Full_x86_x64.exe", "dev/dotnet/dotNetFx40_Full_x86_x64.exe" }, }; Reverse::Reverse(QWidget *parent, int tabid) : CommonMainTabObject::CommonMainTabObject((OpenArk*)parent) { ui.setupUi(this); ui.progressBar->setValue(0); ui.progressBar->show(); InitWindowsView(); InitLinuxView(); InitAndroidView(); InitDevKitsView(); CommonMainTabObject::Init(ui.tabWidget, tabid); } Reverse::~Reverse() { } void Reverse::onTabChanged(int index) { CommonMainTabObject::onTabChanged(index); } void Reverse::onExecute() { QString name; static auto is64 = UNONE::OsIs64(); auto sender = QObject::sender(); name = sender->objectName().replace("Btn", ""); if (sender == ui.pchunterBtn) name = is64 ? "pchunter64" : "pchunter32"; if (sender == ui.pchunternewBtn) name = is64 ? "pchunternew64" : "pchunternew32"; if (sender == ui.wkeBtn) name = is64 ? "wke64" : "wke32"; if (sender == ui.gitBtn) name = is64 ? "git64" : "git32"; if (sender == ui.torgitBtn) name = is64 ? "torgit64" : "torgit32"; if (sender == ui.torsvnBtn) name = is64 ? "torsvn64" : "torsvn32"; WINTOOL_ITEM wintool; for (int i = 0; i < _countof(WinAllTools); i++) { if (WinAllTools[i].name == name) { wintool = WinAllTools[i]; break; } } DownloadAndExecuteFile(wintool); } void Reverse::DownloadAndExecuteFile(WINTOOL_ITEM wintool) { int type; QString uri, exec; uri = wintool.uri; exec = wintool.exec; type = wintool.type; if (type == RUN_OPEN_URL) { ShellOpenUrl(exec); return; } auto &&filebase = WStrToQ(AppConfigDir() + L"/files/"); if (!UNONE::FsIsExistedW(filebase.toStdWString())) { UNONE::FsCreateDirW(filebase.toStdWString()); } auto &&path = filebase + uri; auto &&url = AppFsUrl() + "/" + uri; exec = filebase + exec; auto Run = [&](int type, QString exe)->bool { if (UNONE::FsIsExistedW(QToWStr(exe))) { if (type == RUN_EXE) ShellRun(exe, ""); if (type == RUN_EXE_HIDE) ShellRunCmdExe(exe, SW_HIDE); else if (type == RUN_CMD_DIR) ShellRunCmdDir(exe); else if (type == RUN_DIR) ExploreFile(exe); else if (type == RUN_EXE_BY_CMD) ShellRunCmdExe(exe, SW_HIDE); return true; } return false; }; static bool pending = false; if (Run(type, exec)) return; if (pending) { QMessageBox::critical(NULL, tr("Error"), tr("Download pending, wait for a while...")); return; } pending = true; UNONE::FsCreateDirW(UNONE::FsPathToDirW(QToWStr(path))); file = new QFile(path); file->open(QIODevice::WriteOnly); QNetworkAccessManager *accessmgr = new QNetworkAccessManager(this); accessmgr->setNetworkAccessible(QNetworkAccessManager::Accessible); QUrl qurl(url); QNetworkRequest request(qurl); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream"); reply = accessmgr->get(request); connect((QObject *)reply, SIGNAL(readyRead()), this, SLOT(readContent())); connect(accessmgr, &QNetworkAccessManager::finished, [&, Run, type, path, exec](QNetworkReply*) { if (reply->error() != QNetworkReply::NoError) { QMessageBox::critical(NULL, tr("Error"), tr("Download failed, err:%1").arg(reply->error())); ui.progressBar->setValue(0); ui.progressBar->setMaximum(100); file->close(); DeleteFileW(QToWStr(path).c_str()); pending = false; return; } reply->deleteLater(); file->flush(); file->close(); auto filepath = path.toStdString(); if (UNONE::FsPathToExtensionA(filepath) == ".zip") { //Unpack auto dir = UNONE::FsPathToDirA(filepath); ZipUtils::UnpackToDir(filepath, ZipUtils::UNPACK_CURRENT, dir); //Clean DeleteFileA(filepath.c_str()); } //Run Run(type, exec); pending = false; }); connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(onProgress(qint64, qint64))); } void Reverse::readContent() { file->write(reply->readAll()); } void Reverse::onProgress(qint64 bytesSent, qint64 bytesTotal) { ui.progressBar->setMaximum(bytesTotal); ui.progressBar->setValue(bytesSent); } void Reverse::InitWindowsView() { QList<QPushButton*> buttons = ui.windowsBox->findChildren<QPushButton*>(); for (auto &btn : buttons) { connect(btn, SIGNAL(clicked()), this, SLOT(onExecute())); } connect(ui.toolsfolderBtn, &QPushButton::clicked, [] { auto folder = AppConfigDir() + L"\\files"; ShellRun(WStrToQ(folder), ""); }); } void Reverse::InitLinuxView() { QList<QPushButton*> buttons = ui.linuxBox->findChildren<QPushButton*>(); for (auto &btn : buttons) { connect(btn, SIGNAL(clicked()), this, SLOT(onExecute())); } } void Reverse::InitAndroidView() { QList<QPushButton*> buttons = ui.androidBox->findChildren<QPushButton*>(); for (auto &btn : buttons) { connect(btn, SIGNAL(clicked()), this, SLOT(onExecute())); } } void Reverse::InitDevKitsView() { QList<QPushButton*> buttons = ui.devkitsBox->findChildren<QPushButton*>(); for (auto &btn : buttons) { connect(btn, SIGNAL(clicked()), this, SLOT(onExecute())); } }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/reverse/reverse.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <QtCore> #include <QtWidgets> #include <Windows.h> #include "ui_reverse.h" #include <QString> #include <QNetworkAccessManager> #include <QNetworkRequest> #include <QNetworkReply> #include <QUrl> #include <QFile> #include <QDebug> #include <QProgressBar> #include "../common/ui-wrapper/ui-wrapper.h" class OpenArk; class Ui::Reverse; typedef struct _WINTOOL_ITEM { int type; QString name; QString exec; QString uri; } WINTOOL_ITEM; class Reverse : public CommonMainTabObject { Q_OBJECT public: Reverse(QWidget *parent, int tabid); ~Reverse(); private slots: void onTabChanged(int index); void onExecute(); void readContent(); void onProgress(qint64 bytesSent, qint64 bytesTotal); private: void DownloadAndExecuteFile(WINTOOL_ITEM wintool); void InitWindowsView(); void InitLinuxView(); void InitAndroidView(); void InitDevKitsView(); private: Ui::Reverse ui; QNetworkReply *reply; QFile *file; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/scanner/scanner.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "scanner.h" #include "../common/common.h" #include "../openark/openark.h" #define PE_UNKNOWN_FILE L"Unknown file" #define PE_FILE32 L"PE 32-bit" #define PE_FILE64 L"PE 64-bit" Scanner::Scanner(QWidget *parent, int tabid) : CommonMainTabObject::CommonMainTabObject((OpenArk*)parent), pe_image_(NULL) { ui.setupUi(this); connect(OpenArkLanguage::Instance(), &OpenArkLanguage::languageChaned, this, [this]() {ui.retranslateUi(this); }); setAcceptDrops(true); sumup_model_ = new QStandardItemModel; SetDefaultTableViewStyle(ui.summaryUpView, sumup_model_); sumup_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Value")); ui.summaryUpView->setColumnWidth(0, 120); sumdown_model_ = new QStandardItemModel; SetDefaultTableViewStyle(ui.summaryDownView, sumdown_model_); ui.summaryDownView->horizontalHeader()->hide(); ui.summaryDownView->setColumnWidth(0, 120); ui.splitterSummary->setStretchFactor(0, 2); ui.splitterSummary->setStretchFactor(1, 1); headers_model_ = new QStandardItemModel; headers_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Value")); SetDefaultTreeViewStyle(ui.headersView, headers_model_); ui.headersView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); ui.headersView->viewport()->installEventFilter(this); ui.headersView->installEventFilter(this); headers_menu_ = new QMenu(); headers_menu_->addAction(tr("ExpandAll"), this, SLOT(onExpandAll())); sections_model_ = new QStandardItemModel; SetDefaultTableViewStyle(ui.sectionsView, sections_model_); sections_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("VirtualSize") << tr("VirtualAddress") << tr("SizeOfRawData") << tr("PointerToRawData") << tr("PointerToRelocations") << tr("PointerToLinenumbers") << tr("NumberOfRelocations") << tr("NumberOfLinenumbers") << tr("Characteristics")); imp_model_ = new QStandardItemModel; imp_func_model_ = new QStandardItemModel; SetDefaultTableViewStyle(ui.impView, imp_model_); SetDefaultTableViewStyle(ui.impFuncView, imp_func_model_); imp_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("OriginalFirstThunk") << tr("TimeDateStamp") << tr("ForwarderChain") << tr("FirstThunk")); imp_func_model_->setHorizontalHeaderLabels(QStringList() << tr("ForwarderString") << tr("Function") << tr("Ordinal") << tr("AddressOfData") << tr("Hint") << tr("Name")); connect(ui.impView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &Scanner::onImportChanged); exp_model_ = new QStandardItemModel; exp_func_model_ = new QStandardItemModel; SetDefaultTableViewStyle(ui.expView, exp_model_); SetDefaultTableViewStyle(ui.expFuncView, exp_func_model_); exp_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Value")); exp_func_model_->setHorizontalHeaderLabels(QStringList() << tr("FunctionAddr") << tr("Ordinal") << tr("Name")); reloc_model_ = new QStandardItemModel; reloc_item_model_ = new QStandardItemModel; SetDefaultTableViewStyle(ui.relocView, reloc_model_); SetDefaultTableViewStyle(ui.relocItemView, reloc_item_model_); reloc_model_->setHorizontalHeaderLabels(QStringList() << tr("VirtualAddress") << tr("SizeOfBlock") << tr("ItemCount")); reloc_item_model_->setHorizontalHeaderLabels(QStringList() << tr("Item") << tr("Address") << tr("Type")); connect(ui.relocView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &Scanner::onRelocChanged); dbg_model_ = new QStandardItemModel; SetDefaultTableViewStyle(ui.debugView, dbg_model_); dbg_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Value")); connect(ui.baseEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.rebaseEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.vaEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.revaEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.rvaEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.rawEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); CommonMainTabObject::Init(ui.tabWidget, tabid); } Scanner::~Scanner() { } bool Scanner::eventFilter(QObject *obj, QEvent *e) { if (obj == ui.headersView->viewport()) { if (e->type() == QEvent::ContextMenu) { QContextMenuEvent* ctxevt = dynamic_cast<QContextMenuEvent*>(e); if (ctxevt != nullptr) { headers_menu_->move(ctxevt->globalPos()); headers_menu_->show(); } } } return QWidget::eventFilter(obj, e); } void Scanner::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasFormat("text/uri-list")) event->acceptProposedAction(); } void Scanner::dragMoveEvent(QDragMoveEvent *event) { } void Scanner::dropEvent(QDropEvent *event) { if (!event->mimeData()->hasUrls()) return; QString& path = event->mimeData()->urls()[0].toLocalFile(); onOpenFile(path); } void Scanner::onImportChanged(const QModelIndex &current, const QModelIndex &previous) { ClearItemModelData(imp_func_model_); std::string dll = GetCurItemViewData(ui.impView, 0).toStdString(); PIMAGE_IMPORT_DESCRIPTOR imp = (PIMAGE_IMPORT_DESCRIPTOR)UNONE::PeGetDataEntity(IMAGE_DIRECTORY_ENTRY_IMPORT, pe_image_); if (!imp) return; while (imp->Name != 0) { if ((pe_image_ + imp->Name) != dll) { imp++; continue; } if (UNONE::PeX64(pe_image_)) { PIMAGE_THUNK_DATA64 othunk = NULL; PIMAGE_THUNK_DATA64 fthunk = (PIMAGE_THUNK_DATA64)(pe_image_ + imp->FirstThunk); if (imp->OriginalFirstThunk != 0) othunk = (PIMAGE_THUNK_DATA64)(pe_image_ + imp->OriginalFirstThunk); else othunk = fthunk; while (othunk != NULL && othunk->u1.Ordinal != 0) { WORD hint = 0; std::string func_name; if (IMAGE_SNAP_BY_ORDINAL64(othunk->u1.Ordinal)) { func_name = UNONE::StrFormatA("Ordinal: %08X", othunk->u1.Ordinal & (~IMAGE_ORDINAL_FLAG64)); } else { PIMAGE_IMPORT_BY_NAME imp_name = (PIMAGE_IMPORT_BY_NAME)(pe_image_ + othunk->u1.AddressOfData); func_name = (LPCSTR)(imp_name->Name); hint = imp_name->Hint; } InitTableItem(imp_func_model_); AppendTableItem(imp_func_model_, QWordToHexQ(othunk->u1.Ordinal)); AppendTableItem(imp_func_model_, QWordToHexQ(othunk->u1.Ordinal)); AppendTableItem(imp_func_model_, QWordToHexQ(othunk->u1.Ordinal)); AppendTableItem(imp_func_model_, QWordToHexQ(othunk->u1.Ordinal)); AppendTableItem(imp_func_model_, DWordToHexQ(hint)); AppendTableItem(imp_func_model_, StrToQ(func_name)); fthunk++; othunk++; } } else { PIMAGE_THUNK_DATA32 othunk = NULL; PIMAGE_THUNK_DATA32 fthunk = (PIMAGE_THUNK_DATA32)(pe_image_ + imp->FirstThunk); if (imp->OriginalFirstThunk != 0) othunk = (PIMAGE_THUNK_DATA32)(pe_image_ + imp->OriginalFirstThunk); else othunk = fthunk; while (othunk != NULL && othunk->u1.Ordinal != 0) { WORD hint = 0; std::string func_name; if (IMAGE_SNAP_BY_ORDINAL32(othunk->u1.Ordinal)) { func_name = UNONE::StrFormatA("Ordinal: %08X", othunk->u1.Ordinal & (~IMAGE_ORDINAL_FLAG32)); } else { PIMAGE_IMPORT_BY_NAME imp_name = (PIMAGE_IMPORT_BY_NAME)(pe_image_ + othunk->u1.AddressOfData); func_name = (LPCSTR)(imp_name->Name); hint = imp_name->Hint; } InitTableItem(imp_func_model_); AppendTableItem(imp_func_model_, DWordToHexQ(othunk->u1.Ordinal)); AppendTableItem(imp_func_model_, DWordToHexQ(othunk->u1.Ordinal)); AppendTableItem(imp_func_model_, DWordToHexQ(othunk->u1.Ordinal)); AppendTableItem(imp_func_model_, DWordToHexQ(othunk->u1.Ordinal)); AppendTableItem(imp_func_model_, WordToHexQ(hint)); AppendTableItem(imp_func_model_, StrToQ(func_name)); fthunk++; othunk++; } } imp++; } } void Scanner::onRelocChanged(const QModelIndex &current, const QModelIndex &previous) { ClearItemModelData(reloc_item_model_); int row = GetCurViewRow(ui.relocView); PIMAGE_BASE_RELOCATION reloc = (PIMAGE_BASE_RELOCATION)UNONE::PeGetDataEntity(IMAGE_DIRECTORY_ENTRY_BASERELOC, pe_image_); if (!reloc) return; PIMAGE_DATA_DIRECTORY dir = UNONE::PeGetDataDirectory(IMAGE_DIRECTORY_ENTRY_BASERELOC, pe_image_); DWORD reloc_size = dir->Size; DWORD reloc_rva = dir->VirtualAddress; DWORD item_size = 0; int idx = 0; while (item_size < reloc_size) { DWORD itemcnt = (reloc->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(USHORT); PUSHORT items = (PUSHORT)(reloc + 1); if (idx++ == row) { for (int i = 0; i < itemcnt; i++) { USHORT offset = items[i] & 0xFFF; DWORD rva = reloc->VirtualAddress + offset; CHAR *type = NULL; switch (items[i] >> 12) { case IMAGE_REL_BASED_ABSOLUTE: type = "IMAGE_REL_BASED_ABSOLUTE"; break; case IMAGE_REL_BASED_HIGHLOW: type = "IMAGE_REL_BASED_HIGHLOW"; break; case IMAGE_REL_BASED_HIGH: type = "IMAGE_REL_BASED_HIGH"; break; case IMAGE_REL_BASED_LOW: type = "IMAGE_REL_BASED_LOW"; break; case IMAGE_REL_BASED_HIGHADJ: type = "IMAGE_REL_BASED_HIGHADJ"; break; case IMAGE_REL_BASED_DIR64: type = "IMAGE_REL_BASED_DIR64"; break; default: type = "IMAGE_REL_BASED_UNKNOWN"; break; } InitTableItem(reloc_item_model_); AppendTableItem(reloc_item_model_, DWordToHexQ(items[i])); AppendTableItem(reloc_item_model_, DWordToHexQ(rva)); AppendTableItem(reloc_item_model_, CharsToQ(type)); } break; } item_size += reloc->SizeOfBlock; reloc = (PIMAGE_BASE_RELOCATION)(pe_image_ + reloc_rva + item_size); } } void Scanner::onExpandAll() { ExpandTreeView(ui.headersView->currentIndex(), ui.headersView); } void Scanner::onTextChanged(const QString& text) { QLineEdit* sender = qobject_cast<QLineEdit*>(QObject::sender()); auto SetEditValue = [&](QLineEdit* edit, int64_t val){ if (sender != edit) edit->setText(StrToQ(UNONE::StrFormatA("%llX", val))); }; auto GetEditValue = [](QLineEdit* edit) { return UNONE::StrToHex64A(edit->text().toStdString()); }; try { std::string str = sender->text().toStdString(); auto InputFilter = [&](std::string& input) { UNONE::StrReplaceA(input, "-"); UNONE::StrReplaceA(input, " "); UNONE::StrReplaceA(input, "0x"); UNONE::StrReplaceA(input, "h"); UNONE::StrReplaceA(input, "\\x"); UNONE::StrReplaceA(input, "`"); input = UNONE::StrTrimLeftA(input, "0"); UNONE::StrUpperA(input); sender->setText(StrToQ(input)); }; InputFilter(str); std::unique_lock<std::mutex> guard(upt_mutex_, std::try_to_lock); if (!guard.owns_lock()) return; int64_t hex = UNONE::StrToHex64A(str); int64_t base, va, reva, rva, raw; if (sender == ui.baseEdit) { va = hex + GetEditValue(ui.revaEdit) - GetEditValue(ui.rebaseEdit); SetEditValue(ui.vaEdit, va); } else if (sender == ui.vaEdit) { __va: reva = hex - GetEditValue(ui.baseEdit) + GetEditValue(ui.rebaseEdit); SetEditValue(ui.revaEdit, reva); rva = hex - GetEditValue(ui.baseEdit); SetEditValue(ui.rvaEdit, rva); hex = rva; goto __rva; } else if (sender == ui.rebaseEdit) { reva = GetEditValue(ui.vaEdit) - GetEditValue(ui.baseEdit) + hex; SetEditValue(ui.revaEdit, reva); hex = reva; goto __reva; } else if (sender == ui.revaEdit) { __reva: va = hex - GetEditValue(ui.rebaseEdit) + GetEditValue(ui.baseEdit); SetEditValue(ui.vaEdit, va); hex = va; goto __va; } else if (sender == ui.rvaEdit) { __rva: va = hex + GetEditValue(ui.baseEdit); SetEditValue(ui.vaEdit, va); reva = va - GetEditValue(ui.baseEdit) + GetEditValue(ui.rebaseEdit); SetEditValue(ui.revaEdit, reva); if (pe_image_) { raw = UNONE::PeRvaToRaw(pe_image_, hex); SetEditValue(ui.rawEdit, raw); } hex = raw; goto __raw; } else if (sender == ui.rawEdit) { __raw: if (pe_image_) { rva = UNONE::PeRawToRva(pe_image_, hex); if (rva != 0) { SetEditValue(ui.rvaEdit, rva); hex = rva + GetEditValue(ui.baseEdit); /* if (va != hex) goto __va;*/ } } } } catch (...) { } } void Scanner::onTabChanged(int index) { CommonMainTabObject::onTabChanged(index); } void Scanner::onOpenFile(const QString& file) { if (file.isEmpty()) { ERR(tr("file path is empty").toStdWString().c_str()); return; } bool pe_valid = false; std::wstring path = file.toStdWString(); pe_file_ = file; if (pe_image_) UnmapPe(); if (MapPe(path)) pe_valid = true; RefreshSummary(path); if (!pe_valid) return; RefreshHeaders(); RefreshSections(); RefreshImport(); RefreshExport(); RefreshResource(); RefreshRelocation(); RefreshDebug(); RefreshRva(); } void Scanner::onRefresh() { onOpenFile(pe_file_); } std::wstring Scanner::GuessFileType() { if (!pe_image_) return PE_UNKNOWN_FILE; std::wstring filetype; if (UNONE::PeX64(pe_image_)) { filetype.append(PE_FILE64); } else { filetype.append(PE_FILE32); } return filetype.empty() ? PE_UNKNOWN_FILE : filetype; } bool Scanner::CheckIsPe() { return pe_valid_; } bool Scanner::MapPe(const std::wstring& path) { pe_valid_ = false; pe_image_ = UNONE::PeMapImageByPathW(path); if (!pe_image_) return false; pe_valid_ = UNONE::PeValid(pe_image_) == TRUE; pe_x64_ = UNONE::PeX64(pe_image_) == TRUE; return true; } bool Scanner::UnmapPe() { bool ret = UNONE::PeUnmapImage(pe_image_); pe_image_ = NULL; ClearItemModelData(sumup_model_); ClearItemModelData(sumdown_model_); ClearItemModelData(headers_model_); ClearItemModelData(sections_model_); ClearItemModelData(imp_model_); ClearItemModelData(imp_func_model_); ClearItemModelData(exp_model_); ClearItemModelData(exp_func_model_); ClearItemModelData(reloc_model_); ClearItemModelData(reloc_item_model_); ClearItemModelData(dbg_model_); return ret; } void Scanner::RefreshSummary(const std::wstring& path) { int up_seq = 0, down_seq = 0; double kbytes, mbytes; DWORD64 size; UNONE::FsGetFileSizeW(path, (DWORD64&)size); kbytes = size / 1024; mbytes = kbytes / 1024; std::wstring formed = UNONE::StrFormatW(L"%.2f MB | %.2f KB | %d B", mbytes, kbytes, size); auto AddSummaryUpItem = [&](QString name, QString value) { sumup_model_->setItem(up_seq, 0, new QStandardItem(name)); sumup_model_->setItem(up_seq, 1, new QStandardItem(value)); up_seq++; }; auto AddSummaryDownItem = [&](QString name, QString value) { sumdown_model_->setItem(down_seq, 0, new QStandardItem(name)); sumdown_model_->setItem(down_seq, 1, new QStandardItem(value)); down_seq++; }; auto std_path = WStrToQ(UNONE::FsPathStandardW(path)); sumup_model_->setItem(up_seq, 0, new QStandardItem(tr("File Path"))); sumup_model_->setItem(up_seq, 1, new QStandardItem(LoadIcon(std_path), std_path)); up_seq++; AddSummaryUpItem(tr("File Type"), WStrToQ(GuessFileType())); AddSummaryUpItem(tr("File Size"), WStrToQ(formed)); LONGLONG create_tm, access_tm, modify_tm; UNONE::FsGetFileTimeW(path, &create_tm, &access_tm, &modify_tm); AddSummaryUpItem(tr("Created Time"), MsToTime(create_tm)); AddSummaryUpItem(tr("Modified Time"), MsToTime(access_tm)); AddSummaryUpItem(tr("Accessed Time"), MsToTime(modify_tm)); auto &&temp = UNONE::StrToA(path); auto crc32 = Cryptor::GetCRC32ByFile(temp); auto md5 = UNONE::StrStreamToHexStrA(Cryptor::GetMD5ByFile(temp)); auto sha1 = UNONE::StrStreamToHexStrA(Cryptor::GetSHA1ByFile(temp)); AddSummaryUpItem(tr("CRC32"), StrToQ(UNONE::StrFormatA("%08x", crc32))); AddSummaryUpItem(tr("MD5"), StrToQ(md5)); AddSummaryUpItem(tr("SHA1"), StrToQ(sha1)); if (!CheckIsPe()) return; std::wstring file_ver, prod_ver, prod_name, cright, origin, inner, corp, desc; UNONE::FsGetFileInfoW(path, L"FileVersion", file_ver); UNONE::FsGetFileInfoW(path, L"ProductVersion", prod_ver); UNONE::FsGetFileInfoW(path, L"ProductName", prod_name); UNONE::FsGetFileInfoW(path, L"LegalCopyright", cright); UNONE::FsGetFileInfoW(path, L"OriginalFileName", origin); UNONE::FsGetFileInfoW(path, L"InternalName", inner); UNONE::FsGetFileInfoW(path, L"CompanyName", corp); UNONE::FsGetFileInfoW(path, L"FileDescription", desc); AddSummaryUpItem(tr("File Version"), WStrToQ(file_ver)); AddSummaryUpItem(tr("ProductVersion"), WStrToQ(prod_ver)); AddSummaryUpItem(tr("ProductName"), WStrToQ(prod_name)); AddSummaryUpItem(tr("LegalCopyright"), WStrToQ(cright)); AddSummaryUpItem(tr("OriginalFileName"), WStrToQ(origin)); AddSummaryUpItem(tr("InternalName"), WStrToQ(inner)); AddSummaryUpItem(tr("CompanyName"), WStrToQ(corp)); AddSummaryUpItem(tr("FileDescription"), WStrToQ(desc)); std::wstring pdb, cptime, cpver; pdb = UNONE::StrToW(UNONE::PeGetPdb(pe_image_)); cptime = UNONE::TmFormatUnixTimeW((time_t)PE_NT_HEADER(pe_image_)->FileHeader.TimeDateStamp, L"Y-M-D H:W:S"); DWORD link_major, link_minor; if (UNONE::PeX64(pe_image_)) { AddSummaryDownItem(tr("ImageBase"), QWordToHexQ(PE_OPT_HEADER64(pe_image_)->ImageBase)); AddSummaryDownItem(tr("ImageSize"), DWordToHexQ(PE_OPT_HEADER64(pe_image_)->SizeOfImage)); AddSummaryDownItem(tr("OEP"), DWordToHexQ(PE_OPT_HEADER64(pe_image_)->AddressOfEntryPoint)); link_major = PE_OPT_HEADER64(pe_image_)->MajorLinkerVersion; link_minor = PE_OPT_HEADER64(pe_image_)->MinorLinkerVersion; } else { AddSummaryDownItem(tr("ImageBase"), DWordToHexQ(PE_OPT_HEADER32(pe_image_)->ImageBase)); AddSummaryDownItem(tr("ImageSize"), DWordToHexQ(PE_OPT_HEADER32(pe_image_)->SizeOfImage)); AddSummaryDownItem(tr("OEP"), DWordToHexQ(PE_OPT_HEADER32(pe_image_)->AddressOfEntryPoint)); link_major = PE_OPT_HEADER32(pe_image_)->MajorLinkerVersion; link_minor = PE_OPT_HEADER32(pe_image_)->MinorLinkerVersion; } struct { int major; int minor; wchar_t* info; } linkers[] = { { 5, -1, L"vc50 (5.0)" }, { 6, -1, L"vc60 (6.0)" }, { 7, -1, L"vc70 (2003)" }, { 8, -1, L"vc80 (2005)" }, { 9, -1, L"vc90 (2008)" }, { 10, -1, L"vc100 (2010)" }, { 11, -1, L"vc110 (2012)" }, { 12, -1, L"vc120 (2013)" }, { 14, 0, L"vc140 (2015)" }, { 14, 0x10, L"vc141 (2017)" }, { 14, 0x10, L"vc142 (2019)" }, }; cpver = UNONE::StrFormatW(L"vc%d%d (unknown)", link_major, link_minor); for (int i = 0; i < _countof(linkers); i++) { if (linkers[i].major == link_major && (linkers[i].minor == link_minor || linkers[i].minor == -1)) { cpver = linkers[i].info; break; } } AddSummaryDownItem(tr("Linker"), WStrToQ(cpver)); AddSummaryDownItem(tr("CompileTime"), WStrToQ(cptime)); AddSummaryDownItem(tr("PDB File"), WStrToQ(pdb)); std::vector<UNONE::CertInfoW> infos; std::wstring sign, sn; bool ret = UNONE::SeGetCertInfoW(path, infos); if (!ret) { DWORD err = GetLastError(); UNONE::StrFormatW(sign, L"%X %s", err, UNONE::OsDosErrorMsgW(err).c_str()); } else { sign = infos[0].owner; sn = infos[0].sn; } AddSummaryDownItem(tr("Cert Owner"), WStrToQ(sign)); AddSummaryDownItem(tr("Cert SN"), WStrToQ(sn)); } void Scanner::RefreshHeaders() { int row = 0; QStandardItem *item, *value; auto dos_item = new QStandardItem("IMAGE_DOS_HEADER"); headers_model_->appendRow(dos_item); PIMAGE_DOS_HEADER dos_hdr = PE_DOS_HEADER(pe_image_); AppendTreeItem(dos_item, "e_magic", WordToHexQ(dos_hdr->e_magic)); AppendTreeItem(dos_item, "e_cblp", WordToHexQ(dos_hdr->e_cblp)); AppendTreeItem(dos_item, "e_cp", WordToHexQ(dos_hdr->e_cp)); AppendTreeItem(dos_item, "e_crlc", WordToHexQ(dos_hdr->e_crlc)); AppendTreeItem(dos_item, "e_cparhdr", WordToHexQ(dos_hdr->e_cparhdr)); AppendTreeItem(dos_item, "e_minalloc", WordToHexQ(dos_hdr->e_minalloc)); AppendTreeItem(dos_item, "e_maxalloc", WordToHexQ(dos_hdr->e_maxalloc)); AppendTreeItem(dos_item, "e_ss", WordToHexQ(dos_hdr->e_ss)); AppendTreeItem(dos_item, "e_sp", WordToHexQ(dos_hdr->e_sp)); AppendTreeItem(dos_item, "e_csum", WordToHexQ(dos_hdr->e_csum)); AppendTreeItem(dos_item, "e_ip", WordToHexQ(dos_hdr->e_ip)); AppendTreeItem(dos_item, "e_cs", WordToHexQ(dos_hdr->e_cs)); AppendTreeItem(dos_item, "e_lfarlc", WordToHexQ(dos_hdr->e_lfarlc)); AppendTreeItem(dos_item, "e_ovno", WordToHexQ(dos_hdr->e_ovno)); AppendTreeItem(dos_item, "e_res", WordArrayToHexQ(dos_hdr->e_res, 4)); AppendTreeItem(dos_item, "e_oemid", WordToHexQ(dos_hdr->e_oemid)); AppendTreeItem(dos_item, "e_oeminfo", WordToHexQ(dos_hdr->e_oeminfo)); AppendTreeItem(dos_item, "e_res2", WordArrayToHexQ(dos_hdr->e_res2, 10)); AppendTreeItem(dos_item, "e_lfanew", DWordToHexQ(dos_hdr->e_lfanew)); row = 0; auto nt_item = new QStandardItem(pe_x64_ ? "IMAGE_NT_HEADERS64":"IMAGE_FILE_HEADER32"); headers_model_->appendRow(nt_item); PIMAGE_NT_HEADERS nt_hdr = PE_NT_HEADER(pe_image_); AppendTreeItem(nt_item, "Signature", DWordToHexQ(nt_hdr->Signature)); PIMAGE_FILE_HEADER file_hdr = &nt_hdr->FileHeader; auto file_item = new QStandardItem("FileHeader"); nt_item->appendRow(file_item); nt_item->setChild(row++, 1, new QStandardItem("IMAGE_FILE_HEADER")); row = 0; AppendTreeItem(file_item, "Machine", WordToHexQ(file_hdr->Machine)); AppendTreeItem(file_item, "NumberOfSections", WordToHexQ(file_hdr->NumberOfSections)); AppendTreeItem(file_item, "TimeDateStamp", DWordToHexQ(file_hdr->TimeDateStamp)); AppendTreeItem(file_item, "PointerToSymbolTable", DWordToHexQ(file_hdr->PointerToSymbolTable)); AppendTreeItem(file_item, "NumberOfSymbols", DWordToHexQ(file_hdr->NumberOfSymbols)); AppendTreeItem(file_item, "SizeOfOptionalHeader", WordToHexQ(file_hdr->SizeOfOptionalHeader)); AppendTreeItem(file_item, "Characteristics", WordToHexQ(file_hdr->Characteristics)); PIMAGE_OPTIONAL_HEADER32 opt_hdr32; PIMAGE_OPTIONAL_HEADER64 opt_hdr64; char* opt_title; if (pe_x64_) { opt_title = "IMAGE_FILE_HEADER64"; opt_hdr64 = PE_OPT_HEADER64(pe_image_); } else { opt_title = "IMAGE_FILE_HEADER32"; opt_hdr32 = PE_OPT_HEADER32(pe_image_); } row = 0; auto opt_item = new QStandardItem("OptionalHeader"); nt_item->appendRow(opt_item); nt_item->setChild(2, 1, new QStandardItem(opt_title)); if (pe_x64_) { AppendTreeItem(opt_item, "Magic", WordToHexQ(opt_hdr64->Magic)); AppendTreeItem(opt_item, "MajorLinkerVersion", ByteToHexQ(opt_hdr64->MajorLinkerVersion)); AppendTreeItem(opt_item, "MinorLinkerVersion", ByteToHexQ(opt_hdr64->MinorLinkerVersion)); AppendTreeItem(opt_item, "SizeOfCode", DWordToHexQ(opt_hdr64->SizeOfCode)); AppendTreeItem(opt_item, "SizeOfInitializedData", DWordToHexQ(opt_hdr64->SizeOfInitializedData)); AppendTreeItem(opt_item, "SizeOfUninitializedData", DWordToHexQ(opt_hdr64->SizeOfUninitializedData)); AppendTreeItem(opt_item, "AddressOfEntryPoint", DWordToHexQ(opt_hdr64->AddressOfEntryPoint)); AppendTreeItem(opt_item, "BaseOfCode", DWordToHexQ(opt_hdr64->BaseOfCode)); AppendTreeItem(opt_item, "ImageBase", QWordToHexQ(opt_hdr64->ImageBase)); AppendTreeItem(opt_item, "SectionAlignment", DWordToHexQ(opt_hdr64->SectionAlignment)); AppendTreeItem(opt_item, "FileAlignment", DWordToHexQ(opt_hdr64->FileAlignment)); AppendTreeItem(opt_item, "MajorOperatingSystemVersion", WordToHexQ(opt_hdr64->MajorOperatingSystemVersion)); AppendTreeItem(opt_item, "MinorOperatingSystemVersion", WordToHexQ(opt_hdr64->MinorOperatingSystemVersion)); AppendTreeItem(opt_item, "MajorImageVersion", WordToHexQ(opt_hdr64->MajorImageVersion)); AppendTreeItem(opt_item, "MinorImageVersion", WordToHexQ(opt_hdr64->MinorImageVersion)); AppendTreeItem(opt_item, "MajorSubsystemVersion", WordToHexQ(opt_hdr64->MajorSubsystemVersion)); AppendTreeItem(opt_item, "MinorSubsystemVersion", WordToHexQ(opt_hdr64->MinorSubsystemVersion)); AppendTreeItem(opt_item, "Win32VersionValue", DWordToHexQ(opt_hdr64->Win32VersionValue)); AppendTreeItem(opt_item, "SizeOfImage", DWordToHexQ(opt_hdr64->SizeOfImage)); AppendTreeItem(opt_item, "SizeOfHeaders", DWordToHexQ(opt_hdr64->SizeOfHeaders)); AppendTreeItem(opt_item, "CheckSum", DWordToHexQ(opt_hdr64->CheckSum)); AppendTreeItem(opt_item, "Subsystem", WordToHexQ(opt_hdr64->Subsystem)); AppendTreeItem(opt_item, "DllCharacteristics", WordToHexQ(opt_hdr64->DllCharacteristics)); AppendTreeItem(opt_item, "SizeOfStackReserve", QWordToHexQ(opt_hdr64->SizeOfStackReserve)); AppendTreeItem(opt_item, "SizeOfStackCommit", QWordToHexQ(opt_hdr64->SizeOfStackCommit)); AppendTreeItem(opt_item, "SizeOfHeapReserve", QWordToHexQ(opt_hdr64->SizeOfHeapReserve)); AppendTreeItem(opt_item, "SizeOfHeapCommit", QWordToHexQ(opt_hdr64->SizeOfHeapCommit)); AppendTreeItem(opt_item, "LoaderFlags", DWordToHexQ(opt_hdr64->LoaderFlags)); AppendTreeItem(opt_item, "NumberOfRvaAndSizes", DWordToHexQ(opt_hdr64->NumberOfRvaAndSizes)); } else { AppendTreeItem(opt_item, "Magic", WordToHexQ(opt_hdr32->Magic)); AppendTreeItem(opt_item, "MajorLinkerVersion", ByteToHexQ(opt_hdr32->MajorLinkerVersion)); AppendTreeItem(opt_item, "MinorLinkerVersion", ByteToHexQ(opt_hdr32->MinorLinkerVersion)); AppendTreeItem(opt_item, "SizeOfCode", DWordToHexQ(opt_hdr32->SizeOfCode)); AppendTreeItem(opt_item, "SizeOfInitializedData", DWordToHexQ(opt_hdr32->SizeOfInitializedData)); AppendTreeItem(opt_item, "SizeOfUninitializedData", DWordToHexQ(opt_hdr32->SizeOfUninitializedData)); AppendTreeItem(opt_item, "AddressOfEntryPoint", DWordToHexQ(opt_hdr32->AddressOfEntryPoint)); AppendTreeItem(opt_item, "BaseOfCode", DWordToHexQ(opt_hdr32->BaseOfCode)); AppendTreeItem(opt_item, "BaseOfData", DWordToHexQ(opt_hdr32->BaseOfData)); AppendTreeItem(opt_item, "ImageBase", DWordToHexQ(opt_hdr32->ImageBase)); AppendTreeItem(opt_item, "SectionAlignment", DWordToHexQ(opt_hdr32->SectionAlignment)); AppendTreeItem(opt_item, "FileAlignment", DWordToHexQ(opt_hdr32->FileAlignment)); AppendTreeItem(opt_item, "MajorOperatingSystemVersion", WordToHexQ(opt_hdr32->MajorOperatingSystemVersion)); AppendTreeItem(opt_item, "MinorOperatingSystemVersion", WordToHexQ(opt_hdr32->MinorOperatingSystemVersion)); AppendTreeItem(opt_item, "MajorImageVersion", WordToHexQ(opt_hdr32->MajorImageVersion)); AppendTreeItem(opt_item, "MinorImageVersion", WordToHexQ(opt_hdr32->MinorImageVersion)); AppendTreeItem(opt_item, "MajorSubsystemVersion", WordToHexQ(opt_hdr32->MajorSubsystemVersion)); AppendTreeItem(opt_item, "MinorSubsystemVersion", WordToHexQ(opt_hdr32->MinorSubsystemVersion)); AppendTreeItem(opt_item, "Win32VersionValue", DWordToHexQ(opt_hdr32->Win32VersionValue)); AppendTreeItem(opt_item, "SizeOfImage", DWordToHexQ(opt_hdr32->SizeOfImage)); AppendTreeItem(opt_item, "SizeOfHeaders", DWordToHexQ(opt_hdr32->SizeOfHeaders)); AppendTreeItem(opt_item, "CheckSum", DWordToHexQ(opt_hdr32->CheckSum)); AppendTreeItem(opt_item, "Subsystem", WordToHexQ(opt_hdr32->Subsystem)); AppendTreeItem(opt_item, "DllCharacteristics", WordToHexQ(opt_hdr32->DllCharacteristics)); AppendTreeItem(opt_item, "SizeOfStackReserve", DWordToHexQ(opt_hdr32->SizeOfStackReserve)); AppendTreeItem(opt_item, "SizeOfStackCommit", DWordToHexQ(opt_hdr32->SizeOfStackCommit)); AppendTreeItem(opt_item, "SizeOfHeapReserve", DWordToHexQ(opt_hdr32->SizeOfHeapReserve)); AppendTreeItem(opt_item, "SizeOfHeapCommit", DWordToHexQ(opt_hdr32->SizeOfHeapCommit)); AppendTreeItem(opt_item, "LoaderFlags", DWordToHexQ(opt_hdr32->LoaderFlags)); AppendTreeItem(opt_item, "NumberOfRvaAndSizes", DWordToHexQ(opt_hdr32->NumberOfRvaAndSizes)); } auto dir_item = new QStandardItem("DataDirectory[]"); opt_item->appendRow(dir_item); opt_item->setChild(row++, 1, new QStandardItem("IMAGE_DATA_DIRECTORY")); QStandardItem* subdir_item; PIMAGE_DATA_DIRECTORY dir; struct {char* name; int value;} dir_arr[] = { "IMAGE_DIRECTORY_ENTRY_EXPORT", IMAGE_DIRECTORY_ENTRY_EXPORT, "IMAGE_DIRECTORY_ENTRY_IMPORT", IMAGE_DIRECTORY_ENTRY_IMPORT, "IMAGE_DIRECTORY_ENTRY_RESOURCE", IMAGE_DIRECTORY_ENTRY_RESOURCE, "IMAGE_DIRECTORY_ENTRY_EXCEPTION", IMAGE_DIRECTORY_ENTRY_EXCEPTION, "IMAGE_DIRECTORY_ENTRY_SECURITY", IMAGE_DIRECTORY_ENTRY_SECURITY, "IMAGE_DIRECTORY_ENTRY_BASERELOC", IMAGE_DIRECTORY_ENTRY_BASERELOC, "IMAGE_DIRECTORY_ENTRY_DEBUG", IMAGE_DIRECTORY_ENTRY_DEBUG, "IMAGE_DIRECTORY_ENTRY_ARCHITECTURE", IMAGE_DIRECTORY_ENTRY_ARCHITECTURE, "IMAGE_DIRECTORY_ENTRY_GLOBALPTR", IMAGE_DIRECTORY_ENTRY_GLOBALPTR, "IMAGE_DIRECTORY_ENTRY_TLS", IMAGE_DIRECTORY_ENTRY_TLS, "IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG", IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG, "IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT", IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT, "IMAGE_DIRECTORY_ENTRY_IAT", IMAGE_DIRECTORY_ENTRY_IAT, "IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT", IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT, "IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR", IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR }; for (int i = 0; i < _countof(dir_arr); i++) { row = 0; subdir_item = new QStandardItem(dir_arr[i].name); dir_item->appendRow(subdir_item); dir_item->setChild(dir_arr[i].value, 1, new QStandardItem(StrToQ(UNONE::StrFormatA("%d", dir_arr[i].value)))); dir = UNONE::PeGetDataDirectory(dir_arr[i].value, pe_image_); AppendTreeItem(subdir_item, "VirtualAddress",DWordToHexQ(dir->VirtualAddress)); AppendTreeItem(subdir_item, "Size", DWordToHexQ(dir->Size)); } } void Scanner::RefreshSections() { PIMAGE_NT_HEADERS nt_header = PE_NT_HEADER(pe_image_); PIMAGE_SECTION_HEADER header = IMAGE_FIRST_SECTION(nt_header); for (DWORD i = 0; i < nt_header->FileHeader.NumberOfSections; i++) { char name[IMAGE_SIZEOF_SHORT_NAME+1] = { 0 }; memcpy(name, header->Name, IMAGE_SIZEOF_SHORT_NAME); InitTableItem(sections_model_); AppendTableItem(sections_model_, CharsToQ(name)); AppendTableItem(sections_model_, DWordToHexQ(header->Misc.VirtualSize)); AppendTableItem(sections_model_, DWordToHexQ(header->VirtualAddress)); AppendTableItem(sections_model_, DWordToHexQ(header->SizeOfRawData)); AppendTableItem(sections_model_, DWordToHexQ(header->PointerToRawData)); AppendTableItem(sections_model_, DWordToHexQ(header->PointerToRelocations)); AppendTableItem(sections_model_, DWordToHexQ(header->PointerToLinenumbers)); AppendTableItem(sections_model_, DWordToHexQ(header->NumberOfRelocations)); AppendTableItem(sections_model_, DWordToHexQ(header->NumberOfLinenumbers)); AppendTableItem(sections_model_, DWordToHexQ(header->Characteristics)); header++; } } void Scanner::RefreshImport() { auto imp = (PIMAGE_IMPORT_DESCRIPTOR)UNONE::PeGetDataEntity(IMAGE_DIRECTORY_ENTRY_IMPORT, pe_image_); if (!imp) return; while (imp->Name != 0) { InitTableItem(imp_model_); AppendTableItem(imp_model_, CharsToQ(pe_image_ + imp->Name)); AppendTableItem(imp_model_, DWordToHexQ(imp->OriginalFirstThunk)); AppendTableItem(imp_model_, DWordToHexQ(imp->TimeDateStamp)); AppendTableItem(imp_model_, DWordToHexQ(imp->ForwarderChain)); AppendTableItem(imp_model_, DWordToHexQ(imp->FirstThunk)); imp++; } } void Scanner::RefreshExport() { #define AppendExpKvItem(key, value) \ item = new QStandardItem(key); \ count = exp_model_->rowCount();\ exp_model_->setItem(count, 0, item); \ item = new QStandardItem(value); \ exp_model_->setItem(count, 1, item); int row = 0, count = 0; QStandardItem *item; auto exp = (PIMAGE_EXPORT_DIRECTORY)UNONE::PeGetDataEntity(IMAGE_DIRECTORY_ENTRY_EXPORT, pe_image_); if (!exp) return; AppendExpKvItem("Characteristics", DWordToHexQ(exp->Characteristics)); AppendExpKvItem("TimeDateStamp", DWordToHexQ(exp->TimeDateStamp)); AppendExpKvItem("MajorVersion", WordToHexQ(exp->MajorVersion)); AppendExpKvItem("MinorVersion", WordToHexQ(exp->MinorVersion)); AppendExpKvItem("Name", DWordToHexQ(exp->Name)); AppendExpKvItem("Base", DWordToHexQ(exp->Base)); AppendExpKvItem("NumberOfFunctions", DWordToHexQ(exp->NumberOfFunctions)); AppendExpKvItem("NumberOfNames", DWordToHexQ(exp->NumberOfNames)); AppendExpKvItem("AddressOfFunctions", DWordToHexQ(exp->AddressOfFunctions)); AppendExpKvItem("AddressOfNames", DWordToHexQ(exp->AddressOfNames)); AppendExpKvItem("AddressOfNameOrdinals", DWordToHexQ(exp->AddressOfNameOrdinals)); PIMAGE_DATA_DIRECTORY dir = UNONE::PeGetDataDirectory(IMAGE_DIRECTORY_ENTRY_EXPORT, pe_image_); PDWORD addr_names = (PDWORD)(exp->AddressOfNames + pe_image_); if (!UNONE::PeRegionValid(pe_image_, addr_names)) return; PDWORD addr_funcs = (PDWORD)(exp->AddressOfFunctions + pe_image_); if (!UNONE::PeRegionValid(pe_image_, addr_funcs)) return; PWORD addr_ordinals = (PWORD)(exp->AddressOfNameOrdinals + pe_image_); if (!UNONE::PeRegionValid(pe_image_, addr_ordinals)) return; DWORD cnt_names = exp->NumberOfNames; DWORD cnt_ordinals = exp->NumberOfFunctions; DWORD base_ordinal = exp->Base; for (DWORD i = 0; i < cnt_names; i++) { DWORD idx = addr_ordinals[i]; DWORD func_addr = addr_funcs[idx]; CHAR* func_name = pe_image_ + addr_names[i]; InitTableItem2(exp_func_model_, exp_func_model_->rowCount()); AppendTableItem(exp_func_model_, DWordToHexQ(func_addr)); AppendTableItem(exp_func_model_, DWordToHexQ(idx)); AppendTableItem(exp_func_model_, CharsToQ(func_name)); } } void Scanner::RefreshResource() { } void Scanner::RefreshRelocation() { auto reloc = (PIMAGE_BASE_RELOCATION)UNONE::PeGetDataEntity(IMAGE_DIRECTORY_ENTRY_BASERELOC, pe_image_); if (!reloc) return; PIMAGE_DATA_DIRECTORY dir = UNONE::PeGetDataDirectory(IMAGE_DIRECTORY_ENTRY_BASERELOC, pe_image_); DWORD reloc_size = dir->Size; DWORD reloc_rva = dir->VirtualAddress; DWORD item_size = 0; while (item_size < reloc_size) { DWORD itemcnt = (reloc->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(USHORT); InitTableItem(reloc_model_); AppendTableItem(reloc_model_, DWordToHexQ(reloc->VirtualAddress)); AppendTableItem(reloc_model_, DWordToHexQ(reloc->SizeOfBlock)); AppendTableItem(reloc_model_, DWordToDecQ(itemcnt)); item_size += reloc->SizeOfBlock; reloc = (PIMAGE_BASE_RELOCATION)(pe_image_ + reloc_rva + item_size); } } void Scanner::RefreshDebug() { ClearItemModelData(dbg_model_); PIMAGE_DEBUG_DIRECTORY dbg = (PIMAGE_DEBUG_DIRECTORY)UNONE::PeGetDataEntity(IMAGE_DIRECTORY_ENTRY_DEBUG, pe_image_); if (dbg == NULL || dbg->Type != IMAGE_DEBUG_TYPE_CODEVIEW || !dbg->AddressOfRawData || !dbg->SizeOfData) { return; } UNONE::CV_HEADER* cv_hdr = (UNONE::CV_HEADER*)(pe_image_ + dbg->AddressOfRawData); DWORD cv_size = dbg->SizeOfData; if (!UNONE::PeRegionValid(pe_image_, cv_hdr, cv_size)) return; int count = 0; AppendNameValue(dbg_model_, tr("Characteristics"), DWordToHexQ(dbg->Characteristics)); AppendNameValue(dbg_model_, tr("TimeDateStamp"), DWordToHexQ(dbg->TimeDateStamp)); AppendNameValue(dbg_model_, tr("MajorVersion"), WordToHexQ(dbg->MajorVersion)); AppendNameValue(dbg_model_, tr("MinorVersion"), WordToHexQ(dbg->MinorVersion)); AppendNameValue(dbg_model_, tr("Type"), DWordToHexQ(dbg->Type)); AppendNameValue(dbg_model_, tr("SizeOfData"), DWordToHexQ(dbg->SizeOfData)); AppendNameValue(dbg_model_, tr("AddressOfRawData"), DWordToHexQ(dbg->AddressOfRawData)); AppendNameValue(dbg_model_, tr("PointerToRawData"), DWordToHexQ(dbg->PointerToRawData)); PIMAGE_NT_HEADERS nt_hdr = PE_NT_HEADER(pe_image_); PIMAGE_FILE_HEADER file_hdr = &nt_hdr->FileHeader; auto ts = file_hdr->TimeDateStamp; PIMAGE_OPTIONAL_HEADER32 opt_hdr32; PIMAGE_OPTIONAL_HEADER64 opt_hdr64; ULONG imgsize; char* opt_title; if (pe_x64_) imgsize = PE_OPT_HEADER64(pe_image_)->SizeOfImage; else imgsize = PE_OPT_HEADER32(pe_image_)->SizeOfImage; auto imgid = UNONE::StrFormatA("%X%x", ts, imgsize); DWORD age = 0; CHAR *sig = ""; std::string pdb, guidsig, symid; if (cv_hdr->Signature == NB10_SIG) { sig = "NB10"; age = ((UNONE::CV_INFO_PDB20*)cv_hdr)->Age; auto name = (CHAR*)((UNONE::CV_INFO_PDB20*)cv_hdr)->PdbFileName; auto name_size = (DWORD)strlen(name); if (name_size && name_size < MAX_PATH) pdb = name; } else if (cv_hdr->Signature == RSDS_SIG) { sig = "RSDS"; auto name = (CHAR*)((UNONE::CV_INFO_PDB70*)cv_hdr)->PdbFileName; auto name_size = (DWORD)strlen(name); if (name_size && name_size < MAX_PATH) pdb = name; GUID guid = ((UNONE::CV_INFO_PDB70*)cv_hdr)->Signature; age = ((UNONE::CV_INFO_PDB70*)cv_hdr)->Age; guidsig = UNONE::StrFormatA("{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); symid = UNONE::StrFormatA("%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%X", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7], age); pdb = UNONE::StrUTF8ToACP(name); } AppendNameValue(dbg_model_, tr("Signature"), CharsToQ(sig)); AppendNameValue(dbg_model_, tr("Age"), DWordToHexQ(age)); AppendNameValue(dbg_model_, tr("GUID"), StrToQ(guidsig)); AppendNameValue(dbg_model_, tr("ImageID"), StrToQ(imgid)); AppendNameValue(dbg_model_, tr("SymbolID"), StrToQ(symid)); AppendNameValue(dbg_model_, tr("PDB"), WStrToQ(UNONE::StrToW(pdb))); } void Scanner::RefreshRva() { connect(ui.baseEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.rebaseEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.vaEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.revaEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.rvaEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); connect(ui.rawEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); if (pe_x64_) { ULONGLONG base = PE_OPT_HEADER64(pe_image_)->ImageBase; base_prev_ = base; QString basestr = StrToQ(UNONE::StrFormatA("%llX", base)); ui.baseEdit->setText(basestr); ui.vaEdit->setText(basestr); ui.rebaseEdit->setText(basestr); ui.revaEdit->setText(basestr); } else { ULONG base = PE_OPT_HEADER32(pe_image_)->ImageBase; base_prev_ = base; QString basestr = StrToQ(UNONE::StrFormatA("%X", base)); ui.baseEdit->setText(basestr); ui.vaEdit->setText(basestr); ui.rebaseEdit->setText(basestr); ui.revaEdit->setText(basestr); } ui.rvaEdit->setText("0"); ui.rawEdit->setText("0"); }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/scanner/scanner.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <QtGui> #include <QtCore> #include <QtWidgets> #include <QMutex> #include <Windows.h> #include <mutex> #include "ui_scanner.h" #include "../common/ui-wrapper/ui-wrapper.h" namespace Ui { class Scanner; class OpenArkWindow; } class OpenArk; class Scanner : public CommonMainTabObject { Q_OBJECT public: Scanner(QWidget *parent, int tabid); ~Scanner(); protected: bool eventFilter(QObject *obj, QEvent *e); public slots: void onTabChanged(int index); void onOpenFile(const QString& file); void onRefresh(); private slots: void dragEnterEvent(QDragEnterEvent *event); void dragMoveEvent(QDragMoveEvent *event); void dropEvent(QDropEvent *event); void onImportChanged(const QModelIndex &current, const QModelIndex &previous); void onRelocChanged(const QModelIndex &current, const QModelIndex &previous); void onExpandAll(); void onTextChanged(const QString& text); private: std::wstring GuessFileType(); bool CheckIsPe(); void RefreshSummary(const std::wstring& path); void RefreshHeaders(); void RefreshSections(); void RefreshImport(); void RefreshExport(); void RefreshResource(); void RefreshRelocation(); void RefreshDebug(); void RefreshRva(); bool MapPe(const std::wstring& path); bool UnmapPe(); private: Ui::Scanner ui; QString pe_file_; CHAR* pe_image_; bool pe_x64_; bool pe_valid_; QStandardItemModel* sumup_model_; QStandardItemModel* sumdown_model_; QStandardItemModel* headers_model_; QStandardItemModel* sections_model_; QStandardItemModel* imp_model_; QStandardItemModel* imp_func_model_; QStandardItemModel* exp_model_; QStandardItemModel* exp_func_model_; QStandardItemModel* reloc_model_; QStandardItemModel* reloc_item_model_; QStandardItemModel* dbg_model_; QMenu* headers_menu_; int64_t base_prev_; std::mutex upt_mutex_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/settings/settings.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "settings.h" #include "../common/common.h" #include <QMessageBox> bool Settings::eventFilter(QObject *obj, QEvent *e) { if (e->type() == QEvent::KeyPress) { QKeyEvent *keyevt = dynamic_cast<QKeyEvent*>(e); if (keyevt->matches(QKeySequence::Cancel)) { close(); } } return QWidget::eventFilter(obj, e); } void Settings::InitConsoleView() { console_model_ = new QStandardItemModel; console_model_->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("Value")); SetDefaultTableViewStyle(ui.consoleView, console_model_); InitTableItem(console_model_); QString name; name = "History.MaxRecords"; AppendTableRowNameVaule(console_model_, name, OpenArkConfig::Instance()->GetConsole(name)); name = "History.FilePath"; AppendTableRowNameVaule(console_model_, name, OpenArkConfig::Instance()->GetConsole(name)); } void Settings::InitCleanView() { QString clean_file_suffix = ui.edit_file_suffix->text(); ui.edit_file_suffix->setText(OpenArkConfig::Instance()->GetValue("clean_file_suffix").toString()); QStringList path_list = OpenArkConfig::Instance()->GetValue("clean_path_list").toStringList(); for (int i = 0; i < path_list.size(); i++) ui.listWidget_path->addItem(path_list[i]); connect(ui.add_path_btn, &QPushButton::clicked, [this]() { QString folder = QFileDialog::getExistingDirectory(this, tr("Open Folder"), ""); if (folder.isEmpty()) return; QString path = folder.replace("/", "\\"); if (!path.isEmpty()) ui.listWidget_path->addItem(path); }); connect(ui.del_path_btn, &QPushButton::clicked, [this]() { QListWidgetItem *item = ui.listWidget_path->takeItem(ui.listWidget_path->currentRow()); delete item; }); connect(ui.save_btn, &QPushButton::clicked, [this]() { QStringList path_list; for (int i = 0; i < ui.listWidget_path->count(); i++) { QListWidgetItem * item = ui.listWidget_path->item(i); path_list << item->text(); } OpenArkConfig::Instance()->SetValue("clean_file_suffix", ui.edit_file_suffix->text()); OpenArkConfig::Instance()->SetValue("clean_path_list", path_list); QMessageBox::information(NULL, "", tr("Save Success")); }); } void Settings::InitGeneralView() { QString section = "/Setting.General/"; QString ctxkey = section + "context_menu"; auto ctx = OpenArkConfig::Instance()->GetValue(ctxkey, 0).toInt(); connect(ui.ctxmenuBox, &QCheckBox::toggled, [=](bool checked) { const char *subkey = R"(*\shell\OpenArk)"; if (checked) { UNONE::RegistryKey reg; reg.Create(HKEY_CLASSES_ROOT, subkey, KEY_SET_VALUE); reg.WriteValue("CommandFlags", 0x20); reg.WriteValue("ExtendedSubCommandsKey", "OpenArk"); reg.WriteValue("Icon", QToChars(AppFilePath())); reg.WriteValue("MUIVerb", "OpenArk"); reg.Close(); reg.Create(HKEY_CLASSES_ROOT, R"(OpenArk\shell\scan)", KEY_SET_VALUE); reg.WriteValue("CommandFlags", 0x20); reg.WriteValue("", tr("Scan").toLocal8Bit().toStdString()); reg.CreateKey("command", KEY_SET_VALUE); reg.WriteValue("", QToChars(AppFilePath())); reg.Close(); reg.Create(HKEY_CLASSES_ROOT, R"(OpenArk\shell\unlockfile)", KEY_SET_VALUE); reg.WriteValue("CommandFlags", 0x20); reg.WriteValue("", tr("UnlockFile").toLocal8Bit().toStdString()); reg.CreateKey("command", KEY_SET_VALUE); reg.WriteValue("", QToChars(AppFilePath())); reg.Close(); reg.Create(HKEY_CLASSES_ROOT, R"(OpenArk\shell\settings)", KEY_SET_VALUE); reg.WriteValue("CommandFlags", 0x20); reg.WriteValue("", tr("Settings").toLocal8Bit().toStdString()); reg.CreateKey("command", KEY_SET_VALUE); reg.WriteValue("", QToChars(AppFilePath())); reg.Close(); } else { UNONE::RegistryKey::DeleteKey(HKEY_CLASSES_ROOT, subkey); UNONE::RegistryKey::DeleteKey(HKEY_CLASSES_ROOT, "OpenArk"); } OpenArkConfig::Instance()->SetValue(ctxkey, (int)checked); }); ui.ctxmenuBox->setChecked(ctx); } Settings::Settings(QWidget *parent) { ui.setupUi(this); connect(OpenArkLanguage::Instance(), &OpenArkLanguage::languageChaned, this, [this]() {ui.retranslateUi(this); }); setAttribute(Qt::WA_ShowModal, true); setAttribute(Qt::WA_DeleteOnClose); setWindowFlags(windowFlags()& ~(Qt::WindowMaximizeButtonHint| Qt::WindowMinimizeButtonHint)| Qt::MSWindowsFixedSizeDialogHint); installEventFilter(this); InitConsoleView(); InitCleanView(); InitGeneralView(); } Settings::~Settings() { } void Settings::closeEvent(QCloseEvent *e) { QString section = "/Console/"; for (int i = 0; i < console_model_->rowCount(); i++) { auto name = console_model_->item(i, 0)->data(Qt::DisplayRole).toString(); auto value = console_model_->item(i, 1)->data(Qt::DisplayRole); auto key = section + name; OpenArkConfig::Instance()->SetValue(key, value); } OpenArkConfig::Instance()->Sync(); }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/settings/settings.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <QtCore> #include <QtWidgets> #include <Windows.h> #include "ui_settings.h" enum SettingsTabNumber { TAB_SETTINGS_GENERAL, TAB_SETTINGS_CONSOLE, TAB_SETTINGS_CLEAN, }; class Settings : public QWidget { Q_OBJECT public: Settings(QWidget *parent); ~Settings(); void SetActiveTab(int idx) const { ui.tabWidget->setCurrentIndex(idx); }; bool eventFilter(QObject *obj, QEvent *e); protected: void closeEvent(QCloseEvent *e); void InitConsoleView(); void InitCleanView(); void InitGeneralView(); private: Ui::Settings ui; QStandardItemModel *console_model_; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/utilities/utilities.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "utilities.h" #include <common/common.h> #include <openark/openark.h> #include <settings/settings.h> #include <arkdrv-api/arkdrv-api.h> #define MODEL_STRING(model, row, columm) (model->index(row, columm).data(Qt::DisplayRole).toString()) #define RECYCLEBIN "RecycleBin" struct { int s = 0; int dir = s++; int filecnt = s++; int detail = s++; int sumsize = s++; } JUNKS; bool JunksSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto s1 = sourceModel()->data(left); auto s2 = sourceModel()->data(right); auto column = left.column(); if ((column == JUNKS.filecnt || column == JUNKS.sumsize)) return s1.toUInt() < s2.toUInt(); return QString::compare(s1.toString(), s2.toString(), Qt::CaseInsensitive) < 0; } Utilities::Utilities(QWidget *parent, int tabid) : CommonMainTabObject::CommonMainTabObject((OpenArk*)parent), scanjunks_thread_(nullptr), cleanjunks_thread_(nullptr) { ui.setupUi(this); qRegisterMetaType<JunkCluster>("JunkCluster"); InitCleanerView(); InitSystemToolsView(); CommonMainTabObject::Init(ui.tabWidget, tabid); } Utilities::~Utilities() { if (scanjunks_thread_) scanjunks_thread_->terminate(); scanjunks_thread_ = nullptr; } void Utilities::RecordAppServer(const QString &svr) { app_server_ = svr; } void Utilities::onTabChanged(int index) { CommonMainTabObject::onTabChanged(index); } void Utilities::onOpJunkfiles(int op, JunkCluster cluster) { bool existed = false; int rows = junks_model_->rowCount(); int seq = rows; for (int i = 0; i < rows; i++) { if (cluster.dir == MODEL_STRING(junks_model_, i, JUNKS.dir)) { seq = i; existed = true; break; } } auto &items = cluster.items; DWORD64 sumsize = cluster.sumsize; DWORD filecnt = items.size(); if (existed) { if (op == 0) { filecnt += MODEL_STRING(junks_model_, seq, JUNKS.filecnt).toULong(); sumsize += MODEL_STRING(junks_model_, seq, JUNKS.sumsize).toULongLong(); } else { filecnt = MODEL_STRING(junks_model_, seq, JUNKS.filecnt).toULong() - filecnt; sumsize = MODEL_STRING(junks_model_, seq, JUNKS.sumsize).toULongLong() - sumsize; } } QStandardItem *dir_item; if (cluster.dir == RECYCLEBIN) { dir_item = new QStandardItem(QIcon(":/OpenArk/systools/recyclebin.png"), cluster.dir); } else { dir_item = new QStandardItem(LoadIcon(cluster.dir), cluster.dir); } dir_item->setCheckable(true); dir_item->setCheckState(Qt::Checked); QStandardItem *filecnt_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%d", filecnt))); QStandardItem *sumsize_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%lld B", sumsize))); QStandardItem *detail_item; if (sumsize > GB) { detail_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%.2f GB", (double)sumsize / GB))); } else if (sumsize > MB) { detail_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%.2f MB", (double)sumsize / MB))); } else if (sumsize > KB) { detail_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%.2f KB", (double)sumsize/KB))); } else { detail_item = new QStandardItem(WStrToQ(UNONE::StrFormatW(L"%lld Bytes", sumsize))); } junks_model_->setItem(seq, JUNKS.dir, dir_item); junks_model_->setItem(seq, JUNKS.filecnt, filecnt_item); junks_model_->setItem(seq, JUNKS.sumsize, sumsize_item); junks_model_->setItem(seq, JUNKS.detail, detail_item); if (items.size() > 0) { auto path = items.first().path; int maxcnt = 65; int ellipsis = 5; if (path.size() > maxcnt) { int s1 = (maxcnt - ellipsis) / 2; auto p1 = path.mid(0, s1); auto p2 = QString(".").repeated(ellipsis); auto p3 = path.right(s1); path = p1 + p2 + p3; } ui.fileLabel->setText(path); } } void Utilities::onAppendJunkfiles(JunkCluster cluster) { onOpJunkfiles(0, cluster); } void Utilities::onCleanJunkfiles(JunkCluster cluster) { onOpJunkfiles(1, cluster); } void ScanJunksThread::run() { QList<JunkItem> items; auto SendToUI = [&](QString dir, DWORD64 sumsize = 0) { JunkCluster cluster; if (!sumsize) { for (auto &item : items) { sumsize += item.size; } } cluster.dir = dir; cluster.sumsize = sumsize; cluster.items = items; emit appendJunks(cluster); bool existed = false; for (auto &c : junks_cluster_) { if (cluster.dir == c.dir) { c.sumsize = sumsize; c.items.append(items); existed = true; } } if (!existed)junks_cluster_.push_back(cluster); items.clear(); }; std::function<bool(wchar_t*, wchar_t*, void*)> ScanCallback; ScanCallback = [&](wchar_t* path, wchar_t* name, void* param)->bool { if (UNONE::FsIsDirW(path)) { UNONE::FsEnumDirectoryW(path, ScanCallback, param); } JunkItem item; item.name = WCharsToQ(name); item.path = WCharsToQ(path); DWORD64 fsize = 0; UNONE::FsGetFileSizeW(path, fsize); item.size = fsize; items.push_back(item); if (items.size() >= 50) { SendToUI(*(QString*)param); } return true; }; std::function<bool(wchar_t*, wchar_t*, void*)> ScanCallbackCustom; QStringList clear_suffixes_list = custom_suffex_.split(QRegExp("[,;]")); ScanCallbackCustom = [&](wchar_t* path, wchar_t* name, void* param)->bool { if (UNONE::FsIsDirW(path)) { UNONE::FsEnumDirectoryW(path, ScanCallbackCustom, param); } QFileInfo file_info = QFileInfo(WCharsToQ(path)); QString suffix = "." + file_info.suffix(); if (custom_suffex_.isEmpty() || clear_suffixes_list.contains(suffix, Qt::CaseInsensitive)){ JunkItem item; item.name = WCharsToQ(name); item.path = WCharsToQ(path); DWORD64 fsize = 0; UNONE::FsGetFileSizeW(path, fsize); item.size = fsize; items.push_back(item); SendToUI(*(QString*)param); } return true; }; junks_cluster_.clear(); if (is_custom_scan_) { for (int i = 0; i < custom_path_.size(); i++) { SendToUI(custom_path_[i]); UNONE::FsEnumDirectoryW(custom_path_[i].toStdWString(), ScanCallbackCustom, &custom_path_[i]); } } if (is_builtin_scan_) { auto &&junkdirs = OpenArkConfig::Instance()->GetJunkDirs(); for (auto &dir : junkdirs) { if (!UNONE::FsIsExistedW(dir.toStdWString())) continue; UNONE::FsEnumDirectoryW(dir.toStdWString(), ScanCallback, &dir); if (items.size() >= 0) { SendToUI(dir); } } // RecycleBin SHQUERYRBINFO bi; bi.cbSize = sizeof(SHQUERYRBINFO); HRESULT hr = SHQueryRecycleBin(NULL, &bi); if (hr == S_OK) { items.clear(); auto nums = bi.i64NumItems; while (nums--) { JunkItem junk; items.append(junk); } SendToUI(RECYCLEBIN, bi.i64Size); } } } void CleanJunksThread::run() { for (auto &cluster : junks_cluster_) { int cnt = 0; JunkCluster c; c.dir = cluster.dir; c.sumsize = 0; if (cluster.dir == RECYCLEBIN) { auto flags = SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND; SHEmptyRecycleBin(NULL, NULL, flags); continue; } for (auto &item : cluster.items) { bool ret; auto &&path = item.path.toStdWString(); if (UNONE::FsIsDirW(path)) { ret = UNONE::FsDeleteDirectoryW(path); } else { ret = DeleteFileW(path.c_str()); } c.sumsize += item.size; c.items.append(item); if (c.items.size() > 199) { emit cleanJunks(c); c.sumsize = 0; c.items.clear(); } } if (c.items.size() > 0) { emit cleanJunks(c); c.sumsize = 0; c.items.clear(); } } } void Utilities::InitCleanerView() { junks_model_ = new QStandardItemModel; junks_model_->setHorizontalHeaderLabels(QStringList() << tr("Directory") << tr("FileCount") << tr("Detail") << tr("SumSize")); QTreeView *view = ui.junksView; proxy_junks_ = new JunksSortFilterProxyModel(view); proxy_junks_->setSourceModel(junks_model_); proxy_junks_->setDynamicSortFilter(true); proxy_junks_->setFilterKeyColumn(1); view->setModel(proxy_junks_); view->selectionModel()->setModel(proxy_junks_); view->header()->setSortIndicator(-1, Qt::AscendingOrder); view->setSortingEnabled(true); view->viewport()->installEventFilter(this); view->installEventFilter(this); view->setEditTriggers(QAbstractItemView::NoEditTriggers); view->setColumnWidth(JUNKS.dir, 700); view->setColumnWidth(JUNKS.filecnt, 100); view->setColumnWidth(JUNKS.sumsize, 170); connect(ui.settingBtn, &QPushButton::clicked, this, [&] { auto about = new Settings(this); about->raise(); about->SetActiveTab(TAB_SETTINGS_CLEAN); about->show(); }); connect(ui.scanBtn, &QPushButton::clicked, this, [&] { ClearItemModelData(junks_model_); ui.cleanBtn->setEnabled(false); ui.scanBtn->setEnabled(false); ui.statusLabel->setText(tr("[STATUS] Scanning...")); ui.statusLabel->setStyleSheet("color:purple"); if (!scanjunks_thread_) { scanjunks_thread_ = new ScanJunksThread(); connect(scanjunks_thread_, SIGNAL(appendJunks(JunkCluster)), this, SLOT(onAppendJunkfiles(JunkCluster))); connect(scanjunks_thread_, &QThread::finished, this, [&] { ui.cleanBtn->setEnabled(true); ui.scanBtn->setEnabled(true); ui.statusLabel->setText(tr("[STATUS] Scan completed...")); ui.statusLabel->setStyleSheet("color:green"); }); } scanjunks_thread_->is_custom_scan_ = (ui.customScanCheckBox->checkState() == Qt::Checked); scanjunks_thread_->is_builtin_scan_ = (ui.builtinScanCheckBox->checkState() == Qt::Checked); scanjunks_thread_->custom_path_ = OpenArkConfig::Instance()->GetValue("clean_path_list").toStringList(); scanjunks_thread_->custom_suffex_ = OpenArkConfig::Instance()->GetValue("clean_file_suffix").toString(); scanjunks_thread_->start(QThread::NormalPriority); }); connect(ui.cleanBtn, &QPushButton::clicked, this, [&] { ui.cleanBtn->setEnabled(false); ui.scanBtn->setEnabled(false); ui.statusLabel->setText(tr("[STATUS] Cleaning...")); ui.statusLabel->setStyleSheet("color:purple"); if (!cleanjunks_thread_) { cleanjunks_thread_ = new CleanJunksThread(); connect(cleanjunks_thread_, SIGNAL(cleanJunks(JunkCluster)), this, SLOT(onCleanJunkfiles(JunkCluster))); connect(cleanjunks_thread_, &QThread::finished, this, [&] { ui.cleanBtn->setEnabled(true); ui.scanBtn->setEnabled(true); RemoveCleanerItems(); ui.statusLabel->setText(tr("[STATUS] Clean completed...")); ui.statusLabel->setStyleSheet("color:green"); }); } removed_rows_.clear(); QList<JunkCluster> clusters; int rows = junks_model_->rowCount(); for (int i = 0; i < rows; i++) { auto stat = junks_model_->item(i, JUNKS.dir)->checkState(); if (stat == Qt::Checked) { removed_rows_.push_back(i); for (auto &c : scanjunks_thread_->junks_cluster_) { if (c.dir == MODEL_STRING(junks_model_, i, JUNKS.dir)) { clusters.append(c); break; } } } } cleanjunks_thread_->setJunkCluster(clusters); cleanjunks_thread_->start(QThread::NormalPriority); }); } void Utilities::InitSystemToolsView() { ui.hideBtn0->setVisible(false); ui.hideBtn1->setVisible(false); ui.hideBtn2->setVisible(false); ui.hideBtn3->setVisible(false); connect(ui.cmdBtn, &QPushButton::clicked, [] {ShellRun("cmd.exe", "/k cd /d %userprofile%"); }); connect(ui.wslBtn, &QPushButton::clicked, [] {ShellRun("wsl.exe", ""); }); connect(ui.powershellBtn, &QPushButton::clicked, [] {ShellRun("powershell.exe", ""); }); connect(ui.calcBtn, &QPushButton::clicked, [] {ShellRun("calc.exe", ""); }); connect(ui.regeditBtn, &QPushButton::clicked, [] {ShellRun("regedit.exe", ""); }); connect(ui.servicesBtn, &QPushButton::clicked, [] {ShellRun("services.msc", ""); }); connect(ui.taskmgrBtn, &QPushButton::clicked, [] {ShellRun("taskmgr.exe", ""); }); connect(ui.programsBtn, &QPushButton::clicked, [] {ShellRun("control.exe", "appwiz.cpl"); }); connect(ui.envBtn, &QPushButton::clicked, [] {ShellRun("SystemPropertiesAdvanced.exe", ""); }); connect(ui.pcnameBtn, &QPushButton::clicked, [] {ShellRun("SystemPropertiesComputerName.exe", ""); }); connect(ui.fastrebootBtn, &QPushButton::clicked, [&] { if (QMessageBox::warning(this, tr("Warning"), tr("Are you sure to reboot?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { UNONE::OsFastReboot(); } }); connect(ui.fastpoweroffBtn, &QPushButton::clicked, [&] { if (QMessageBox::warning(this, tr("Warning"), tr("Are you sure to poweroff?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { UNONE::OsFastPoweroff(); } }); connect(ui.resetexplorerBtn, &QPushButton::clicked, [&] { auto pid = OsGetExplorerPid(); auto path = UNONE::OsWinDirW() + L"\\explorer.exe"; if (pid != -1) { PsKillProcess(pid); } UNONE::PsCreateProcessW(path); }); connect(ui.killexplorerBtn, &QPushButton::clicked, [&] { auto pid = OsGetExplorerPid(); PsKillProcess(pid); }); connect(ui.sysinfoBtn, &QPushButton::clicked, [] {ShellRun("cmd.exe", "/c systeminfo |more & pause"); }); connect(ui.datetimeBtn, &QPushButton::clicked, [] {ShellRun("control.exe", "date/time"); }); connect(ui.tasksBtn, &QPushButton::clicked, [] {ShellRun("taskschd.msc", "/s"); }); connect(ui.versionBtn, &QPushButton::clicked, [] {ShellRun("winver.exe", ""); }); connect(ui.deskiconsBtn, &QPushButton::clicked, [] {ShellRun("rundll32.exe", "shell32.dll,Control_RunDLL desk.cpl,,0"); }); connect(ui.wallpaperBtn, &QPushButton::clicked, [] { if (UNONE::OsMajorVer() <= 5) ShellRun("rundll32.exe", "shell32.dll,Control_RunDLL desk.cpl,,0"); else ShellRun("control.exe", "/name Microsoft.Personalization /page pageWallpaper"); }); connect(ui.devmgrBtn, &QPushButton::clicked, [] {ShellRun("devmgmt.msc", ""); }); connect(ui.diskmgrBtn, &QPushButton::clicked, [] {ShellRun("diskmgmt.msc", ""); }); connect(ui.resmonBtn, &QPushButton::clicked, [] {ShellRun("resmon.exe", ""); }); connect(ui.perfBtn, &QPushButton::clicked, [] {ShellRun("perfmon.exe", ""); }); connect(ui.perfsetBtn, &QPushButton::clicked, [] {ShellRun("SystemPropertiesPerformance.exe", ""); }); connect(ui.powerBtn, &QPushButton::clicked, [] {ShellRun("control.exe", "powercfg.cpl,,3"); }); connect(ui.usersBtn, &QPushButton::clicked, [] {ShellRun("lusrmgr.msc", ""); }); connect(ui.uacBtn, &QPushButton::clicked, [] {ShellRun("UserAccountControlSettings.exe", ""); }); connect(ui.evtBtn, &QPushButton::clicked, [] {ShellRun("eventvwr.msc", ""); }); connect(ui.gpoBtn, &QPushButton::clicked, [] {ShellRun("gpedit.msc", ""); }); connect(ui.secpolBtn, &QPushButton::clicked, [] {ShellRun("secpol.msc", ""); }); connect(ui.certBtn, &QPushButton::clicked, [] {ShellRun("certmgr.msc", ""); }); connect(ui.credBtn, &QPushButton::clicked, [] {ShellRun("control.exe", "/name Microsoft.CredentialManager"); }); connect(ui.firewallBtn, &QPushButton::clicked, [] {ShellRun("control.exe", "firewall.cpl"); }); connect(ui.proxyBtn, &QPushButton::clicked, [] {ShellRun("rundll32.exe", "shell32.dll,Control_RunDLL inetcpl.cpl,,4"); }); connect(ui.netconnBtn, &QPushButton::clicked, [] {ShellRun("control.exe", "ncpa.cpl"); }); connect(ui.hostsBtn, &QPushButton::clicked, [&] {ShellRun("notepad.exe", WStrToQ(UNONE::OsSystem32DirW() + L"\\drivers\\etc\\hosts")); }); connect(ui.ipv4Btn, &QPushButton::clicked, [] {ShellRun("cmd.exe", "/k ipconfig|findstr /i ipv4"); }); connect(ui.ipv6Btn, &QPushButton::clicked, [] {ShellRun("cmd.exe", "/k ipconfig|findstr /i ipv6"); }); connect(ui.routeBtn, &QPushButton::clicked, [] {ShellRun("cmd.exe", "/k route print"); }); connect(ui.sharedBtn, &QPushButton::clicked, [] {ShellRun("fsmgmt.msc", ""); }); } void Utilities::RemoveCleanerItems() { int delta = 0; for (auto r : removed_rows_) { junks_model_->removeRows(r - delta, 1); delta++; } removed_rows_.clear(); }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArk/utilities/utilities.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <QtCore> #include <QtWidgets> #include <Windows.h> #include "ui_utilities.h" #include "../common/ui-wrapper/ui-wrapper.h" class OpenArk; class Ui::Utilities; class JunksSortFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT public: JunksSortFilterProxyModel(QWidget *parent) {}; ~JunksSortFilterProxyModel() {}; protected: bool lessThan(const QModelIndex &left, const QModelIndex &right) const; }; struct JunkItem { QString name; QString path; DWORD64 size; }; struct JunkCluster { QString dir; DWORD64 sumsize; QList<JunkItem> items; }; class ScanJunksThread : public QThread { Q_OBJECT signals: void appendJunks(JunkCluster); protected: void run(); public: QList<JunkCluster> junks_cluster_; bool is_custom_scan_ = false; bool is_builtin_scan_ = false; QStringList custom_path_; QString custom_suffex_; }; class CleanJunksThread : public QThread { Q_OBJECT signals: void cleanJunks(JunkCluster); public: void setJunkCluster(QList<JunkCluster> clusters) { junks_cluster_ = clusters; }; protected: void run(); private: QList<JunkCluster> junks_cluster_; }; class Utilities : public CommonMainTabObject { Q_OBJECT public: Utilities(QWidget *parent, int tabid); ~Utilities(); public: void RecordAppServer(const QString &svr); private slots: void onTabChanged(int index); void onOpJunkfiles(int, JunkCluster); void onAppendJunkfiles(JunkCluster); void onCleanJunkfiles(JunkCluster); private: void InitCleanerView(); void InitSystemToolsView(); void RemoveCleanerItems(); QVector<int> removed_rows_; private: QString app_server_; QStandardItemModel *junks_model_; JunksSortFilterProxyModel *proxy_junks_; ScanJunksThread *scanjunks_thread_; CleanJunksThread *cleanjunks_thread_; Ui::Utilities ui; };
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-driver/api-driver.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "api-driver.h" #ifdef _ARKDRV_ #else namespace ArkDrvApi { namespace Driver { bool DriverEnumInfo(std::vector<DRIVER_ITEM> &infos) { infos.clear(); DWORD op = DRIVER_ENUM_INFO; PDRIVER_INFO drivers; DWORD outlen; bool ret = IoControlDriver(IOCTL_ARK_DRIVER, op, NULL, 0, (PVOID*)&drivers, &outlen); if (!ret) return false; for (int i = 0; i < drivers->count; i++) { infos.push_back(drivers->items[i]); } free(drivers); return true; } } // namespace Memory } // namespace ArkDrvApi #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-driver/api-driver.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include "../arkdrv-api.h" #ifdef _ARKDRV_ #include <ntifs.h> #include <windef.h> #else #include <Windows.h> #endif //_NTDDK_ // Driver enum DRIVER_OPS { DRIVER_ENUM_INFO, }; #pragma pack(push, 1) typedef struct _DRIVER_ITEM { ULONG64 base; ULONG size; ULONG flags; USHORT load_seq; USHORT init_seq; UCHAR path[256]; } DRIVER_ITEM, *PDRIVER_ITEM; typedef struct _DRIVER_INFO { ULONG count; DRIVER_ITEM items[1]; } DRIVER_INFO, *PDRIVER_INFO; #pragma pack(pop) //#undef _ARKDRV_ #ifdef _ARKDRV_ #include <ntifs.h> #else #include <unone.h> #include <string> #include <vector> namespace ArkDrvApi { namespace Driver { bool DriverEnumInfo(std::vector<DRIVER_ITEM> &infos); } // namespace Memory } // namespace ArkDrvApi #endif //_NTDDK_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-memory/api-memory.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "api-memory.h" #ifdef _ARKDRV_ #else namespace ArkDrvApi { namespace Memory { static ARK_MEMORY_RANGE sys_range = { 0 }; ARK_MEMORY_RANGE MemoryRange() { if (!sys_range.r0start) { SYSTEM_INFO sys; GetSystemInfo(&sys); sys_range.r3start = (ULONG64)sys.lpMinimumApplicationAddress; sys_range.r3end = (ULONG64)sys.lpMaximumApplicationAddress; sys_range.r0start = 0xFFFF080000000000; sys_range.r0end = 0xFFFFFFFFFFFFFFFF; if (!UNONE::OsIs64()) { sys_range.r0start = 0x80000000; sys_range.r0end = 0xFFFFFFFF; } } return sys_range; } bool IsKernelAddress(ULONG64 addr) { auto range = MemoryRange(); return addr >= sys_range.r0start; } bool MemoryReadR0(ULONG pid, ULONG64 addr, ULONG size, std::string &readbuf) { if (!size) return false; ARK_MEMORY_IN memin; memin.pid = pid; memin.addr = addr; memin.size = size; DWORD outlen; PARK_MEMORY_OUT memout; bool ret = IoControlDriver(IOCTL_ARK_MEMORY, ARK_MEMORY_READ, &memin, sizeof(memin), (PVOID*)&memout, &outlen); if (!ret) return false; if (memout) { readbuf.resize(memout->size); memcpy(&readbuf[0], memout->readbuf, memout->size); free(memout); } return true; } bool MemoryRead(ULONG pid, ULONG64 addr, ULONG size, std::string &readbuf) { if (IsKernelAddress(addr)) return MemoryReadR0(pid, addr, size, readbuf); HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); if (!phd) return FALSE; DWORD readlen; std::string data; data.resize(size); BOOL ret = ReadProcessMemory(phd, (PVOID)addr, (PVOID)data.data(), (SIZE_T)size, (SIZE_T*)&readlen); if (!ret) { auto err = GetLastError(); if (err != ERROR_PARTIAL_COPY) goto err; MEMORY_BASIC_INFORMATION mbi; if (!VirtualQueryEx(phd, (PVOID)addr, &mbi, sizeof(mbi))) goto err; auto exact = (ULONG)mbi.RegionSize - (ULONG)(addr - (ULONG64)mbi.BaseAddress); ret = ReadProcessMemory(phd, (PVOID)addr, (PVOID)data.data(), (SIZE_T)exact, (SIZE_T*)&readlen); if (!ret) goto err; } CloseHandle(phd); data.resize(readlen); readbuf = std::move(data); return true; err: ERR(L"ReadProcessMemory pid:%d, err:%d", pid, GetLastError()); CloseHandle(phd); return false; } bool MemoryWriteR0(ULONG pid, ULONG64 addr, std::string &writebuf) { DWORD written = writebuf.size(); DWORD total = ARK_HEADER_SIZE(ARK_MEMORY_IN) + written; PARK_MEMORY_IN memin = (PARK_MEMORY_IN)malloc(total); if (!memin) return false; memin->addr = addr; memin->pid = pid; memin->size = writebuf.size(); memcpy(memin->u.writebuf, writebuf.data(), written); DWORD outlen; PARK_MEMORY_OUT memout; bool ret = IoControlDriver(IOCTL_ARK_MEMORY, ARK_MEMORY_WRITE, memin, total, (PVOID*)&memout, &outlen); free(memin); if (!ret) return false; if (memout) free(memout); return true; } bool MemoryWrite(ULONG pid, ULONG64 addr, std::string &writebuf) { if (IsKernelAddress(addr)) return MemoryWriteR0(pid, addr, writebuf); HANDLE phd = ArkDrvApi::Process::OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE, FALSE, pid); if (!phd) return FALSE; PVOID buf = (PVOID)writebuf.data(); SIZE_T bufsize = (SIZE_T)writebuf.size(); DWORD written, oldprotect; BOOL ret = FALSE; ret = VirtualProtectEx(phd, (PVOID)addr, bufsize, PAGE_READWRITE, &oldprotect); if (!ret) { ERR(L"VirtualProtectEx pid:%d, err:%d", pid, GetLastError()); CloseHandle(phd); return FALSE; } ret = WriteProcessMemory(phd, (PVOID)addr, buf, bufsize, (SIZE_T*)&written); if (!ret) { ERR(L"WriteProcessMemory pid:%d, err:%d", pid, GetLastError()); VirtualProtectEx(phd, (PVOID)addr, bufsize, oldprotect, &oldprotect); CloseHandle(phd); return FALSE; } VirtualProtectEx(phd, (PVOID)addr, bufsize, oldprotect, &oldprotect); CloseHandle(phd); return true; } } // namespace Memory } // namespace ArkDrvApi #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-memory/api-memory.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #define ARK_HEADER_SIZE(st) (sizeof(st) - sizeof(UCHAR)) #include "../arkdrv-api.h" #ifdef _ARKDRV_ #include <ntifs.h> #include <windef.h> #else #include <Windows.h> #endif //_NTDDK_ // Memory enum ARK_MEMORY_OPS { ARK_MEMORY_READ, ARK_MEMORY_WRITE, }; #pragma pack(push, 1) typedef struct _ARK_MEMORY_IN { ULONG pid; ULONG64 addr; ULONG size; union { UCHAR dummy[1]; UCHAR writebuf[1]; } u; } ARK_MEMORY_IN, *PARK_MEMORY_IN; typedef struct _ARK_MEMORY_OUT { ULONG pid; ULONG size; UCHAR readbuf[1]; } ARK_MEMORY_OUT, *PARK_MEMORY_OUT; typedef struct _ARK_MEMORY_RANGE { ULONG64 r3start; ULONG64 r3end; ULONG64 r0start; ULONG64 r0end; } ARK_MEMORY_RANGE, *PARK_MEMORY_RANGE; #pragma pack(pop) //#undef _ARKDRV_ #ifdef _ARKDRV_ #include <ntifs.h> #else #include <unone.h> #include <string> #include <vector> namespace ArkDrvApi { namespace Memory { ARK_MEMORY_RANGE MemoryRange(); bool IsKernelAddress(ULONG64 addr); bool MemoryRead(ULONG pid, ULONG64 addr, ULONG size, std::string &readbuf); bool MemoryWrite(ULONG pid, ULONG64 addr, std::string &writebuf); } // namespace Memory } // namespace ArkDrvApi #endif //_NTDDK_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-network/api-network.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include <Winsock2.h> #include <ws2ipdef.h> #include <IPHlpApi.h> #include <vector> #include <mstcpip.h> #include <ws2tcpip.h> #include "api-network.h" #pragma comment(lib, "IPHlpApi.lib") #ifdef _ARKDRV_ #else namespace ArkDrvApi { namespace Network { char* GetReadableState(int state) { switch (state) { case MIB_TCP_STATE_CLOSED: return "CLOSED"; case MIB_TCP_STATE_LISTEN: return "LISTENING"; case MIB_TCP_STATE_ESTAB: return "ESTABLISHED"; case MIB_TCP_STATE_SYN_SENT: return "SYN_SENT"; case MIB_TCP_STATE_SYN_RCVD: return "SYN_RECV"; case MIB_TCP_STATE_FIN_WAIT1: return "FIN_WAIT1"; case MIB_TCP_STATE_FIN_WAIT2: return "FIN_WAIT2"; case MIB_TCP_STATE_CLOSE_WAIT: return "CLOSE_WAIT"; case MIB_TCP_STATE_CLOSING: return "CLOSING"; case MIB_TCP_STATE_LAST_ACK: return "LAST_ACK"; case MIB_TCP_STATE_TIME_WAIT: return "TIME_WAIT"; case MIB_TCP_STATE_DELETE_TCB: return "DELETE_TCB"; default: return "UNKNOWN"; } } bool EnumTcp4Endpoints(std::vector<ARK_NETWORK_ENDPOINT_ITEM> &items) { DWORD size = 0; PMIB_TCPTABLE_OWNER_PID tcp = NULL; if (GetExtendedTcpTable(tcp, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0) != ERROR_INSUFFICIENT_BUFFER) return false; tcp = (MIB_TCPTABLE_OWNER_PID *)new char[size]; if (GetExtendedTcpTable(tcp, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0) != NO_ERROR) { delete tcp; return false; } int nums = (int)tcp->dwNumEntries; for (int i = 0; i < nums; i++) { ARK_NETWORK_ENDPOINT_ITEM endpoint; endpoint.ip_ver = ARK_NETWORK_IPV4; endpoint.tran_ver = ARK_NETWORK_TCP; strcpy_s(endpoint.protocol, "TCP"); endpoint.u0.local_addr = tcp->table[i].dwLocalAddr; endpoint.u1.remote_addr = tcp->table[i].dwRemoteAddr; endpoint.local_port = tcp->table[i].dwLocalPort; endpoint.remote_port = tcp->table[i].dwRemotePort; endpoint.state = tcp->table[i].dwState; endpoint.pid = tcp->table[i].dwOwningPid; strcpy_s(endpoint.readable_state, GetReadableState(endpoint.state)); sprintf_s(endpoint.local, "%s:%d", inet_ntoa(*(in_addr*)& tcp->table[i].dwLocalAddr), htons(tcp->table[i].dwLocalPort)); if (endpoint.state == MIB_TCP_STATE_LISTEN) { strcpy_s(endpoint.remote, "0.0.0.0:0"); } else { sprintf_s(endpoint.remote, "%s:%d", inet_ntoa(*(in_addr*)& tcp->table[i].dwRemoteAddr), htons(tcp->table[i].dwRemotePort)); } items.push_back(endpoint); } delete tcp; //for (auto i : items) printf("%s %s %s %s %d\n", i.protocol, i.local, i.remote, i.readable_state, i.pid); return 0; } bool EnumTcp6Endpoints(std::vector<ARK_NETWORK_ENDPOINT_ITEM> &items) { typedef PSTR(NTAPI *__RtlIpv6AddressToStringA)( _In_ const struct in6_addr *Addr, _Out_writes_(46) PSTR S ); auto pRtlIpv6AddressToStringA = (__RtlIpv6AddressToStringA) GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlIpv6AddressToStringA"); if (!pRtlIpv6AddressToStringA) return false; DWORD size = 0; PMIB_TCP6TABLE_OWNER_PID tcp = NULL; if (GetExtendedTcpTable(tcp, &size, TRUE, AF_INET6, TCP_TABLE_OWNER_PID_ALL, 0) != ERROR_INSUFFICIENT_BUFFER) return false; tcp = (MIB_TCP6TABLE_OWNER_PID *)new char[size]; if (GetExtendedTcpTable(tcp, &size, TRUE, AF_INET6, TCP_TABLE_OWNER_PID_ALL, 0) != NO_ERROR) { delete[] tcp; return false; } int nums = (int)tcp->dwNumEntries; for (int i = 0; i < nums; i++) { ARK_NETWORK_ENDPOINT_ITEM endpoint; endpoint.ip_ver = ARK_NETWORK_IPV6; endpoint.tran_ver = ARK_NETWORK_TCP; strcpy_s(endpoint.protocol, "TCP6"); RtlCopyMemory(&endpoint.u0.local_addr6, &tcp->table[i].ucLocalAddr, 16); RtlCopyMemory(&endpoint.u1.remote_addr6, &tcp->table[i].ucRemoteAddr, 16); endpoint.local_port = tcp->table[i].dwLocalPort; endpoint.remote_port = tcp->table[i].dwRemotePort; endpoint.state = tcp->table[i].dwState; endpoint.pid = tcp->table[i].dwOwningPid; strcpy_s(endpoint.readable_state, GetReadableState(endpoint.state)); CHAR str[64] = { 0 }; pRtlIpv6AddressToStringA((in6_addr*)&endpoint.u0.local_addr6, (char*)&str); sprintf_s(endpoint.local, "[%s]:%d", &str, htons(endpoint.local_port)); if (endpoint.state == MIB_TCP_STATE_LISTEN) { strcpy_s(endpoint.remote, "[::]:0"); } else { RtlZeroMemory(&str, sizeof(str)); pRtlIpv6AddressToStringA((in6_addr*)&endpoint.u1.remote_addr6, (char*)&str); sprintf_s(endpoint.remote, "[%s]:%d", &str, htons(endpoint.remote_port)); } items.push_back(endpoint); } delete[] tcp; //for (auto i : items) printf("%s %s %s %s %d\n", i.protocol, i.local, i.remote, i.readable_state, i.pid); return 0; } bool EnumUdp4Endpoints(std::vector<ARK_NETWORK_ENDPOINT_ITEM> &items) { DWORD size = 0; PMIB_UDPTABLE_OWNER_PID udp = NULL; if (GetExtendedUdpTable(udp, &size, TRUE, AF_INET, UDP_TABLE_OWNER_PID, 0) != ERROR_INSUFFICIENT_BUFFER) return false; udp = (MIB_UDPTABLE_OWNER_PID *)new char[size]; if (GetExtendedUdpTable(udp, &size, TRUE, AF_INET, UDP_TABLE_OWNER_PID, 0) != NO_ERROR) { delete udp; return false; } int nums = (int)udp->dwNumEntries; for (int i = 0; i < nums; i++) { ARK_NETWORK_ENDPOINT_ITEM endpoint; endpoint.ip_ver = ARK_NETWORK_IPV4; endpoint.tran_ver = ARK_NETWORK_UDP; strcpy_s(endpoint.protocol, "UDP"); endpoint.u0.local_addr = udp->table[i].dwLocalAddr; endpoint.local_port = udp->table[i].dwLocalPort; endpoint.pid = udp->table[i].dwOwningPid; sprintf_s(endpoint.local, "%s:%d", inet_ntoa(*(in_addr*)&udp->table[i].dwLocalAddr), htons(udp->table[i].dwLocalPort)); strcpy_s(endpoint.remote, "*:*"); items.push_back(endpoint); } delete udp; //for (auto i : items) printf("%s %s %s %s %d\n", i.protocol, i.local, i.remote, i.readable_state, i.pid); return 0; } bool EnumUdp6Endpoints(std::vector<ARK_NETWORK_ENDPOINT_ITEM> &items) { typedef PSTR(NTAPI *__RtlIpv6AddressToStringA)( _In_ const struct in6_addr *Addr, _Out_writes_(46) PSTR S ); auto pRtlIpv6AddressToStringA = (__RtlIpv6AddressToStringA) GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlIpv6AddressToStringA"); if (!pRtlIpv6AddressToStringA) return false; DWORD size = 0; PMIB_UDP6TABLE_OWNER_PID udp = NULL; if (GetExtendedUdpTable(udp, &size, TRUE, AF_INET6, UDP_TABLE_OWNER_PID, 0) != ERROR_INSUFFICIENT_BUFFER) return false; udp = (MIB_UDP6TABLE_OWNER_PID *)new char[size]; if (GetExtendedUdpTable(udp, &size, TRUE, AF_INET6, UDP_TABLE_OWNER_PID, 0) != NO_ERROR) { delete udp; return false; } int nums = (int)udp->dwNumEntries; for (int i = 0; i < nums; i++) { ARK_NETWORK_ENDPOINT_ITEM endpoint; endpoint.ip_ver = ARK_NETWORK_IPV6; endpoint.tran_ver = ARK_NETWORK_UDP; strcpy_s(endpoint.protocol, "UDP6"); RtlCopyMemory(&endpoint.u0.local_addr6, &udp->table[i].ucLocalAddr, 16); endpoint.local_port = udp->table[i].dwLocalPort; endpoint.pid = udp->table[i].dwOwningPid; CHAR str[64] = { 0 }; pRtlIpv6AddressToStringA((in6_addr*)&endpoint.u0.local_addr6, (char*)&str); sprintf_s(endpoint.local, "[%s]:%d", &str, htons(endpoint.local_port)); strcpy_s(endpoint.remote, "*:*"); items.push_back(endpoint); } delete udp; //for (auto i : items) printf("%s %s %s %s %d\n", i.protocol, i.local, i.remote, i.readable_state, i.pid); return 0; } } // namespace Network } // namespace ArkDrvApi #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-network/api-network.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include "../arkdrv-api.h" #ifdef _ARKDRV_ #include <ntifs.h> #include <windef.h> #else #include <Windows.h> #endif //_NTDDK_ enum ARK_NETWORK_OPS { }; #define ARK_NETWORK_IPV4 4 #define ARK_NETWORK_IPV6 6 #define ARK_NETWORK_TCP 0 #define ARK_NETWORK_UDP 1 #pragma pack(push, 1) typedef struct _ARK_NETWORK_ENDPOINT_ITEM { ULONG ip_ver; ULONG tran_ver; CHAR protocol[8]; union { ULONG local_addr; UCHAR local_addr6[16]; } u0; union { ULONG remote_addr; UCHAR remote_addr6[16]; } u1; ULONG local_port; ULONG remote_port; CHAR local[64]; CHAR remote[64]; ULONG state; CHAR readable_state[32]; ULONG pid; } ARK_NETWORK_ENDPOINT_ITEM, *PARK_NETWORK_ENDPOINT_ITEM; #pragma pack(pop) //#undef _ARKDRV_ #ifdef _ARKDRV_ #include <ntifs.h> #else #include <unone.h> #include <string> #include <vector> namespace ArkDrvApi { namespace Network { bool EnumTcp4Endpoints(std::vector<ARK_NETWORK_ENDPOINT_ITEM> &items); bool EnumTcp6Endpoints(std::vector<ARK_NETWORK_ENDPOINT_ITEM> &items); bool EnumUdp4Endpoints(std::vector<ARK_NETWORK_ENDPOINT_ITEM> &items); bool EnumUdp6Endpoints(std::vector<ARK_NETWORK_ENDPOINT_ITEM> &items); } // namespace Network } // namespace ArkDrvApi #endif //_NTDDK_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-notify/api-notify.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "api-notify.h" #ifdef _ARKDRV_ #else namespace ArkDrvApi { namespace Notify { bool NotifyPatch(NOTIFY_TYPE type, ULONG64 routine); bool NotifyPatchRegularly(NOTIFY_TYPE type, ULONG64 routine, int interval); bool NotifyRemove(NOTIFY_TYPE type, ULONG64 routine) { if (routine == 0) return false; NOTIFY_REMOVE_INFO info; info.type = type; info.item = routine; bool ret = IoControlDriver(IOCTL_ARK_NOTIFY, NOTIFY_REMOVE, &info, sizeof(info), NULL, 0); return ret; } bool NotifyRemoveRegularly(NOTIFY_TYPE type, ULONG64 routine, int interval); bool NotifyEnum(DWORD op, std::vector<ULONG64> &routines) { routines.clear(); PNOTIFY_INFO notify; DWORD outlen; bool ret = IoControlDriver(IOCTL_ARK_NOTIFY, op, NULL, 0, (PVOID*)&notify, &outlen); if (!ret) return false; for (int i = 0; i < notify->count; i++) { routines.push_back(notify->items[i]); } free(notify); return true; } bool NotifyEnumProcess(std::vector<ULONG64> &routines) { return NotifyEnum(NOTIFY_ENUM_PROCESS, routines); } bool NotifyEnumThread(std::vector<ULONG64> &routines) { return NotifyEnum(NOTIFY_ENUM_THREAD, routines); } bool NotifyEnumImage(std::vector<ULONG64> &routines) { return NotifyEnum(NOTIFY_ENUM_IMAGE, routines); } bool NotifyEnumRegistry(std::vector<ULONG64> &routines) { return NotifyEnum(NOTIFY_ENUM_REGISTRY, routines); } } // namespace Memory } // namespace ArkDrvApi #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-notify/api-notify.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include "../arkdrv-api.h" #ifdef _ARKDRV_ #include <ntifs.h> #include <windef.h> #else #include <Windows.h> #endif //_NTDDK_ // Notify enum NOTIFY_OPS { NOTIFY_PATCH, NOTIFY_PATCH_REGULARLY, NOTIFY_REMOVE, NOTIFY_REMOVE_REGULARLY, NOTIFY_ENUM_PROCESS, NOTIFY_ENUM_THREAD, NOTIFY_ENUM_IMAGE, NOTIFY_ENUM_REGISTRY, }; enum NOTIFY_TYPE { CREATE_PROCESS, CREATE_THREAD, LOAD_IMAGE, CM_REGISTRY, }; #pragma pack(push, 1) typedef struct _NOTIFY_INFO { ULONG count; NOTIFY_TYPE type; ULONG64 items[1]; } NOTIFY_INFO, *PNOTIFY_INFO; typedef struct _NOTIFY_REMOVE_INFO { NOTIFY_TYPE type; ULONG64 item; } NOTIFY_REMOVE_INFO, *PNOTIFY_REMOVE_INFO; #pragma pack(pop) //#undef _ARKDRV_ #ifdef _ARKDRV_ #include <ntifs.h> #else #include <unone.h> #include <string> #include <vector> namespace ArkDrvApi { namespace Notify { bool NotifyPatch(NOTIFY_TYPE type, ULONG64 routine); bool NotifyPatchRegularly(NOTIFY_TYPE type, ULONG64 routine, int interval); bool NotifyRemove(NOTIFY_TYPE type, ULONG64 routine); bool NotifyRemoveRegularly(NOTIFY_TYPE type, ULONG64 routine, int interval); bool NotifyEnumProcess(std::vector<ULONG64> &routines); bool NotifyEnumThread(std::vector<ULONG64> &routines); bool NotifyEnumImage(std::vector<ULONG64> &routines); bool NotifyEnumRegistry(std::vector<ULONG64> &routines); } // namespace Notify } // namespace ArkDrvApi #endif //_NTDDK_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-object/api-object.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "api-object.h" #ifdef _ARKDRV_ ULONG ObjectTypeIndexByName(WCHAR *object_type_name) { ULONG index = -1; NTSTATUS status; ULONG bufsize = PAGE_SIZE; PVOID buf = ExAllocatePoolWithTag(NonPagedPool, bufsize, 'obte'); while ((status = ZwQueryObject( NULL, (OBJECT_INFORMATION_CLASS)3, //ObjectTypesInformation, buf, bufsize, NULL )) == STATUS_INFO_LENGTH_MISMATCH) { ExFreePoolWithTag(buf, 'obte'); bufsize *= 2; buf = ExAllocatePoolWithTag(NonPagedPool, bufsize, 'obte'); } if (!NT_SUCCESS(status)) { ExFreePoolWithTag(buf, 'obte'); return index; } ULONG number_types = *(ULONG *)buf; POBJECT_TYPE_INFORMATION obj_info = (POBJECT_TYPE_INFORMATION)(((PUCHAR)buf) + ALIGN_UP(sizeof(number_types), ULONG_PTR)); for (ULONG i = 0; i < number_types; i++) { UNICODE_STRING t_type_name; RtlInitUnicodeString(&t_type_name, object_type_name); if (0 == RtlCompareUnicodeString(&t_type_name, &(obj_info->TypeName), TRUE)) { index = i + 2; break; } obj_info = (POBJECT_TYPE_INFORMATION) ((PCHAR)(obj_info + 1) + ALIGN_UP(obj_info->TypeName.MaximumLength, ULONG_PTR)); } if (buf) { ExFreePoolWithTag(buf, 'obte'); } return index; } #else #undef ALIGN_DOWN_BY #undef ALIGN_UP_BY #undef ALIGN_DOWN_POINTER_BY #undef ALIGN_UP_POINTER_BY #undef ALIGN_DOWN #undef ALIGN_UP #undef ALIGN_DOWN_POINTER #undef ALIGN_UP_POINTER #define ALIGN_DOWN_BY(length, alignment) \ ((ULONG_PTR)(length) & ~(alignment - 1)) #define ALIGN_UP_BY(length, alignment) \ (ALIGN_DOWN_BY(((ULONG_PTR)(length) + alignment - 1), alignment)) #define ALIGN_DOWN_POINTER_BY(address, alignment) \ ((PVOID)((ULONG_PTR)(address) & ~((ULONG_PTR)alignment - 1))) #define ALIGN_UP_POINTER_BY(address, alignment) \ (ALIGN_DOWN_POINTER_BY(((ULONG_PTR)(address) + alignment - 1), alignment)) #define ALIGN_DOWN(length, type) \ ALIGN_DOWN_BY(length, sizeof(type)) #define ALIGN_UP(length, type) \ ALIGN_UP_BY(length, sizeof(type)) #define ALIGN_DOWN_POINTER(address, type) \ ALIGN_DOWN_POINTER_BY(address, sizeof(type)) #define ALIGN_UP_POINTER(address, type) \ ALIGN_UP_POINTER_BY(address, sizeof(type)) typedef struct _OBJECT_TYPE_INFORMATION2 { UNICODE_STRING TypeName; ULONG TotalNumberOfObjects; ULONG TotalNumberOfHandles; ULONG TotalPagedPoolUsage; ULONG TotalNonPagedPoolUsage; ULONG TotalNamePoolUsage; ULONG TotalHandleTableUsage; ULONG HighWaterNumberOfObjects; ULONG HighWaterNumberOfHandles; ULONG HighWaterPagedPoolUsage; ULONG HighWaterNonPagedPoolUsage; ULONG HighWaterNamePoolUsage; ULONG HighWaterHandleTableUsage; ULONG InvalidAttributes; GENERIC_MAPPING GenericMapping; ULONG ValidAccessMask; BOOLEAN SecurityRequired; BOOLEAN MaintainHandleCount; UCHAR TypeIndex; // since WINBLUE CHAR ReservedByte; ULONG PoolType; ULONG DefaultPagedPoolCharge; ULONG DefaultNonPagedPoolCharge; } OBJECT_TYPE_INFORMATION2, *POBJECT_TYPE_INFORMATION2; //#include <WtsApi32.h> //#pragma comment(lib, "WtsApi32.lib") namespace ArkDrvApi { namespace Object { bool ObjectTypeEnumR3(std::vector<ARK_OBJECT_TYPE_ITEM> &items) { NTSTATUS status; __NtQueryObject pNtQueryObject = (__NtQueryObject)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtQueryObject"); if (!pNtQueryObject) return false; ULONG bufsize = PAGE_SIZE; PVOID buf = VirtualAlloc(NULL, bufsize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); while ((status = pNtQueryObject( INVALID_HANDLE_VALUE, ObjectTypesInformation, buf, bufsize, NULL )) == STATUS_INFO_LENGTH_MISMATCH) { VirtualFree(buf, bufsize, MEM_RELEASE); bufsize *= 2; buf = VirtualAlloc(NULL, bufsize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); } if (!NT_SUCCESS(status)) { VirtualFree(buf, bufsize, MEM_RELEASE); return status; } POBJECT_TYPES_INFORMATION obj_types = (POBJECT_TYPES_INFORMATION)buf; POBJECT_TYPE_INFORMATION obj_info = (POBJECT_TYPE_INFORMATION)(((PUCHAR)obj_types) + ALIGN_UP(sizeof(*obj_types), ULONG_PTR)); for (ULONG i = 0; i < obj_types->NumberOfTypes; i++) { ARK_OBJECT_TYPE_ITEM item; item.type_index = i + 2; RtlZeroMemory(item.type_name, sizeof(item.type_name)); RtlCopyMemory(item.type_name, obj_info->TypeName.Buffer, obj_info->TypeName.Length*2); std::wstring &&type_name = UNONE::StrTrimRightW(item.type_name); RtlCopyMemory(item.type_name, type_name.c_str(), (type_name.size()+1) * 2); item.type_object = NULL; item.total_objects = obj_info->TotalNumberOfObjects; item.total_handles = obj_info->TotalNumberOfHandles; items.push_back(item); obj_info = (POBJECT_TYPE_INFORMATION) ((PCHAR)(obj_info + 1) + ALIGN_UP(obj_info->TypeName.MaximumLength, ULONG_PTR)); } VirtualFree(buf, bufsize, MEM_RELEASE); return true; } bool ObjectTypeEnum(std::vector<ARK_OBJECT_TYPE_ITEM> &items) { return ObjectTypeEnumR3(items); } typedef NTSTATUS(NTAPI *__NtOpenDirectoryObject)( __out PHANDLE DirectoryHandle, __in ACCESS_MASK DesiredAccess, __in POBJECT_ATTRIBUTES ObjectAttributes ); typedef NTSTATUS(NTAPI *__NtQueryDirectoryObject)( __in HANDLE DirectoryHandle, __out_bcount_opt(Length) PVOID Buffer, __in ULONG Length, __in BOOLEAN ReturnSingleEntry, __in BOOLEAN RestartScan, __inout PULONG Context, __out_opt PULONG ReturnLength ); typedef struct _OBJECT_DIRECTORY_INFORMATION { UNICODE_STRING Name; UNICODE_STRING TypeName; } OBJECT_DIRECTORY_INFORMATION, *POBJECT_DIRECTORY_INFORMATION; typedef enum _WTS_CONNECTSTATE_CLASS { WTSActive, // User logged on to WinStation WTSConnected, // WinStation connected to client WTSConnectQuery, // In the process of connecting to client WTSShadow, // Shadowing another WinStation WTSDisconnected, // WinStation logged on without client WTSIdle, // Waiting for client to connect WTSListen, // WinStation is listening for connection WTSReset, // WinStation is being reset WTSDown, // WinStation is down due to error WTSInit, // WinStation in initialization } WTS_CONNECTSTATE_CLASS; #define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL) typedef struct _WTS_SESSION_INFOW { DWORD SessionId; // session id LPWSTR pWinStationName; // name of WinStation this session is // connected to WTS_CONNECTSTATE_CLASS State; // connection state (see enum) } WTS_SESSION_INFOW, *PWTS_SESSION_INFOW; typedef struct _SESSION_INFOW { DWORD SessionId; // session id std::wstring pWinStationName; // name of WinStation this session is // connected to WTS_CONNECTSTATE_CLASS State; // connection state (see enum) } SESSION_INFOW, *PSESSION_INFOW; bool GetSessions(std::vector<SESSION_INFOW> &sinfos) { typedef BOOL (WINAPI *__WTSEnumerateSessionsW)( IN HANDLE hServer, IN DWORD Reserved, IN DWORD Version, PWTS_SESSION_INFOW *ppSessionInfo, DWORD *pCount ); typedef void (WINAPI *__WTSFreeMemory)( IN PVOID pMemory ); HMODULE wts = GetModuleHandleA("Wtsapi32.dll"); if (!wts) wts = LoadLibraryA("Wtsapi32.dll"); __WTSEnumerateSessionsW pWTSEnumerateSessionsW = (__WTSEnumerateSessionsW)GetProcAddress(wts, "WTSEnumerateSessionsW"); __WTSFreeMemory pWTSFreeMemory = (__WTSFreeMemory)GetProcAddress(wts, "WTSFreeMemory"); if (!pWTSEnumerateSessionsW || !pWTSFreeMemory) return false; DWORD scount = 0; PWTS_SESSION_INFOW sessions = NULL; BOOL ret = pWTSEnumerateSessionsW(WTS_CURRENT_SERVER_HANDLE, 0, 1, &sessions, &scount); if (!ret) { ERR(L"WTSEnumerateSessionsW err:%d", GetLastError()); return false; } for (int i = 0; i < scount; i++) { SESSION_INFOW info; info.SessionId = sessions[i].SessionId; info.pWinStationName = sessions[i].pWinStationName; info.State = sessions[i].State; sinfos.push_back(info); } pWTSFreeMemory(sessions); return true; } bool ObjectSectionEnumR3(std::vector<ARK_OBJECT_SECTION_ITEM> &items, ULONG session) { std::wstring dirname, prefix; if (session == ARK_SESSION_GLOBAL) { dirname = L"\\BaseNamedObjects"; prefix = L"Global"; } else { dirname = UNONE::StrFormatW(L"\\Sessions\\%u\\BaseNamedObjects", session); prefix = L""; } #define DIRECTORY_QUERY (0x0001) NTSTATUS status; __NtOpenDirectoryObject pNtOpenDirectoryObject = (__NtOpenDirectoryObject)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtOpenDirectoryObject"); __NtQueryDirectoryObject pNtQueryDirectoryObject = (__NtQueryDirectoryObject)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtQueryDirectoryObject"); if (!pNtOpenDirectoryObject || !pNtQueryDirectoryObject) return false; HANDLE dirobj; OBJECT_ATTRIBUTES oa; UNICODE_STRING udirname; udirname.Buffer = (WCHAR*)dirname.c_str(); udirname.Length = dirname.size() * 2; udirname.MaximumLength = udirname.Length; InitializeObjectAttributes(&oa, &udirname, 0, NULL, NULL); status = pNtOpenDirectoryObject(&dirobj, DIRECTORY_QUERY, &oa); if (!NT_SUCCESS(status)) { ERR(L"NtOpenDirectoryObject status:%d", status); return false; } ULONG context, written; ULONG bufsize = 512; POBJECT_DIRECTORY_INFORMATION info = (POBJECT_DIRECTORY_INFORMATION)malloc(bufsize); if (!info) return false; status = pNtQueryDirectoryObject(dirobj, info, bufsize, TRUE, TRUE, &context, &written); if (!NT_SUCCESS(status)) { CloseHandle(dirobj); free(info); ERR(L"NtQueryDirectoryObject status:%d", status); return false; } while (NT_SUCCESS(pNtQueryDirectoryObject(dirobj, info, bufsize, TRUE, FALSE, &context, &written))) { if (!wcsncmp(L"Section", info->TypeName.Buffer, 7)) { ARK_OBJECT_SECTION_ITEM item; RtlZeroMemory(item.section_name, sizeof(item.section_name)); RtlZeroMemory(item.section_dir, sizeof(item.section_dir)); wcsncpy(item.section_name, info->Name.Buffer, MIN(info->Name.Length / 2, 127)); wcsncpy(item.section_dir, dirname.c_str(), MIN(dirname.size(), 127)); std::wstring map_name; if (!prefix.empty()) { map_name = UNONE::StrFormatW(L"%s\\%s", prefix.c_str(), item.section_name); } else { map_name = item.section_name; } HANDLE maphd = OpenFileMappingW(FILE_MAP_READ, FALSE, map_name.c_str()); if (maphd) { PVOID mapaddr = MapViewOfFileEx(maphd, FILE_MAP_READ, 0, 0, 0, NULL); MEMORY_BASIC_INFORMATION mbi; VirtualQuery(mapaddr, &mbi, sizeof(mbi)); item.section_size = (ULONG)mbi.RegionSize; UnmapViewOfFile(mapaddr); CloseHandle(maphd); } item.session_id = session; items.push_back(item); } } CloseHandle(dirobj); free(info); return true; } bool ObjectSectionEnum(std::vector<ARK_OBJECT_SECTION_ITEM> &items, ULONG session) { return ObjectSectionEnumR3(items, session); } bool ObjectSectionEnum(std::vector<ARK_OBJECT_SECTION_ITEM> &items) { std::vector<ARK_OBJECT_SECTION_ITEM> temps; ObjectSectionEnumR3(temps, ARK_SESSION_GLOBAL); items.insert(items.end(), temps.begin(), temps.end()); for (auto &item : items) { wcscpy(item.session_name, L"Global"); } std::vector<SESSION_INFOW> sinfos; GetSessions(sinfos); for (int i = 0; i < sinfos.size(); i++) { temps.clear(); ObjectSectionEnumR3(temps, sinfos[i].SessionId); for (auto &item : temps) { wcscpy(item.session_name, sinfos[i].pWinStationName.c_str()); } items.insert(items.end(), temps.begin(), temps.end()); } return true; } } // namespace Object } // namespace ArkDrvApi #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-object/api-object.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include "../arkdrv-api.h" #ifdef _ARKDRV_ #include <ntifs.h> #include <windef.h> #else #include <Windows.h> #endif //_NTDDK_ enum ARK_OBJECT_OPS { ARK_OBJECT_TYPE_ENUM, }; #define ARK_SESSION_GLOBAL -1 #pragma pack(push, 1) typedef struct _ARK_OBJECT_TYPE_ITEM { ULONG type_index; WCHAR type_name[128]; PVOID type_object; ULONG total_objects; ULONG total_handles; } ARK_OBJECT_TYPE_ITEM, *PARK_OBJECT_TYPE_ITEM; typedef struct _OBJECT_TYPE_INFO { ULONG count; ARK_OBJECT_TYPE_ITEM items[1]; } ARK_OBJECT_TYPE_INFO, *PARK_OBJECT_TYPE_INFO; typedef struct _ARK_OBJECT_SECTION_ITEM { ULONG session_id; WCHAR session_name[128]; ULONG section_size; WCHAR section_name[128]; WCHAR section_dir[128]; } ARK_OBJECT_SECTION_ITEM, *PARK_OBJECT_SECTION_ITEM; typedef struct _ARK_OBJECT_SECTION_INFO { ULONG count; ARK_OBJECT_SECTION_ITEM items[1]; } ARK_OBJECT_SECTION_INFO, *PARK_OBJECT_SECTION_INFO; #pragma pack(pop) //#undef _ARKDRV_ #ifdef _ARKDRV_ #include <ntifs.h> typedef struct _OBJECT_TYPE_INFORMATION { UNICODE_STRING TypeName; ULONG TotalNumberOfHandles; ULONG TotalNumberOfObjects; WCHAR Unused1[8]; ULONG HighWaterNumberOfHandles; ULONG HighWaterNumberOfObjects; WCHAR Unused2[8]; ACCESS_MASK InvalidAttributes; GENERIC_MAPPING GenericMapping; ACCESS_MASK ValidAttributes; BOOLEAN SecurityRequired; BOOLEAN MaintainHandleCount; USHORT MaintainTypeList; POOL_TYPE PoolType; ULONG DefaultPagedPoolCharge; ULONG DefaultNonPagedPoolCharge; } OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION; ULONG ObjectTypeIndexByName(WCHAR *object_type_name); #else #include <unone.h> #include <string> #include <vector> namespace ArkDrvApi { namespace Object { bool ObjectTypeEnum(std::vector<ARK_OBJECT_TYPE_ITEM> &items); bool ObjectSectionEnum(std::vector<ARK_OBJECT_SECTION_ITEM> &items); bool ObjectSectionEnum(std::vector<ARK_OBJECT_SECTION_ITEM> &items, ULONG session); } // namespace Object } // namespace ArkDrvApi #endif //_NTDDK_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-process/api-process.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "api-process.h" #ifdef _ARKDRV_ #else namespace ArkDrvApi { namespace Process { HANDLE WINAPI OpenProcessR0(DWORD access, BOOL inherit, DWORD pid) { std::string outdata; PROCESS_OPEN_INFO info; info.access = access; info.inherit = inherit; info.pid = pid; bool ret = IoControlDriver(IOCTL_ARK_PROCESS, PROCESS_OPEN, TO_STREAM(info), outdata); if (!ret) return NULL; HANDLE phd = (HANDLE)*(DWORD*)outdata.c_str(); return phd; } HANDLE WINAPI OpenProcess(DWORD access, BOOL inherit, DWORD pid) { if (pid == -1) return NULL; HANDLE phd = ::OpenProcess(access, inherit, pid); if (phd) return phd; if (GetLastError() != ERROR_ACCESS_DENIED) { ERR(L"OpenProcess pid:%d err:%d", pid, GetLastError()); return NULL; } phd = OpenProcessR0(access, inherit, pid); if (!phd) { ERR(L"OpenProcess by Kernel pid:%d err:%d", pid, GetLastError()); return NULL; } return phd; } HANDLE WINAPI OpenThreadR0(DWORD access, BOOL inherit, DWORD tid) { std::string outdata; THREAD_OPEN_INFO info; info.access = access; info.inherit = inherit; info.tid = tid; bool ret = IoControlDriver(IOCTL_ARK_PROCESS, THREAD_OPEN, TO_STREAM(info), outdata); if (!ret) return NULL; HANDLE thd = (HANDLE)*(DWORD*)outdata.c_str(); return thd; } HANDLE WINAPI OpenThread(DWORD access, BOOL inherit, DWORD tid) { HANDLE thd = ::OpenThread(access, inherit, tid); if (!thd && GetLastError() == ERROR_ACCESS_DENIED) { thd = OpenThreadR0(access, inherit, tid); if (!thd) return 0; } return thd; } } // namespace Process } // namespace ArkDrvApi #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-process/api-process.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include "../arkdrv-api.h" #ifdef _ARKDRV_ #include <ntifs.h> #include <windef.h> #else #include <Windows.h> #endif //_NTDDK_ enum PROCESS_OPS { PROCESS_OPEN, THREAD_OPEN, }; #pragma pack(push, 1) typedef struct _PROCESS_OPEN_INFO { DWORD access; BOOL inherit; DWORD pid; } PROCESS_OPEN_INFO, *PPROCESS_OPEN_INFO; typedef struct _THREAD_OPEN_INFO { DWORD access; BOOL inherit; DWORD tid; } THREAD_OPEN_INFO, *PTHREAD_OPEN_INFO; #pragma pack(pop) //#undef _ARKDRV_ #ifdef _ARKDRV_ #include <ntifs.h> #else #include <unone.h> #include <string> #include <vector> namespace ArkDrvApi { namespace Process { HANDLE WINAPI OpenProcessR0(DWORD access, BOOL inherit, DWORD pid); HANDLE WINAPI OpenProcess(DWORD access, BOOL inherit, DWORD pid); HANDLE WINAPI OpenThreadR0(DWORD access, BOOL inherit, DWORD tid); HANDLE WINAPI OpenThread(DWORD access, BOOL inherit, DWORD tid); } // namespace Process } // namespace ArkDrvApi #include <common/cpp-wrapper/cpp-wrapper.h> #define EN_VID_PROCESS() \ bool regok = UNONE::InterCreateTlsValue(ArkDrvApi::Process::OpenProcess, UNONE::PROCESS_VID);\ ON_SCOPE_EXIT([&] {if (regok) UNONE::InterDeleteTlsValue(UNONE::PROCESS_VID); }); #endif //_NTDDK_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-storage/api-storage.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "api-storage.h" #ifdef _ARKDRV_ #else namespace ArkDrvApi { namespace Storage { bool UnlockEnum(const std::wstring &path, std::vector<HANDLE_ITEM> &items) { std::string outdata; bool ret = IoControlDriver(IOCTL_ARK_STORAGE, STORAGE_UNLOCK_ENUM, path, outdata); if (!ret) return false; PHANDLE_INFO info = (PHANDLE_INFO)outdata.c_str(); for (int i = 0; i < info->count; i++) { items.push_back(info->items[i]); } return true; } bool UnlockClose(HANDLE_ITEM &item) { std::string indata; std::string outdata; indata.assign((char *)&item, sizeof(HANDLE_ITEM)); bool ret = IoControlDriver(IOCTL_ARK_STORAGE, STORAGE_UNLOCK_CLOSE, indata, outdata); if (!ret) return false; return true; } bool HotkeyRemoveInfo(HOTKEY_ITEM &item) { return false; } } // namespace Storage } // namespace ArkDrvApi #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-storage/api-storage.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include "../arkdrv-api.h" #ifdef _ARKDRV_ #include <ntifs.h> #include <windef.h> #else #include <Windows.h> #endif //_NTDDK_ enum STORAGE_OPS { STORAGE_UNLOCK_ENUM, STORAGE_UNLOCK_CLOSE, }; #pragma pack(push, 1) typedef struct _HANDLE_ITEM { ULONG type_index; // object type index ULONG ref_count; // ref count HANDLE pid; // process id LPVOID object; // HANDLE handle; // WCHAR type_name[64]; // the object type name WCHAR name[260]; // object name } HANDLE_ITEM, *PHANDLE_ITEM; typedef struct _HANDLE_INFO { ULONG count; HANDLE_ITEM items[1]; } HANDLE_INFO, *PHANDLE_INFO; #pragma pack(pop) //#undef _ARKDRV_ #ifdef _ARKDRV_ #include <ntifs.h> #else #include <unone.h> #include <string> #include <vector> namespace ArkDrvApi { namespace Storage { bool UnlockEnum(const std::wstring &path, std::vector<HANDLE_ITEM> &items); bool UnlockClose(HANDLE_ITEM &item); } // namespace Storage } // namespace ArkDrvApi #endif //_NTDDK_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-wingui/api-wingui.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "api-wingui.h" #ifdef _ARKDRV_ #else namespace ArkDrvApi { namespace WinGUI { bool HotkeyEnumInfo(std::vector<HOTKEY_ITEM> &hotkeys) { if (!ConnectDriver()) return false; DWORD op = HOTKEY_ENUM; PHOTKEY_INFO info; DWORD outlen; int hkmarks[HOTKEY_MAX_VK+1] = { 0 }; for (int i = 1; i <= HOTKEY_MAX_VK; i++) { if (RegisterHotKey(NULL, HOTKEY_PLACEHOLDER_ID + i, MOD_ALT | MOD_NOREPEAT, i)) { hkmarks[i] = ~i; } else { OutputDebugStringA(UNONE::StrFormatA("Register err:%s\n", UNONE::OsDosErrorMsgA(GetLastError()).c_str()).c_str()); } } bool ret = IoControlDriver(IOCTL_ARK_HOTKEY, op, NULL, 0, (PVOID*)&info, &outlen); for (int i = 1; i <= HOTKEY_MAX_VK; i++) { if (hkmarks[i]) { UnregisterHotKey(NULL, HOTKEY_PLACEHOLDER_ID + i); } } if (!ret) return false; for (int i = 0; i < info->count; i++) { hotkeys.push_back(info->items[i]); } free(info); return true; } bool HotkeyRemoveInfo(HOTKEY_ITEM &item) { DWORD op = HOTKEY_REMOVE; DWORD out; DWORD outlen; bool ret = IoControlDriver(IOCTL_ARK_HOTKEY, op, &item, sizeof(item), (PVOID*)&out, &outlen); if (!ret) return false; return true; } } // namespace WinGUI } // namespace ArkDrvApi #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/api-wingui/api-wingui.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include "../arkdrv-api.h" #ifdef _ARKDRV_ #include <ntifs.h> #include <windef.h> #else #include <Windows.h> #endif //_NTDDK_ // WinGUI #define HOTKEY_MAX_VK 0x80 #define HOTKEY_PLACEHOLDER_ID 0x99887766 enum HOTKEY_OPS { HOTKEY_ENUM, HOTKEY_REMOVE, }; #pragma pack(push, 1) typedef struct _HOTKEY_ITEM { UCHAR name[64]; UINT32 wnd; UINT16 mod1; UINT16 mod2; UINT32 vk; UINT32 id; UINT32 pid; UINT32 tid; ULONG64 hkobj; } HOTKEY_ITEM, *PHOTKEY_ITEM; typedef struct _HOTKEY_INFO { ULONG count; HOTKEY_ITEM items[1]; } HOTKEY_INFO, *PHOTKEY_INFO; #pragma pack(pop) //#undef _ARKDRV_ #ifdef _ARKDRV_ #include <ntifs.h> #else #include <unone.h> #include <string> #include <vector> namespace ArkDrvApi { namespace WinGUI { bool HotkeyEnumInfo(std::vector<HOTKEY_ITEM> &hotkeys); bool HotkeyRemoveInfo(HOTKEY_ITEM &item); } // namespace Memory } // namespace ArkDrvApi #endif //_NTDDK_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/arkdrv-api.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "arkdrv-api.h" #ifdef _ARKDRV_ #else namespace ArkDrvApi { HANDLE arkdrv = INVALID_HANDLE_VALUE; bool ConnectDriver() { if (arkdrv != INVALID_HANDLE_VALUE) return true; arkdrv = CreateFileW( ARK_USER_SYMBOLINK, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (arkdrv == INVALID_HANDLE_VALUE) { return false; } return true; } bool DisconnectDriver() { if (arkdrv == INVALID_HANDLE_VALUE) return true; CloseHandle(arkdrv); arkdrv = INVALID_HANDLE_VALUE; return true; } bool IoControlDriver(DWORD ctlcode, DWORD op, PVOID inbuf, DWORD inlen, PVOID *outbuf, DWORD *outlen) { DWORD retlen = 0; if (arkdrv == INVALID_HANDLE_VALUE) return false; *outbuf = NULL; *outlen = 0; DWORD wrap_inlen = sizeof(op) + inlen; PUCHAR wrap_inbuf = (PUCHAR)malloc(wrap_inlen); if (!wrap_inbuf) return false; memcpy(wrap_inbuf, &op, sizeof(op)); if (inbuf) memcpy(wrap_inbuf + sizeof(op), inbuf, inlen); bool ret = DeviceIoControl( arkdrv, ctlcode, wrap_inbuf, wrap_inlen, NULL, 0, &retlen, NULL); if (ret) { free(wrap_inbuf); return true; } if (GetLastError() != ERROR_MORE_DATA) { free(wrap_inbuf); ERR(L"DeviceIoControl err:%d", GetLastError()); return false; } auto bufsize = retlen; auto buf = (PVOID)calloc(bufsize, 1); if (!buf) return false; if (!DeviceIoControl( arkdrv, ctlcode, wrap_inbuf, wrap_inlen, buf, bufsize, &retlen, NULL)) { free(buf); free(wrap_inbuf); ERR(L"DeviceIoControl err:%d", GetLastError()); return false; } *outbuf = buf; *outlen = retlen; free(wrap_inbuf); return true; } bool IoControlDriver(DWORD ctlcode, DWORD op, const std::wstring &indata, std::string &outdata) { if (!ConnectDriver()) return false; DWORD outlen; CHAR *info; WCHAR *tempdata = NULL; DWORD tempsize = 0; if (indata.size()) { tempdata = (WCHAR*)indata.c_str(); tempsize = (indata.size() + 1) * 2; } bool ret = IoControlDriver(ctlcode, op, (PVOID)tempdata, tempsize, (PVOID*)&info, &outlen); if (!ret) return false; if (outlen) outdata.assign(info, outlen); if (info) free(info); return true; } bool IoControlDriver(DWORD ctlcode, DWORD op, const std::string &indata, std::string &outdata) { if (!ConnectDriver()) return false; DWORD outlen; CHAR *info; CHAR *tempdata = NULL; DWORD tempsize = 0; if (indata.size()) { tempdata = (CHAR*)indata.c_str(); tempsize = indata.size(); } bool ret = IoControlDriver(ctlcode, op, (PVOID)tempdata, tempsize, (PVOID*)&info, &outlen); if (!ret) return false; outdata.assign(info, outlen); if (info) free(info); return true; } bool HeartBeatPulse() { if (!ConnectDriver()) return false; PVOID outbuf; DWORD outlen; bool ret = IoControlDriver(IOCTL_ARK_HEARTBEAT, 0, NULL, 0, &outbuf, &outlen); return ret; } } // namespace IArkDrv #endif
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/arkdrv-api/arkdrv-api.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #ifdef _ARKDRV_ #include <ntifs.h> #include <windef.h> #else #include <Windows.h> #include <common/app/app.h> #endif //_NTDDK_ #include "api-storage/api-storage.h" #include "api-memory/api-memory.h" #include "api-wingui/api-wingui.h" #include "api-driver/api-driver.h" #include "api-notify/api-notify.h" #include "api-object/api-object.h" #include "api-process/api-process.h" #include "api-network/api-network.h" #define ARK_NTDEVICE_NAME L"\\Device\\OpenArkDrv" #define ARK_DOSDEVICE_NAME L"\\DosDevices\\OpenArkDrv" #define ARK_USER_SYMBOLINK L"\\\\.\\OpenArkDrv" #define ARK_DRV_TYPE 41827 #define IOCTL_ARK_HEARTBEAT CTL_CODE(ARK_DRV_TYPE, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_ARK_DRIVER CTL_CODE(ARK_DRV_TYPE, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_ARK_NOTIFY CTL_CODE(ARK_DRV_TYPE, 0x802, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_ARK_MEMORY CTL_CODE(ARK_DRV_TYPE, 0x803, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_ARK_HOTKEY CTL_CODE(ARK_DRV_TYPE, 0x900, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_ARK_STORAGE CTL_CODE(ARK_DRV_TYPE, 0x920, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_ARK_OBJECT CTL_CODE(ARK_DRV_TYPE, 0x940, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_ARK_PROCESS CTL_CODE(ARK_DRV_TYPE, 0x960, METHOD_BUFFERED, FILE_ANY_ACCESS) //#undef _ARKDRV_ #ifdef _ARKDRV_ #include <ntifs.h> #else #include <unone.h> #include <string> #include <vector> namespace ArkDrvApi { extern HANDLE arkdrv; bool ConnectDriver(); bool DisconnectDriver(); bool HeartBeatPulse(); bool IoControlDriver(DWORD ctlcode, DWORD op, PVOID inbuf, DWORD inlen, PVOID *outbuf, DWORD *outlen); bool IoControlDriver(DWORD ctlcode, DWORD op, const std::wstring &indata, std::string &outdata); bool IoControlDriver(DWORD ctlcode, DWORD op, const std::string &indata, std::string &outdata); #define TO_STREAM(st) std::string((char*)&st, sizeof(st)) #define TO_STREAM_P(pst, size) std::string((char*)pst, size) #define TO_STRUCT(str, type) ((type)str.c_str()) } // namespace ArkDrvApi #endif //_NTDDK_
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/common/c-assist.c
C
#include "c-assist.h" VOID MmEnableWP() { SIZE_T cr0 = (SIZE_T)__readcr0(); cr0 |= 0x10000; __writecr0(cr0); } VOID MmDisableWP() { SIZE_T cr0 = (SIZE_T)__readcr0(); cr0 &= ~((SIZE_T)1 << 16); __writecr0(cr0); } VOID MmWriteProtectOn(IN KIRQL Irql) { SIZE_T cr0 = (SIZE_T)__readcr0(); cr0 |= 0x10000; #ifdef _AMD64_ _enable(); #else __asm cli #endif __writecr0(cr0); KeLowerIrql(Irql); } KIRQL MmWriteProtectOff() { KIRQL irql = KeRaiseIrqlToDpcLevel(); SIZE_T cr0 = (SIZE_T)__readcr0(); cr0 &= ~((SIZE_T)1 << 16); __writecr0(cr0); #ifdef _AMD64_ _disable(); #else __asm sti #endif return irql; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/common/c-assist.h
C/C++ Header
#pragma once #include <ntifs.h> EXTERN_C VOID MmEnableWP(); EXTERN_C VOID MmDisableWP(); EXTERN_C VOID MmWriteProtectOn(IN KIRQL Irql); EXTERN_C KIRQL MmWriteProtectOff();
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/common/common.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "common.h" #include "../kdriver/kdriver.h" #include "../knotify/knotify.h" ARK_DRIVER ArkDrv; /*++ Description: get os version Arguments: void Return: NTOS_VERSION --*/ NTOS_VERSION_X OsNtVersion() { RTL_OSVERSIONINFOEXW info; if (!KNONE::OsGetVersionInfo(info)) return _NTOS_UNKNOWN; switch (info.dwMajorVersion) { case 5: { if (info.dwMinorVersion == 1) { if (info.wServicePackMajor == 1) return _NTOS_WINXPSP1; if (info.wServicePackMajor == 2) return _NTOS_WINXPSP2; if (info.wServicePackMajor == 3) return _NTOS_WINXPSP3; return _NTOS_WINXP; } if (info.dwMinorVersion == 2) { if (info.wServicePackMajor == 1) return _NTOS_WIN2003SP1; if (info.wServicePackMajor == 2) return _NTOS_WIN2003SP2; return _NTOS_WIN2003; } break; } case 6: { if (info.dwMinorVersion == 0) { if (info.wServicePackMajor == 1) return _NTOS_WINVISTASP1; if (info.wServicePackMajor == 2) return _NTOS_WINVISTASP2; return _NTOS_WINVISTA; } if (info.dwMinorVersion == 1) { if (info.wServicePackMajor == 1) return _NTOS_WIN7SP1; return _NTOS_WIN7; } if (info.dwMinorVersion == 2) { return _NTOS_WIN8; } if (info.dwMinorVersion == 3) { return _NTOS_WIN81; } break; } case 10: { if (info.dwBuildNumber == 10240) return _NTOS_WIN10_1507; if (info.dwBuildNumber == 10586) return _NTOS_WIN10_1511; if (info.dwBuildNumber == 14393) return _NTOS_WIN10_1607; if (info.dwBuildNumber == 15063) return _NTOS_WIN10_1703; if (info.dwBuildNumber == 16299) return _NTOS_WIN10_1709; if (info.dwBuildNumber == 17134) return _NTOS_WIN10_1803; if (info.dwBuildNumber == 17763) return _NTOS_WIN10_1809; if (info.dwBuildNumber == 18362) return _NTOS_WIN10_1903; if (info.dwBuildNumber == 18363) return _NTOS_WIN10_1909; if (info.dwBuildNumber == 19041) return _NTOS_WIN10_2004; if (info.dwBuildNumber == 19042) return _NTOS_WIN10_20H2; if (info.dwBuildNumber == 19043) return _NTOS_WIN10_21H1; if (info.dwBuildNumber == 19043) return _NTOS_WIN10_21H2; if (info.dwBuildNumber == 22000) return _NTOS_WIN11_21H2; } default: break; } return _NTOS_UNKNOWN; } BOOLEAN InitArkDriver(PDRIVER_OBJECT drvobj, PDEVICE_OBJECT devobj) { ArkDrv.drvobj = drvobj; ArkDrv.devobj = devobj; ArkDrv.ver = OsNtVersion(); ArkDrv.major = KNONE::OsMajorVersion(); ArkDrv.minor = KNONE::OsMinorVersion(); ArkDrv.build = KNONE::OsBuildNumber(); InitDriverDispatcher(); InitNotifyDispatcher(); return TRUE; } PVOID GetNtRoutineAddress(IN PCWSTR name) { UNICODE_STRING ustr; RtlInitUnicodeString(&ustr, name); return MmGetSystemRoutineAddress(&ustr); } NTSTATUS DuplicateInputBuffer(IN PIRP irp, PVOID &inbuf) { NTSTATUS status = STATUS_SUCCESS; PIO_STACK_LOCATION irpstack; PVOID inbuf_dup = NULL; PVOID outbuf = NULL; ULONG inlen = 0; irpstack = IoGetCurrentIrpStackLocation(irp); inlen = irpstack->Parameters.DeviceIoControl.InputBufferLength - 4; if (inbuf && inlen) { inbuf_dup = ExAllocatePoolWithTag(NonPagedPool, inlen, ARK_POOLTAG); if (!inbuf_dup) return STATUS_MEMORY_NOT_ALLOCATED; RtlCopyMemory(inbuf_dup, inbuf, inlen); inbuf = inbuf_dup; } return status; } NTSTATUS ReleaseInputBuffer(IN PIRP irp, PVOID &inbuf) { NTSTATUS status = STATUS_SUCCESS; if (inbuf) { inbuf = NULL; ExFreePoolWithTag(inbuf, ARK_POOLTAG); } return status; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/common/common.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <knone.h> #include <ntifs.h> #define ARK_POOLTAG 'OARK' typedef struct _ARK_DRIVER { PDRIVER_OBJECT drvobj; PDEVICE_OBJECT devobj; ULONG ver; ULONG major; ULONG minor; ULONG build; PVOID process_notify; PVOID thread_notify; PVOID image_notify; PVOID registry_notify; } ARK_DRIVER, *PARK_DRIVER; extern ARK_DRIVER ArkDrv; typedef enum { _NTOS_UNKNOWN, _NTOS_WINXP, _NTOS_WINXPSP1, _NTOS_WINXPSP2, _NTOS_WINXPSP3, _NTOS_WIN2003, _NTOS_WIN2003SP1, _NTOS_WIN2003SP2, _NTOS_WINVISTA, _NTOS_WINVISTASP1, _NTOS_WINVISTASP2, _NTOS_WIN7, _NTOS_WIN7SP1, _NTOS_WIN8, _NTOS_WIN81, _NTOS_WIN10_1507, //10240 _NTOS_WIN10_1511, //10586 _NTOS_WIN10_1607, //14393 _NTOS_WIN10_1703, //15063 _NTOS_WIN10_1709, //16299 _NTOS_WIN10_1803, //17134 _NTOS_WIN10_1809, //17763 _NTOS_WIN10_1903, //18362 _NTOS_WIN10_1909, //18363 _NTOS_WIN10_2004, //19041 _NTOS_WIN10_20H2, //19042 _NTOS_WIN10_21H1, //19043 _NTOS_WIN10_21H2, //19044 _NTOS_WIN11_21H2, //22000 } NTOS_VERSION_X, *PNTOS_VERSION_X; BOOLEAN InitArkDriver(PDRIVER_OBJECT drvobj, PDEVICE_OBJECT devobj); PVOID GetNtRoutineAddress(IN PCWSTR name); NTSTATUS DuplicateInputBuffer(IN PIRP irp, PVOID &inbuf); NTSTATUS ReleaseInputBuffer(IN PIRP irp, PVOID &inbuf);
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/driver-entry.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include <ntifs.h> #include "arkdrv-api/arkdrv-api.h" #include "common/common.h" #include "kdriver/kdriver.h" #include "knotify/knotify.h" #include "kmemory/kmemory.h" #include "kwingui/ops-hotkey/ops-hotkey.h" #include "kstorage/kstorage.h" #include "kobject/kobject.h" #include "kprocess/kprocess.h" EXTERN_C NTSTATUS DriverEntry(PDRIVER_OBJECT drvobj, PUNICODE_STRING registry); NTSTATUS MainDispatcher(PDEVICE_OBJECT devobj, PIRP irp); NTSTATUS DefaultDispatcher(PDEVICE_OBJECT devobj, PIRP irp); VOID DriverUnload(PDRIVER_OBJECT drvobj); NTSTATUS DriverEntry(PDRIVER_OBJECT drvobj, PUNICODE_STRING registry) { NTSTATUS status; UNICODE_STRING devname, symlnk; PDEVICE_OBJECT devobj; UNREFERENCED_PARAMETER(registry); KdPrint(("OpenArkDrv loading...")); RtlInitUnicodeString(&devname, ARK_NTDEVICE_NAME); RtlInitUnicodeString(&symlnk, ARK_DOSDEVICE_NAME); status = IoCreateDevice(drvobj, 0, &devname, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &devobj); if (!NT_SUCCESS(status)) { KdPrint(("IoCreateDevice err:%x", status)); return status; } drvobj->DriverUnload = DriverUnload; drvobj->MajorFunction[IRP_MJ_CREATE] = DefaultDispatcher; drvobj->MajorFunction[IRP_MJ_CLOSE] = DefaultDispatcher; drvobj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = MainDispatcher; status = IoCreateSymbolicLink(&symlnk, &devname); if (!NT_SUCCESS(status)) { IoDeleteDevice(devobj); KdPrint(("IoCreateSymbolicLink err:%x", status)); return status; } if (!InitArkDriver(drvobj, devobj)) { KdPrint(("InitArkDriver err")); IoDeleteSymbolicLink(&symlnk); IoDeleteDevice(devobj); return STATUS_UNSUCCESSFUL; } status = STATUS_SUCCESS; return status; } NTSTATUS MainDispatcher(PDEVICE_OBJECT devobj, PIRP irp) { NTSTATUS status = STATUS_UNSUCCESSFUL; PIO_STACK_LOCATION irpstack; PVOID inbuf_dup = NULL; PVOID inbuf = NULL; PVOID outbuf = NULL; ULONG inlen = 0; ULONG outlen = 0; ULONG ctlcode = 0; ULONG op = 0; irpstack = IoGetCurrentIrpStackLocation(irp); ctlcode = irpstack->Parameters.DeviceIoControl.IoControlCode; // [TODO] try except ProbeForRead/Write inlen = irpstack->Parameters.DeviceIoControl.InputBufferLength; if (inlen < 4) return STATUS_INVALID_PARAMETER; inbuf = irp->AssociatedIrp.SystemBuffer; if (!inbuf) return STATUS_INVALID_PARAMETER; op = *(ULONG*)inbuf; inlen = inlen - 4; inbuf = (UCHAR*)inbuf + 4; status = DuplicateInputBuffer(irp, inbuf); if (!NT_SUCCESS(status)) return status; outbuf = irp->AssociatedIrp.SystemBuffer; outlen = irpstack->Parameters.DeviceIoControl.OutputBufferLength; switch (ctlcode) { case IOCTL_ARK_HEARTBEAT: status = STATUS_SUCCESS; break; case IOCTL_ARK_DRIVER: status = DriverDispatcher(op, devobj, irp); break; case IOCTL_ARK_NOTIFY: status = NotifyDispatcher(op, devobj, irp); break; case IOCTL_ARK_MEMORY: status = MemoryDispatcher(op, devobj, inbuf, inlen, outbuf, outlen, irp); break; case IOCTL_ARK_HOTKEY: status = HotkeyDispatcher(op, devobj, irp); break; case IOCTL_ARK_STORAGE: status = StorageDispatcher(op, devobj, irp); break; case IOCTL_ARK_OBJECT: status = ObjectDispatcher(op, devobj, inbuf, inlen, outbuf, outlen, irp); break; case IOCTL_ARK_PROCESS: status = ProcessDispatcher(op, devobj, inbuf, inlen, outbuf, outlen, irp); break; default: status = STATUS_INVALID_DEVICE_REQUEST; break; } irp->IoStatus.Status = status; IoCompleteRequest(irp, IO_NO_INCREMENT); return status; } NTSTATUS DefaultDispatcher(PDEVICE_OBJECT devobj, PIRP irp) { irp->IoStatus.Status = STATUS_SUCCESS; irp->IoStatus.Information = 0; IoCompleteRequest(irp, IO_NO_INCREMENT); return STATUS_SUCCESS; } VOID DriverUnload(PDRIVER_OBJECT drvobj) { UNICODE_STRING symlnk; PDEVICE_OBJECT dev = drvobj->DeviceObject; if (dev) { RtlInitUnicodeString(&symlnk, ARK_DOSDEVICE_NAME); IoDeleteSymbolicLink(&symlnk); IoDeleteDevice(dev); } }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/kdriver/kdriver.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "../arkdrv-api/arkdrv-api.h" #include "kdriver.h" PRTL_PROCESS_MODULES QueryModuleInformation() { NTSTATUS status = STATUS_SUCCESS; PRTL_PROCESS_MODULES system_information = NULL; ULONG retlen = 0; status = ZwQuerySystemInformation(SystemModuleInformation, NULL, 0, &retlen); if (status != STATUS_INFO_LENGTH_MISMATCH) { return NULL; } ULONG bufsize = retlen + 10 * sizeof(RTL_PROCESS_MODULE_INFORMATION); PRTL_PROCESS_MODULES modules = (PRTL_PROCESS_MODULES)ExAllocatePool(NonPagedPool, bufsize); if (modules == NULL) { return NULL; } status = ZwQuerySystemInformation(SystemModuleInformation, modules, bufsize, &retlen); if (!NT_SUCCESS(status)) { ExFreePool(modules); return NULL; } return modules; } NTSTATUS DriverEnumInfo(PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, PIRP irp) { PRTL_PROCESS_MODULES mods = QueryModuleInformation(); if (!mods) { return STATUS_UNSUCCESSFUL; } ULONG count = mods->NumberOfModules; ULONG size = count * sizeof(DRIVER_ITEM) + 4; if (size > outlen) { irp->IoStatus.Information = size + 10 * sizeof(DRIVER_ITEM); ExFreePool(mods); return STATUS_BUFFER_OVERFLOW; } PDRIVER_INFO info = (PDRIVER_INFO)outbuf; info->count = count; for (ULONG i = 0; i < count; i++) { auto &item = info->items[i]; auto &mod = mods->Modules[i]; #ifdef _AMD64_ item.base = (ULONG64)mod.ImageBase; #else item.base = (ULONG64)(ULONG)mod.ImageBase; #endif item.size = mod.ImageSize; item.flags = mod.Flags; item.init_seq = mod.InitOrderIndex; item.load_seq = mod.LoadOrderIndex; RtlCopyMemory(item.path, mod.FullPathName, sizeof(mod.FullPathName)); } ExFreePool(mods); irp->IoStatus.Information = size; return STATUS_SUCCESS; } BOOLEAN InitDriverDispatcher() { return TRUE; } NTSTATUS DriverDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, IN PIRP irp) { //KdBreakPoint(); NTSTATUS status; PIO_STACK_LOCATION irpstack; PVOID inbuf = NULL; PVOID outbuf = NULL; ULONG inlen = 0; ULONG outlen = 0; irpstack = IoGetCurrentIrpStackLocation(irp); inbuf = (UCHAR*)irp->AssociatedIrp.SystemBuffer + 4; inlen = irpstack->Parameters.DeviceIoControl.InputBufferLength - 4; outbuf = irp->AssociatedIrp.SystemBuffer; outlen = irpstack->Parameters.DeviceIoControl.OutputBufferLength; switch (op) { case DRIVER_ENUM_INFO: status = DriverEnumInfo(inbuf, inlen, outbuf, outlen, irp); break; default: break; } return status; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/kdriver/kdriver.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <ntifs.h> typedef enum _SYSTEM_INFORMATION_CLASS { SystemBasicInformation, SystemProcessorInformation, SystemPerformanceInformation, SystemTimeOfDayInformation, SystemNotImplemented1, SystemProcessesAndThreadsInformation, SystemCallCounts, SystemConfigurationInformation, SystemProcessorTimes, SystemGlobalFlag, SystemNotImplemented2, SystemModuleInformation, SystemLockInformation, SystemNotImplemented3, SystemNotImplemented4, SystemNotImplemented5, SystemHandleInformation, SystemObjectInformation, SystemPagefileInformation, SystemInstructionEmulationCounts, SystemInvalidInfoClass1, SystemCacheInformation, SystemPoolTagInformation, SystemProcessorStatistics, SystemDpcInformation, SystemNotImplemented6, SystemLoadImage, SystemUnloadImage, SystemTimeAdjustment, SystemNotImplemented7, SystemNotImplemented8, SystemNotImplemented9, SystemCrashDumpInformation, SystemExceptionInformation, SystemCrashDumpStateInformation, SystemKernelDebuggerInformation, SystemContextSwitchInformation, SystemRegistryQuotaInformation, SystemLoadAndCallImage, SystemPrioritySeparation, SystemNotImplemented10, SystemNotImplemented11, SystemInvalidInfoClass2, SystemInvalidInfoClass3, SystemTimeZoneInformation, SystemLookasideInformation, SystemSetTimeSlipEvent, SystemCreateSession, SystemDeleteSession, SystemInvalidInfoClass4, SystemRangeStartInformation, SystemVerifierInformation, SystemAddVerifier, SystemSessionProcessesInformation } SYSTEM_INFORMATION_CLASS; typedef struct _RTL_PROCESS_MODULE_INFORMATION { HANDLE Section; // Not filled in PVOID MappedBase; PVOID ImageBase; ULONG ImageSize; ULONG Flags; USHORT LoadOrderIndex; USHORT InitOrderIndex; USHORT LoadCount; USHORT OffsetToFileName; UCHAR FullPathName[256]; } RTL_PROCESS_MODULE_INFORMATION, *PRTL_PROCESS_MODULE_INFORMATION; typedef struct _RTL_PROCESS_MODULES { ULONG NumberOfModules; RTL_PROCESS_MODULE_INFORMATION Modules[1]; } RTL_PROCESS_MODULES, *PRTL_PROCESS_MODULES; EXTERN_C NTSTATUS NTAPI ZwQuerySystemInformation( __in SYSTEM_INFORMATION_CLASS SystemInformationClass, __out_bcount_opt(SystemInformationLength) PVOID SystemInformation, __in ULONG SystemInformationLength, __out_opt PULONG ReturnLength ); BOOLEAN InitDriverDispatcher(); NTSTATUS DriverDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, IN PIRP irp);
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/kmemory/kmemory.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include <arkdrv-api/arkdrv-api.h> #include <common/common.h> #include <common/c-assist.h> #include "memory.h" #ifndef MM_COPY_MEMORY_VIRTUAL #define MM_COPY_MEMORY_VIRTUAL 0x2 #endif #ifndef _MM_COPY_ADDRESS typedef struct _MM_COPY_ADDRESS { union { PVOID VirtualAddress; PHYSICAL_ADDRESS PhysicalAddress; }; } MM_COPY_ADDRESS, *PMMCOPY_ADDRESS; #endif typedef NTSTATUS(NTAPI *__MmCopyMemory)( PVOID TargetAddress, MM_COPY_ADDRESS SourceAddress, SIZE_T NumberOfBytes, ULONG Flags, PSIZE_T NumberOfBytesTransferred ); BOOLEAN MmReadKernelMemory(PVOID addr, PVOID buf, ULONG len) { BOOLEAN ret = FALSE; if (ArkDrv.ver >= NTOS_WIN81) { PVOID data = ExAllocatePool(NonPagedPool, len); if (data) { auto pMmCopyMemory = (__MmCopyMemory)GetNtRoutineAddress(L"MmCopyMemory"); if (pMmCopyMemory) { SIZE_T cplen; MM_COPY_ADDRESS cpaddr; cpaddr.VirtualAddress = addr; NTSTATUS status = pMmCopyMemory(data, cpaddr, len, MM_COPY_MEMORY_VIRTUAL, &cplen); if (NT_SUCCESS(status)) { RtlCopyMemory(buf, data, cplen); ret = TRUE; } } ExFreePool(data); } return ret; } // [TDOO] BYTE_OFFSET PAGE_ALIGN PHYSICAL_ADDRESS pa; pa = MmGetPhysicalAddress(addr); if (pa.QuadPart) { PVOID va = MmMapIoSpace(pa, len, MmNonCached); if (va) { RtlCopyMemory(buf, va, len); MmUnmapIoSpace(va, len); ret = TRUE; } } return ret; } BOOLEAN MmWriteKernelMemory(PVOID addr, PVOID buf, ULONG len) { if (addr > MM_HIGHEST_USER_ADDRESS) { if (!MmIsAddressValid(addr)) return FALSE; KIRQL irql = MmWriteProtectOff(); RtlCopyMemory(addr, buf, len); MmWriteProtectOn(irql); return TRUE; } BOOLEAN ret = FALSE; MmDisableWP(); __try { RtlCopyMemory(addr, buf, len); ret = TRUE; } __except (1) {} MmEnableWP(); return ret; } NTSTATUS MemoryReadData(PARK_MEMORY_IN inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, PIRP irp) { ULONG total = ARK_HEADER_SIZE(ARK_MEMORY_OUT) + inbuf->size; if (total > outlen) { irp->IoStatus.Information = total; return STATUS_BUFFER_OVERFLOW; } PVOID data = ExAllocatePool(NonPagedPool, inbuf->size); if (!data) return STATUS_MEMORY_NOT_ALLOCATED; BOOL attach = FALSE; PEPROCESS eproc = NULL; KAPC_STATE apc_state; ULONG pid = inbuf->pid; if (pid != 4 && pid != 0 && pid != (ULONG)PsGetCurrentProcessId()) { if (NT_SUCCESS(PsLookupProcessByProcessId((HANDLE)pid, &eproc))) { KeStackAttachProcess(eproc, &apc_state); attach = TRUE; } } BOOLEAN ret = MmReadKernelMemory((PVOID)inbuf->addr, data, inbuf->size); if (attach) { KeUnstackDetachProcess(&apc_state); ObDereferenceObject(eproc); } if (!ret) { ExFreePool(data); return STATUS_UNSUCCESSFUL; } PARK_MEMORY_OUT memout = (PARK_MEMORY_OUT)outbuf; memout->size = inbuf->size; memout->pid = pid; RtlCopyMemory(memout->readbuf, data, inbuf->size); ExFreePool(data); irp->IoStatus.Information = total; return STATUS_SUCCESS; } NTSTATUS MemoryWriteData(PARK_MEMORY_IN inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, PIRP irp) { ULONG total = ARK_HEADER_SIZE(PARK_MEMORY_OUT); if (total > outlen) { irp->IoStatus.Information = total; return STATUS_BUFFER_OVERFLOW; } BOOL attach = FALSE; PEPROCESS eproc = NULL; KAPC_STATE apc_state; ULONG pid = inbuf->pid; //KdBreakPoint(); if (pid != 4 && pid != 0 && pid != (ULONG)PsGetCurrentProcessId()) { if (NT_SUCCESS(PsLookupProcessByProcessId((HANDLE)pid, &eproc))) { KeStackAttachProcess(eproc, &apc_state); attach = TRUE; } } BOOLEAN ret = MmWriteKernelMemory((PVOID)inbuf->addr, inbuf->u.writebuf, inbuf->size); if (attach) { KeUnstackDetachProcess(&apc_state); ObDereferenceObject(eproc); } if (!ret) { return STATUS_UNSUCCESSFUL; } PARK_MEMORY_OUT memout = (PARK_MEMORY_OUT)outbuf; memout->pid = pid; irp->IoStatus.Information = ARK_HEADER_SIZE(PARK_MEMORY_OUT); return STATUS_SUCCESS; } NTSTATUS MemoryDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, IN PIRP irp) { NTSTATUS status = STATUS_UNSUCCESSFUL; switch (op) { case ARK_MEMORY_READ: status = MemoryReadData((PARK_MEMORY_IN)inbuf, inlen, outbuf, outlen, irp); break; case ARK_MEMORY_WRITE: status = MemoryWriteData((PARK_MEMORY_IN)inbuf, inlen, outbuf, outlen, irp); break; default: break; } return status; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/kmemory/kmemory.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <ntifs.h> NTSTATUS MemoryDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, IN PIRP irp);
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/knotify/knotify.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "../common/common.h" #include "knotify.h" #include "notify-lib.h" NTSTATUS GetNotifyInfo(NOTIFY_TYPE type, PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, PIRP irp) { ULONG count = 0; PULONG64 items = NULL; NTSTATUS status = STATUS_UNSUCCESSFUL; BOOLEAN ret = FALSE; switch (type) { case CREATE_PROCESS: ret= GetProcessNotifyInfo(count, items); break; case CREATE_THREAD: ret = GetThreadNotifyInfo(count, items); break; case LOAD_IMAGE: ret = GetImageNotifyInfo(count, items); break; case CM_REGISTRY: ret = GetRegistryNotifyInfo(count, items); break; default: break; } if (!ret) return STATUS_UNSUCCESSFUL; ULONG size = sizeof(NOTIFY_INFO) + (count-1) * sizeof(ULONG64); if (size > outlen) { irp->IoStatus.Information = size + 10 * sizeof(ULONG64); ExFreePool(items); return STATUS_BUFFER_OVERFLOW; } auto info = (PNOTIFY_INFO)outbuf; info->count = count; info->type = type; for (ULONG i = 0; i < count; i++) { info->items[i] = items[i]; } ExFreePool(items); irp->IoStatus.Information = size; return STATUS_SUCCESS; } NTSTATUS RemoveNotifyInfo(PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, PIRP irp) { auto removed = (PNOTIFY_REMOVE_INFO)inbuf; auto type = removed->type; auto routine = removed->item; BOOLEAN ret = FALSE; switch (type) { case CREATE_PROCESS: ret = RemoveProcessNotify(routine); break; case CREATE_THREAD: ret = RemoveThreadNotify(routine); break; case LOAD_IMAGE: ret = RemoveImageNotify(routine); break; case CM_REGISTRY: ret = RemoveRegistryNotify(routine); break; default: break; } if (!ret) return STATUS_UNSUCCESSFUL; irp->IoStatus.Information = 0; return STATUS_SUCCESS; } BOOLEAN InitNotifyDispatcher() { ArkDrv.process_notify = NULL; ArkDrv.thread_notify = NULL; ArkDrv.image_notify = NULL; ArkDrv.registry_notify = NULL; return TRUE; } NTSTATUS NotifyDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, IN PIRP irp) { //KdBreakPoint(); NTSTATUS status = STATUS_UNSUCCESSFUL; PIO_STACK_LOCATION irpstack; PVOID inbuf = NULL; PVOID outbuf = NULL; ULONG inlen = 0; ULONG outlen = 0; irpstack = IoGetCurrentIrpStackLocation(irp); inbuf = (UCHAR*)irp->AssociatedIrp.SystemBuffer + 4; inlen = irpstack->Parameters.DeviceIoControl.InputBufferLength - 4; outbuf = irp->AssociatedIrp.SystemBuffer; outlen = irpstack->Parameters.DeviceIoControl.OutputBufferLength; switch (op) { case NOTIFY_PATCH: break; case NOTIFY_PATCH_REGULARLY: break; case NOTIFY_REMOVE: status = RemoveNotifyInfo(inbuf, inlen, outbuf, outlen, irp); break; case NOTIFY_REMOVE_REGULARLY: break; case NOTIFY_ENUM_PROCESS: status = GetNotifyInfo(CREATE_PROCESS, inbuf, inlen, outbuf, outlen, irp); break; case NOTIFY_ENUM_THREAD: status = GetNotifyInfo(CREATE_THREAD, inbuf, inlen, outbuf, outlen, irp); break; case NOTIFY_ENUM_IMAGE: status = GetNotifyInfo(LOAD_IMAGE, inbuf, inlen, outbuf, outlen, irp); break; case NOTIFY_ENUM_REGISTRY: status = GetNotifyInfo(CM_REGISTRY, inbuf, inlen, outbuf, outlen, irp); break; default: break; } return status; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/knotify/knotify.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <ntifs.h> #include "../arkdrv-api/arkdrv-api.h" BOOLEAN InitNotifyDispatcher(); NTSTATUS NotifyDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, IN PIRP irp);
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/knotify/notify-lib.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "notify-lib.h" #include "../common/common.h" #include "../arkdrv-api/arkdrv-api.h" #if defined (_WIN64) #define MAX_FAST_REFS 15 #else #define MAX_FAST_REFS 7 #endif typedef struct _EX_FAST_REF { union { PVOID Object; #if defined (_WIN64) ULONG_PTR RefCnt : 4; #else ULONG_PTR RefCnt : 3; #endif ULONG_PTR Value; }; } EX_FAST_REF, *PEX_FAST_REF; typedef NTSTATUS (NTAPI *__PEX_CALLBACK_FUNCTION)(IN PVOID CallbackContext, IN PVOID Argument1, IN PVOID Argument2); typedef struct _EX_CALLBACK_ROUTINE_BLOCK { EX_RUNDOWN_REF RundownProtect; __PEX_CALLBACK_FUNCTION Function; PVOID Context; } EX_CALLBACK_ROUTINE_BLOCK, *PEX_CALLBACK_ROUTINE_BLOCK; typedef struct _EX_CALLBACK { EX_FAST_REF RoutineBlock; } EX_CALLBACK, *PEX_CALLBACK; typedef struct _CM_CALLBACK_CONTEXT_BLOCKEX { LIST_ENTRY ListEntry; ULONG Unknown1; ULONG Unknown2; LARGE_INTEGER Cookie; PVOID CallerContext; PVOID Function; UNICODE_STRING Altitude; LIST_ENTRY ObjectContextListHead; } CM_CALLBACK_CONTEXT_BLOCKEX, *PCM_CALLBACK_CONTEXT_BLOCKEX; BOOLEAN ExFastRefCanBeReferenced(PEX_FAST_REF ref) { return ref->RefCnt != 0; } BOOLEAN ExFastRefObjectNull(PEX_FAST_REF ref) { return (BOOLEAN)(ref->Value == 0); } PVOID ExFastRefGetObject(PEX_FAST_REF ref) { return (PVOID)(ref->Value & ~MAX_FAST_REFS); } PEX_CALLBACK_ROUTINE_BLOCK ExReferenceCallBackBlock(PEX_FAST_REF ref) { if (ExFastRefObjectNull(ref)) { return NULL; } if (!ExFastRefCanBeReferenced(ref)) { return NULL; } return (PEX_CALLBACK_ROUTINE_BLOCK)ExFastRefGetObject(ref); } FORCEINLINE ULONG GetProcessNotifyMaximum() { #ifdef _AMD64_ return 64; #else if (ArkDrv.major >= 6) return 64; else return 8; #endif } FORCEINLINE ULONG GetThreadNotifyMaximum() { #ifdef _AMD64_ return 64; #else if (ArkDrv.major >= 6) return 64; else return 8; #endif } FORCEINLINE ULONG GetImageNotifyMaximum() { if (ArkDrv.ver >= _NTOS_WIN7SP1) return 64; else return 8; } FORCEINLINE ULONG GetRegistryNotifyMaximum() { return 100; } // Process Notify PEX_CALLBACK GetProcessNotifyCallback() { PUCHAR routine = (PUCHAR)GetNtRoutineAddress(L"PsSetCreateProcessNotifyRoutine"); if (!routine) return NULL; PEX_CALLBACK callback = NULL; #ifdef _AMD64_ if (ArkDrv.ver >= _NTOS_WINVISTA && ArkDrv.ver < _NTOS_WIN7) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x10; ptr1++) { // e9 jmp if (*ptr1 == 0xe9) { PUCHAR psp_routine = *(LONG*)(ptr1 + 1) + ptr1 + 5; if (!MmIsAddressValid((PVOID)psp_routine)) break; //Win Vista 4c 8d 25 lea r12 //Win Vista SP1 4c 8d 35 lea r14 //Win Vista SP2 4c 8d 35 lea r14 for (PUCHAR ptr2 = psp_routine; ptr2 <= psp_routine + 0x50; ptr2++) { if (*ptr2 == 0x4c && *(ptr2 + 1) == 0x8d && (*(ptr2 + 2) == 0x25 || *(ptr2 + 2) == 0x35)) { callback = (PEX_CALLBACK)(ptr2 + (*(LONG*)(ptr2 + 3)) + 7); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } } } else if (ArkDrv.ver >= _NTOS_WIN7 && ArkDrv.ver < _NTOS_WIN8) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x10; ptr1++) { // e9 jmp if (*ptr1 == 0xe9) { PUCHAR psp_routine = *(LONG*)(ptr1 + 1) + ptr1 + 5; if (!MmIsAddressValid(psp_routine)) break; // lea r14 for (PUCHAR ptr2 = psp_routine; ptr2 <= psp_routine + 0x50; ptr2++) { if (*ptr2 == 0x4c && *(ptr2 + 1) == 0x8d && *(ptr2 + 2) == 0x35) { callback = (PEX_CALLBACK)(ptr2 + (*(LONG*)(ptr2 + 3)) + 7); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } } } else if (ArkDrv.ver >= _NTOS_WIN8 && ArkDrv.ver < _NTOS_WIN10_1507) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x10; ptr1++) { PUCHAR psp_routine = NULL; //Win8 eb jmp if (*ptr1 == 0xeb) { psp_routine = *(UCHAR*)(ptr1 + 1) + ptr1 + 2; } else if (*ptr1 == 0xe9) { //Win8.1 e9 jmp psp_routine = *(LONG*)(ptr1 + 1) + ptr1 + 5; } if (!psp_routine || !MmIsAddressValid(psp_routine)) break; // 4c 8d 3d lea r15 for (PUCHAR ptr2 = psp_routine; ptr2 <= psp_routine + 0x60; ptr2++) { if (*ptr2 == 0x4c && *(ptr2 + 1) == 0x8d && *(ptr2 + 2) == 0x3d) { callback = (PEX_CALLBACK)(ptr2 + (*(LONG*)(ptr2 + 3)) + 7); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } } else if (ArkDrv.ver >= _NTOS_WIN10_1507) { //Win10 2004 0xe8 call //Win10 1909 0xe8 call //Win10 1903 0xe8 call //Win10 1809 0xe8 call //Win10 1803 0xe8 call //Win10 1709 0xe8 call //Win10 1703 0xe9 jmp //Win10 1607 0xe9 jmp //Win10 1511 0xe9 jmp //Win10 1507 0xe9 jmp for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x10; ptr1++) { PUCHAR psp_routine = NULL; if (ptr1[0] == 0xe8 || ptr1[0] == 0xe9) { psp_routine = *(LONG*)(ptr1 + 1) + ptr1 + 5; if (!MmIsAddressValid((PVOID)psp_routine)) break; //Win10 2004 4c 8d 2d lea r13 //Win10 1909 4c 8d 2d lea r13 //Win10 1809 4c 8d 2d lea r13 //Win10 1803 4c 8d 2d lea r13 48 8d 0d lea rcx //Win10 1709 4c 8d 2d lea r13 //Win10 1703 4c 8d 25 lea r12 //Win10 1607 4c 8d 25 lea r12 //Win10 1511 4c 8d 3d lea r15 //Win10 1507 4c 8d 3d lea r15 for (PUCHAR ptr2 = psp_routine; ptr2 <= psp_routine + 0x100; ptr2++) { if (ptr2[0] == 0x4c && ptr2[1] == 0x8d && (ptr2[2] == 0x2d || ptr2[2] == 0x25 || ptr2[2] == 0x3d)) { callback = (PEX_CALLBACK)(ptr2 + (*(LONG*)(ptr2 + 3)) + 7); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } } } #else if (ArkDrv.major == 5) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x20; ptr1++) { if (*ptr1 == 0xbf) { callback = (PEX_CALLBACK)*(LONG*)(ptr1 + 1); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } else if (ArkDrv.major == 6) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x20; ptr1++) { if (*ptr1 == 0xe8) { PUCHAR psp_routine = *(LONG*)(ptr1 + 1) + ptr1 + 5; if (!MmIsAddressValid((PVOID)psp_routine)) break; for (PUCHAR ptr2 = psp_routine; ptr2 <= psp_routine + 0x30; ptr2++) { if (*ptr2 == 0xc7) { callback = (PEX_CALLBACK)*(LONG*)(ptr2 + 3); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } } } #endif return callback; } BOOLEAN GetProcessNotifyInfo(ULONG &count, PULONG64 &items) { if (!ArkDrv.process_notify) { ArkDrv.process_notify = GetProcessNotifyCallback(); } PEX_CALLBACK callback = (PEX_CALLBACK)ArkDrv.process_notify; if (!callback) return FALSE; ULONG maxinum = GetProcessNotifyMaximum(); if (!maxinum) return FALSE; auto bufsize = maxinum * sizeof(ULONG64); auto buf = (PULONG64)ExAllocatePool(NonPagedPool, bufsize); if (!buf) return FALSE; count = 0; for (ULONG i = 0; i < maxinum; i++) { if (!MmIsAddressValid(callback)) break; auto block = (PEX_CALLBACK_ROUTINE_BLOCK)ExReferenceCallBackBlock(&callback->RoutineBlock); if (block != NULL) { buf[count] = (ULONG64)block->Function; count++; } callback++; } items = buf; if (count <= 0) { ExFreePool(buf); return FALSE; } return TRUE; } BOOLEAN RemoveProcessNotify(ULONG64 routine) { NTSTATUS status; if (!MmIsAddressValid((PVOID)routine)) return false; status = PsSetCreateProcessNotifyRoutine((PCREATE_PROCESS_NOTIFY_ROUTINE)routine, TRUE); return NT_SUCCESS(status); } // Thread Notify PEX_CALLBACK GetThreadNotifyCallback() { PUCHAR routine = (PUCHAR)GetNtRoutineAddress(L"PsSetCreateThreadNotifyRoutine"); if (!routine) return NULL; PEX_CALLBACK callback = NULL; #ifdef _AMD64_ if (ArkDrv.ver >= _NTOS_WINVISTA && ArkDrv.ver <= _NTOS_WIN81) { // lea rcx for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x30; ptr1++) { if (*ptr1 == 0x48 && *(ptr1 + 1) == 0x8d && *(ptr1 + 2) == 0x0d) { callback = (PEX_CALLBACK)(ptr1 + (*(LONG*)(ptr1 + 3)) + 7); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } else if (ArkDrv.ver >= _NTOS_WIN10_1507) { //Win10 2004 e8 call //Win10 1909 e8 call //Win10 1903 e8 call //Win10 1809 e8 call //Win10 1803 e8 call //Win10 1709 e8 call //Win10 1703 e9 jmp //Win10 1607 e9 jmp //Win10 1511 e9 jmp //Win10 1507 e9 jmp for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x10; ptr1++) { PUCHAR psp_routine = NULL; if (*ptr1 == 0xe8 || *ptr1 == 0xe9) { psp_routine = *(LONG*)(ptr1 + 1) + ptr1 + 5; if (!MmIsAddressValid((PVOID)psp_routine)) break; //Win10 2004 48 8d 0d lea rcx //Win10 1909 48 8d 0d lea rcx //Win10 1903 48 8d 0d lea rcx //Win10 1809 48 8d 0d lea rcx //Win10 1803 48 8d 0d lea rcx //Win10 1709 48 8d 0d lea rcx //Win10 1703 48 8d 0d lea rcx //Win10 1607 48 8d 0d lea rcx //Win10 1511 48 8d 0d lea rcx //Win10 1507 48 8d 0d lea rcx for (PUCHAR ptr2 = psp_routine; ptr2 <= psp_routine + 0x40; ptr2++) { if (*ptr2 == 0x48 && *(ptr2 + 1) == 0x8d && *(ptr2 + 2) == 0x0d) { callback = (PEX_CALLBACK)(ptr2 + (*(LONG*)(ptr2 + 3)) + 7); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } } } #else if (ArkDrv.major <= 6) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x30; ptr1++) { if (*ptr1 == 0x56 && *(ptr1 + 1) == 0xbe) { callback = (PEX_CALLBACK)*(LONG*)(ptr1 + 2); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } #endif return callback; } BOOLEAN GetThreadNotifyInfo(ULONG &count, PULONG64 &items) { if (!ArkDrv.thread_notify) { ArkDrv.thread_notify = GetThreadNotifyCallback(); } PEX_CALLBACK callback = (PEX_CALLBACK)ArkDrv.thread_notify; if (!callback) return FALSE; ULONG maxinum = GetThreadNotifyMaximum(); if (!maxinum) return FALSE; auto bufsize = maxinum * sizeof(ULONG64); auto buf = (PULONG64)ExAllocatePool(NonPagedPool, bufsize); if (!buf) return FALSE; count = 0; for (ULONG i = 0; i < maxinum; i++) { if (!MmIsAddressValid(callback)) break; auto block = (PEX_CALLBACK_ROUTINE_BLOCK)ExReferenceCallBackBlock(&callback->RoutineBlock); if (block != NULL) { buf[count] = (ULONG64)block->Function; count++; } callback++; } items = buf; if (count <= 0) { ExFreePool(buf); return FALSE; } return TRUE; } BOOLEAN RemoveThreadNotify(ULONG64 routine) { NTSTATUS status; if (!MmIsAddressValid((PVOID)routine)) return false; status = PsRemoveCreateThreadNotifyRoutine((PCREATE_THREAD_NOTIFY_ROUTINE)routine); return NT_SUCCESS(status); } // Image Notify PEX_CALLBACK GetImageNotifyCallback() { PUCHAR routine = NULL; if (ArkDrv.ver >= _NTOS_WINXP && ArkDrv.ver <= _NTOS_WIN10_1703) { routine = (PUCHAR)GetNtRoutineAddress(L"PsSetLoadImageNotifyRoutine"); } else if (ArkDrv.ver >= _NTOS_WIN10_1709 && ArkDrv.ver <= _NTOS_WIN11_21H2) { routine = (PUCHAR)GetNtRoutineAddress(L"PsSetLoadImageNotifyRoutineEx"); } if (!routine) return NULL; PEX_CALLBACK callback = NULL; #ifdef _AMD64_ // lea rcx for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x60; ptr1++) { if (*ptr1 == 0x48 && *(ptr1 + 1) == 0x8d && *(ptr1 + 2) == 0x0d) { callback = (PEX_CALLBACK)(ptr1 + (*(LONG*)(ptr1 + 3)) + 7); if (!MmIsAddressValid(callback)) callback = NULL; break; } } #else if (ArkDrv.major == 5) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x30; ptr1++) { if (*ptr1 == 0x56 && *(ptr1 + 1) == 0xbe) { callback = (PEX_CALLBACK)*(LONG*)(ptr1 + 2); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } else if (ArkDrv.major == 6) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x30; ptr1++) { if ((*ptr1 == 0x25 || *ptr1 == 0x28) && *(ptr1 + 1) == 0xbe) { callback = (PEX_CALLBACK)*(LONG*)(ptr1 + 2); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } #endif return callback; } BOOLEAN GetImageNotifyInfo(ULONG &count, PULONG64 &items) { if (!ArkDrv.image_notify) { ArkDrv.image_notify = GetImageNotifyCallback(); } PEX_CALLBACK callback = (PEX_CALLBACK)ArkDrv.image_notify; if (!callback) return FALSE; ULONG maxinum = GetImageNotifyMaximum(); if (!maxinum) return FALSE; auto bufsize = maxinum * sizeof(ULONG64); auto buf = (PULONG64)ExAllocatePool(NonPagedPool, bufsize); if (!buf) return FALSE; count = 0; for (ULONG i = 0; i < maxinum; i++) { if (!MmIsAddressValid(callback)) break; auto block = (PEX_CALLBACK_ROUTINE_BLOCK)ExReferenceCallBackBlock(&callback->RoutineBlock); if (block != NULL) { buf[count] = (ULONG64)block->Function; count++; } callback++; } items = buf; if (count <= 0) { ExFreePool(buf); return FALSE; } return TRUE; } BOOLEAN RemoveImageNotify(ULONG64 routine) { NTSTATUS status; if (!MmIsAddressValid((PVOID)routine)) return false; status = PsRemoveLoadImageNotifyRoutine((PLOAD_IMAGE_NOTIFY_ROUTINE)routine); return NT_SUCCESS(status); } // Registry Notify PVOID GetRegistryNotifyCallback() { PUCHAR routine = (PUCHAR)GetNtRoutineAddress(L"CmUnRegisterCallback"); if (!routine) return NULL; PVOID callback = NULL; #ifdef _AMD64_ if (ArkDrv.ver >= _NTOS_WINVISTA) { // xor r8d, r8d // lea rcx, CallbackListHead for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x100; ptr1++) { if (*ptr1 == 0x45 && *(ptr1 + 1) == 0x33 && *(ptr1 + 2) == 0xc0 && *(ptr1 + 8) == 0x48 && *(ptr1 + 9) == 0x8d && *(ptr1 + 10) == 0x0d) { callback = (PLIST_ENTRY)((ptr1 + 8) + (*(LONG*)((ptr1 + 8) + 3)) + 7); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } #else if (ArkDrv.major == 5) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x20; ptr1++) { if (*ptr1 == 0x57 && *(ptr1 + 1) == 0xbb) { callback = (PEX_CALLBACK)*(LONG*)(ptr1 + 2); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } else if (ArkDrv.major == 6) { for (PUCHAR ptr1 = routine; ptr1 <= routine + 0x100; ptr1++) { if (*ptr1 == 0x4d && *(ptr1 + 1) == 0xd4 && *(ptr1 + 1) == 0xbf) { callback = (PEX_CALLBACK)*(LONG*)(ptr1 + 3); if (!MmIsAddressValid(callback)) callback = NULL; break; } } } #endif return callback; } BOOLEAN GetRegistryNotifyInfo(ULONG &count, PULONG64 &items) { if (!ArkDrv.registry_notify) { ArkDrv.registry_notify = GetRegistryNotifyCallback(); } PEX_CALLBACK callback = (PEX_CALLBACK)ArkDrv.registry_notify; if (!callback) return FALSE; ULONG maxinum = GetRegistryNotifyMaximum(); if (!maxinum) return FALSE; auto bufsize = maxinum * sizeof(ULONG64); auto buf = (PULONG64)ExAllocatePool(NonPagedPool, bufsize); if (!buf) return FALSE; count = 0; if (ArkDrv.major >= 6) { PLIST_ENTRY head = (PLIST_ENTRY)callback; PCM_CALLBACK_CONTEXT_BLOCKEX ctx; for (PLIST_ENTRY entry = head->Flink; entry != head;) { if (count >= maxinum) break; ctx = CONTAINING_RECORD(entry, CM_CALLBACK_CONTEXT_BLOCKEX, ListEntry); entry = entry->Flink; if (ctx->Function == NULL) continue; if (MmIsAddressValid(ctx->Function)) { buf[count] = (ULONG64)ctx->Function; count++; } } } else { for (ULONG i = 0; i < maxinum; i++) { if (!MmIsAddressValid(callback)) break; auto block = (PEX_CALLBACK_ROUTINE_BLOCK)ExReferenceCallBackBlock(&callback->RoutineBlock); if (block != NULL) { buf[count] = (ULONG64)block->Function; count++; } callback++; } } items = buf; if (count <= 0) { ExFreePool(buf); return FALSE; } return TRUE; } BOOLEAN RemoveRegistryNotify(ULONG64 routine) { // [TODO] NT5 cookie if (ArkDrv.major <= 5) return false; if (!ArkDrv.registry_notify) { ArkDrv.registry_notify = GetRegistryNotifyCallback(); } PEX_CALLBACK callback = (PEX_CALLBACK)ArkDrv.registry_notify; if (!callback) return FALSE; ULONG maxinum = GetRegistryNotifyMaximum(); if (!maxinum) return FALSE; PLIST_ENTRY head = (PLIST_ENTRY)callback; PCM_CALLBACK_CONTEXT_BLOCKEX ctx; for (PLIST_ENTRY entry = head->Flink; entry != head;) { ctx = CONTAINING_RECORD(entry, CM_CALLBACK_CONTEXT_BLOCKEX, ListEntry); entry = entry->Flink; if (routine == (ULONG64)ctx->Function) { CmUnRegisterCallback(ctx->Cookie); return TRUE; } } return FALSE; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/knotify/notify-lib.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <ntifs.h> BOOLEAN GetProcessNotifyInfo(ULONG &count, PULONG64 &items); BOOLEAN RemoveProcessNotify(ULONG64 routine); BOOLEAN GetThreadNotifyInfo(ULONG &count, PULONG64 &items); BOOLEAN RemoveThreadNotify(ULONG64 routine); BOOLEAN GetImageNotifyInfo(ULONG &count, PULONG64 &items); BOOLEAN RemoveImageNotify(ULONG64 routine); BOOLEAN GetRegistryNotifyInfo(ULONG &count, PULONG64 &items); BOOLEAN RemoveRegistryNotify(ULONG64 routine);
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/kobject/kobject.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "kobject.h" #include "../common/common.h" #include <knone.h> #include <ntifs.h> #include <ntimage.h> #include <ntintsafe.h> #include <windef.h> NTSTATUS ObjectDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, IN PIRP irp) { NTSTATUS status = STATUS_UNSUCCESSFUL; switch (op) { case ARK_OBJECT_TYPE_ENUM: break; case STORAGE_UNLOCK_CLOSE: break; default: break; } return status; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/kobject/kobject.h
C/C++ Header
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #pragma once #include <ntifs.h> #include <arkdrv-api/arkdrv-api.h> NTSTATUS ObjectDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, IN PIRP irp);
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong
src/OpenArkDrv/kprocess/kprocess.cpp
C++
/**************************************************************************** ** ** Copyright (C) 2019 BlackINT3 ** Contact: https://github.com/BlackINT3/OpenArk ** ** GNU Lesser General Public License Usage (LGPL) ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ****************************************************************************/ #include "kprocess.h" #include "../common/common.h" #include <knone.h> #include <ntifs.h> #include <ntimage.h> #include <ntintsafe.h> #include <windef.h> EXTERN_C NTSTATUS NTAPI ZwOpenThread( __out PHANDLE ThreadHandle, __in ACCESS_MASK DesiredAccess, __in POBJECT_ATTRIBUTES ObjectAttributes, __in_opt PCLIENT_ID ClientId ); NTSTATUS ProcessOpenByInfo(PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, IN PIRP irp) { if (outlen < 4) { irp->IoStatus.Information = 4; return STATUS_BUFFER_OVERFLOW; } if (inlen < sizeof(PROCESS_OPEN_INFO)) return STATUS_UNSUCCESSFUL; PPROCESS_OPEN_INFO info = (PPROCESS_OPEN_INFO)inbuf; CLIENT_ID cid; cid.UniqueProcess = (HANDLE)info->pid; cid.UniqueThread = (HANDLE)0; DWORD attr = 0; HANDLE handle; OBJECT_ATTRIBUTES oa; if (info->inherit) attr |= OBJ_INHERIT; InitializeObjectAttributes(&oa, NULL, attr, NULL, NULL); NTSTATUS status = ZwOpenProcess(&handle, info->access, &oa, &cid); if (!NT_SUCCESS(status)) { return status; } RtlCopyMemory(outbuf, &handle, 4); irp->IoStatus.Information = 4; return status; } NTSTATUS ThreadOpenByInfo(PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, IN PIRP irp) { if (outlen < 4) { irp->IoStatus.Information = 4; return STATUS_BUFFER_OVERFLOW; } if (inlen < sizeof(THREAD_OPEN_INFO)) return STATUS_UNSUCCESSFUL; PTHREAD_OPEN_INFO info = (PTHREAD_OPEN_INFO)inbuf; CLIENT_ID cid; cid.UniqueProcess = (HANDLE)0; cid.UniqueThread = (HANDLE)info->tid; DWORD attr = 0; HANDLE handle; OBJECT_ATTRIBUTES oa; if (info->inherit) attr |= OBJ_INHERIT; InitializeObjectAttributes(&oa, NULL, attr, NULL, NULL); NTSTATUS status = ZwOpenThread(&handle, info->access, &oa, &cid); if (!NT_SUCCESS(status)) { return status; } RtlCopyMemory(outbuf, &handle, 4); irp->IoStatus.Information = 4; return status; } NTSTATUS ProcessDispatcher(IN ULONG op, IN PDEVICE_OBJECT devobj, PVOID inbuf, ULONG inlen, PVOID outbuf, ULONG outlen, IN PIRP irp) { NTSTATUS status = STATUS_UNSUCCESSFUL; switch (op) { case PROCESS_OPEN: status = ProcessOpenByInfo(inbuf, inlen, outbuf, outlen, irp); break; case THREAD_OPEN: status = ThreadOpenByInfo(inbuf, inlen, outbuf, outlen, irp); break; default: break; } return status; }
wsdjeg/OpenArk-backup
0
C++
wsdjeg
Eric Wong